Corrected header file include guards.

Dependencies:   FiniteStateMachine HipControl Knee LinearBlend1 LocalFileSystem_Read dataComm hapticFeedback initExoVars mbed Blend_Generator Brad_poly_gait Gait_Generator MM_gait Encoders IMUdriver

Fork of Motion Control by HEL's Angels

Committer:
cashdollar
Date:
Fri Feb 13 23:00:57 2015 +0000
Revision:
3:9719ad064a2c
Parent:
2:89b78367d173
Child:
5:498c9bfc56f0
Phase 1 of safety check implementation. Not fully functional but need to collaborate - still need to finish knee check and FSM and periodicFcns implementation.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
perr1940 0:d38d627c922f 1 /**************************************
perr1940 0:d38d627c922f 2 This is the main file for the "RyanEXO" control software.
perr1940 0:d38d627c922f 3 This sets up the main control loop that operates at a 1kHz frequency
perr1940 0:d38d627c922f 4 and controls the flow of the rest of the software
perr1940 0:d38d627c922f 5
perr1940 0:d38d627c922f 6 The configuration for the exo system that this software runs:
perr1940 0:d38d627c922f 7 amplifiers: 2 Copley Controls 10A digital amplifiers
perr1940 0:d38d627c922f 8 sensors: 2 Austria Microsystems 12 bit magnetic encoders, handled by encoders.h
perr1940 0:d38d627c922f 9 motors: 2 maxon EC90 DC brushless motors, handled by HipMotorControl.h (called in FSM.h)
perr1940 0:d38d627c922f 10 Knees: wrap spring clutch controlled by Firgelli PQ12P linear actuators, controlled in linearActuatorControl.h
cashdollar 3:9719ad064a2c 11 **************************************/
perr1940 0:d38d627c922f 12
perr1940 0:d38d627c922f 13 #include "mbed.h"
perr1940 0:d38d627c922f 14 #include "initExoVars.h"
perr1940 0:d38d627c922f 15 #include "FSM.h"
perr1940 2:89b78367d173 16 #include "dataBedComm.h"
perr1940 2:89b78367d173 17 int dataIn[4];
perr1940 2:89b78367d173 18 int dataOut[]={0xFF,30,31,0xFE};
cashdollar 3:9719ad064a2c 19
perr1940 0:d38d627c922f 20 ///////////////////////////////////////////////////////////////////////////
cashdollar 3:9719ad064a2c 21
cashdollar 3:9719ad064a2c 22 // periodicFcns runs at the start of every control loop cycle
cashdollar 3:9719ad064a2c 23 // It initiates communication with dataBed, checks for errors/safety, and starts the FSM
perr1940 0:d38d627c922f 24 void periodicFcns()
perr1940 0:d38d627c922f 25 {
perr1940 2:89b78367d173 26 dataOut[1]=encoder_L.readRaw();
perr1940 2:89b78367d173 27 dataOut[2]=encoder_R.readRaw();
perr1940 2:89b78367d173 28 int* ptr=dataIn;
perr1940 2:89b78367d173 29 ptr=sendData(dataOut, 4, dataIn);
cashdollar 3:9719ad064a2c 30 // why only 3 of the %d?
cashdollar 3:9719ad064a2c 31 pc.printf("%d, %d, %d, %d, ", dataIn[0], dataIn[1], dataIn[2], dataIn[3]);
cashdollar 3:9719ad064a2c 32
cashdollar 3:9719ad064a2c 33
cashdollar 3:9719ad064a2c 34
cashdollar 3:9719ad064a2c 35 // Run state change/analysis in FSM
perr1940 0:d38d627c922f 36 int exoState=fsm.state(dataIn[1]);
cashdollar 3:9719ad064a2c 37
perr1940 0:d38d627c922f 38
perr1940 0:d38d627c922f 39 }
perr1940 0:d38d627c922f 40
perr1940 0:d38d627c922f 41 int main()
perr1940 0:d38d627c922f 42 {
perr1940 0:d38d627c922f 43 pc.printf("ExoStart \r\n");
perr1940 0:d38d627c922f 44 initializeExoIOs();
cashdollar 3:9719ad064a2c 45 // pc.printf("Blah\r\n");
perr1940 2:89b78367d173 46
perr1940 0:d38d627c922f 47 pc.printf("Starting exo...\n\r");
perr1940 0:d38d627c922f 48 //If desired, a startup sound can be played. This function is defined in the DatabedCode, because it will command a sound to be played once it detects a heartbeat from ControlBed
perr1940 0:d38d627c922f 49 wait(2);
perr1940 0:d38d627c922f 50 Ticker doControl;
perr1940 0:d38d627c922f 51 dataBedSPI.format(8,1);
perr1940 0:d38d627c922f 52 doControl.attach(&periodicFcns, SAMPLE_TIME);
perr1940 0:d38d627c922f 53
perr1940 0:d38d627c922f 54 while (1);
perr1940 0:d38d627c922f 55 }