State machine

Dependencies:   mbed Adafruit_GFX BioroboticsMotorControl MODSERIAL BioroboticsEMGFilter

Revision:
0:7d25c2ade6c5
Child:
1:cfa5abca6d43
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 29 13:44:06 2018 +0000
@@ -0,0 +1,26 @@
+#include "mbed.h"
+
+
+enum states {wait, calib_motor, calib_bicep1, calib_bicep2, homing, operation, failure}; // The possible states of the state machine
+
+// Global variables
+const double PI = 3.14159265359;
+const double PULSES_PER_ROTATION = 6533;
+states current_state;   // Defining the state we are currently in
+Ticker loop_ticker;     // Ticker for the loop function
+float emg1_unfiltered, emg1_filtered; // Floats for EMG bicep 1
+float emg2_unfiltered, emg2_filtered; // Floats for EMG bicep 2
+float u1, u2;           // Floats for motor duty cycle
+float des_motor1_angle, des_motor2_angle;           // Floats for position end-effector
+
+void measure_everything() {
+    motor1_angle = motor1_counts * 2.0f * PI/PULSES_PER_ROTATION; // Gives angle of motor1
+    motor2_angle = motor2_counts * 2.0f * PI/PULSES_PER_ROTATION; // Gives angle of motor2
+    
+
+
+
+void 
+
+
+