/* * walk.c * * Elliot Nicholls * * Program to allow the j5bot biped to walk with a preset gait * **********************************************************************/ #include #include #include "gaitgen.h" #include "trial.h" #define NUM_LINKS 9 #define GAIT_TIME 3000 #define SMOOTH 20 typedef struct { int sacc[NUM_ACC]; int frontAve; int front; int frontE; BYTE fsw; int rHipB; int lHipB; } Sensors; void gait(void); void send(void); void sendstr(char *); ServoHandle servo[9]; int sIndex; BYTE bmask[8] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80}; int accPort[NUM_ACC] = {7,15}; typedef enum{ frontTilt,sideTilt} ACCNAME; Sensors sensors[GAIT_TIME*FPS/1000]; ACCDATA kP; int main() { int i; char k; /* initialization */ LCDPrintf("Here is Johnny..\n"); sIndex = 0; kP[sideTilt] = 0; kP[frontTilt] = 4; /* get parameters */ /* LCDMenu("+","-"," ","CON");*/ /* allocate handels for all servos */ servo[rHipT]=SERVOInit(RHipT); servo[rHipB]=SERVOInit(RHipB); servo[rKnee]=SERVOInit(RKnee); servo[rAnkle]=SERVOInit(RAnkle); servo[torso]=SERVOInit(Torso); servo[lAnkle]=SERVOInit(LAnkle); servo[lKnee]=SERVOInit(LKnee); servo[lHipB]=SERVOInit(LHipB); servo[lHipT]=SERVOInit(LHipT); /* middle position */ LCDPrintf("Servos mid-pos..\n"); for(i=0;i SMOOTH - 1) { for(i=0; i