Nathaniel Honka / initExoVars

Fork of initExoVars by HEL's Angels

Revision:
0:cd5ad8e47eb8
Child:
1:72e0bd01c8e0
Child:
2:650a015179b9
diff -r 000000000000 -r cd5ad8e47eb8 initExoVars.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/initExoVars.h	Wed Jun 24 19:24:08 2015 +0000
@@ -0,0 +1,112 @@
+
+
+#ifndef INIT_H
+#define INIT_H
+
+#include "mbed.h"
+#include "Encoder.h"
+#include "HipControl.h"
+#include "knee.h"
+#include "FSM.h"
+#include "MM_gait.h"
+#include "dataComm.h"
+#define PI (3.141592653589793)
+#define my_delete(x) {delete x; x = NULL;}
+
+//#define SAMPLE_TIME .01
+#define SAMPLE_TIME .001
+#define TO_RAD(x) (x * 0.01745329252)  // *pi/180
+
+
+/********************************
+*  Initializing various I/O pins!
+********************************/
+extern DigitalOut mbedLED1;
+extern DigitalOut mbedLED2;
+extern DigitalOut mbedLED3;
+extern DigitalOut motorLED;
+
+extern SPI dataBedSPI; // mosi, miso, sclk
+extern DigitalOut DB_cs;
+extern SPI IMUspi;
+extern DigitalOut IMUcs;
+extern Serial pc;
+
+// Setup stuff
+// absolutes
+//extern SPI encoder_L;
+//extern DigitalOut encoder_cs_L;
+//extern SPI encoder_R;
+//extern DigitalOut encoder_cs_R;
+extern Encoder encoder_L;
+extern Encoder encoder_R;
+
+// Incremental Indexes (only for homing!)
+extern InterruptIn encIdx_R;
+extern InterruptIn encIdx_L;
+
+// Right Leg
+extern PwmOut pwmpin_R;
+extern DigitalOut dirpin_R;
+
+//Left Leg
+//extern PwmOut pwmpin_L;
+//extern DigitalOut dirpin_L;
+extern HipControl hip_L;
+extern HipControl hip_R;
+extern Knee knee_L;
+extern Knee knee_R;
+
+extern FSM fsm;
+
+extern struct MMgait_t mm_gait_params;
+extern MMSwing swing;
+extern MMStance stance;
+extern GaitGenerator mm_gait;
+
+
+/*******************************
+* END OF I/O Initialization
+*******************************/
+
+/*******************************
+* GLOBAL VARS
+*******************************/
+
+// Global Timers!
+extern Timer sysClk;     // system clock (primarily for datalogging)
+extern Timer tState;   // time in FSM state
+extern Timer t_HCl;  // time when high current begins
+extern Timer t_HCr;
+extern Timer t_BetweenStepCommand;
+
+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
+const float enc2deg = 360./enc_ticks; // converts encoder reading from 0-16383 (14 bit) to 0-360deg (360 / 16383);
+const float control_lim_high=90; //soft stop on the controller
+const float control_lim_low=-55;//soft stop on the controller
+extern float TimeSinceLastStep;
+
+//Control Variables
+// Control variables
+// Gain Scheduling!
+extern const float Kp_Swing;
+extern const float Kp_Stance;
+extern const float Kp_DoubleStance;//.01;
+extern const float Kp_Standing;//.01; //0.0025
+extern const float Kp_StandUp;
+extern const float Kp_SitDown ;
+extern const float Kp_Seated;
+
+extern const float Kp;
+extern const float Kd;
+extern const float sat;
+extern const float Kp_mag;
+extern const float Kp_freq;
+extern const float Kp_offset;
+extern float stand_adjust;
+extern const float zero_ang_L;
+extern const float zero_ang_R;
+
+#endif
+
+extern void initializeExoIOs();