ardupliot、SITL、Gazebo联合仿真

Ardupliot、SITL、Gezabo联合仿真安装教程

Ardupliot

官方:https://ardupilot.org/dev/docs/building-setup-linux.html

git clone --recurse-submodules https://github.com/ArduPilot/ardupilot.git  # 这步可能由于网络原因会很慢

或者

git clone https://github.com/ArduPilot/ardupilot.git
git submodule update --init --recursive 

安装依赖包

cd ardupilot
# 安装一些依赖包
Tools/environment_install/install-prereqs-ubuntu.sh -y  # 这一步可能会编译有问题,原因是报错位置结构体初始化的问题

Ubuntu安装MAVProxy

https://ardupilot.org/mavproxy/docs/getting_started/download_and_installation.html#linux

在Ubuntu中设置SITL

官方:https://ardupilot.org/dev/docs/setting-up-sitl-on-linux.html

通过以下语句查看环境中缺少的库,用pip或者conda去安装(主要缺少wxPython、matplotlib)

./sim_vehicle.py -v ArduCopter --console --map --moddebug 3

启动对应载具的SITL仿真,–console是工作台,–map是地图(出现下图就代表成功)

sim_vehicle.py -v ArduCopter --console --map

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

Gazebo

Ubuntu20.04推荐安装最新的Gazebo Garden,因为最新的版的ardupliot_gazebo插件是基于Gazebo Garden

安装教程https://gazebosim.org/docs/garden/install

Gazebo官方入门教程 https://gazebosim.org/docs/all/getstarted

Ubuntu18.04安装Gazebo9

(1)添加源

sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'

(2)查询源是否添加

cat /etc/apt/sources.list.d/gazebo-stable.list
显示:deb http://packages.osrfoundation.org/gazebo/ubuntu-stable xenial main

输入cat指令后,下面正常显示,说明添加源成功!

(3)设置Keys

wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -

(4)开始安装gazebo

sudo apt-get update
sudo apt-get install gazebo9
sudo apt-get install libgazebo9-dev

ardupliot_gazebo

旧版:https://github.com/khancyr/ardupilot_gazebo

新版:https://github.com/ArduPilot/ardupilot_gazebo

git clone https://github.com/khancyr/ardupilot_gazebo      # Ubuntu 18.04 
cd ardupilot_gazebo
mkdir build
cd build
cmake ..
make -j4
sudo make install

环境变量到bashrc

echo 'source /usr/share/gazebo/setup.sh' >> ~/.bashrc
echo 'export GAZEBO_MODEL_PATH=~/ardupilot_gazebo/models' >> ~/.bashrc
echo 'export GAZEBO_RESOURCE_PATH=~/ardupilot_gazebo/worlds:${GAZEBO_RESOURCE_PATH}' >> ~/.bashrc
source ~/.bashrc

eg:

启动 Ardupilot SITL)

sim_vehicle.py -v ArduCopter -f gazebo-iris --map --console

启动 Gazebo with demo 3DR Iris model)

gazebo --verbose worlds/iris_arducopter_runway.world

# 这一布可能会由于下载模型卡住,可以将ardupilot_gazebo/models/iris_with_ardupilot/model.sdf 以下内容注释掉
    <!-- <include>
      <uri>model://gimbal_small_2d</uri>
      <pose>0 -0.01 0.070 1.57 0 1.57</pose>
    </include> 

    <joint name="iris_gimbal_mount" type="revolute">
      <parent>iris::base_link</parent>
      <child>gimbal_small_2d::base_link</child>
      <axis>
        <limit>
          <lower>0</lower>
          <upper>0</upper>
        </limit>
        <xyz>0 0 1</xyz>
        <use_parent_model_frame>true</use_parent_model_frame>
      </axis>
    </joint> -->

启动之后会出现SITL仿真界面和Gazebo仿真界面,在SITL终端中输入一些命令,Gazebo会同步进行相应的动作,例如:

mode guided  # 切换引导模式
arm throttle    # 电机
takeoff 40        # 起飞到40m高度

QGroundControl地面站

用户指南:https://docs.qgroundcontrol.com/master/en/

简单使用教程:https://blog.51cto.com/u_15352549/5321405

官方下载教程:https://docs.qgroundcontrol.com/master/en/getting_started/download_and_install.html

官方最新的可能不支持Ubuntu18.04,会报如下错误

/tmp/.mount_QGrounEJ5eRN/QGroundControl: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /tmp/.mount_QGrounEJ5eRN/QGroundControl)
/tmp/.mount_QGrounEJ5eRN/QGroundControl: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /tmp/.mount_QGrounEJ5eRN/QGroundControl)

可以到https://github.com/mavlink/qgroundcontrol/releases/tag/v3.5.6下载旧的稳定版本

chmod +x ./QGroundControl.AppImage
./QGroundControl.AppImage

可通过地面站中的一些操作发送相应的指令,gazebo中无人机会执行相应的指令,并且能够显示各种参数信息,更为方便# Ardupliot、SITL、Gezabo联合仿真安装教程

Ardupliot

官方:https://ardupilot.org/dev/docs/building-setup-linux.html

git clone --recurse-submodules https://github.com/ArduPilot/ardupilot.git  # 这步可能由于网络原因会很慢

或者

git clone https://github.com/ArduPilot/ardupilot.git
git submodule update --init --recursive 

安装依赖包

cd ardupilot
# 安装一些依赖包
Tools/environment_install/install-prereqs-ubuntu.sh -y  # 这一步可能会编译有问题,原因是报错位置结构体初始化的问题

Ubuntu安装MAVProxy

https://ardupilot.org/mavproxy/docs/getting_started/download_and_installation.html#linux

在Ubuntu中设置SITL

官方:https://ardupilot.org/dev/docs/setting-up-sitl-on-linux.html

通过以下语句查看环境中缺少的库,用pip或者conda去安装(主要缺少wxPython、matplotlib)

./sim_vehicle.py -v ArduCopter --console --map --moddebug 3

启动对应载具的SITL仿真,–console是工作台,–map是地图(出现下图就代表成功)

sim_vehicle.py -v ArduCopter --console --map

Gazebo

Ubuntu20.04推荐安装最新的Gazebo Garden,因为最新的版的ardupliot_gazebo插件是基于Gazebo Garden

安装教程https://gazebosim.org/docs/garden/install

Gazebo官方入门教程 https://gazebosim.org/docs/all/getstarted

Ubuntu18.04安装Gazebo9

(1)添加源

sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'

(2)查询源是否添加

cat /etc/apt/sources.list.d/gazebo-stable.list
显示:deb http://packages.osrfoundation.org/gazebo/ubuntu-stable xenial main

输入cat指令后,下面正常显示,说明添加源成功!

(3)设置Keys

wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -

(4)开始安装gazebo

sudo apt-get update
sudo apt-get install gazebo9
sudo apt-get install libgazebo9-dev

ardupliot_gazebo

旧版:https://github.com/khancyr/ardupilot_gazebo

新版:https://github.com/ArduPilot/ardupilot_gazebo

git clone https://github.com/khancyr/ardupilot_gazebo      # Ubuntu 18.04 
cd ardupilot_gazebo
mkdir build
cd build
cmake ..
make -j4
sudo make install

环境变量到bashrc

echo 'source /usr/share/gazebo/setup.sh' >> ~/.bashrc
echo 'export GAZEBO_MODEL_PATH=~/ardupilot_gazebo/models' >> ~/.bashrc
echo 'export GAZEBO_RESOURCE_PATH=~/ardupilot_gazebo/worlds:${GAZEBO_RESOURCE_PATH}' >> ~/.bashrc
source ~/.bashrc

eg:

启动 Ardupilot SITL)

sim_vehicle.py -v ArduCopter -f gazebo-iris --map --console

启动 Gazebo with demo 3DR Iris model)

gazebo --verbose worlds/iris_arducopter_runway.world

# 这一布可能会由于下载模型卡住,可以将ardupilot_gazebo/models/iris_with_ardupilot/model.sdf 以下内容注释掉
    <!-- <include>
      <uri>model://gimbal_small_2d</uri>
      <pose>0 -0.01 0.070 1.57 0 1.57</pose>
    </include> 

    <joint name="iris_gimbal_mount" type="revolute">
      <parent>iris::base_link</parent>
      <child>gimbal_small_2d::base_link</child>
      <axis>
        <limit>
          <lower>0</lower>
          <upper>0</upper>
        </limit>
        <xyz>0 0 1</xyz>
        <use_parent_model_frame>true</use_parent_model_frame>
      </axis>
    </joint> -->

启动之后会出现SITL仿真界面和Gazebo仿真界面,在SITL终端中输入一些命令,Gazebo会同步进行相应的动作,例如:

mode guided  # 切换引导模式
arm throttle    # 电机
takeoff 40        # 起飞到40m高度

QGroundControl地面站

用户指南:https://docs.qgroundcontrol.com/master/en/

简单使用教程:https://blog.51cto.com/u_15352549/5321405

官方下载教程:https://docs.qgroundcontrol.com/master/en/getting_started/download_and_install.html

官方最新的可能不支持Ubuntu18.04,会报如下错误

/tmp/.mount_QGrounEJ5eRN/QGroundControl: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /tmp/.mount_QGrounEJ5eRN/QGroundControl)
/tmp/.mount_QGrounEJ5eRN/QGroundControl: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by /tmp/.mount_QGrounEJ5eRN/QGroundControl)

可以到https://github.com/mavlink/qgroundcontrol/releases/tag/v3.5.6下载旧的稳定版本

chmod +x ./QGroundControl.AppImage
./QGroundControl.AppImage

可通过地面站中的一些操作发送相应的指令,gazebo中无人机会执行相应的指令,并且能够显示各种参数信息,更为方便

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值