6 years, 2 months ago.

Motion control in Hexapods !

Hi, I'm doing a hexapod with 18 servos and 6 legs (3 servos for each leg). I am using a core board and the Mbed environment with C language.

My question is: how could I initially consider the movements?

Initially I have declared all the necessary pins (18) and in which I have passed a pulse to servo number 1 to prove that the pin works on the board. I would like to know how to perform a simple movement even if they are 3 servos that would be 1 leg.

My code is the following:

  1. include "mbed.h"
  1. include "SoftPWM.h"

Serial serial(PC_6, PA_12);

SoftPWM servo1(PB_8);

SoftPWM servo2(PB_9);

SoftPWM servo3(PB_7);

SoftPWM servo4(PA_0);

SoftPWM servo5(PA_1);

SoftPWM servo6(PB_0);

SoftPWM servo7(PB_1);

SoftPWM servo8(PA_3);

SoftPWM servo9(PA_2);

SoftPWM servo10(PA_5);

SoftPWM servo11(PA_6);

SoftPWM servo12(PA_7);

SoftPWM servo13(PB_6);

SoftPWM servo14(PA_9);

SoftPWM servo15(PA_8);

SoftPWM servo16(PB_10);

SoftPWM servo17(PB_3);

SoftPWM servo18(PA_10);

int main() {

servo1.period_us(20000);

int servopulsewidth=1000;

int si_mueve = 1200;

int no_mueve = 1900;

bool movimiento = false;

servo1.pulsewidth_us(servopulsewidth);

while(1){

if (movimiento == true) {

servo1.pulsewidth_us(si_mueve);

serial.printf("YES: %f\r\n", servo1.read());

} else {

servo1.pulsewidth_us(no_mueve);

serial.printf("NO: %f\r\n", servo1.read());

}

movimiento = !movimiento;

wait_ms(250);

}

}

Be the first to answer this question.