Remote control code for https://developer.mbed.org/users/ivo_david_michelle/code/QuadTrio/

Dependencies:   Analog_Joystick Sender mbed

Fork of ESE350-Whack-a-Mole by Eric Berdinis

Files at this revision

API Documentation at this revision

Comitter:
ivo_david_michelle
Date:
Sun May 01 21:58:57 2016 +0000
Parent:
9:2a3b3e067847
Commit message:
calibrate remote control

Changed in this revision

rc.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 2a3b3e067847 -r 8981152753a6 rc.cpp
--- a/rc.cpp	Thu Apr 07 22:04:42 2016 +0000
+++ b/rc.cpp	Sun May 01 21:58:57 2016 +0000
@@ -35,8 +35,29 @@
 
     char txBuffer[250];
 
+
+    float thrustOffset =0;
+    float rollOffset =0;
+    float pitchOffset =0;
+    float yawOffset =0;
+
+    int nSamples = 100;
+
+    for (int n = 0; n < nSamples; n++) {
+        thrustOffset += read_thrust();
+        yawOffset += read_yaw();
+        pitchOffset += read_pitch();
+        rollOffset += read_roll();
+
+    }
+    thrustOffset /= nSamples;
+    yawOffset /= nSamples;
+    pitchOffset /= nSamples;
+    rollOffset /= nSamples;
+
+
     while(1) {
-        sprintf(txBuffer, "%lld,%f,%f,%f,%f", id, read_thrust(), read_yaw(), read_pitch(), read_roll());
+        sprintf(txBuffer, "%lld,%f,%f,%f,%f", id, read_thrust()-thrustOffset, read_yaw()-yawOffset, read_pitch()-pitchOffset, read_roll()-rollOffset);
         rf_send(mrf, txBuffer, strlen(txBuffer) + 1);
         pc.printf("RC Sent: %s \r\n", txBuffer);