• 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: Sipeed-Lichee-Tang-Nano-FPGA-Series-IDE-Install Raspberry Pi PICO Ranging Sensor 树莓派Pico 2 RP2350B-Plus-W开发板WIFI官方Radio Module 2 Sipeed Tang Primer 25K GW5A RISCV FPGA Development Board Dock SDRAM GW5A-LV25MG121 Retro Game linux Raspberry Pi ST7789 Raspberry Pi 5 Pure-Copper Cooler TVOC Sensor gas Sensor Expansion board UART High Sensitivity For Arduino /Raspberry Pi /Pico /ESP32 RP2040 Wireless AW CB375N 2.4G/5GHz Dual Band WiFi5 Wireless module RTL8822CE CG Bluetooth 5.0 UGV Beast PT Kit AI OpenCV Robot Car MediaPipe For Jetson Orin ESP32 C3 JETSON-IO-BASE-A 10-Axis DOF ROS IMU (A) Sensor UART ARM 32 DSP Processor BLE 5.3 Bluetooth / Accelerometer / Gyroscope / Magnetometer / Temperature & Pressure Milk-V Duo S Extend Partition on SD Card or eMMC ESP32 ST7789 configuration Raspberry Pi 5 Audio Jack Raspberry-Pi-A7670E-GSM-GPRS-GNSS-LTE-Cat-1-2G-A-User-Guide Raspberry Pi 18.5inch FHD LCD 1920x1080 Capacitive TouchScreen Display For Raspberry Pi/Jetson Nano/ Mobile Robot