A Quadcopter Flight Controller
A flight controller for a quadcopter with four electric motors.
Project Description
This project contains a model of a controller for a quadcopter with four electric motors, control and display panels referenced as a dependencies, and a test model to verify its behavior.
The model takes as inputs the current attitude (pitch, roll, yaw), the desired attitude and the vertical acceleration. And from this data, the command of the four motors are computed. Control and display panels can be used to set model inputs and visualize its outputs.
There are also two other inputs : one to give the motor state (in order or damaged) and one to specify if the controller is reset. The controller also returns if the motors are in normal conditions or not.
Project Organisation
The model is composed of the following modules with functions, definitions and constants:
- QuadFlightControl: the quadcopter controller model and constants
- QuadUtils: utilities functions for the quadcopter controller
- QuadTypes: definitions of types for the quadcopter controller
The model contains the following test modules:
- QuadTest: the test model and constants to verify the motors direction
- QuadSimuRP: the test model with control and display panels
This model also uses functions from different libraries and graphical panels:
- Librairies of different mathematical functions
- Librairies for the tests: Sources to create inputs
- Graphical panels, generated with SCADE Rapid Prototyper: ControlPanel to set inputs and VTOLDisplay to visualize outputs
Root Operator
- Root operator: QuadFlightControl::QuadFlightControl
- Inputs
Name Type Description motorStates QuadTypes::MotorsFault four Booleans indicating for each motor if it is faulty or not isReset bool to specify if the quadcopter flight controller is reset currentAttitude QuadTypes::AttitudeType current attitude (pitch, roll and yaw) desiredAttitude QuadTypes::AttitudeType attitude to reach desiredVerticalAccel float32 vertical acceleration - Outputs
Name Type Description motorHealthState QuadTypes::MotorsHealth indicates if each motor works in nominal or abnormal or failure conditions rotorCmd QuadTypes::RotorCommands the four rotor commands
Jobs
The project contains the following jobs:
- CodeGen: a code generation job to generate the code from the root operator, which takes
- the QuadFlightControl module as input
- QuadFlightControl::QuadFlightControl as root operator
- ModelCheckQuadFlightC: a model check job to check that a model is correct, without generating code, which takes
- the QuadFlightControl module as input
- QuadFlightControl::QuadFlightControl as root operator
- Two simulation jobs which take as input the QuadTest module:
- SimVerticalAccel: takes QuadTest::SimVerticalAccel as test harness.
On the simulation trace, or during debug, you can observe that when the current attitude is set to 0.0 for the 3 components, and the desiredVerticalAccel evolves, the four rotors go up
- SimRightRoll: takes QuadTest::SimRightRoll as test harness.
On the simulation trace, or during debug, you can observe that when the desiredAttitude is fixed and when in currentAttitude, the roll goes from zero to positive, in order to rotate clockwise, the right rotors go down and the left rotors go up.
- SimVerticalAccel: takes QuadTest::SimVerticalAccel as test harness.
- Three test execution jobs to generate test result files that take as input the QuadTest module:
- QuadTest: allows to execute all the test harnesses (empty
Test Harness field) declared in the module. - TestExeRightRoll: takes QuadTest::TestRightRoll as test harness.
- TestVerticalAccel: takes QuadTest::TestVerticalAccel as test harness.
- QuadTest: allows to execute all the test harnesses (empty