R111样机是一款拥有12个自由度的串联仿生六足机器人。本文为这个六足机器人增加蓝牙遥控功能,可以通过安卓手机APP对机器人的动作实现遥控。
在这个示例中,我们采用了以下硬件,请大家参考:
主控板 |
Basra主控板(兼容Arduino Uno) |
扩展板 | SH-SR舵机扩展板 |
舵机 | 标准舵机 |
电池 | 7.4V锂电池 |
通信 |
蓝牙串口模块 |
电路连接说明:
12自由度六足机器人结构上装有12个舵机,所以将采用 SH-SR舵机扩展板 。
舵机接线顺序:1、3; 4、 5; 6、 8;11、13;15、 21;24、26。
下面的例程可以实现通过安卓手机APP按钮实现机器人前进、后退、左转、右转、跳舞等动作。安卓APP的设置也可以参考 如何使用探索者通信模块一文中蓝牙串口模块部分。
你也可以设计自己想要的动作,利用Controller 1.0b软件获取想要的动作参数,拷贝到下面的例程里。
将参考例程(R111_bluetooth.ino)下载到主控板:
/*------------------------------------------------------------------------------------
版权说明:Copyright 2023 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 机器谱 2023-02-16 https://www.robotway.com/
------------------------------*/
#include
#include
#include "Config.h"
#include
#include
int count_input = 0;
boolean _b = false;
/**************+++++++++++动作组数组,请将转换后的动作组数据粘贴到相应的动作组中+++++++***************************/
const PROGMEM int actionInit[] = {
1090, 1790, 1220, 980, 650, 1800, 1020, 1330, 520, 1155, 1260, 2020,
1090, 1790, 1220, 980, 650, 1800, 1020, 1330, 520, 1155, 1260, 2020,
// 1660, 1230, 1220, 980, 1280, 1190, 1020, 1330, 1090, 1155, 1260, 1540,
// 1090, 1790, 1220, 980, 650, 1800, 1020, 1330, 520, 1155, 1260, 2020
};
const PROGMEM int actionMove[] = {
1660, 1230, 1220, 980, 1280, 1190, 1020, 1330, 1090, 1155, 1260, 1540,
1660, 1790, 1320, 1080, 1280, 1800, 920, 1230, 1090, 1255, 1360, 2020,
1660, 1230, 1320, 1080, 1280, 1190, 920, 1230, 1090, 1255, 1360, 1540,
1090, 1300, 1120, 880, 650, 900, 1120, 1430, 520, 1055, 1160, 1300,
1660, 1300, 1120, 880, 1280, 900, 1120, 1430, 1090, 1055, 1160, 1300,
};
const PROGMEM int actionLeft[] = {
1660, 1230, 1220, 980, 1280, 1190, 1020, 1330, 1090, 1155, 1260, 1540,
1080,1160,1420,780,650,1100,1220,1130,520,955,1460,1430,
1700,1160,1420,780,1440,1100,1220,1130,1100,955,1460,1430,
1700,1700,1020,1180,1440,1800,820,1530,1100,1355,1060,2020,
1700,1160,1020,1180,1440,1100,820,1530,1100,1355,1060,1430,
};
const PROGMEM int actionRight[] = {
1660, 1230, 1220, 980, 1280, 1190, 1020, 1330, 1090, 1155, 1260, 1540,
1700,1700,1420,780,1440,1800,1220,1130,1100,955,1460,2020,
1700,1160,1420,780,1440,1100,1220,1130,1100,955,1460,1430,
1090,1160,1020,1180,650,1100,820,1530,520,1355,1060,1430,
1700,1160,1020,1180,1440,1100,820,1530,1100,1355,1060,1430,
};
const PROGMEM int actionBack[] = {
1660, 1230, 1220, 980, 1280, 1190, 1020, 1330, 1090, 1155, 1260, 1540,
1700,1680,1020,780,1440,1800,1220,1530,1100,955,1060,2020,
1700,1060,1020,780,1440,1100,1220,1530,1100,955,1060,1430,
1100,1060,1220,1180,650,1100,1020,1130,520,1355,1260,1430,
1700,1060,1220,1180,1440,1100,1020,1130,1110,1355,1260,1430,
};
const PROGMEM int actionDance[] = {
1660, 1230, 1220, 980, 1280, 1190, 1020, 1330, 1090, 1155, 1260, 1540,
1090,1790,1220,980,650,1800,1020,1330,520,1155,1260,2020,
1490,1590,1220,980,850,1400,1020,1330,1320,1155,1260,2020,
1490,1590,1220,980,850,1400,1020,1330,1320,1155,1700,1700,
1490,1590,1220,980,850,1400,1020,1330,1320,1155,1700,2020,
1090,1790,1220,980,650,1800,1020,1330,520,1155,1260,2020,
1490,1590,1220,980,850,1400,1020,1330,520,1155,1260,1220,
1490,1590,1220,980,850,1400,1020,1330,800,700,1260,1220,
1490,1590,1220,980,850,1400,1020,1330,520,700,1260,1220,
1090,1790,1220,980,650,1800,1020,1330,520,1155,1260,2020,
1670,1190,1220,980,1370,1100,1020,1330,1100,1155,1260,1430,
1090,1190,1220,980,1370,1800,620,1730,1100,1155,1260,1430,
1090,1190,1220,980,1370,1100,620,1730,1100,1155,1260,1430,
1670,1190,1220,980,1370,1800,620,1730,1100,1155,1260,1430,
1090,1190,1220,980,1370,1100,620,1730,1100,1155,1260,1430,
1090,1190,1220,980,1370,1800,700,1570,1100,1155,1260,1430,
1670,1190,1220,980,1370,1100,700,1570,1100,1155,1260,1430,
1670,1190,1220,980,1370,1100,700,1570,520,520,1930,2020,
1670,1190,1220,980,1370,1100,700,1570,800,520,1930,1700,
1670,1190,1220,980,1370,1100,700,1570,520,520,1930,2020,
1670,1190,1220,980,1370,1100,700,1570,800,520,1930,1700,
1670,1190,1220,980,1370,1100,700,1570,1100,1155,1260,1430,
1670,1190,1220,980,1370,1100,1020,1330,1100,1155,1260,1430,
1670,1190,1220,980,1370,1100,1020,1330,1100,1155,1260,1430,
1670,1190,1220,980,900,1590,1020,1330,720,1155,1260,1430,
1320,1540,1220,980,1370,1100,1020,1330,1100,1155,1260,1830,
1670,1190,1220,980,1370,1100,1020,1330,1100,1155,1260,1430,
1320,1410,1220,980,1370,1100,1020,1330,1100,1155,1260,1950,
1300,1670,1220,980,1370,1100,1020,1330,1100,1155,1260,1600,
1670,1190,1220,980,940,1540,1020,1330,920,1155,1260,1430,
1670,1190,1220,980,1235,1480,1020,1330,580,1155,1260,1430,
1670,1190,1220,980,940,1540,1020,1330,920,1155,1260,1430,
1670,1190,990,1210,940,1540,1140,1100,920,1400,1060,1430,
1300,1670,990,1210,1370,1100,1140,1100,1100,1400,1060,1600,
1320,1540,990,1210,1370,1100,1140,1100,1100,1400,1060,1830,
1670,1190,990,1210,1370,1100,1140,1100,1100,1400,1060,1430,
1670,1190,990,1210,1370,1100,1140,1100,1100,1400,1060,1430,
1670,1190,1280,920,1370,1100,920,1410,1100,1030,1410,1430,
1670,1190,990,1210,1370,1100,1140,1100,1100,1400,1060,1430,
1670,1190,1280,920,1370,1100,920,1410,1100,1030,1410,1430,
1670,1190,1220,980,1370,1100,1020,1330,1100,1155,1260,1430,
};
/**************************+++++---------分割线--------++++++*******************************************************/
//动作组数组长度获取函数,增加动作组时需要按如下格式添加:actPwmNum[增加的动作组序号] = sizeof(增加的动作组名称) / sizeof(增加的动作组名称[0]);
void act_length()
{
actPwmNum[0] = (sizeof(actionMove) / sizeof(actionMove[0]))/servo_num;
actPwmNum[1] = (sizeof(actionLeft) / sizeof(actionLeft[0]))/servo_num;
actPwmNum[2] = (sizeof(actionRight) / sizeof(actionRight[0]))/servo_num;
actPwmNum[3] = (sizeof(actionBack) / sizeof(actionBack[0]))/servo_num;
actPwmNum[4] = (sizeof(actionDance) / sizeof(actionDance[0]))/servo_num;
actPwmNum[5] = (sizeof(actionInit) / sizeof(actionInit[0]))/servo_num;
// for(int i=0;i 0 ;
void servo_move(int act, int num)
{
float value_delta[servo_num] = {};
float in_value[servo_num] = {};
servo_init(act, num);
for(int i=0;i< num * actPwmNum[act];i++)
{
//Serial.println(i);
//Serial.println(count_input);
count_input++;
if(count_input == actPwmNum[act])
{
count_input = 0;
continue;
}
for(int i=0;i
① 蓝牙遥控-例程源代码
② Controller1.0b资料包
资料内容详见 12自由度六足-蓝牙遥控