• sales

    +86-0755-88291180

WAVEGO Gait Debugging Specific Method

Gait Debugging

Adjust the gait motion effect by modifying the gait-related parameters in ServoCtrl.h.


Related Parameters

In ServoCtrl.h, in addition to the parameters in the Single Leg Control section, the parameters used for overall gait debugging are as follows:

  • WALK_ACC: This is a distance in mm, used for the transition between the support pair and the swing pair
  • WALK_EXTENDED_Z: Unit in mm, controls the extension distance of the landing point in the left and right directions
  • WALK_SIDE_MAX: The maximum amplitude of the left and right swing of the end point of the leg, in mm
  • WALK_MASS_ADJUST: Used to adjust the offset of the center of gravity during movement. The coefficient has no unit, and the larger the value, the greater the center of gravity offset. Currently, it is only used in triangular gait
  • WALK_LIFT_PROP: The occupancy ratio (time) of the swing pair in the motion cycle. For example, 0.25 means that it is in the swinging pair in 25% of the time in a complete motion cycle. The smaller the value, the faster the swing. Theoretically the longer the support pair time, the more stable it is. This parameter is primarily limited by the servo motor's speed and the sizes of WALK_RANGE, WALK_LIFT, and WALK_ACC.
  • STEP_DELAY: Used to set the interpolation interval time for leg swings.
  • The other parameters are not set by the user and are not introduced here; they will be covered in the function debugging chapter.


Function Debugging

Diagonal Gait

According to the method introduced in single leg control, let each leg swing within its own motion cycle, with the left front leg as 1, the left rear leg as 2, the right front leg as 3, and the right rear leg as 4. When legs 1 and 4 swing according to the same motion cycle (referred to as Group A), and legs 2 and 3 swing according to the same motion cycle (referred to as Group B), Group A and Group B are phase-shifted by half a cycle. This ensures that at least one group is in support at any given moment.

void simpleGait(float GlobalInput, float directionAngle, int turnCmd){
  float Group_A;
  float Group_B;

  Group_A = GlobalInput;
  Group_B = GlobalInput+0.5;
  if(Group_B>1){Group_B--;}

  if(!turnCmd){
    singleGaitCtrl(1, 1, Group_A, directionAngle,  WALK_EXTENDED_X, WALK_EXTENDED_Z);
    singleGaitCtrl(4, 1, Group_A, -directionAngle, -WALK_EXTENDED_X, WALK_EXTENDED_Z);

    singleGaitCtrl(2, 1, Group_B, directionAngle, -WALK_EXTENDED_X, WALK_EXTENDED_Z);
    singleGaitCtrl(3, 1, Group_B, -directionAngle, WALK_EXTENDED_X, WALK_EXTENDED_Z);
  }
  else if(turnCmd == -1){
    singleGaitCtrl(1, 1.5, Group_A, 90,  WALK_EXTENDED_X, WALK_EXTENDED_Z);
    singleGaitCtrl(4, 1.5, Group_A, 90, -WALK_EXTENDED_X, WALK_EXTENDED_Z);

    singleGaitCtrl(2, 1.5, Group_B, -90, -WALK_EXTENDED_X, WALK_EXTENDED_Z);
    singleGaitCtrl(3, 1.5, Group_B, -90, WALK_EXTENDED_X, WALK_EXTENDED_Z);
  }
  else if(turnCmd == 1){
    singleGaitCtrl(1, 1.5, Group_A, -90,  WALK_EXTENDED_X, WALK_EXTENDED_Z);
    singleGaitCtrl(4, 1.5, Group_A, -90, -WALK_EXTENDED_X, WALK_EXTENDED_Z);

    singleGaitCtrl(2, 1.5, Group_B, 90, -WALK_EXTENDED_X, WALK_EXTENDED_Z);
    singleGaitCtrl(3, 1.5, Group_B, 90, WALK_EXTENDED_X, WALK_EXTENDED_Z);
  }
}

The code above is used to perform diagonal gait, with Group_A and Group_B phase-shifted by half a cycle

Group_A = GlobalInput;
Group_B = GlobalInput+0.5;
if(Group_B>1){Group_B--;}

GlobaIInput cycles from 0 to 1, and groups A and B obtain their own motion cycle parameters through the above algorithm, forming diagonal gait.

turnCmd is used to adjust the rotation direction. When turnCmd is 0, directionAngle can be used to adjust the translation direction (at which point the robot's head orientation remains unchanged)


Triangular Gait

The purpose of the triangular gait is to make the robot have at least three legs in the support pair at all times. This gait is more complex and requires more fine debugging to use. The diagonal gait mentioned above divides the four legs into two groups, A and B, while the triangular gait divides the four legs into four groups, with 1, 2, 3, and 4 corresponding to A, B, C, and D. The motion cycles of each two groups differ by at least 1/4 phase.

void triangularGait(float GlobalInput, float directionAngle, int turnCmd){
  float StepA;
  float StepB;
  float StepC;
  float StepD;

  float aInput = 0;
  float bInput = 0;
  float adProp;

  StepB = GlobalInput;
  StepC = GlobalInput + 0.25;
  StepD = GlobalInput + 0.5;
  StepA = GlobalInput + 0.75;

  if(StepA>1){StepA--;}
  if(StepB>1){StepB--;}
  if(StepC>1){StepC--;}
  if(StepD>1){StepD--;}

  if(GlobalInput <= 0.25){
    adProp = GlobalInput;
    aInput =  WALK_MASS_ADJUST - (adProp/0.125)*WALK_MASS_ADJUST;
    bInput = -WALK_MASS_ADJUST;
  }
  else if(GlobalInput > 0.25 && GlobalInput <= 0.5){
    adProp = GlobalInput-0.25;
    aInput = -WALK_MASS_ADJUST + (adProp/0.125)*WALK_MASS_ADJUST;
    bInput = -WALK_MASS_ADJUST + (adProp/0.125)*WALK_MASS_ADJUST;
  }
  else if(GlobalInput > 0.5 && GlobalInput <= 0.75){
    adProp = GlobalInput-0.5;
    aInput =  WALK_MASS_ADJUST - (adProp/0.125)*WALK_MASS_ADJUST;
    bInput =  WALK_MASS_ADJUST;
  }
  else if(GlobalInput > 0.75 && GlobalInput <= 1){
    adProp = GlobalInput-0.75;
    aInput = -WALK_MASS_ADJUST + (adProp/0.125)*WALK_MASS_ADJUST;
    bInput =  WALK_MASS_ADJUST - (adProp/0.125)*WALK_MASS_ADJUST;
  }

  if(!turnCmd){
    singleGaitCtrl(1, 1, StepA,  directionAngle,  WALK_EXTENDED_X - aInput, WALK_EXTENDED_Z - bInput);
    singleGaitCtrl(4, 1, StepD, -directionAngle, -WALK_EXTENDED_X - aInput, WALK_EXTENDED_Z + bInput);

    singleGaitCtrl(2, 1, StepB,  directionAngle, -WALK_EXTENDED_X - aInput, WALK_EXTENDED_Z - bInput);
    singleGaitCtrl(3, 1, StepC, -directionAngle,  WALK_EXTENDED_X - aInput, WALK_EXTENDED_Z + bInput);
  }
  else if(turnCmd == -1){
    singleGaitCtrl(1, 1.5, StepA,  90,  WALK_EXTENDED_X - aInput, WALK_EXTENDED_Z - bInput);
    singleGaitCtrl(4, 1.5, StepD,  90, -WALK_EXTENDED_X - aInput, WALK_EXTENDED_Z + bInput);

    singleGaitCtrl(2, 1.5, StepB, -90, -WALK_EXTENDED_X - aInput, WALK_EXTENDED_Z - bInput);
    singleGaitCtrl(3, 1.5, StepC, -90,  WALK_EXTENDED_X - aInput, WALK_EXTENDED_Z + bInput);
  }
  else if(turnCmd == 1){
    singleGaitCtrl(1, 1.5, StepA,  -90,  WALK_EXTENDED_X - aInput, WALK_EXTENDED_Z - bInput);
    singleGaitCtrl(4, 1.5, StepD,  -90, -WALK_EXTENDED_X - aInput, WALK_EXTENDED_Z + bInput);

    singleGaitCtrl(2, 1.5, StepB, 90, -WALK_EXTENDED_X - aInput, WALK_EXTENDED_Z - bInput);
    singleGaitCtrl(3, 1.5, StepC, 90,  WALK_EXTENDED_X - aInput, WALK_EXTENDED_Z + bInput);
  }
}


Compared to the diagonal gait, in addition to changing from two groups to four groups, three more parameters were added below:

float aInput = 0;
float bInput = 0;
float adProp;

These three parameters are not set by the user. They are used to dynamically adjust the center of gravity offset of the robot during motion. aInput and bInput are used to save the calculated offset, and adProp is used to calculate the offset aInput and bInput from the current position of the motion cycle.


StepB = GlobalInput;
StepC = GlobalInput + 0.25;
StepD = GlobalInput + 0.5;
StepA = GlobalInput + 0.75;

if(StepA>1){StepA--;}
if(StepB>1){StepB--;}
if(StepC>1){StepC--;}
if(StepD>1){StepD--;}

The above is used to adjust the phase difference for each set of motions, for example, the current swing order is 2 3 4 1 2 3 4 1......, you can change the above code to:

StepB = GlobalInput;
StepC = GlobalInput + 0.25;
StepA = GlobalInput + 0.5;
StepD = GlobalInput + 0.75;

The current swing order is 2 3 1 4 2 3 1 4 …, but try not to change the phase difference by 1/4.


if(GlobalInput <= 0.25){
    adProp = GlobalInput;
    aInput =  WALK_MASS_ADJUST - (adProp/0.125)*WALK_MASS_ADJUST;
    bInput = -WALK_MASS_ADJUST;
  }
  else if(GlobalInput > 0.25 && GlobalInput <= 0.5){
    adProp = GlobalInput-0.25;
    aInput = -WALK_MASS_ADJUST + (adProp/0.125)*WALK_MASS_ADJUST;
    bInput = -WALK_MASS_ADJUST + (adProp/0.125)*WALK_MASS_ADJUST;
  }
  else if(GlobalInput > 0.5 && GlobalInput <= 0.75){
    adProp = GlobalInput-0.5;
    aInput =  WALK_MASS_ADJUST - (adProp/0.125)*WALK_MASS_ADJUST;
    bInput =  WALK_MASS_ADJUST;
  }
  else if(GlobalInput > 0.75 && GlobalInput <= 1){
    adProp = GlobalInput-0.75;
    aInput = -WALK_MASS_ADJUST + (adProp/0.125)*WALK_MASS_ADJUST;
    bInput =  WALK_MASS_ADJUST - (adProp/0.125)*WALK_MASS_ADJUST;
  }

The code above is used to calculate aInput and bInput, the specific center of gravity offset position, with the main purpose is to move the center of gravity to the triangle formed by the horizontal projection of the three feet currently on the support pair. You can modify the code above (the calculation logic and the weight coefficient of 0.125) or delete it to observe the changes in the action.

The rest of algorithm logic for the triangular gait is the same as that for the diagonal gait. Gait adjustments need to be made by combining with the single leg control and the parameter adjustment in the relevant parameters above.

TAG: ADXL354C Dev Board Raspberry Pi 5 PCIe to M.2 NVME SSD And Gigabit Ethernet RJ45 HAT RTL8111H M_KEY For 2230/2242/2260/2280 RP2040 DDSM115 Direct Drive Servo Motor All-In-One Design Hub RS485 Motor Raspberry Pi 4B/5 Industrial UART 2CH RS485 RS232 CAN FD HAT With Case For Installation of guide rails and hanging DeepSeek AI Voice Chat ESP32 S3 Development Board 2.06-inch AMOLED Display 410&times;502 2.06inch TouchScreen Programmable Watch Raspberry Pi Pico 2 RP2350 USB A Development Board RP2350A Pi5 PCIe SpotPear Raspberry Pi Pico Screen Raspberry Pi 1.3inch LCD Sipeed NanoCluster Mini Cluster Board mini data center For Raspberry Pi CM45 / Computer /LM3H /M4N PC USB Secondary Screen Raspberry Pi 4 Camera 0.85inch LCD ESP32 P4 Development Board WIFI6 4 inch LCD Round Display 4inch TouchScreen 720×720 Dual Microphones SpotPear Modbus RTU ESP32-S3 Development Board 3.16 inch LCD display 3.16inch Screen SD slot 320x820 RGB LED ST7701 ESP32-P4 DEV-KIT C6 WiFi6 MIPI DSI 7/10.1 inch Display/CSI Camera/Audio Speaker For AI Deepseek