Work in progress...

Dependencies:   ESC FreeIMU mbed-rtos mbed

Experiment - work in progress...

Committer:
MatteoT
Date:
Tue Oct 15 18:30:46 2013 +0000
Revision:
2:7439607ccd51
Child:
3:5e7476bca25f
IMU experiments with serial communication

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MatteoT 2:7439607ccd51 1 #include <stdint.h>
MatteoT 2:7439607ccd51 2
MatteoT 2:7439607ccd51 3 //this struct must be the same for all the programs communicating with the Quad.
MatteoT 2:7439607ccd51 4 struct QuadState;
MatteoT 2:7439607ccd51 5 struct QuadState {
MatteoT 2:7439607ccd51 6 float requested_throttle_1; //negative if not requested
MatteoT 2:7439607ccd51 7 float requested_throttle_2;
MatteoT 2:7439607ccd51 8 float requested_throttle_3;
MatteoT 2:7439607ccd51 9 float requested_throttle_4;
MatteoT 2:7439607ccd51 10
MatteoT 2:7439607ccd51 11 float actual_throttle_1;
MatteoT 2:7439607ccd51 12 float actual_throttle_2;
MatteoT 2:7439607ccd51 13 float actual_throttle_3;
MatteoT 2:7439607ccd51 14 float actual_throttle_4;
MatteoT 2:7439607ccd51 15
MatteoT 2:7439607ccd51 16 float actual_throttle_dt;
MatteoT 2:7439607ccd51 17 float average_throttle_dt;
MatteoT 2:7439607ccd51 18 float average_throttle_dt_k;
MatteoT 2:7439607ccd51 19
MatteoT 2:7439607ccd51 20 float actual_rx_delta_ms;
MatteoT 2:7439607ccd51 21 float actual_rx_wait_ms;
MatteoT 2:7439607ccd51 22
MatteoT 2:7439607ccd51 23 float estimated_altitude;
MatteoT 2:7439607ccd51 24 float estimated_rotation_q1;
MatteoT 2:7439607ccd51 25 float estimated_rotation_q2;
MatteoT 2:7439607ccd51 26 float estimated_rotation_q3;
MatteoT 2:7439607ccd51 27 float estimated_rotation_q4;
MatteoT 2:7439607ccd51 28
MatteoT 2:7439607ccd51 29 float estimated_position_x;
MatteoT 2:7439607ccd51 30 float estimated_position_y;
MatteoT 2:7439607ccd51 31 float estimated_position_z;
MatteoT 2:7439607ccd51 32 float estimated_rotation_y;
MatteoT 2:7439607ccd51 33 float estimated_rotation_p;
MatteoT 2:7439607ccd51 34 float estimated_rotation_r;
MatteoT 2:7439607ccd51 35
MatteoT 2:7439607ccd51 36 float target_position_x; //see _isRequired members
MatteoT 2:7439607ccd51 37 float target_position_y;
MatteoT 2:7439607ccd51 38 float target_position_z;
MatteoT 2:7439607ccd51 39 float target_rotation_y;
MatteoT 2:7439607ccd51 40 float target_rotation_p;
MatteoT 2:7439607ccd51 41 float target_rotation_r;
MatteoT 2:7439607ccd51 42
MatteoT 2:7439607ccd51 43 bool target_position_x_isRequired;
MatteoT 2:7439607ccd51 44 bool target_position_y_isRequired;
MatteoT 2:7439607ccd51 45 bool target_position_z_isRequired;
MatteoT 2:7439607ccd51 46 bool target_rotation_y_isRequired;
MatteoT 2:7439607ccd51 47 bool target_rotation_p_isRequired;
MatteoT 2:7439607ccd51 48 bool target_rotation_r_isRequired;
MatteoT 2:7439607ccd51 49
MatteoT 2:7439607ccd51 50 bool ZERO_ALL_MOTORS_NOW__DANGER;
MatteoT 2:7439607ccd51 51
MatteoT 2:7439607ccd51 52
MatteoT 2:7439607ccd51 53 void reset (){
MatteoT 2:7439607ccd51 54
MatteoT 2:7439607ccd51 55 requested_throttle_1 = -1;
MatteoT 2:7439607ccd51 56 requested_throttle_2 = -1;
MatteoT 2:7439607ccd51 57 requested_throttle_3 = -1;
MatteoT 2:7439607ccd51 58 requested_throttle_4 = -1;
MatteoT 2:7439607ccd51 59
MatteoT 2:7439607ccd51 60 actual_throttle_1 = 0;
MatteoT 2:7439607ccd51 61 actual_throttle_2 = 0;
MatteoT 2:7439607ccd51 62 actual_throttle_3 = 0;
MatteoT 2:7439607ccd51 63 actual_throttle_4 = 0;
MatteoT 2:7439607ccd51 64
MatteoT 2:7439607ccd51 65 actual_throttle_dt = 0.01;
MatteoT 2:7439607ccd51 66 average_throttle_dt = 0.01;
MatteoT 2:7439607ccd51 67 average_throttle_dt_k = 0.0125;
MatteoT 2:7439607ccd51 68
MatteoT 2:7439607ccd51 69 actual_rx_delta_ms = 0.1;
MatteoT 2:7439607ccd51 70 actual_rx_wait_ms = 0.1;
MatteoT 2:7439607ccd51 71
MatteoT 2:7439607ccd51 72 estimated_altitude = 0;
MatteoT 2:7439607ccd51 73 estimated_rotation_q1 = 0;
MatteoT 2:7439607ccd51 74 estimated_rotation_q2 = 0;
MatteoT 2:7439607ccd51 75 estimated_rotation_q3 = 0;
MatteoT 2:7439607ccd51 76 estimated_rotation_q4 = 0;
MatteoT 2:7439607ccd51 77
MatteoT 2:7439607ccd51 78 estimated_position_x = 0;
MatteoT 2:7439607ccd51 79 estimated_position_y = 0;
MatteoT 2:7439607ccd51 80 estimated_position_z = 0;
MatteoT 2:7439607ccd51 81 estimated_rotation_y = 0;
MatteoT 2:7439607ccd51 82 estimated_rotation_p = 0;
MatteoT 2:7439607ccd51 83 estimated_rotation_r = 0;
MatteoT 2:7439607ccd51 84
MatteoT 2:7439607ccd51 85 target_position_x = 0;
MatteoT 2:7439607ccd51 86 target_position_y = 0;
MatteoT 2:7439607ccd51 87 target_position_z = 0;
MatteoT 2:7439607ccd51 88 target_rotation_y = 0;
MatteoT 2:7439607ccd51 89 target_rotation_p = 0;
MatteoT 2:7439607ccd51 90 target_rotation_r = 0;
MatteoT 2:7439607ccd51 91
MatteoT 2:7439607ccd51 92 target_position_x_isRequired = false;
MatteoT 2:7439607ccd51 93 target_position_y_isRequired = false;
MatteoT 2:7439607ccd51 94 target_position_z_isRequired = false;
MatteoT 2:7439607ccd51 95 target_rotation_y_isRequired = false;
MatteoT 2:7439607ccd51 96 target_rotation_p_isRequired = false;
MatteoT 2:7439607ccd51 97 target_rotation_r_isRequired = false;
MatteoT 2:7439607ccd51 98
MatteoT 2:7439607ccd51 99 ZERO_ALL_MOTORS_NOW__DANGER = false;
MatteoT 2:7439607ccd51 100 }
MatteoT 2:7439607ccd51 101 };
MatteoT 2:7439607ccd51 102
MatteoT 2:7439607ccd51 103 struct QuadCommandHeader; //to be used with TCP (or UDP for control signals)
MatteoT 2:7439607ccd51 104 struct QuadCommandHeader {
MatteoT 2:7439607ccd51 105 uint8_t xor_name;
MatteoT 2:7439607ccd51 106 uint8_t xor_name_repeat;
MatteoT 2:7439607ccd51 107 uint32_t payload_length;
MatteoT 2:7439607ccd51 108 };