履带加伸缩机械手机器人
本帖最后由 RichardFu 于 2016-4-1 14:59 编辑视频展示http://v.youku.com/v_show/id_XMTUxOTU1OTg3Ng==.html
材料1. Romeo BLE多合一控制器(DFR0305) 2. L298N双路H桥电机驱动(DRI0002) 3. 金属夹持器(ROB0099) 4. Devastator履带机器人移动平台(ROB0112)5. 全方位蜂巢云台(ROB0114)6. 云台舵机支架套件(FIT0004)7. 7.4V 2200MA 锂电池(FIT0137)8. 180度舵机(SER0020) x29. 螺纹电机 6V,100rpm (https://item.taobao.com/item.htm?spm=2013.1.1998246701.2.CVdNkj&scm=1007.10152.21663.1i35577771546&id=38892435595&pvid=37962211-c1bc-4e0a-ac5a-76d7d76bcb0f&qq-pf-to=pcqq.c2c)10. 3D打印伸缩臂
简介
创客喜欢用自己的双手进行创作,但有没有想过让自己做的机器人同样拥有动手能力呢?在这个项目里我打算把履带小车结合夹持器做一个有抓取功能的小车。由于装在小车上方难以抓到地面上的东西,因此还需要给小车增加伸缩的功能。我们使用3D打印机打印一个可以伸缩的支架,并找了一个可以配合的螺纹电机来实现伸缩功能。
这个机器人还是个比较粗略的原型,希望由此可以发展出更精密并且也容易制作的机械爪机器人。
制作流程
组装过程:1.用3D打印机打印伸缩臂的零件,并用螺丝组装起来。另外还打印螺纹电机的支架,把螺纹电机和伸缩臂组装起来。(模型在最后附上)2.将蜂巢云台装在履带机器人上。3.在云台上使用舵机支架套件来安装一个舵机。4.把螺纹电机装在舵机上。5.把另一个舵机装在夹持器上,使它可以做抓取动作。6.把夹持器的舵机固定到伸缩臂上。
使用下图进行连接:
M1 – 右轮电机M2 – 左轮电机数字13 – 电机驱动E1数字12 – 电机驱动M1数字9 – 机械臂抬起/降落舵机数字8 – 夹持器舵机
Vin – 电机驱动VDGND – 电机驱动GND电机驱动M1 – 螺纹电机电池 – 控制板电源电池 – 电机驱动VS和GND
代码
#include <Servo.h>
#include <Metro.h>
#include "GoBLE.h"
int speedPin_M1 = 5; //电机1速度控制 M1 Speed Control
int speedPin_M2 = 6; //电机2速度控制 M2 Speed Control
int directionPin_M1 = 4; //电机1方向控制 M1 Direction Control
int directionPin_M2 = 7; //电机2方向控制 M1 Direction Control
int E1 = 13;
int M1 = 12;
int tGo = 13000;
int tBack = 13000;
int tCatch = 2000;
int tRelease = 2000;
bool catched = false;
Servo claw; //claw platform servo
Servo top; //上层舵机 top servo
int clawPosition = 45; // 45 ~ 100
int topPosition = 45; //45 ~ 155
int recordPin = 11;
int playPin = 10;
int joystickX, joystickY;
int buttonState;
bool leftPressed = false;
bool rightPressed = false;
bool clawMoved = false;
void setup() {
Goble.begin(); //启动GoBLE
Serial.begin(115200);
top.attach(9); // Top Servo– Digital 9
claw.attach(8); // claw Servo - Digital 8
top.write(topPosition); //写入起始角度
claw.write(clawPosition);//写入起始角度
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
pinMode(10, OUTPUT);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
analogWrite(E1, 0);
}
void loop() {
if (Goble.available()) {
joystickX = Goble.readJoystickX();
joystickY = Goble.readJoystickY();
buttonState = Goble.readSwitchUp();
buttonState = Goble.readSwitchDown();
buttonState = Goble.readSwitchLeft();
buttonState= Goble.readSwitchRight();
// Serial.print("Joystick Value: ");
// Serial.print(joystickX);
// Serial.print("");
// Serial.println(joystickY);
if (joystickY > 196) {
Serial.println("turn right");
carTurnRight(250, 250);
}
else if (joystickY < 64) {
Serial.println("turn left");
carTurnLeft(250, 250);
}
else if (joystickX > 196) {
Serial.println("move forward");
carAdvance(400, 400);
}
else if (joystickX < 64) {
Serial.println("move backward");
carBack(400, 400);
}
else {
carStop();
}
if (buttonState == PRESSED && buttonState == PRESSED) {
analogWrite(E1, 0);
if (!clawMoved) {
if (clawPosition <= 45) {
clawPosition = 100;
claw.write(clawPosition);
}
else {
clawPosition = 45;
claw.write(clawPosition);
}
clawMoved = true;
}
}
else if (buttonState == PRESSED) {
digitalWrite(M1, LOW);
analogWrite(E1, 255);
}
else if (buttonState == PRESSED) {
digitalWrite(M1, HIGH);
analogWrite(E1, 255);
}
else if (buttonState == PRESSED) {
topPosition -= 5;
if (topPosition <= 45) {
topPosition = 45;
}
top.write(topPosition);
}
else if (buttonState == PRESSED) {
topPosition += 5;
if (topPosition >= 155) {
topPosition = 155;
}
top.write(topPosition);
}
if( buttonState == RELEASED && buttonState == RELEASED){
analogWrite(E1, 0);
}
if( buttonState == RELEASED || buttonState == RELEASED){
clawMoved = false;
}
}
}
void carStop() { //Motor Stop
digitalWrite(speedPin_M2, 0);
digitalWrite(directionPin_M1, LOW);
digitalWrite(speedPin_M1, 0);
digitalWrite(directionPin_M2, LOW);
}
void carTurnLeft(int leftSpeed, int rightSpeed) { //Turn Left
analogWrite (speedPin_M2, leftSpeed);
digitalWrite(directionPin_M1, LOW);
analogWrite (speedPin_M1, rightSpeed);
digitalWrite(directionPin_M2, LOW);
}
void carTurnRight(int leftSpeed, int rightSpeed) { //Turn Right
analogWrite (speedPin_M2, leftSpeed);
digitalWrite(directionPin_M1, HIGH);
analogWrite (speedPin_M1, rightSpeed);
digitalWrite(directionPin_M2, HIGH);
}
void carBack(int leftSpeed, int rightSpeed) { //Move backward
analogWrite (speedPin_M2, leftSpeed); //PWM Speed Control
digitalWrite(directionPin_M1, HIGH);
analogWrite (speedPin_M1, rightSpeed);
digitalWrite(directionPin_M2, LOW);
}
void carAdvance(int leftSpeed, int rightSpeed) { //Move forward
analogWrite (speedPin_M2, leftSpeed);
digitalWrite(directionPin_M1, LOW);
analogWrite (speedPin_M1, rightSpeed);
digitalWrite(directionPin_M2, HIGH);
}
实际效果小车可以用iOS系统的GoBLE软件控制。用左边的遥杆控制小车移动,右边的键控制机械臂升起降落以及伸缩,左右键同时按可以让夹持器夹持或松开。
注意事项1.螺纹电机转速过慢,可以再尝试一下其它型号。2.机械臂负重过多,会导致弯曲以及无法伸展。以后可以考虑修改构造把夹持器舵机放到后面。3.组装时尽量把机械臂放在直立状态。4.注意将电线和驱动固定,各个连接口打胶。
模型
为什么每次总强在我前面 楼主这个有点抖,哈哈 一抖一抖的,很搞笑 语音识别 - - ?{:5_153:}
楼主你好神奇…… hnyzcj 发表于 2016-4-1 15:43
为什么每次总强在我前面
你是大忙人啊 丄帝De咗臂 发表于 2016-4-7 17:20
你是大忙人啊
在你面前我不敢说自己忙! 都这么高大上 学习中,希望自己能成功做出一个来!谢谢分享! 厉害厉害 系统有些抖 66666666666666666666666666666666666 机械舞的灵感就是这么来的,抖啊抖 这抖来抖去的能抓稳吗?
页:
[1]