参考:https://docs.px4.io/master/en/ros/mavros_installation.html

/
https://docs.px4.io/master/en/dev_setup/dev_env_linux_ubuntu.html
/
git clone https://github.com/PX4/Firmware.git

git checkout v1.11.3


git submodule update --init --recursive

cd Tools/setup

./ubuntu.sh

cd /opt/ros/noetic/lib/mavros

./install_geographiclib_datasets.sh


/home/xl/opt/Firmware/Tools/setup

pip install -r requirements.txt

sudo apt-get install ros-noetic-mavros ros-noetic-mavros-extras

sudo apt-get install python3-catkin-tools python3-rosinstall-generator -y
rosinstall_generator --rosdistro noetic mavlink | tee /tmp/mavros.rosinstall

rosinstall_generator --upstream mavros | tee -a /tmp/mavros.rosinstall
rosinstall_generator --upstream-development mavros | tee -a /tmp/mavros.rosinstall
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin init
wstool init src
wstool merge -t src /tmp/mavros.rosinstall
wstool update -t src -j4
rosdep install --from-paths src --ignore-src -y
catkin build
source devel/setup.bash

cd /home/xl/catkin_ws/src


catkin_create_pkg offboard_pkg roscpp std_msgs geometry_msgs mavros_msgs

编写cpp文件

/home/xl/catkin_ws/src/offboard_pkg/src目录

新建offboard_node.cpp

然后打开目录~/catkin_ws/src/offboard_pkg/下的CMakeLists.txt添加下面的两行

add_executable(offboard_node src/offboard_node.cpp)

target_link_libraries(offboard_node ${catkin_LIBRARIES})

然后到目录~/catkin_ws下,运行命令


catkin build

catkin init

source devel/setup.bash




编译完成后

cd /home/xl/px4/Firmware

执行

make px4_sitl gazebo_iris

新开终端执行


roscore


打开QGroundControl

新开终端执行

roslaunch mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14557"


roslaunch mavros px4.launch fcu_url:="udp://:14540@192.168.1.196:14557"


make px4_sitl jmavsim



修改之后可以直接使用
roslaunch mavros px4.launch

查看是否连接成功
rostopic list


新开终端
cd 
/home/xl/catkin_ws

执行

rosrun offboard_pkg offboard_node

 

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐