Ardupilot 软件在环SITL仿真学习

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lixiaoweimashixiao/article/details/83244115

目录

摘要


本文主要学习Ardupilot 的软件在环SITL仿真功能!需要的工具:ardupilot固件代码+Missionplanner地面站;这里我用的是3.6固件
Ardupilot飞控固件本身已经做的很完善了,但是如果我们需要定制特定的代码,需要修改代码。修改代码完成特定的功能后,就需要飞行验证。
如果直接去飞行,有可能会出现意外,造成不必要的损失,并且每次出去测试需要找一定的场所,花费时间和经历!
因此要是可以在电脑上模拟自己修改代码完成的功能就好了???以至于我们可以在电脑上模拟一个仿真的环境来验证修改后的代码的有效性!!!
幸运的是:Ardupilot固件代码中集成了仿真程序,我们只需要做一些简单的设置就可以方便地搭建出一个运行在电脑上的完全模拟真实飞行的仿真环境。
本节基于ardupilot的多旋翼固件arducopter进行SITL仿真学习

参考资料:ardupilot官网SITL地址



1.配置SITL功能



  • Step #1 - Install VMWare and create an Ubuntu Virtual Machine
  • Step #2 - Start the VM for the first time
  • Step #3 - Setting up shared partition with Windows & Ubuntu Virtual Machine

以上三步不再叙述,主要配置虚拟机VM


  • Step #4 - install packages on your VM

打开一个终端并键入以下内容来更新软件中心的软件包列表:

在终端输入下面命令:sudo apt-get update

在这里插入图片描述

然后安装下面的软件包(答复“Y”,如果它提示你使用了额外的磁盘空间)

sudo apt-get install python-dev dos2unix python-wxgtk2.8 python-matplotlib python-opencv python-pip g++ g++-4.7 gawk git ccache

sudo pip install pymavlink
sudo pip install mavproxy

如果您希望运行飞机,您还需要安装这些软件包:

sudo apt-get install libexpat1-dev auto.conf libtool automake

  • Step #5 - Follow the Linux instructions

查看电脑IP
在这里插入图片描述


配置地面站:UDP+115200


在这里插入图片描述



  • Step #6 - 切换到VM终端

输入:自己飞控固件的目录:
cd Desktop/apmv5/arducopter/ArduCopter(根据自己的目录来定)
终端继续执行命令:

../Tools/autotest/sim_vehicle.py --console --map

编译后的界面


在这里插入图片描述


编译成功后,继续命令:


output add 192.168.159.1:14550(注意这里192.168.190.1是自己的IP地址,根据自己电脑替换)

在这里插入图片描述

然后打开missionplanner点击链接就可以
在这里插入图片描述
显示界面
在这里插入图片描述



第一部分总结:

  • 配置环境这里讲解的不详细,大家可以参考官网,我配置时,有很多命令执行都不对,但是后面还是可以仿真的
  • 这个关键的命令是

(1)切换到自己的ArduCopter目录:

cd Desktop/apmv5\(10-19)/ardupilot/ArduCopter

(2)编译仿真代码

../Tools/autotest/sim_vehicle.py --console --map

(3)输入链接地面站命令

output add 192.168.159.1:14550

(4)进入地面站,设置UDP+115200,然后点击连接按钮就可以



2.SITL指令学习



1.如何起飞

输入下面命令

arm throttle
rc 3 1800

在这里插入图片描述

在这里插入图片描述

会看到地面站显示无人机在自稳模式下:一直爬升


2.如何上锁


disarm

3.如何降落


mode land
rc 3 1500

在这里插入图片描述
在这里插入图片描述


4.如何修改模式


注意参数要小写

悬停模式:mode LOITER
自稳模式:mode STABILIZE
悬停着落:mode LAND
返航模式:mode RTL
绕圈模式:mode CIRCLE
自动模式:mode AUTO
刹车模式:mode BRAKE
('Available modes: ', ['STABILIZE', 'LAND', 'OF_LOITER', 'RTL', 'DRIFT', 'FLIP', 'AUTOTUNE', 'BRAKE', 'GUIDED_NOGPS', 'AVOID_ADSB', 'POSITION', 'SPORT', 'FLOWHOLD', 'POSHOLD', 'AUTO', 'GUIDED', 'ACRO', 'SMART_RTL', 'ALT_HOLD', 'LOITER', 'CIRCLE', 'THROW'])


如果你新增加了自己的模式,怎么办?
可以采用:mode 数字

enum control_mode_t {
    STABILIZE =     0,  // manual airframe angle with manual throttle
    ACRO =          1,  // manual body-frame angular rate with manual throttle
    ALT_HOLD =      2,  // manual airframe angle with automatic throttle
    AUTO =          3,  // fully automatic waypoint control using mission commands
    GUIDED =        4,  // fully automatic fly to coordinate or fly at velocity/direction using GCS immediate commands
    LOITER =        5,  // automatic horizontal acceleration with automatic throttle
    RTL =           6,  // automatic return to launching point
    CIRCLE =        7,  // automatic circular flight with automatic throttle
    LAND =          9,  // automatic landing with horizontal position control
    DRIFT =        11,  // semi-automous position, yaw and throttle control
    SPORT =        13,  // manual earth-frame angular rate control with manual throttle
    FLIP =         14,  // automatically flip the vehicle on the roll axis
    AUTOTUNE =     15,  // automatically tune the vehicle's roll and pitch gains
    POSHOLD =      16,  // automatic position hold with manual override, with automatic throttle
    BRAKE =        17,  // full-brake using inertial/GPS system, no pilot input
    THROW =        18,  // throw to launch mode using inertial/GPS system, no pilot input
    AVOID_ADSB =   19,  // automatic avoidance of obstacles in the macro scale - e.g. full-sized aircraft
    GUIDED_NOGPS = 20,  // guided mode but only accepts attitude and altitude
    SMART_RTL =    21,  // SMART_RTL returns to home by retracing its steps
    FLOWHOLD  =    22,  // FLOWHOLD holds position with optical flow without rangefinder
    FOLLOW    =    23,  // follow attempts to follow another vehicle or ground station
    ZIGZAG    =    24,  // ZIGZAG mode is able to fly in a zigzag manner with predefined point A and point B
};

例如:mode 24 就是切换到你新定义的模式
在这里插入图片描述


实现这些命令的参数在哪呢?进入ardupilot/Tools/scripts目录



5.如何修改遥控器输入


横滚命令: rc 1  1200
俯仰命令: rc 2  1200
油门命令: rc 3   1200
偏航命令: rc 4    1600

在这里插入图片描述

在这里插入图片描述

上面参数下载地址:参数设置表


6.如何修改参数


可以在地面站的参数列表直接修改参数,进行仿真,这里距离绕圈模式:
设定绕圈半径:circle_radius=2000cm
绕圈角速率;20deg/s

在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/lixiaoweimashixiao/article/details/83244115
今日推荐