Hexapod
/
PwmOut_HelloWorld
Proyecto Hexápodo
Fork of PwmOut_HelloWorld by
Diff: main.cpp
- Revision:
- 8:b0a6c16e781b
- Parent:
- 7:4bc4af0236f0
--- a/main.cpp Tue Oct 09 17:32:33 2018 +0000 +++ b/main.cpp Tue Oct 09 18:10:45 2018 +0000 @@ -43,11 +43,11 @@ */ SoftPWM pata1[] = {SoftPWM(PB_8),SoftPWM(PB_9),SoftPWM(PB_7)}; //{Coxa, Femur, Tibia} -> Behind Right -SoftPWM pata2[] = {SoftPWM(PA_0),SoftPWM(PA_1),SoftPWM(PB_0)}; //-> Medium Right -SoftPWM pata3[] = {SoftPWM(PB_1),SoftPWM(PA_3),SoftPWM(PA_2)}; //-> Forward Right -SoftPWM pata4[] = {SoftPWM(PA_5),SoftPWM(PA_6),SoftPWM(PA_7)}; //-> Behind Left -SoftPWM pata5[] = {SoftPWM(PB_6),SoftPWM(PA_9),SoftPWM(PA_8)}; //-> Medium Left -SoftPWM pata6[] = {SoftPWM(PB_10),SoftPWM(PB_3),SoftPWM(PA_10)}; //-> Forward Left +SoftPWM pata2[] = {SoftPWM(PA_0),SoftPWM(PA_1),SoftPWM(PB_0)}; //{Coxa, Femur, Tibia} -> Medium Right +SoftPWM pata3[] = {SoftPWM(PB_1),SoftPWM(PA_3),SoftPWM(PA_2)}; //{Coxa, Femur, Tibia} -> Forward Right +SoftPWM pata4[] = {SoftPWM(PA_5),SoftPWM(PA_6),SoftPWM(PA_7)}; //{Coxa, Femur, Tibia} -> Behind Left +SoftPWM pata5[] = {SoftPWM(PB_6),SoftPWM(PA_9),SoftPWM(PA_8)}; //{Coxa, Femur, Tibia} -> Medium Left +SoftPWM pata6[] = {SoftPWM(PB_10),SoftPWM(PB_3),SoftPWM(PA_10)}; //{Coxa, Femur, Tibia} -> Forward Left void mueve_servo(SoftPWM* pata, int grados); void mueve_pata1(char pos); @@ -56,10 +56,10 @@ void mueve_pata4(char pos); void mueve_pata5(char pos); void mueve_pata6(char pos); - +void hexapod_mov(int type); + int main() { pata3[1].period_us(20000); //20ms period, typical for analog RC servo - pata3[0].period_us(20000); //20ms period, typical for analog RC servo bool mov = false; while(1){ if (mov == true) { @@ -73,13 +73,13 @@ } } -void mueve_servo(SoftPWM* pata, int grados){ +void mueve_servo(SoftPWM* pata, int grados){ //Función que realiza el movimiento de un servo int th=0; th = 560 + (1925*grados)/180; //Límites del Servo [560 - 2485] -> OFFSET:1925 pata->pulsewidth_us(th); } -void mueve_pata1(char pos){ +void mueve_pata1(char pos){ //Función que realiza el movimiento de una pata dependiendo de lo que se quiera hacer switch(pos){ case 'A': //Avanza mueve_servo(&pata1[0], MOV_AV); @@ -234,20 +234,20 @@ } } -void hexapod_mov(int type){ +void hexapod_mov(int type){ //Función que hace el movimiento del hexápodo dependiendo de lo que se quiera hacer if(type == ARRIBA){ - + //Rellenar el movimiento con las patas }else if(type == ABAJO){ - + //Rellenar el movimiento con las patas }else if(type == HOME){ - + //Rellenar el movimiento con las patas }else if(type == AVANZA){ - + //Rellenar el movimiento con las patas }else if(type == RETROCEDE){ - + //Rellenar el movimiento con las patas }else if(type == DERECHA){ - + //Rellenar el movimiento con las patas }else if(type == IZQUIERDA){ - + //Rellenar el movimiento con las patas } } \ No newline at end of file