A library used for controlling a quadcopter. It provides an easy to use interface, which allows to mount, calibrate and run motors. It is also able to calibrate the actual speed according to calculated PID roll & pitch difference. I used the original Servo library as ESC modules use the same PWM signal as Servo motors.
Diff: Quadcopter.h
- Revision:
- 5:2aa78a442132
- Parent:
- 4:90ce5817667b
- Child:
- 6:a6b8e508643d
diff -r 90ce5817667b -r 2aa78a442132 Quadcopter.h --- a/Quadcopter.h Fri Feb 20 00:11:00 2015 +0000 +++ b/Quadcopter.h Fri Feb 20 00:28:52 2015 +0000 @@ -8,23 +8,43 @@ class Quadcopter { public: - //constructor of the instance. FL correspond to Front_Left, FR to Front Right... + /** + * Constructor. + * + * @param FL - Front Left motor. + * @param FR - Front Right motor. + * @param BL - Back Left motor. + * @param BR - Back Right motor. + * + */ Quadcopter(PinName FL, PinName FR, PinName BL, PinName BR); - //function used to calibrate all 4 ESC before actually flying the copter - //it takes min and max values, which are in range from 0.0 to 1.0 - //it does not matter which of inputs is min and which is max as function checks that itself - //If inputs are out of boundaries, min value becomes 0.0, and max value becomes 1.0 automatically + /** + * Function used to calibrate all 4 ESC before actually flying the quadcopter. + * It does not matter which of inputs is min and which is max as function checks that itself. + * If inputs are out of boundaries, min value becomes 0.0, and max value becomes 1.0 automatically + * + * @param min - minimum value for the ESC in range from 0.0 to 1.0. + * @param max - maximum value for the ESC in range from 0.0 to 1.0. + */ void calibrate (float min, float max); - //function for runing motors - //Function takes array of 4 variables, which corresponds to the speed for all 4 motors - //speeds are in range from 0.0 to 1.0 + /** + * function for runing motors. + * + * @param speed - array of 4 variables, which corresponds to the speed for all 4 motors. speeds are in range from 0.0 to 1.0. + */ void run (float* speed); - //function used calculate the speed at which each of the motors should run to be able to stabilise the quadcopter - //speed here is the current speed for each motor, actSpeed is the output speed at which motors should run - //rollDiff & pitchDiff are both calculated using PID library function PID::compute(); + /** + * Function used to calculate the speed at which each of the motors should run to be able to stabilise the quadcopter. + * + * @param speed - current speed for each motor. + * @param actSpeed - actual speed at which motors should run + * @param rollDiff - calculated using PID library function PID::compute(); + * @param pitchDiff - calculated using PID library function PID::compute(); + * + */ void stabilise (float* speed, float* actSpeed, float rollDiff, float pitchDiff); private: