State machine

Dependencies:   mbed Adafruit_GFX BioroboticsMotorControl MODSERIAL BioroboticsEMGFilter

main.cpp

Committer:
MAHCSnijders
Date:
2018-10-29
Revision:
0:7d25c2ade6c5
Child:
1:cfa5abca6d43

File content as of revision 0:7d25c2ade6c5:

#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