一、ubuntu、ros安装教程比较多,此文章不做详细讲解。该文章基于ubuntu20.04系统。
pix4参考地址:https://docs.px4.io/main/zh/index.html
二、安装pix4
1. git clone https://github.com/PX4/PX4-Autopilot.git --recursive
2. bash ./PX4-Autopilot/Tools/setup/ubuntu.sh
3. sudo apt-get install protobuf-compiler libeigen3-dev libopencv-dev -y
更新一下,完成后重启系统
测试进入下载的PX4-Autopilot文件夹内
make px4_sitl_default gazebo
端输入 commander takeoff ,可以看到无人机起飞
终端输入 commander land , 可以看到无人机降落
添加环境变量(添加到~/.bashrc文件中)
source ~/PX4-Autopilot/Tools/simulation/gazebo-classic/setup_gazebo.bash ~/PX4-Autopilot ~/PX4-Autopilot/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4-Autopilot
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic
此处换成自己的路径
二、安装mavros
sudo apt-get install ros-noetic-mavros ros-noetic-mavros-extras
sudo /opt/ros/noetic/lib/mavros/install_geographiclib_datasets.sh
测试
roslaunch mavros px4.launch
出现[FATAL] [1711808359.038923077]: FCU: DeviceError:serial:open: No such file or directory
================================================================================REQUIRED process [mavros-2] has died!
process has finished cleanly
log file: /home/ikun/.ros/log/7ee08aa0-eea0-11ee-ba0c-85043e8d2678/mavros-2*.log
Initiating shutdown!
================================================================================不要紧张没有连接真机
三、安装qgc
https://docs.qgroundcontrol.com/master/en/qgc-user-guide/getting_started/download_and_install.html
四、pix4仿真
roslaunch px4 mavros_posix_sitl.launch
五、更换为自己的世界地图
在PX4-Autopilot目录下搜索PX4-Autopilot,将里面的empty.world换成自己的世界模型,世界模型可以用3D软件转成ros支持的格式,拿gazebo打开保存为世界模型文件。
六、效果图
七、参考文章
ROS (1) with MAVROS Installation Guide | PX4 Guide (main)
http://t.csdnimg.cn/6Yw4Q