1、环境配置
按照官网教程配置环境,链接:https://ardupilot.org/dev/docs/building-setup-windows-cygwin.html#building-setup-windows-cygwin
按照步骤安装即可。都安装在默认目录会比较好,之前尝试cygwin安装在D盘,git这些功能出了点问题。cygwin默认目录为:C:\cygwin64
1.1 安装 Cygwin
下载安装包: www.cygwin.com/install.html
方案1:将安装包放入 C:\Users\Administrator,然后打开cmd,输入
setup-x86_64.exe -P autoconf,automake,ccache,gcc-g++,git,libtool,make,gawk,libexpat-devel,libxml2-devel,python36,python36-future,python36-lxml,python36-pip,libxslt-devel,python36-devel,procps-ng,zip,gdb,ddd
安装过程可能遇到无法下载的问题,开 VPN 或者网上搜 cygwin 中国镜像地址,粘如URL,add即可,如:http://mirrors.163.com/cygwin/
然后一路默认,下一步…
方案2:一个一个选,安装步骤“Cygwin Installer: Select Package Dialog”可能比较繁琐,支持方案1。有一个简便教程:http://www.nufeichuiyun.com/?page_id=121
题主尝试失败了,有兴趣的可以尝试一下
按照教程安装好 cygwin,如果需要卸载,可以参考链接:
https://blog.csdn.net/some_times/article/details/21469551?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param
1.2 安装 GCC
下载安装包: firmware.ardupilot.org/Tools/STM32-tools
打开一路默认,直到最后一步,选上 “Add path to environment variable”
1.3 安装 MAVProxy
下载安装包: http://firmware.ardupilot.org/Tools/MAVProxy/
下载最新版: MAVProxySetup-latest.exe.
打开一路默认
1.4 配置python
打开cygwin然后关闭,以生成 initialisation files
打开cygwin,输入:
ln -s /usr/bin/python3.6 /usr/bin/python
ln -s /usr/bin/pip3.6 /usr/bin/pip
pip install empy pyserial pymavlink
第三步可能会很卡,下载失败,如图:多试几次即可,也可以尝试开VPN
这步会卡很久,等待
在cygwin窗口下载 ardupilot 源码:
git clone https://github.com/ardupilot/ardupilot.git
cd ardupilot
git submodule update --init --recursive
此处做一个提示:git 到的 ardupilot 文件夹不能随便复制粘贴,有的隐藏文件之类的东西粘不走会导致无法编译运行,两个办法可以解决:
1)重新 git 新的,一定没问题
2)先完成编译,跑一遍,然后整个 ardupilot 文件夹就可以粘贴并备份了
2、编译和运行
进入 cygwin 的根目录,找到文件 “.bashrc”, 如题主目录为:“D:\cygwin64\home\ling”。在 “.bashrc” 末尾添加:
export PATH = "$PATH:$HOME/ardupilot/Tools/autotest/"
之后编译运行即可,参考官网教程:
https://github.com/ArduPilot/ardupilot/blob/master/BUILD.md
编译 CubeBlack,copter:
cd ardupilot
./waf configure --board CubeBlack
./waf copter
编译其他板子参照官网教程
特别说明,SITL中,无需生成固件,第一次编译以后修改程序,可以省略这两个步骤:
./waf configure --board CubeBlack
./waf copter
以下是题主运行步骤:
参考官网教程:https://ardupilot.org/dev/docs/copter-sitl-mavproxy-tutorial.html#copter-sitl-mavproxy-tutorial
(1)、四旋翼
cd ardupilot/ArduCopter/
../Tools/autotest/sim_vehicle.py --map --console
在打开的 mavproxy 控制输入 输入指令,比如实现切到guided模式,解锁,起飞至20米,降落:
mode guided
arm throttle
takeoff 20
mode land
可以打开 mission planner 地面站,将通过UDP协议自动连接
如果需要修改起始位置,cygwin启动的命令行加入 "-L 位置“,如旧金山机场 KSFO:
../Tools/autotest/sim_vehicle.py --map --console -L KSFO
如需增加初始位置:可在cygwin64\home\ling\ardupilot\Tools\autotest\locations.txt 中添加,格式见 txt 文件第一行(#NAME=latitude,longitude,absolute-altitude,heading),如在末尾添加:
AirPort1=30,30,200,20
保存调用即可
(2)、固定翼
cd ~/ardupilot/ArduPLane/
../Tools/autotest/sim_vehicle.py --map --console -f plane
在打开的 mavproxy 控制输入 输入指令,比如实现切到takeoff模式,解锁,切到RTL模式(绕home点转圈),切到guided模式(默认以当前点为圆心转圈):
mode takeoff
arm throttle
mode rtl
mode guided
如图:
(3)、垂直起降固定翼(VTOL)
cd ~/ardupilot/ArduPLane/
../Tools/autotest/sim_vehicle.py --map --console -f quadplane
可以按照固定翼模式起飞,现切到takeoff模式,解锁:
mode takeoff
arm throttle
可以飞 QuadPlane AUTO Missions
参考官网教程:https://ardupilot.org/plane/docs/quadplane-auto-mode.html
打开 mission planner,航点设置如下:
3、开发,修改固件
参考官网 : https://ardupilot.org/dev/docs/learning-the-ardupilot-codebase.html
四旋翼进入 ardupilot\ArduCopter,修改 Copter.h和 Copter.cpp,重新编译执行
固定翼和VTOL,进入 ardupilot\ArduPlane,修改 Plane.h 和 ArduPlane.cpp,重新编译执行
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)