机器谱 发表于 2022-12-22 10:31:59

轮式机械臂小车的制作分享

本帖最后由 机器谱 于 2022-12-22 10:34 编辑

1. 运动功能说明        该样机是一款搭载了机械臂的双轮小车。它的底盘具备基本的行驶和原地转向功能,机械臂具备抬升、放下、抓取等功能。整体上可以实现抓取、搬运、码放等功能,可作为搬运机器人、排爆机器人等的模型使用。
2. 结构说明        该样机的底盘是一个小型双轮差速底盘【https://www.robotway.com/h-col-113.html】,机械臂包含2个串联的关节模组【https://www.robotway.com/h-col-121.html】和1个舵机夹爪模组【https://www.robotway.com/h-col-122.html】。
3. 运动功能实现
本样机的运动功能相当于是把底盘、关节、夹爪的动作进行组合实现。
3.1 电子硬件
在这个示例中,采用了以下硬件,请大家参考:

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




3.2 编写程序编程环境:Arduino 1.8.19
编写并烧录以下代码(Servo_Sync_Se.ino):
/*------------------------------------------------------------------------------------

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

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

         https://opensource.org/licenses/MIT

         by 机器谱 2022-9-14 https://www.robotway.com/

------------------------------

实验功能: 小车前进→机械臂下落→夹爪闭合→机械臂抬起→小车后退→夹爪张开

-----------------------------------------------------

实验接线:

机械爪:D4

腕部(连接机械爪)舵机:D7

底部舵机:D11

左轮:D9,D10

右轮:D5,D6。                                    

------------------------------------------------------------------------------------*/

#include <Servo.h>


int SERVO_SPEED=20;                                        //定义舵机转动快慢的时间

int ACTION_DELAY=200;                                    //定义所有舵机每个状态时间间隔


Servo myServo;


int f = 50;                                                   //定义舵机每个状态间转动的次数,以此来确定每个舵机每次转动的角度

int servo_port = {4,7,11,3,8,12};                            //定义舵机引脚

int servo_num = sizeof(servo_port) / sizeof(servo_port);   //定义舵机数量

float value_init = {125, 130, 160, 30, 60, 120};                //定义舵机初始角度


void setup() {

Serial.begin(9600);

pinMode(5, OUTPUT);

pinMode(6, OUTPUT);

pinMode(9, OUTPUT);

pinMode(10, OUTPUT);

for(int i=0;i<servo_num;i++){

    ServoGo(i,value_init);

}

}


void loop() {

/*

servo_move(90, 130, 15, 70, 10, 150);

servo_move(90, 90, 90, 36, 110, 75);

servo_move(90, 130, 140, 132, 44, 16);

servo_move(90, 90, 90, 36, 110, 75);

while(1){

    f = 20;

    SERVO_SPEED = 20;

    servo_move(120, 90, 90, 70, 10, 150);

    servo_move(90, 90, 90, 70, 10, 150);

};

*/

//实现了定点多角度抓取、放置的动作

digitalWrite(5, HIGH);

digitalWrite(6, LOW);

digitalWrite(9, HIGH);

digitalWrite(10, LOW);

delay(1000);

digitalWrite(5, LOW);

digitalWrite(6, LOW);

digitalWrite(9, LOW);

digitalWrite(10, LOW);

delay(1000);

servo_move(125, 70, 70, 30, 60, 120);

delay(500);

servo_move(98, 70, 70, 30, 60, 120);

delay(500);

servo_move(98, 160, 160, 30, 60, 120);

delay(500);

digitalWrite(5, LOW);

digitalWrite(6, HIGH);

digitalWrite(9, LOW);

digitalWrite(10, HIGH);

delay(1000);

digitalWrite(5, LOW);

digitalWrite(6, LOW);

digitalWrite(9, LOW);

digitalWrite(10, LOW);

delay(1000);

servo_move(125, 160, 160, 30, 60, 120);

delay(500);

while(true);

}


void ServoStart(int which)

{

if(!myServo.attached())myServo.attach(servo_port);

pinMode(servo_port, OUTPUT);

}




void ServoStop(int which)

{

myServo.detach();

digitalWrite(servo_port,LOW);

}


void ServoGo(int which , int where)

{

if(where!=200)

{

    if(where==201) ServoStop(which);

    else

    {

      ServoStart(which);

      myServo.write(where);

    }

}

}


void servo_move(float value0, float value1, float value2, float value3, float value4, float value5)

{



float value_arguments[] = {value0, value1, value2, value3, value4, value5};

float value_delta;



for(int i=0;i<servo_num;i++)

{

    value_delta = (value_arguments - value_init) / f;


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

//    Serial.print(value_init);

//    Serial.print(" ");

//    Serial.print(value_arguments);

//    Serial.print(" ");

//    Serial.println(value_delta);

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

}



for(int i=0;i<f;i++)

{

    for(int k=0;k<servo_num;k++)

    {

      value_init = value_delta == 0 ? value_arguments : value_init + value_delta;


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

//      Serial.print(value_init);

//      Serial.print(" ");

    }

//    Serial.println();

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

   

    for(int j=0;j<servo_num;j++)

    {

      ServoGo(j,value_init);

    }

    delay(SERVO_SPEED);

}

delay(ACTION_DELAY);



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

//   for(int i=0;i<6;i++)

//   {

//    Serial.println(value_init);

//   }

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



}
4. 扩展样机       可以通过更换底盘、增加机械臂数量、改变机械臂安装位置、增加或减少机械臂的关节数量来对样机进行扩展。

5. 资料下载资料内容:①样机3D文件②样机例程源代码
资料下载链接:https://www.robotway.com/h-col-150.html





页: [1]
查看完整版本: 轮式机械臂小车的制作分享