Work in progress...

Dependencies:   ESC FreeIMU mbed-rtos mbed

Experiment - work in progress...

Revision:
2:7439607ccd51
Child:
3:5e7476bca25f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/state.h	Tue Oct 15 18:30:46 2013 +0000
@@ -0,0 +1,108 @@
+#include <stdint.h>
+
+//this struct must be the same for all the programs communicating with the Quad.
+struct QuadState;
+struct QuadState {
+    float    requested_throttle_1; //negative if not requested
+    float    requested_throttle_2;
+    float    requested_throttle_3;
+    float    requested_throttle_4;
+
+    float    actual_throttle_1;
+    float    actual_throttle_2;
+    float    actual_throttle_3;
+    float    actual_throttle_4;
+    
+    float    actual_throttle_dt;
+    float    average_throttle_dt;
+    float    average_throttle_dt_k;
+    
+    float    actual_rx_delta_ms;
+    float    actual_rx_wait_ms;
+    
+    float    estimated_altitude;
+    float    estimated_rotation_q1;
+    float    estimated_rotation_q2;
+    float    estimated_rotation_q3;
+    float    estimated_rotation_q4;
+    
+    float    estimated_position_x;
+    float    estimated_position_y;
+    float    estimated_position_z;
+    float    estimated_rotation_y;
+    float    estimated_rotation_p;
+    float    estimated_rotation_r;
+    
+    float    target_position_x; //see _isRequired members
+    float    target_position_y;
+    float    target_position_z;
+    float    target_rotation_y;
+    float    target_rotation_p;
+    float    target_rotation_r;
+    
+    bool     target_position_x_isRequired;
+    bool     target_position_y_isRequired;
+    bool     target_position_z_isRequired;
+    bool     target_rotation_y_isRequired;
+    bool     target_rotation_p_isRequired;
+    bool     target_rotation_r_isRequired;
+    
+    bool     ZERO_ALL_MOTORS_NOW__DANGER;
+    
+    
+    void reset (){
+    
+        requested_throttle_1 = -1;
+        requested_throttle_2 = -1;
+        requested_throttle_3 = -1;
+        requested_throttle_4 = -1;
+
+        actual_throttle_1 = 0;
+        actual_throttle_2 = 0;
+        actual_throttle_3 = 0;
+        actual_throttle_4 = 0;
+    
+        actual_throttle_dt = 0.01;
+        average_throttle_dt = 0.01;
+        average_throttle_dt_k = 0.0125;
+    
+        actual_rx_delta_ms = 0.1;
+        actual_rx_wait_ms = 0.1;
+    
+        estimated_altitude = 0;
+        estimated_rotation_q1 = 0;
+        estimated_rotation_q2 = 0;
+        estimated_rotation_q3 = 0;
+        estimated_rotation_q4 = 0;
+    
+        estimated_position_x = 0;
+        estimated_position_y = 0;
+        estimated_position_z = 0;
+        estimated_rotation_y = 0;
+        estimated_rotation_p = 0;
+        estimated_rotation_r = 0;
+    
+        target_position_x = 0;
+        target_position_y = 0;
+        target_position_z = 0;
+        target_rotation_y = 0;
+        target_rotation_p = 0;
+        target_rotation_r = 0;
+    
+        target_position_x_isRequired = false;
+        target_position_y_isRequired = false;
+        target_position_z_isRequired = false;
+        target_rotation_y_isRequired = false;
+        target_rotation_p_isRequired = false;
+        target_rotation_r_isRequired = false;
+        
+        ZERO_ALL_MOTORS_NOW__DANGER = false;
+    }
+};
+
+struct QuadCommandHeader; //to be used with TCP (or UDP for control signals)
+struct QuadCommandHeader {
+  uint8_t   xor_name;
+  uint8_t   xor_name_repeat;
+  uint32_t  payload_length;
+};