Nathaniel Honka / Mbed 2 deprecated Motion-Control

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:
perr1940
Date:
Wed May 13 19:24:10 2015 +0000
Revision:
26:c4372c518ac3
Parent:
25:1292b886b8d2
Child:
28:67f5892586c2
publishing to share with Michael;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
perr1940 0:d38d627c922f 1
perr1940 0:d38d627c922f 2
perr1940 0:d38d627c922f 3 #ifndef INIT_H
perr1940 0:d38d627c922f 4 #define INIT_H
perr1940 0:d38d627c922f 5
perr1940 0:d38d627c922f 6 #include "mbed.h"
perr1940 0:d38d627c922f 7 #include "Encoder.h"
perr1940 0:d38d627c922f 8 #include "HipControl.h"
perr1940 0:d38d627c922f 9 #include "knee.h"
perr1940 0:d38d627c922f 10 #include "FSM.h"
perr1940 26:c4372c518ac3 11 #include "MM_gait.h"
perr1940 26:c4372c518ac3 12 #include "dataComm.h"
perr1940 0:d38d627c922f 13 #define PI (3.141592653589793)
perr1940 0:d38d627c922f 14
perr1940 26:c4372c518ac3 15 //#define SAMPLE_TIME .01
perr1940 0:d38d627c922f 16 #define SAMPLE_TIME .001
perr1940 0:d38d627c922f 17 #define TO_RAD(x) (x * 0.01745329252) // *pi/180
perr1940 0:d38d627c922f 18
mzling 25:1292b886b8d2 19
perr1940 0:d38d627c922f 20 /********************************
perr1940 0:d38d627c922f 21 * Initializing various I/O pins!
perr1940 0:d38d627c922f 22 ********************************/
perr1940 0:d38d627c922f 23 extern DigitalOut mbedLED1;
perr1940 0:d38d627c922f 24 extern DigitalOut mbedLED2;
perr1940 0:d38d627c922f 25 extern DigitalOut mbedLED3;
perr1940 0:d38d627c922f 26 extern DigitalOut motorLED;
perr1940 0:d38d627c922f 27
perr1940 0:d38d627c922f 28 extern SPI dataBedSPI; // mosi, miso, sclk
perr1940 0:d38d627c922f 29 extern DigitalOut DB_cs;
perr1940 0:d38d627c922f 30 extern SPI IMUspi;
perr1940 0:d38d627c922f 31 extern DigitalOut IMUcs;
perr1940 0:d38d627c922f 32 extern Serial pc;
perr1940 0:d38d627c922f 33
perr1940 0:d38d627c922f 34 // Setup stuff
perr1940 0:d38d627c922f 35 // absolutes
perr1940 0:d38d627c922f 36 //extern SPI encoder_L;
perr1940 0:d38d627c922f 37 //extern DigitalOut encoder_cs_L;
perr1940 0:d38d627c922f 38 //extern SPI encoder_R;
perr1940 0:d38d627c922f 39 //extern DigitalOut encoder_cs_R;
perr1940 0:d38d627c922f 40 extern Encoder encoder_L;
perr1940 0:d38d627c922f 41 extern Encoder encoder_R;
perr1940 0:d38d627c922f 42
perr1940 0:d38d627c922f 43 // Incremental Indexes (only for homing!)
perr1940 0:d38d627c922f 44 extern InterruptIn encIdx_R;
perr1940 0:d38d627c922f 45 extern InterruptIn encIdx_L;
perr1940 0:d38d627c922f 46
perr1940 0:d38d627c922f 47 // Right Leg
perr1940 0:d38d627c922f 48 extern PwmOut pwmpin_R;
perr1940 0:d38d627c922f 49 extern DigitalOut dirpin_R;
perr1940 0:d38d627c922f 50
perr1940 0:d38d627c922f 51 //Left Leg
perr1940 0:d38d627c922f 52 //extern PwmOut pwmpin_L;
perr1940 0:d38d627c922f 53 //extern DigitalOut dirpin_L;
perr1940 0:d38d627c922f 54 extern HipControl hip_L;
perr1940 0:d38d627c922f 55 extern HipControl hip_R;
perr1940 0:d38d627c922f 56 extern Knee knee_L;
perr1940 0:d38d627c922f 57 extern Knee knee_R;
perr1940 0:d38d627c922f 58
perr1940 0:d38d627c922f 59 extern FSM fsm;
perr1940 0:d38d627c922f 60
perr1940 26:c4372c518ac3 61 extern struct MMgait_t mm_gait_params;
perr1940 26:c4372c518ac3 62 extern MMSwing swing;
perr1940 26:c4372c518ac3 63 extern MMStance stance;
perr1940 26:c4372c518ac3 64 extern GaitGenerator mm_gait;
mzling 25:1292b886b8d2 65
perr1940 0:d38d627c922f 66
perr1940 0:d38d627c922f 67 /*******************************
perr1940 0:d38d627c922f 68 * END OF I/O Initialization
perr1940 0:d38d627c922f 69 *******************************/
perr1940 0:d38d627c922f 70
perr1940 0:d38d627c922f 71 /*******************************
perr1940 0:d38d627c922f 72 * GLOBAL VARS
perr1940 0:d38d627c922f 73 *******************************/
perr1940 0:d38d627c922f 74
perr1940 0:d38d627c922f 75 // Global Timers!
perr1940 0:d38d627c922f 76 extern Timer sysClk; // system clock (primarily for datalogging)
perr1940 0:d38d627c922f 77 extern Timer tState; // time in FSM state
perr1940 0:d38d627c922f 78 extern Timer t_HCl; // time when high current begins
perr1940 0:d38d627c922f 79 extern Timer t_HCr;
perr1940 0:d38d627c922f 80 extern Timer t_BetweenStepCommand;
perr1940 0:d38d627c922f 81
perr1940 0:d38d627c922f 82 const unsigned int enc_ticks=pow(2.,14.)-1; //the number of ticks that the encoder has, 2^14 for our encoder, -1 for 0 state
perr1940 0:d38d627c922f 83 const float enc2deg = 360./enc_ticks; // converts encoder reading from 0-16383 (14 bit) to 0-360deg (360 / 16383);
perr1940 0:d38d627c922f 84 const float control_lim_high=90; //soft stop on the controller
perr1940 0:d38d627c922f 85 const float control_lim_low=-55;//soft stop on the controller
perr1940 0:d38d627c922f 86 extern float TimeSinceLastStep;
perr1940 0:d38d627c922f 87
perr1940 0:d38d627c922f 88 //Control Variables
perr1940 0:d38d627c922f 89 // Control variables
perr1940 0:d38d627c922f 90 // Gain Scheduling!
perr1940 0:d38d627c922f 91 extern const float Kp_Swing;
perr1940 0:d38d627c922f 92 extern const float Kp_Stance;
perr1940 0:d38d627c922f 93 extern const float Kp_DoubleStance;//.01;
perr1940 0:d38d627c922f 94 extern const float Kp_Standing;//.01; //0.0025
perr1940 0:d38d627c922f 95 extern const float Kp_StandUp;
perr1940 0:d38d627c922f 96 extern const float Kp_SitDown ;
perr1940 0:d38d627c922f 97 extern const float Kp_Seated;
perr1940 0:d38d627c922f 98
perr1940 0:d38d627c922f 99 extern const float Kp;
perr1940 0:d38d627c922f 100 extern const float Kd;
perr1940 0:d38d627c922f 101 extern const float sat;
perr1940 0:d38d627c922f 102 extern const float Kp_mag;
perr1940 0:d38d627c922f 103 extern const float Kp_freq;
perr1940 0:d38d627c922f 104 extern const float Kp_offset;
mzling 19:70b2124c7370 105 extern float stand_adjust;
mzling 20:cf8e99d989a6 106 extern const float zero_ang_L;
mzling 20:cf8e99d989a6 107 extern const float zero_ang_R;
perr1940 0:d38d627c922f 108
perr1940 0:d38d627c922f 109 #endif
perr1940 0:d38d627c922f 110
perr1940 0:d38d627c922f 111 extern void initializeExoIOs();