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.

Dependents:   QuadcopterProgram

Revision:
9:22c52af13ac2
Parent:
7:5ab77c583ae3
Child:
10:8147131fcebd
--- a/Quadcopter.h	Fri Feb 20 01:22:20 2015 +0000
+++ b/Quadcopter.h	Wed Feb 25 00:55:08 2015 +0000
@@ -14,12 +14,12 @@
 * #include "Quadcopter.h"
 * Quadcopter quad (p21, p22, p23, p24);   //intance of the Quadcopter class
 *
-* #define SAMPLE_NUM 50
 * #define MIN_CALIBRATE 0.3
 * #define MAX_CALIBRATE 1.0
 *
 * int main(){
-*   quad.calibrate (MIN_CALIBRATE, MAX_CALIBRATE, SAMPLE_NUM);
+*   quad.setLimits (MIN_CALIBRATE, MAX_CALIBRATE);    
+*   quad.calibrate ();
 *   
 *   float speed[4];
 *   for (int i = 0; i < 4; i++){    //initialise speed to be 0.2
@@ -50,13 +50,18 @@
     
     /**
     * Function used to calibrate all 4 ESC before actually flying the quadcopter.
+    */
+    void calibrate ();
+    
+    /**
+    * 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);
+    void setLimits(float min, float max);
     
     /**
     * function for runing motors.
@@ -76,10 +81,12 @@
     */
     void stabilise (float* speed, float* actSpeed, float rollDiff, float pitchDiff);
     
+    float getLowerLimit();
+    float getUpperLimit();
 private:  
     
     float min_calibrate;    //min value at which each motor is calibrated
-    float max_calibrate;     //max value ...
+    float max_calibrate;    //max value ...
     Servo* motor[4];        //motors are used with Servo library as ESC take the same input as usual Servo motors...
     float map(float x, float in_min, float in_max, float out_min, float out_max);    //function for mapping values in the range from min calibrate to max_calibrate
 };