ArduSub SITL Ubuntu环境搭建
第一步:
http://ardupilot.org/dev/docs/building-setup-linux.html#building-setup-linux
Setting up the Build Environment (Linux/Ubuntu)
如果已经有git了。可以忽略页面中git相关的步骤。
git clone https://github.com/ArduPilot/ardupilot
cd ardupilot
git submodule update --init --recursive
Tools/environment_install/install-prereqs-ubuntu.sh -y
(安装耗时很长,需要权限, 可能报错,报错再根据提示或根据经验进行修正)
. ~/.profile
找到你的路径,根据你的路径修改环境变量,例如:
export PATH=$PATH:$HOME/ardupilot/Tools/autotest
export PATH=/usr/lib/ccache:$PATH
安装交叉编译工具
cd TARGET_DIR
tar -xjvf gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2
export PATH=$PATH:TARGET_DIR/gcc-arm-none-eabi-4_9-2015q3/bin
sudo apt-get install ccache
cd /usr/lib/ccache
sudo ln -s /usr/bin/ccache arm-none-eabi-g++
sudo ln -s /usr/bin/ccache arm-none-eabi-gcc
第二步:
http://ardupilot.org/dev/docs/setting-up-sitl-on-linux.html
启动SITL
$ sim_vehicle.py -v ArduSub
当显示
.....
APM: EKF2 IMU0 is using GPS
APM: EKF2 IMU1 is using GPS
Flight battery 100 percent
就成功了。
按ctrl+C。再启动sim_vehicle.py
ardupilot/Tools/autotest$ sim_vehicle.py -L RATBeach --out=udp:0.0.0.0:14550 --map –console -v ArduSub
第三步,安装运行mavros相关软件包
$sudo apt-get install ros-kinetic-mavros*
修改apm.launch
<launch>
<!-- vim: set ft=xml noet : -->
<!-- example launch script for ArduPilot based FCU's
<arg name="fcu_url" default="/dev/ttyACM0:57600" />
-->
<arg name="fcu_url" default="udp://127.0.0.1:14550@" />
<arg name="gcs_url" default="" />
<arg name="tgt_system" default="1" />
<arg name="tgt_component" default="1" />
<arg name="fcu_protocol" default="v2.0" />
<arg name="respawn_mavros" default="false" />
<include file="$(find mavros)/launch/node.launch">
<arg name="pluginlists_yaml" value="$(find mavros)/launch/apm_pluginlists.yaml" />
<arg name="config_yaml" value="$(find mavros)/launch/apm_config.yaml" />
<arg name="fcu_url" value="$(arg fcu_url)" />
<arg name="gcs_url" value="$(arg gcs_url)" />
<arg name="tgt_system" value="$(arg tgt_system)" />
<arg name="tgt_component" value="$(arg tgt_component)" />
<arg name="fcu_protocol" value="$(arg fcu_protocol)" />
<arg name="respawn_mavros" default="$(arg respawn_mavros)" />
</include>
</launch>
运行修改后的apm.launch。
开始SITL了。
可能报错:
File not readable /usr/share/GeographicLib/geoids/egm96-5.pgm |
Run install_geographiclib_dataset.sh script in order to install Geoid Model dataset!
解决方法:从github下mavros源码。源码中找到install_geographiclib_dataset.sh 使用root用户执行此脚本。
$ find . -name install*
./mavros/scripts/install_geographiclib_datasets.sh
安装时间很长。安装好之后,再次遇到同样的错误。发现安装目录在/usr/local/share/GeographicLib/ 而 launch读取路径是/usr/share/GeographicLib。拷贝一份到/usr/share/GeographicLib路径下。OK。