本文主要介绍一下CC3D的两大飞行模式的原理:1. Rate 2. Attitude. 以及PID的基本原理。至于AxisLock模式及Manual,日后续说。
笔者是CC3D开源飞控入门玩家,遇到过不少磕磕碰碰。所以写此文以记之,一是梳理一下遇到的问题及对策,二是希望帮到一些入门玩家。
OpenPilot是CC3D的官网,截止至现在(2016年1月6号),只能访问主页,wiki不能访问,所以要了解飞行器的原理,必须另寻它路。
参考aeroquad开源飞行器,看名字便知道这是一个针对四轴的项目,而CC3D可以控制固定翼等其它飞行器,这个网页介绍了
Rate 和 Attitude 的原理。另外的内容可以不看。
1)Rate Mode(倾斜度模式)-在松掉摇杆时,飞机保持固定倾斜度
Formerly known as Acrobatic or Acro mode. In this mode the software just tries to prevent the quad from pitching/rolling/yawing on its own. It does not try to stay level.
Rate mode uses a stick movement to generate up to 145 degrees/sec of pitch/roll correction.
- If used with attitude, the output of the attitude PID is the cmd input and represents a rate in radian/sec
- If used without attitude, the stick creates a rate in radian/sec (limited internally to +/-2.5 rps)
- That cmd is compared to the gyro rate (or the unbiased rate) in the rate PID
- The PID attempts to maintain a rate in either pitch/roll/yaw based upon the input to the PID
- The output of the PID is the motor command that is needed to maintain that rate
- Output is in PWM
这个模式
能干什么:防止四轴自己沿着 yaw/pitch/roll 方向运动。
不能干什么:保持水平。
简而言之,Rate模式时,遥感的输出会转化成yaw/pitch.roll方向的角速度,这个角速度的大小随着摇杆的偏移而增大,最大转速可以设置;当松掉摇杆后,
PID算法会让四轴维持到松摇杆之前的角度(Gyro rate或者 pitch/roll/yaw rate,即相对于起飞前初始状态的偏斜度)。
Rate 一词在这段话中有两个意思,非常容易混淆。
Rate Mode的Rate代表的是程度、角度,可以理解成偏移度、倾斜度。Rate in radian/sec 代表的是角速度。
在用Rate飞行的时候,对操控的反应速度有一定要求。方向遥感要及时调整,稍不留神,倾斜的飞行器容易就会飞出可控范围,这是Rate模式的特点,
可以做翻滚动作,但是因为不会自动会到水平位,Rate模式不用做航拍。航拍或者悬停要用到另外一种模式:Attitude。
2) Attitude Mode(姿态模式)-在松掉摇杆时,飞机保持水平
Formerly known as Stable mode. This mode uses a stick movement to generate up to 40 degrees of pitch/roll correction. It's like having a way more effective dual rate, and one that is not an exponential rate. Attitude mode is not a mode for bombing around the sky, it’s meant to be a stable platform for those that want to practice hovering or are using their quads for FPV, or other photo work.
While it can be flown around, you have a much degraded ability to counteract any harsh angle in this mode. Also remember that when you have stick command input, the accel auto leveling is basically paused, so you get no auto leveling when there is stick input.
- If used with velocity, the output of the velocity PID is the command input and represents an attitude in radian.
- If used without velocity, the control stick creates an attitude angle in radian (limited internally to +/-.75 rad (40 deg))
- That command is compared to the AHRS angle in the attitude PID
- The PID attempts to maintain an angle in either pitch or roll based upon the input to the PID
- The output of the PID is the correction rate that is needed to maintain this attitude.
- Output is in radians per second (RPS)
从这段话大概知道几个意思:
首选,这个模式属于入门模式,在没有动遥控的情况下,飞机处于水平,不容易大角度倾斜导致失控。同时也是航拍时的稳定模式。
其二,摇杆控制的是倾斜度。掰多少摇杆飞机倾斜多少,松掉摇杆飞机就恢复水平。
其三,PID算法在不断修改倾斜度,以保持姿态。
总之,Attitude模式下的四轴相对与Rate模式要“智能”一些,对新手开说更容易操控,因为默认情况下PID算法让飞机保持水平。
因为Attitude的PID算法有两个Loop,内层的Loop用作Rate模式,外层的Loop将Rate的输出用作姿态控制。
我们为何要一个不安全的Rate模式和一个稳定的Attitude模式?甚至还有没介绍的AxisLock模式?
这就是CC3D的魅力:可以用作稳定性要求更高的航拍,也可玩飞行动作。咸淡皆可。
不同飞行模式下的飞机的表现不同,本质上就是PID算法的不同。笔者对控制理论不是很了解,希望更深入了解的朋友,请参阅更多自动控制方面的知识。