2016年1月2日 星期六

ROSA 系統開發 19 ─ 第二代六腳機器蜘蛛+meArm

https://4rdp.blogspot.com/2016/01/rosa-19-mearm.html

(請開啟字幕觀賞)

// (C) 2015-2016, Bridan Wang, CC BY-NC-SA 3.0 TW
// http://4rdp.blogspot.tw/search/label/ROSA%20(Arduino)

#define LAST_SERVO   16    // for 6 x 2 spider + meArm
#define SERVO_TABLE  17

byte servo_pin[] =
{ 0, 4, 5, 6, 7, 9, 10, 11, 12, 18, 19, 16, 17, 3, 8, 14, 15 };
byte servo_revse[] =
{ 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 };
byte servo_angle[] =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
byte servo_set[] =
{ 0, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 150, 90, 90, 90 };
byte servo_speed[] =
{ 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 };
byte servo_hold[] =

{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

#define zeo 0    // zero
#define lif 45   // lift leg
#define ris 135  // rise leg
#define std 90   // stand
#define hon 251  // hold on
#define hof 250  // hold off
#define fwd 60   // forward
#define mid 90   // middle
#define bck 120  // backward
#define art 30   // arm right
#define alt 150  // arm left
#define clp 150  // clip
#define cop 120  // clip open
#define aup 60   // arm up
#define adn 150  // arm down


const byte RUN_0[] PROGMEM = {                // spider start
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_SPEED, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 5, 5, 5,   //0
_SERVO, fwd, lif, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //1 
_SERVO, mid, std, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //2
_SERVO, hon, hon, fwd, lif, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //3
_SERVO, 255, 255, mid, std, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //4
_SERVO, 255, 255, hon, hon, fwd, lif, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //5
_SERVO, 255, 255, 255, 255, mid, std, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //6
_SERVO, 255, 255, 255, 255, hon, hon, fwd, lif, 255, 255, 255, 255, 255, 255, 255, 255,   //7
_SERVO, 255, 255, 255, 255, 255, 255, mid, std, 255, 255, 255, 255, 255, 255, 255, 255,   //8
_SERVO, 255, 255, 255, 255, 255, 255, hon, hon, fwd, lif, 255, 255, 255, 255, 255, 255,   //9
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, mid, std, 255, 255, 255, 255, 255, 255,   //10
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, hon, hon, fwd, lif, 255, 255, 255, 255,   //11
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, mid, std, 255, 255, 255, 255,   //12
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, hon, hon, cop, alt, 255, 255,   //13
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, clp, mid, 255, 255,   //14
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, hon, hon, 120, adn,   //15
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, hof, hof,  90, aup,   //16
_GOTO, 212,             //17 goto RUN_P
};


const byte RUN_P[] PROGMEM = {                // spider stand 
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_SERVO, 255, std, 255, std, 255, std, 255, std, mid, std, mid, std, 255, 255, 255, 255,   //0
_HOLD, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 255, 255, 255, 255,   //1
_STOP,                  //2
};

const byte RUN_1[] PROGMEM = {                 // spider wave
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_SERVO, 255, 30, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //0 
_SERVO, 255, 150, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //1 
_GOTO, 0,               //2
};

const byte RUN_2[] PROGMEM = {                // spider hello
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_SERVO, 255, lif, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 135, mid, 150, 255,   //0
_LOOP,    3, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //1
_SERVO, fwd, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 135, 120, 255, 255,   //2 
_SERVO, mid, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 135, 60, 255, 255,    //3 
_NEXT, 2, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,        //4 
_SERVO, 255, std, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, clp, mid,  90, 255,   //5 
_RETURN,                //6
};

const byte RUN_3[] PROGMEM = {              // spider dance-1
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_SERVO, bck, std, bck, std, mid, std, mid, std, fwd, std, fwd, std, 255, 255, 255, 255,   //0
_HOLD, 150, 255, 150, 255, 150, 255, 150, 255, 150, 255, 150, 255, 255, 255, 255, 255,   //1
_LOOP, 3, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,        //2
_SERVO, 255, 60, 255, 120, 255, 120, 255, 60, 255, 60, 255, 120, 255, 255, 255, 255,        //3
_SERVO, 255, std, 255, std, 255, std, 255, std, 255, std, 255, std, 255, 255, 255, 255,   //4
_NEXT, 3, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,        //5 
_LOOP, 3, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,        //6
_SERVO, 255, 120, 255, 60, 255, 60, 255, 120, 255, 120, 255, 60, 255, 255, 255, 255,         //7
_SERVO, 255, std, 255, std, 255, std, 255, std, 255, std, 255, std, 255, 255, 255, 255,   //8
_NEXT, 7, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,        //9
_GOTO, 0,               //10
};

const byte RUN_4[] PROGMEM = {              // spider dance-2
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_SERVO, mid, std, mid, std, mid, std, mid, std, mid, std, mid, std, 255, 255, 255, 255,   //0
_HOLD, 150, 255, 150, 255, 150, 255, 150, 255, 150, 255, 150, 255, 255, 255, 255, 255,   //1
_SERVO, 255, hon, 255, zeo, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //2
_SERVO, 255, 255, 255, std, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //3
_SERVO, 255, 255, 255, hon, 255, 255, 255, zeo, 255, 255, 255, 255, 255, 255, 255, 255,   //4
_SERVO, 255, 255, 255, 255, 255, 255, 255, std, 255, 255, 255, 255, 255, 255, 255, 255,   //5
_SERVO, 255, 255, 255, 255, 255, 255, 255, hon, 255, 255, 255, zeo, 255, 255, 255, 255,   //6
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, std, 255, 255, 255, 255,   //7
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, zeo, 255, hon, 255, 255, 255, 255,   //8
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, std, 255, 255, 255, 255, 255, 255,   //9
_SERVO, 255, 255, 255, 255, 255, zeo, 255, 255, 255, hon, 255, 255, 255, 255, 255, 255,   //10
_SERVO, 255, 255, 255, 255, 255, std, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //11
_SERVO, 255, zeo, 255, 255, 255, hon, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //12
_SERVO, 255, std, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //13
_GOTO, 2,               //14
};

const byte RUN_5[] PROGMEM = {  // for meArm base move + clip 
//   0,  1,  2,  3,  4,   5,   6,   7,   8,   9,  10,  11,  12, 13, 14, 15, 16  
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, cop, 255, 255, aup,   //0
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, hon, mid, 90,  255,   //1
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, hon, adn,   //2
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, clp, 255, 255, hon,   //3
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 160, 255,   //4
_RETURN,                //5
};

const byte RUN_6[] PROGMEM = {  // for meArm base right + clip open
//   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12, 13, 14, 15, 16  
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, aup,   //0
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, art, 90,  255,   //1
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, hon, adn,   //2
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, cop, 255, 255, 255,   //3
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, aup,   //4
_RETURN,                //5
};

const byte RUN_7[] PROGMEM = {           // spider speed slow
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_SPEED, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 255, 255,   //0
_RETURN,                //1
};

const byte RUN_8[] PROGMEM = {         // spider speed normal
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_SPEED, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 5, 255, 255,   //0
_RETURN,                //1
};

const byte RUN_9[] PROGMEM = {         // spider speed fast
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_SPEED, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 5, 10, 255, 255,   //0
_RETURN,                //1
};

const byte RUN_U[] PROGMEM = {    // spider forward x 6 steps
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_SERVO, 255, hon, 255, lif, 255, hon, 255, lif, 255, hon, 255, lif, 255, 255, 255, 255,   //0
_SERVO, bck, 255, 255, 255, bck, 255, 255, 255, bck, 255, 255, 255, 255, 255, 255, 255,   //1
_SERVO, hon, 255, fwd, 255, hon, 255, fwd, 255, hon, 255, fwd, 255, 255, 255, 255, 255,   //2
_SERVO, 255, 255, 255, std, 255, 255, 255, std, 255, 255, 255, std, 255, 255, 255, 255,   //3
_SERVO, 255, lif, 255, hon, 255, lif, 255, hon, 255, lif, 255, hon, 255, 255, 255, 255,   //4
_SERVO, fwd, 255, 255, 255, fwd, 255, 255, 255, fwd, 255, 255, 255, 255, 255, 255, 255,   //5
_SERVO, 255, 255, bck, 255, 255, 255, bck, 255, 255, 255, bck, 255, 255, 255, 255, 255,   //6
_SERVO, 255, std, hon, 255, 255, std, hon, 255, 255, std, hon, 255, 255, 255, 255, 255,   //7
_GOTO, 0,               //8
};

const byte RUN_D[] PROGMEM = {   // spider backward x 6 steps
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_SERVO, 255, hon, 255, lif, 255, hon, 255, lif, 255, hon, 255, lif, 255, 255, 255, 255,   //0
_SERVO, fwd, 255, 255, 255, fwd, 255, 255, 255, fwd, 255, 255, 255, 255, 255, 255, 255,   //1
_SERVO, hon, 255, bck, 255, hon, 255, bck, 255, hon, 255, bck, 255, 255, 255, 255, 255,   //2
_SERVO, 255, 255, 255, std, 255, 255, 255, std, 255, 255, 255, std, 255, 255, 255, 255,   //3
_SERVO, 255, lif, 255, hon, 255, lif, 255, hon, 255, lif, 255, hon, 255, 255, 255, 255,   //4
_SERVO, bck, 255, 255, 255, bck, 255, 255, 255, bck, 255, 255, 255, 255, 255, 255, 255,   //5
_SERVO, 255, 255, fwd, 255, 255, 255, fwd, 255, 255, 255, fwd, 255, 255, 255, 255, 255,   //6
_SERVO, 255, std, hon, 255, 255, std, hon, 255, 255, std, hon, 255, 255, 255, 255, 255,   //7
_GOTO, 0,               //8
};

const byte RUN_R[] PROGMEM = {           // spider turn right
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_LOOP, 2, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,        //0
_SERVO, fwd, lif, 255, 255, 255, 255, 255, hon, 255, 255, 255, 255, 255, 255, 255, 255,   //1
_SERVO, 255, std, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //2
_SERVO, 255, hon, bck, lif, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //3
_SERVO, 255, 255, 255, std, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //4
_SERVO, 255, 255, 255, hon, bck, lif, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //5
_SERVO, 255, 255, 255, 255, 255, std, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //6
_SERVO, 255, 255, 255, 255, 255, hon, 255, 255, 255, 255, bck, lif, 255, 255, 255, 255,   //7
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, std, 255, 255, 255, 255,   //8
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, fwd, lif, 255, hon, 255, 255, 255, 255,   //9
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, std, 255, 255, 255, 255, 255, 255,   //10
_SERVO, 255, 255, 255, 255, 255, 255, fwd, lif, 255, hon, 255, 255, 255, 255, 255, 255,   //11
_SERVO, 255, 255, 255, 255, 255, 255, 255, std, 255, 255, 255, 255, 255, 255, 255, 255,   //12
_SERVO, bck, 255, fwd, 255, fwd, 255, bck, 255, bck, 255, fwd, 255, 255, 255, 255, 255,   //13
_NEXT, 1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,        //14 
_RETURN,                //15
};

const byte RUN_L[] PROGMEM = {            // spider turn left
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_LOOP, 2, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,        //0
_SERVO, 255, 255, fwd, lif, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //1
_SERVO, 255, 255, 255, std, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //2
_SERVO, bck, lif, 255, hon, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //3
_SERVO, 255, std, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //4
_SERVO, 255, hon, 255, 255, 255, 255, bck, lif, 255, 255, 255, 255, 255, 255, 255, 255,   //5
_SERVO, 255, 255, 255, 255, 255, 255, 255, std, 255, 255, 255, 255, 255, 255, 255, 255,   //6
_SERVO, 255, 255, 255, 255, 255, 255, 255, hon, bck, lif, 255, 255, 255, 255, 255, 255,   //7
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, std, 255, 255, 255, 255, 255, 255,   //8
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, hon, fwd, lif, 255, 255, 255, 255,   //9
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, std, 255, 255, 255, 255,   //10
_SERVO, 255, 255, 255, 255, fwd, lif, 255, 255, 255, 255, 255, hon, 255, 255, 255, 255,   //11
_SERVO, 255, 255, 255, 255, 255, std, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //12
_SERVO, fwd, 255, bck, 255, bck, 255, fwd, 255, fwd, 255, bck, 255, 255, 255, 255, 255,   //13
_NEXT, 1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,        //14 
_RETURN,                //15
};

const byte RUN_K[] PROGMEM = {  // spider forward-2 x 6 steps
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_SERVO, fwd, lif, hon, 255, hon, 255, hon, 255, hon, 255, hon, 255, 255, 255, 255, 255,   //0
_SERVO, 255, std, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //1
_SERVO, 255, hon, fwd, lif, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //2
_SERVO, 255, 255, 255, std, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,   //3
_SERVO, 255, 255, 255, hon, fwd, lif, fwd, lif, 255, 255, 255, 255, 255, 255, 255, 255,   //4
_SERVO, 255, 255, 255, 255, 255, std, 255, std, 255, 255, 255, 255, 255, 255, 255, 255,   //5
_SERVO, 255, 255, 255, 255, 255, hon, 255, hon, fwd, lif, fwd, lif, 255, 255, 255, 255,   //6
_SERVO, 255, 255, 255, 255, 255, 255, 255, 255, 255, std, 255, std, 255, 255, 255, 255,   //7
_SERVO, bck, 255, bck, 255, bck, 255, bck, 255, bck, hon, bck, hon, 255, 255, 255, 255,   //8
_GOTO, 0,               //9
};

const byte RUN_S[] PROGMEM = {                  // spider sit
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_SERVO, 255, lif, 255, lif, 255, lif, 255, lif, 255, lif, 255, lif, 255, 255, 255, 255,   //0
_GOTO, 200,             //1 goto RUN_N
};

const byte RUN_N[] PROGMEM = {                 // spider stop
//   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16  
_HOLD, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,   //0 
_STOP,                  //1
};

開始 2016 新的一年,先祝大家新年快樂,接續前文, 這回在六足機器蜘蛛上直接架上一個 meArm,以電子秤測過合體總重 753.5 g,可以行動正常,這回紅外線遙控追加 meArm 的程序控制,到目前為止,至少達成哈爸想要的機器蜘蛛+機器手臂的本體設計,至少確認這樣目標可行,系統雛形未來還可以再改進,我也可以繼續進行 ROSA 指令的設計,不會像現在受限紅外線遙控,也可以 USB、藍芽或其它無線控制。

這一版程式由於加了四個 SG90 伺服馬達,相關程式陣列也要擴充。對機器蜘蛛製作有興趣的朋友可以留言或透過電郵 idea22much@gmail.com 與我們聯絡。

沒有留言:

張貼留言