很好的中文参考文档,必看!!!
https://doc.cuav.net/tutorial/copter
官方参考文献
主打的就是一个炫酷
自驾仪 Ardupilot
一套开源的自驾仪,集成了各种各样的代码,包括其他开源代码(如PX4代码)和项目、驱动等。
即:自驾仪即集成了整个可以实现无人载具(如无人机)自动驾驶功能的代码。
固件 Firmware
指定硬件(即target board)后,将Ardupilot编译后的可以下载到硬件的二进制程序(文件)。
文件后缀一般为.hex
软件(地面站)
一般指运行在pc上的地面站Mission Planner或QGC。
常用的地面站包括:
- Mission Planner
- QGC
- APM Planner 2 Home
- MAVProxy
地面站的主要功能包括:
- Point-and-click waypoint/fence/rally point entry, using Google Maps/Bing/Open street maps/Custom WMS.
- Select mission commands from drop-down menus
- Download mission log files and analyze them
- Configure autopilot settings for your vehicle
- Interface with a PC flight simulator to create a full software-in-the-loop (SITL) UAV simulator.
- Run its own SITL simulation of many frames types for all the ArduPilot vehicles.
支持的硬件
不同的载具类型由不同的硬件设备支持,以copter为例:
- 开源硬件 Open hardware:
ARKV6X DS-10 Pixhawk6
CUAV V5 Plus
CUAV V5 Nano
CUAV Nora
CUAV Pixhawk v6X
CUAV X7/X7Pro/X7+/X7+ Pro
Drotek Pixhawk3
F4BY
CubePilot Cube Black
CubePilot Cube Orange/+
CubePilot Cube Purple
CubePilot Cube Yellow
CubePilot Cube Green
Holybro Durandal H7
Holybro Pix32 v5
Holybro Pixhawk 4
Holybro Pixhawk6X
Holybro Pixhawk6C/ 6C Mini
Holybro Pix32v6(Pixhawk6C variant)
mRo Pixhawk
mRo Pixracer
mRo X2.1
mRo X2.1-777
OpenPilot Revolution
TauLabs Sparky2* - 不开源的硬件 Closed hardware:
Aerotenna Ocpoc-Zynq
Airvolute DroneCore
AtomRC F405-NAVI
Emlid NAVIO2 (Linux)
Flywoo F745 AIO BL_32/ Nano
Foxeer Reaper F745-AIO V2
Furious FPV F-35 Lightning and Wing FC-10
Holybro Kakute F4*
Holybro Kakute F4 Mini*
Holybro Kakute F7 AIO*
Holybro Kakute F7 Mini* (only V1 and V2 are compatible)
等等…
更多请参考官网:https://ardupilot.org/copter/docs/common-autopilots.html
查询与Ardupilot兼容的硬件方法:
以Coppter为例
https://ardupilot.org --> DOCUMENTATION --> Coppter --> Autopilot Hardware Options
支持的机器类型(载具类型) Vehicle Types Supported by ArduPilot
如:多旋翼、直升机、无人船、无人小车等…
ArduPilot目前有五种 vehicles(Copter、Plane、Rover、Sub和Antenna Tracker)
更多兼容的载具类型请参考官网:https://ardupilot.org/ardupilot/docs/common-all-vehicle-types.html
MAVLink协议
自驾仪Ardupilot与地面站、上位机、ros等设备或软件通讯的协议。
MAVProxy(最小地面站)
一个基于MAVLink的地面站软件包。A UAV ground station software package for MAVLink based systems。
MAVProxy是一个功能齐全的、最低限度、便携的、可扩展的无人机UAV地面站。
特点:
- 基于命令行的地面站软件,一般适合开发人员使用。
- 它可以通过附加模块进行扩展,也可以与另一个地面站(如Mission Planner、APM Planner 2、QGroundControl等)进行相互的功能补充,以提供图形用户界面。
- 可以通过UDP通信协议将无人机的信息通过网络转发到在其他设备上运行的地面站软件。
- 用户现在在其他地面站工具中看到的许多功能可以追溯到MAVProxy。
- 它是一个基于命令行控制台的应用程序。MAVProxy中包含一些插件来提供基本的GUI。
- 可以联网并在任何数量的计算机上运行。
- 它是便携的,可以在Linux、OS X、Windows和其他操作系统上运行。只要这些系统满足:any POSIX OS with python, pyserial, and select() function calls。
- 它支持可加载模块,并具有支持控制台、移动地图、操纵杆、天线跟踪器等的模块。
- 按Tab键完成命令。
常用的MAVProxy命令:https://ardupilot.org/mavproxy/docs/getting_started/cheatsheet.html#mavproxy-cheetsheet
学习MAVProxy更多知识请参考官网https://ardupilot.org/mavproxy/index.html
配套计算机(上位机) Companion Computers
一般指:
- 运行地面站的PC
- 负责运行一些高级任务(目标检测、拍照等)的上位机,如树莓派、TX2等。
这些上位机与飞控(下位机)通过Mavlink进行通信。
上位机可以划分未两个部分,即:
- 硬件平台,如树莓派
- 软件,如Ros机器人操作系统
流行的上位机硬件和使用教程(与ardupilot通信的教程)
流行的上位机软件和使用教程(与ardupilot通信的教程)
具体请参考官网:https://ardupilot.org/dev/docs/companion-computers.html
ArduPilot外围设备 AP_Periph
AP_Periph是ArduPilot外围设备的缩写,即基于现有ArduPilat自动驾驶仪代码的ArduPilet外围设备。它采用ArduPilot的外围设备驱动程序库,并使其在独立的外围设备上运行,这些外围设备通过CAN、MSP或其他外围总线协议与主自动驾驶仪通信。
详细请参考https://ardupilot.org/dev/docs/ap-peripheral-landing-page.html
Ardupilot 代码学习、二次开发
官方开发者文档:https://ardupilot.org/dev/index.html
建议编译环境:ubantu
编辑器:VSCode
代码框架
代码调用逻辑,从下往上分析,以pixhawk硬件平台为例:
- pixhawk负责执行操作系统ChibiOS;
- ChibiOS执行了一系列进程或应用,这些应用调用了Flight Code;
- Flight Code中的调用逻辑:上层应用如姿态控制代码调用了共享库代码,共享库代码调用了硬件抽象层代码;
- Flight Code与上位机的通信通过MAVLink协议实现;
代码可以分为5个主要模块进行分析:
- vehicle code 车辆代码
- shared libraries 共享库
- hardware abstraction layer (AP_HAL) 硬件抽象层
- tools directories 工具目录
- external support code (i.e. mavlink, dronekit) 外部支持代码(即mavlink、dronekit)
vehicle code 机器代码
vehicle directories是定义每种车辆类型的固件的顶级目录。目前,共有6种车型:Plane, Copter, Rover, Sub, Blimp and AntennaTracker。尽管不同车型之间有很多共同的元素,但它们各不相同。目前,我们只对Copter的代码结构进行了详细描述。
除了*.cpp文件外,每个车辆目录都包含一个wscript文件,该文件列出了库依赖项。
Libraries
这些库在所有车型之间共享。这些库包括传感器驱动器、姿态和位置估计(又名EKF)以及控制代码(即PID控制器)。
硬件抽象层 AP_HAL
AP-HAL层(硬件抽象层)是我们使ArduPilot可移植到许多不同平台的方法。库/AP_HAL中有一个顶级AP_HAL,它定义了代码的其余部分与特定板功能的接口,然后每种板类型都有一个AP_HAL_XXX子目录,例如,基于AVR的板有AP_HAL_AVR,Pixhawk板有AP_HAL_PX4,基于Linux的板有AP-HAL_Linux
Tools directories
工具目录是杂项支持目录。例如,tools/autotest提供了autotest.ardupilot.org网站后面的自动测试基础设施,tools/Relay提供了我们的日志回放实用程序。
External support code 外部支持代码
在某些硬件平台上,我们需要外部支持代码来提供额外的功能或硬件板的支持。目前外部代码包括:
- PX4NuttX - the core NuttX RTOS used on Pixhawk boards
- PX4Firmware - the base PX4 middleware and drivers used on Pixhawk boards
- uavcan - the uavcan CANBUS implementation used in ArduPilot
- mavlink - the mavlink protocol and code generator
这些外部代码编译时才被导入。
当您Build 项目代码时,其中大多数外部支持代码都作为Git子模块( Git Submodules)导入。
所有的外部代码(或称子模块Submodules)都保存在目录modules中,并且需要用Git Submodules命令才会导入,初始git代码时目录内是空的:
ArduPilot使用单一级别的git子模块,所有模块都存储在modules目录中。选择这种方法是因为它可以更简单地诊断子模块的问题。这意味着,如果一个外部项目(即PX4固件)有自己的子模块,这些子模块会直接出现在ArduPilot/modules目录中。
导入或更新子模块(submodule)
- 手动更新子模块:
git submodule update --recursive
- 如果master分支有新添加的子模块时,之后每个开发人员都必须运行以下命令:
git submodule init
- 导入或更新子模块时遇到的问题及解决办法请参考https://ardupilot.org/dev/docs/git-submodules.html#git-submodules
ArduPilot Libraries
The libraries are shared with Copter, Plane and Rover. Below is a high level list of libraries and their function.
Core libraries:
- AP_AHRS :attitude estimation using DCM or EKF
- AP_Common : core includes required by all sketches and libraries
- AP_Math : various math functions especially useful for vector manipulation
- AC_PID :PID(Proportional-Integral-Derivative) controller library
- AP_InertialNav :inertial navigation library for blending accelerometer inputs with gps and baro data
- AC_AttitudeControl :ArduCopter’s control library includes various functions of attitude, position control based on PID control.
- AC_WPNav :waypoint navigation library
- AP_Motors:multicopter and traditional helicopter motor mixing
- RC_Channel :a library to more convert pwm input/output from APM_RC into internal units such as angles
- AP_HAL, AP_HAL_ChibiOS, AP_HAL_Linux :libraries to implement the “Hardware abstraction layer” which presents an identical interface to the high level code so that it can more easily be ported to different boards
Sensor libraries:
- AP_InertialSensor :reads gyro and accelerometer data, perform calibration and provides data in standard units (deg/s, m/s) to main code and other libraries
- AP_RangeFinder :sonar and ir distance sensor interfaced library
- AP_Baro : barometer interface library
- AP_GPS : gps interface library
- AP_Compass :3-axis compass interface library
- AP_OpticalFlow : optical flow sensor interface library
Other libraries:
- AP_Mount, AP_Camera, AP_Rel