Drone V1.0 Cleanflight - Pitt-RAS/iarc7_common GitHub Wiki
V1.0 Flight Controller Important Features (Cleanflight board)
Multiwii serial protocol
The MultiWii Serial Protocol allows control and information to be exchanged from the flight controller over a serial port. Commands include throttle, stick positions, arming, reporting of autopilot status, battery voltage monitoring, sensor readings, and etc.
Most of the things supported are done through the rx channels. The rx channels are currently being used in an incredibly hackish way to report whether the autopilot is enabled and communicate the autopilot enabling procedure.
The code that does communicates with the FC was developed by the team. It is located in the iarc7_fc_comms package.
SBUS Radio Receiver protocol
The radio receiver we have is a FrSky X8R, it supports the PWM or SBUS protocols. We use SBUS since it offers a higher update rate and only uses one wire.
OneShot125 ESC communication protocol
Instead of the traditional pwm used to control the ESC's we use OneShot125 to obtain a higher update rate. The higher the update rate the better.
Angle mode
This is flight mode that the drone normally flies in. Pitch and roll sticks correspond to pitch and roll angles of the drone. The yaw stick still communicates an angular yaw velocity. The throttle is a raw percentage.
Pitch and roll angle limiting
The flight controller limits the maximum pitch and roll angle that it will attempt set the drone at.
Dual rx
The flight controller accepts commands over the SBUS and MSP at the same time. Which commands are used at any given instant is determined by the humand pilot (SBUS) commands. There is a variety of ways the human pilot can limit or disable the MSP commands and take over full control of the drone.
Autopilot enabling procedure enforcement
In order for the MSP commands from the autopilot to be used autopilot enabling procedure must be followed by the human pilot. Some terms need to be defined.
Autopilot mode switch: A switch located on the RC controller. It enables autopilot mode of the flight controller. At this point the arming switch is no longer used to arm the motors but to allow the motors to be armed by the autopilot.
Arming switch: A switch located on the RC controller. When not in autopilot mode, the arming switch arms and disarms the ESC's. When the autopilot switch is on it is used to enable the autopilots control of the RC channels and allow the autopilot to arm the motors. It will not automatically the motors in this mode but instead allows the autopilot to choose if the motors are armed or not.
The procedure to enable autopilot is as follows:
- Switch on the autopilot enable switch
- Switch on the arming switch
At this point the the FC is in autopilot mode and the autopilot is allowed to send RC commands and arm the motors.
If the autopilot switch is turned off and arming switch is on and the the autopilot has armed the drone. The drone remains armed. This so that a human pilot can execute a "hard takeover" as explained below.
If the arming switch is turned off while the autopilot switch is on the autopilot is not allowed to send RC or arming commands and arming is disabled. The motors will be disarmed. This can be used to execute a crash landing during an emergency.
Autopilot soft override
When the autopilot is enabled. The maximum throttle request can be limited by the RC Transmitter. E.g. setting a the throttle stick on the RC transmitter to 90% limits the max thrust to 90%.
When the autopilot is enabled. The pitch and roll commands from the autopilot can be overridden by pitch and roll commands from the RC transmitter. If the pitch and roll command from the transmitter is zero then the autopilot commands are zero. If the pitch and roll commands from the RC transmitter are above a certain threshold they are used instead of the autopilots commands.
Autopilot hard override
If at any point the autopilot switch on the RC transmitter is switched off the pitch and roll commands from the radio are used immediately.
To prevent a jump in throttle (due to the throttle previously being used for a throttle maximum limit) the throttle is limited to the last sent by the autopilot until the RC transmitters throttle is brought back down to the level last sent by the autopilot. Once the RC transmitters throttle has been brought back down to the autopilots last sent throttle the FC will start using the RC transmitters throttle command again.
Autopilot privilege status reporting
Using MSP commands the autopilot can tell if its allowed to send RC commands or not. However, it can still choose to send RC commands regardless of whether or not they will be interpreted.
Accelerometer and gyroscope measurements
The MSP protocol allows reading the raw accelerometer and gyroscope sensor readings from the flight controller. These measurements are used by the navigation and perception stack.
Pitch, roll, yaw measurements
The flight controller uses a Mahoney filter to determine its current pitch, roll, and yaw. These can be read from the flight controller using the MSP protocol.
400 Hz Command and Sensor update rate
The MSP protocol and the baud rate used allows us to update the RC commands from the autopilot to the flight controller at 400 Hz. Additionally, the on-board sensors that are used are updated at 400 Hz. It would be nice if this were higher.
The serial rate has to be increased. This can be done with 'set serial_update_rate_hz = 2000'.
Configuration utility uses wireless connection
The Cleanflight configuration utility operates over a standard serial. This allows cheap serial to Bluetooth modules to be used instead of a physical cable when using the Cleanflight configuration tool. This significantly helps with debugging and PID controller tuning.