NOT FINISHED YET!!! My first try to get a self built fully working Quadrocopter based on an mbed, a self built frame and some other more or less cheap parts.
Mixer/Mixer.cpp@26:96a072233d7a, 2012-11-27 (annotated)
- Committer:
- maetugr
- Date:
- Tue Nov 27 19:49:38 2012 +0000
- Revision:
- 26:96a072233d7a
- Child:
- 28:ba6ca9f4def4
IMU_Filter and Mixer now new appart from the main
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maetugr | 26:96a072233d7a | 1 | #include "Mixer.h" |
maetugr | 26:96a072233d7a | 2 | |
maetugr | 26:96a072233d7a | 3 | Mixer::Mixer() |
maetugr | 26:96a072233d7a | 4 | { |
maetugr | 26:96a072233d7a | 5 | for(int i=0; i<4; i++) |
maetugr | 26:96a072233d7a | 6 | Motor_speed[i]=0; |
maetugr | 26:96a072233d7a | 7 | } |
maetugr | 26:96a072233d7a | 8 | |
maetugr | 26:96a072233d7a | 9 | void Mixer::compute(unsigned long dt, const float * angle, int Throttle, const float * controller_value) |
maetugr | 26:96a072233d7a | 10 | { |
maetugr | 26:96a072233d7a | 11 | // Calculate new motorspeeds |
maetugr | 26:96a072233d7a | 12 | // Pitch |
maetugr | 26:96a072233d7a | 13 | Motor_speed[0] = Throttle +controller_value[1]; |
maetugr | 26:96a072233d7a | 14 | Motor_speed[2] = Throttle -controller_value[1]; |
maetugr | 26:96a072233d7a | 15 | |
maetugr | 26:96a072233d7a | 16 | #if 1 |
maetugr | 26:96a072233d7a | 17 | // Roll |
maetugr | 26:96a072233d7a | 18 | Motor_speed[1] = Throttle +controller_value[0]; |
maetugr | 26:96a072233d7a | 19 | Motor_speed[3] = Throttle -controller_value[0]; |
maetugr | 26:96a072233d7a | 20 | |
maetugr | 26:96a072233d7a | 21 | /*// Yaw |
maetugr | 26:96a072233d7a | 22 | Motor_speed[0] -= controller_value[2]; |
maetugr | 26:96a072233d7a | 23 | Motor_speed[2] -= controller_value[2]; |
maetugr | 26:96a072233d7a | 24 | |
maetugr | 26:96a072233d7a | 25 | Motor_speed[1] += controller_value[2]; |
maetugr | 26:96a072233d7a | 26 | Motor_speed[3] += controller_value[2];*/ |
maetugr | 26:96a072233d7a | 27 | #endif |
maetugr | 26:96a072233d7a | 28 | |
maetugr | 26:96a072233d7a | 29 | for(int i = 0; i < 4; i++) // make shure no motor stands still |
maetugr | 26:96a072233d7a | 30 | Motor_speed[i] = Motor_speed[i] > 50 ? Motor_speed[i] : 50; |
maetugr | 26:96a072233d7a | 31 | } |