极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1943|回复: 0

8自由度串联四足机器人实现前进功能

[复制链接]
发表于 2023-5-15 10:30:41 | 显示全部楼层 |阅读模式
本帖最后由 机器谱 于 2023-5-15 10:30 编辑

1. 功能说明
      本文示例将实现R253样机8自由度串联四足机器人前进的功能,该机构是由4个 2自由度串联仿生腿【https://www.robotway.com/h-col-195.html】 组成。


2. 串联关节型机器人运动算法

       8自由度串联四足机器人的前进步态是将机器人四足分成两组腿(身体一侧的前足与另一侧的后足)分别进行摆动和支撑,即处于对角线上的两条腿的动作一样,均处于摆动相或均处于支撑相,如下图所示:


       当转向时对角线上的腿部摆动方向会跟前进步态不一样,如下图所示为一个左转的步态:


3. 电子硬件
      本实验中采用了以下硬件:

主控板
Basra主控板(兼容Arduino Uno)
扩展板
Bigfish2.1扩展板
电池
7.4V锂电池

电路连接说明: D3、D4;D7、D 8;D11、D12;A2、A3为舵机引脚分别对应8自由度串联四足机器人在Bigfish扩展板上的连接位置
注意:两个舵机为一条腿,不要分开连接】

       这里需要注意下,因为该机器人结构上有8个舵机,而Bigfish扩展板上的舵机接口是6个,所以我们需要对Bigfish扩展板进行改装(通过跳线的方式将Bigfish扩展板上常规使用的传感器接口转为舵机接口)。

4. 功能实现
编程环境:Arduino 1.8.19
下面提供一个8自由度串联四足机器人步态前进的参考例程(_1_17.ino),将参考例程下载到主控板中,具体实验效果可参考官网演示视频。
  1. /*------------------------------------------------------------------------------------

  2.   版权说明:Copyright 2023 Robottime(Beijing) Technology Co., Ltd. All Rights Reserved.

  3.            Distributed under MIT license.See file LICENSE for detail or copy at

  4.            https://opensource.org/licenses/MIT

  5.            by 机器谱 2023-04-20 https://www.robotway.com/

  6.   ------------------------------*/

  7. /*------------------------------------------------------------------------------------

  8.   实验功能:

  9.     八自由度四足机器人运动

  10.            

  11.   实验接线:

  12.                 【--机器人头部(俯视图)--】

  13. ----------------------------------------------------



  14.     左前腿[外侧腿----内侧腿]     右前腿[内侧腿----外侧腿]

  15.             内侧    外侧                 内侧     外侧

  16.              .--.      .--.                    .--.       .--.

  17.              |   |---|   |                     |   |       |   |

  18.     D3    |   |---|   |   D4        D7 |   |       |   | D8

  19.              ---*   ---*                    *--*     *--*



  20.     左后腿[外侧腿----内侧腿]     右后腿[内侧腿----外侧腿]

  21.            内侧    外侧                  内侧     外侧

  22.             .--.      .--.                    .--.       .--.

  23.             |   |---|   |                     |   |      |   |

  24.     A3   |   |---|   |   A2       D12 |   |      |   | D11

  25.             ---*   ---*                    *--*    *--*

  26.     ---------------------------------------------------

  27.   版权说明:Copyright 2023 Robottime(Beijing) Technology Co., Ltd. All Rights Reserved.

  28.     Distributed under MIT license.See file LICENSE for detail or copy at

  29.      https://opensource.org/licenses/MIT   by 机器谱 2023-04-20 https://www.robotway.com/

  30. -------------------------------------------------------------------------------------*/

  31. #include <Arduino.h>

  32. #include <avr/pgmspace.h>

  33. #include <Servo.h>

  34. #include "Config.h"

  35. #include "PROGMEM_DATA.h"


  36. Servo myServo[8];


  37. void act_length();      //动作数组长度计算

  38. void ServoStart();      //舵机连接

  39. void ServoStop();       //舵机断开

  40. void ServoGo();         //舵机转动

  41. void readProgmem();     //读取PWM值

  42. void servo_init();      //舵机初始化

  43. void servo_move();      //动作执行



  44. void setup() {

  45.   Serial.begin(9600);

  46.   act_length();            

  47. }


  48. void loop() {

  49.   servo_move(ACTION_INIT, 2);

  50.   delay(1000);

  51.   servo_move(ACTION_MOVE, 20);

  52.   while(1){};

  53. }


  54. void act_length()

  55. {

  56.   actPwmNum[0] = (sizeof(actionInit) / sizeof(actionInit[0]))/SERVO_NUM;

  57.   actPwmNum[1] = (sizeof(actionMove) / sizeof(actionMove[0]))/SERVO_NUM;

  58.   actPwmNum[2] = (sizeof(actionBack) / sizeof(actionBack[0]))/SERVO_NUM;

  59.   actPwmNum[3] = (sizeof(actionLeft) / sizeof(actionLeft[0]))/SERVO_NUM;

  60.   actPwmNum[4] = (sizeof(actionRight) / sizeof(actionRight[0]))/SERVO_NUM;


  61.   /*******************+++++++++此处可以添加PWM数组++++++++++++****************/

  62. }


  63. void ServoStart(int which){

  64.   if(!myServo[which].attached())myServo[which].attach(servo_port[which]);

  65.   pinMode(servo_port[which], OUTPUT);

  66. }


  67. void ServoStop(int which){

  68.   myServo[which].detach();

  69.   digitalWrite(servo_port[which],LOW);

  70. }


  71. void ServoGo(int which , float where){

  72.   ServoStart(which);

  73.   myServo[which].writeMicroseconds(where);

  74. }


  75. void readProgmem(int p, int act){                                       

  76.   switch(act)

  77.   {

  78.     case 0:   value_cur[p] = pgm_read_word_near(actionInit + p + (SERVO_NUM * count_input));   break;

  79.     case 1:   value_cur[p] = pgm_read_word_near(actionMove + p + (SERVO_NUM * count_input));   break;

  80.     case 2:   value_cur[p] = pgm_read_word_near(actionBack + p + (SERVO_NUM * count_input));   break;

  81.     case 3:   value_cur[p] = pgm_read_word_near(actionLeft + p + (SERVO_NUM * count_input));   break;

  82.     case 4:   value_cur[p] = pgm_read_word_near(actionRight + p + (SERVO_NUM * count_input));   break;

  83.     default: break;

  84.   }

  85. }


  86. void servo_init(int act, int num){                        

  87.   if(!_b)

  88.   {

  89.     for(int i=0;i<SERVO_NUM;i++)

  90.     {

  91.       readProgmem(i, act);

  92.       ServoGo(i, value_cur[i]);

  93.       value_pre[i] = value_cur[i];

  94.     }

  95.   }

  96.   num == 1 ? _b = true : _b = false;

  97. }


  98. void servo_move(int act, int num){           

  99.   float value_delta[SERVO_NUM] = {};

  100.   float in_value[SERVO_NUM] = {};

  101.   servo_init(act, num);

  102.   for(int i=0;i< num * actPwmNum[act];i++)

  103.   {

  104.     count_input++;

  105.    

  106.     if(count_input == actPwmNum[act])

  107.     {

  108.       count_input = 0;

  109.       continue;

  110.     }

  111.    

  112.     for(int i=0;i<SERVO_NUM;i++)

  113.     {

  114.       readProgmem(i, act);

  115.       in_value[i] = value_pre[i];

  116.       value_delta[i] = (value_cur[i] - value_pre[i]) / frequency;


  117.       /**************************************************串口查看输出**************************************************/

  118. //      Serial.print(value_pre[i]);

  119. //      Serial.print(" ");

  120. //      Serial.print(value_cur[i]);

  121. //      Serial.print(" ");

  122. //      Serial.print(value_delta[i]);

  123. //      Serial.println();

  124.       /**************************************************串口查看输出**************************************************/

  125.     }

  126. //    Serial.println();

  127.    

  128.     for(int i=0;i<frequency;i++)

  129.     {

  130.       for(int k=0;k<SERVO_NUM;k++)

  131.       {

  132.         in_value[k] += value_delta[k];  

  133.         value_pre[k] = in_value[k];


  134.         /**************************************************串口查看输出**************************************************/

  135. //        Serial.print(in_value[k]);

  136. //        Serial.print(" ");

  137.         /**************************************************串口查看输出**************************************************/

  138.       }

  139. //      Serial.println();

  140.      

  141.       for(int j=0;j<SERVO_NUM;j++)

  142.       {      

  143.         ServoGo(j, in_value[j]);

  144.       }

  145.       delayMicroseconds(SERVO_SPEED);

  146.     }


  147.     /**************************************************串口查看输出**************************************************/

  148. //    for(int i=0;i<SERVO_NUM;i++)

  149. //    {

  150. //      Serial.println(value_pre[i]);  

  151. //    }

  152.     /**************************************************串口查看输出**************************************************/

  153.   }

  154. }
复制代码

大家可根据转向的步态,参考上述例程,尝试自己编写下8自由度串联四足机器人转弯的实验程序。

5. 资料下载
资料内容:

​①前进-例程源代码
​②前进-样机3D文件
资料下载地址:https://www.robotway.com/h-col-212.html

想了解更多机器人开源项目资料请关注 机器谱网站 https://www.robotway.com

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-3-28 18:47 , Processed in 0.043890 second(s), 17 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表