无人机部署
sudo apt install
ros-noetic-mavros ros-
ninja-build exiftool ninja-build protobuf-compiler libeigen3-dev genromfs xmlstarlet libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev python-pip python3-pip gawk #pip2 install pandas jinja2 pyserial cerberus pyulog==0.7.0 numpy toml pyquaternion empy pyyaml pip3 install packaging numpy empy toml pyyaml jinja2 pyargparse kconfiglib jsonschema futurenoetic
-mavros-extras
5.安装MAVROS
#sudo apt install ros-noetic-mavros ros-noetic
-mavros-extras # for ros-melodic
wget https://gitee.com/robin_shaun/XTDrone/raw/master/sitl_config/mavros/install_geographiclib_datasets.sh
sudo chmod a+x ./install_geographiclib_datasets.sh
sudo ./install_geographiclib_datasets.sh #这步需要装一段时间
或者下载后放到 /usr/share/GeographicLib 下面
通过百度网盘分享的文件:geographic-lib.rar
链接:https://pan.baidu.com/s/1Ydq0cyKK7nu2Orbv8Iw3tA
提取码:1234
PX4配置
git clone https://github.com/PX4/PX4-Autopilot.git
mv PX4-Autopilot PX4_Firmware
cd PX4_Firmware
git checkout -b xtdrone/dev v1.13.2
git submodule update --init --recursive
make px4_sitl_default gazebo
增加环境变量
source ~/PX4_Firmware/Tools/setup_gazebo.bash ~/PX4_Firmware/ ~/PX4_Firmware/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4_Firmware
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4_Firmware/Tools/sitl_gazebo
测试
cd ~/PX4_Firmware roslaunch px4 mavros_posix_sitl.launch #检查与mavros通信 rostopic echo /mavros/state
XTDrone源码下载
git clone https://gitee.com/robin_shaun/XTDrone.git
cd XTDrone
git checkout 1_13_2
git submodule update --init --recursive
# 修改启动脚本文件
cp sitl_config/init.d-posix/* ~/PX4_Firmware/ROMFS/px4fmu_common/init.d-posix/
# 添加launch文件
cp -r sitl_config/launch/* ~/PX4_Firmware/launch/
# 添加世界文件
cp sitl_config/worlds/* ~/PX4_Firmware/Tools/sitl_gazebo/worlds/
# 修改部分插件
cp sitl_config/gazebo_plugin/gimbal_controller/gazebo_gimbal_controller_plugin.cpp ~/PX4_Firmware/Tools/sitl_gazebo/src
cp sitl_config/gazebo_plugin/gimbal_controller/gazebo_gimbal_controller_plugin.hh ~/PX4_Firmware/Tools/sitl_gazebo/include
cp sitl_config/gazebo_plugin/wind_plugin/gazebo_ros_wind_plugin_xtdrone.cpp ~/PX4_Firmware/Tools/sitl_gazebo/src
cp sitl_config/gazebo_plugin/wind_plugin/gazebo_ros_wind_plugin_xtdrone.h ~/PX4_Firmware/Tools/sitl_gazebo/include
# 修改CMakeLists.txt
cp sitl_config/CMakeLists.txt ~/PX4_Firmware/Tools/sitl_gazebo
# 修改部分模型文件
cp -r sitl_config/models/* ~/PX4_Firmware/Tools/sitl_gazebo/models/
# 替换同名文件
cd ~/.gazebo/models/
rm -r stereo_camera/ 3d_lidar/ 3d_gpu_lidar/ hokuyo_lidar/
cp sitl_config/init.d-posix/* ~/PX4_Firmware/ROMFS/px4fmu_common/init.d-posix/ cp -r sitl_config/launch/* ~/PX4_Firmware/launch/ cp sitl_config/worlds/* ~/PX4_Firmware/Tools/sitl_gazebo/worlds/ cp sitl_config/gazebo_plugin/gimbal_controller/gazebo_gimbal_controller_plugin.cpp ~/PX4_Firmware/Tools/sitl_gazebo/src cp sitl_config/gazebo_plugin/gimbal_controller/gazebo_gimbal_controller_plugin.hh ~/PX4_Firmware/Tools/sitl_gazebo/include cp sitl_config/gazebo_plugin/wind_plugin/gazebo_ros_wind_plugin_xtdrone.cpp ~/PX4_Firmware/Tools/sitl_gazebo/src cp sitl_config/gazebo_plugin/wind_plugin/gazebo_ros_wind_plugin_xtdrone.h ~/PX4_Firmware/Tools/sitl_gazebo/include cp sitl_config/CMakeLists.txt ~/PX4_Firmware/Tools/sitl_gazebo cp -r sitl_config/models/* ~/PX4_Firmware/Tools/sitl_gazebo/models/ cd ~/.gazebo/models/ rm -r stereo_camera/ 3d_lidar/ 3d_gpu_lidar/ hokuyo_lidar/
再次编译
cd ~/PX4_Firmware
make px4_sitl_default gazebo
用键盘控制无人机
#terminal1
cd ~/PX4_Firmware
roslaunch px4 indoor1.launch
#terminal2
cd ~/XTDrone/communication/
python multirotor_communication.py iris 0
#terminal3
cd /home/slam/XTDrone/control/keyboard
python3 multirotor_keyboard_control.py iris 1 vel
Eigen:
sudo cp -rf /usr/local/include/eigen3/Eigen/ /usr/local/include/