狗腿的摆线可以使用 https://zhuanlan.zhihu.com/p/69869440

    image.png

    8自由度机械狗没有y方向的移动 x方向移动,分成摆动相和支撑相

    11.png
    22.png
    小跑步态规划实现

    1. //周期 占空比 增加速度
    2. #define faai 0.5
    3. #define Ts 1
    4. #define speed 0.1
    5. #define ori_speed 0.025
    6. //步态规划
    7. void trot_plan(double t,double xs,double xf,double h,
    8. double r1,double r2,double r3,double r4,double x_pos[4],double y_pos[4]){
    9. if(t<=Ts*faai){
    10. sigma = (2*PI*t)/(faai*Ts);
    11. zep = h*(1-cos(sigma))/2;
    12. xep_b = (xf-xs)*((sigma-sin(sigma))/(2*PI))+xs;
    13. xep_z = (xs-xf)*((sigma-sin(sigma))/(2*PI))+xf;
    14. //y坐标值
    15. y_pos[0] = ges_y_1-zep;
    16. y_pos[1] = ges_y_2;
    17. y_pos[2] = ges_y_3;
    18. y_pos[3] = ges_y_4-zep;
    19. //x坐标值
    20. x_pos[0] = xep_b*r1;
    21. x_pos[1] = xep_z*r2;
    22. x_pos[2] = xep_z*r3;
    23. x_pos[3] = xep_b*r4;
    24. }else if((t>Ts*faai)&&(t<=Ts)){
    25. sigma = (2*PI*(t-Ts*faai))/(faai*Ts);
    26. zep = h*(1-cos(sigma))/2;
    27. xep_b = (xf-xs)*((sigma-sin(sigma))/(2*PI))+xs;
    28. xep_z = (xs-xf)*((sigma-sin(sigma))/(2*PI))+xf;
    29. //y坐标值
    30. y_pos[0] = ges_y_1;
    31. y_pos[1] = ges_y_2-zep;
    32. y_pos[2] = ges_y_3-zep;
    33. y_pos[3] = ges_y_4;
    34. //x坐标值
    35. x_pos[0] = xep_z*r1;
    36. x_pos[1] = xep_b*r2;
    37. x_pos[2] = xep_b*r3;
    38. x_pos[3] = xep_z*r4;
    39. }
    40. }