by mochung » Mon Apr 10, 2006 7:16 pm
by mochung
Mon Apr 10, 2006 7:16 pm
Hi PEV, would you try this code and let me know if you experience any delay whenever you move the stick? To me the stick and the movement doesnt sync at all. I really need to wait for more than 10 sec just to get RN-1 CPU understand my TX command and get it up and running.
'== Robot walk ================================
GOTO AUTO
FILL 255,10000
DIM RCX AS BYTE
DIM RCY AS BYTE
CONST ID = 0 ' 1:0, 2:32, 3:64, 4:96,
PTP SETON
PTP ALLON
'== motor diretion setting ======================
DIR G6A,1,0,0,1,0,0
DIR G6B,1,1,1,1,1,1
DIR G6C,0,0,0,0,0,0
DIR G6D,0,1,1,0,1,0
'== motor start position read ===================
TEMPO 230
MUSIC "CDE"
GETMOTORSET G24,1,1,1,1,1,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,1,1,0
'== motor power on =============================
SPEED 5
MOTOR G24
GOSUB standard_pose
'================================================
'Gyro Setup
GYROSET G6A,0,1,1,0,0,0
GYROSET G6D,0,1,1,0,0,0
GYRODIR G6A,1,0,0,1,0,0
GYRODIR G6D,1,0,0,1,0,0
GYROSENSE G6A,0,200,200,0,0,0
GYROSENSE G6D,0,200,200,0,0,0
'================================================
MAIN:
RCX = RCIN(3)
RCY = RCIN(1)
'RC Walk
IF RCX >= 125 THEN ' RIGHT TURN
GOSUB right_turn
GOSUB standard_pose
ENDIF
IF RCX <= 75 AND RCX > 10 THEN 'LEFT TURN
GOSUB left_turn
GOSUB standard_pose
ENDIF
IF RCY > 125 THEN ' BACKWARD
GOSUB backward_walk
GOSUB standard_pose
ENDIF
IF RCY < 75 AND RCY > 40 THEN ' FORWARD
GOSUB forward_walk
GOSUB standard_pose
ENDIF
RETURN
'================================================
forward_walk:
SPEED 5
MOVE24 85, 71, 152, 91, 112, 60, 100, 40, 80, , , , 100, 40, 80, , , , 112, 76, 145, 93, 92, 60,
fwd_walk_main:
SPEED 14
'left up
MOVE24 90, 107, 105, 105, 114, 60, 90, 40, 80, , , , 100, 40, 80, , , , 114, 76, 145, 93, 90, 60,
'---------------------------------------
'left down
MOVE24 90, 56, 143, 122, 114, 60, 80, 40, 80, , , , 105, 40, 80, , , , 113, 80, 145, 90, 90, 60,
MOVE24 90, 46, 163, 112, 114, 60, 80, 40, 80, , , , 105, 40, 80, , , , 112, 80, 145, 90, 90, 60,
SPEED 10
'left center
MOVE24 100, 66, 141, 113, 100, 100, 90, 40, 80, , , , 100, 40, 80, , , , 100, 83, 156, 80, 100, 100,
MOVE24 113, 78, 142, 105, 90, 60, 100, 40, 80, , , , 100, 40, 80, , , , 90, 102, 136, 85, 114, 60,
SPEED 14
'right up
MOVE24 113, 76, 145, 93, 90, 60, 100, 40, 80, , , , 90, 40, 80, , , , 90, 107, 105, 105, 114, 60,
'right down
MOVE24 113, 80, 145, 90, 90, 60, 105, 40, 80, , , , 80, 40, 80, , , , 90, 56, 143, 122, 114, 60,
SPEED 10
'right center
MOVE24 100, 83, 156, 80, 100, 100, 100, 40, 80, , , , 90, 40, 80, , , , 100, 66, 141, 113, 100, 100,
MOVE24 90, 102, 136, 85, 114, 60, 100, 40, 80, , , , 100, 40, 80, , , , 113, 78, 142, 105, 90, 60,
RCX = RCIN(3)
RCY = RCIN(1)
IF RCX >= 75 AND RCX <= 125 THEN
IF RCY <= 75 THEN
GOTO fwd_walk_main
ENDIF
SPEED 5
MOVE24 85, 71, 152, 91, 112, 60, 100, 40, 80, , , , 100, 40, 80, , , , 112, 76, 145, 93, 92, 60,
RETURN
'================================================
'================================================
left_turn:
SPEED 6
MOVE G6D, 85, 71, 152, 91, 112, 60
MOVE G6A, 112, 76, 145, 93, 92, 60
MOVE G6C, 100, 40, 80, , , ,
MOVE G6B, 100, 40, 80, , , ,
WAIT
SPEED 9
MOVE G6A, 113, 75, 145, 97, 93, 60
MOVE G6D, 90, 50, 157, 115, 112, 60
MOVE G6B, 105, 40, 70, , , ,
MOVE G6C, 90, 40, 70, , , ,
WAIT
MOVE G6A, 108, 78, 145, 98, 93, 60
MOVE G6D, 95, 43, 169, 110, 110, 60
MOVE G6B, 105, 40, 70, , , ,
MOVE G6C, 80, 40, 70, , , ,
WAIT
RETURN
'================================================
'================================================
right_turn:
SPEED 6
MOVE G6A, 85, 71, 152, 91, 112, 60
MOVE G6D, 112, 76, 145, 93, 92, 60
MOVE G6B, 100, 40, 80, , , ,
MOVE G6C, 100, 40, 80, , , ,
WAIT
SPEED 9
MOVE G6D, 113, 75, 145, 97, 93, 60
MOVE G6A, 90, 50, 157, 115, 112, 60
MOVE G6C, 105, 40, 70, , , ,
MOVE G6B, 90, 40, 70, , , ,
WAIT
MOVE G6D, 108, 78, 145, 98, 93, 60
MOVE G6A, 95, 43, 169, 110, 110, 60
MOVE G6C, 105, 40, 70, , , ,
MOVE G6B, 80, 40, 70, , , ,
WAIT
RETURN
'================================================
'================================================
backward_walk:
SPEED 5
GOSUB backward_walk1
SPEED 13
GOSUB backward_walk2
SPEED 7
GOSUB backward_walk3
GOSUB backward_walk4
GOSUB backward_walk5
SPEED 13
GOSUB backward_walk6
SPEED 7
GOSUB backward_walk7
GOSUB backward_walk8
GOSUB backward_walk9
SPEED 13
GOSUB backward_walk2
SPEED 5
GOSUB backward_walk1
RETURN
'================================================
backward_walk1:
MOVE G6A, 85, 71, 152, 91, 112, 60
MOVE G6D,112, 76, 145, 93, 92, 60
MOVE G6B,100, 40, 80, , , ,
MOVE G6C,100, 40, 80, , , ,
WAIT
RETURN
backward_walk2:
MOVE G6A, 90, 107, 105, 105, 114, 60
MOVE G6D,113, 78, 145, 93, 90, 60
MOVE G6B, 90, 40, 80, , , ,
MOVE G6C,100, 40, 80, , , ,
WAIT
RETURN
backward_walk9:
MOVE G6A, 90, 56, 143, 122, 114, 60
MOVE G6D,113, 80, 145, 90, 90, 60
MOVE G6B, 80, 40, 80, , , ,
MOVE G6C,105, 40, 80, , , ,
WAIT
RETURN
backward_walk8:
MOVE G6A,100, 62, 146, 108, 100, 100
MOVE G6D,100, 88, 140, 86, 100, 100
MOVE G6B, 90, 40, 80, , , ,
MOVE G6C,100, 40, 80, , , ,
WAIT
RETURN
backward_walk7:
MOVE G6A,113, 76, 142, 105, 90, 60
MOVE G6D,90, 96, 136, 85, 114, 60
MOVE G6B,100, 40, 80, , , ,
MOVE G6C,100, 40, 80, , , ,
WAIT
RETURN
backward_walk6:
MOVE G6D,90, 107, 105, 105, 114, 60
MOVE G6A,113, 78, 145, 93, 90, 60
MOVE G6C,90, 40, 80, , , ,
MOVE G6B,100, 40, 80, , , ,
WAIT
RETURN
backward_walk5:
MOVE G6D,90, 56, 143, 122, 114, 60
MOVE G6A,113, 80, 145, 90, 90, 60
MOVE G6C,80, 40, 80, , , ,
MOVE G6B,105, 40, 80, , , ,
WAIT
RETURN
backward_walk4:
MOVE G6D,100, 62, 146, 108, 100, 100
MOVE G6A,100, 88, 140, 86, 100, 100
MOVE G6C,90, 40, 80, , ,,
MOVE G6B,100, 40, 80, , , ,
WAIT
RETURN
backward_walk3:
MOVE G6D,113, 76, 142, 105, 90, 60
MOVE G6A, 90, 96, 136, 85, 114, 60
MOVE G6C,100, 40, 80, , , ,
MOVE G6B,100, 40, 80, , , ,
WAIT
RETURN
'================================================
'================================================
standard_pose:
MOVE G6A,100, 76, 145, 93, 100, 100
MOVE G6D,100, 76, 145, 93, 100, 100
MOVE G6B,100, 30, 80, 100, 100, 100
MOVE G6C,100, 30, 80, 100, 100, 100
WAIT
RETURN
'================================================
Best,
Mo
Hi PEV, would you try this code and let me know if you experience any delay whenever you move the stick? To me the stick and the movement doesnt sync at all. I really need to wait for more than 10 sec just to get RN-1 CPU understand my TX command and get it up and running.
'== Robot walk ================================
GOTO AUTO
FILL 255,10000
DIM RCX AS BYTE
DIM RCY AS BYTE
CONST ID = 0 ' 1:0, 2:32, 3:64, 4:96,
PTP SETON
PTP ALLON
'== motor diretion setting ======================
DIR G6A,1,0,0,1,0,0
DIR G6B,1,1,1,1,1,1
DIR G6C,0,0,0,0,0,0
DIR G6D,0,1,1,0,1,0
'== motor start position read ===================
TEMPO 230
MUSIC "CDE"
GETMOTORSET G24,1,1,1,1,1,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,1,1,0
'== motor power on =============================
SPEED 5
MOTOR G24
GOSUB standard_pose
'================================================
'Gyro Setup
GYROSET G6A,0,1,1,0,0,0
GYROSET G6D,0,1,1,0,0,0
GYRODIR G6A,1,0,0,1,0,0
GYRODIR G6D,1,0,0,1,0,0
GYROSENSE G6A,0,200,200,0,0,0
GYROSENSE G6D,0,200,200,0,0,0
'================================================
MAIN:
RCX = RCIN(3)
RCY = RCIN(1)
'RC Walk
IF RCX >= 125 THEN ' RIGHT TURN
GOSUB right_turn
GOSUB standard_pose
ENDIF
IF RCX <= 75 AND RCX > 10 THEN 'LEFT TURN
GOSUB left_turn
GOSUB standard_pose
ENDIF
IF RCY > 125 THEN ' BACKWARD
GOSUB backward_walk
GOSUB standard_pose
ENDIF
IF RCY < 75 AND RCY > 40 THEN ' FORWARD
GOSUB forward_walk
GOSUB standard_pose
ENDIF
RETURN
'================================================
forward_walk:
SPEED 5
MOVE24 85, 71, 152, 91, 112, 60, 100, 40, 80, , , , 100, 40, 80, , , , 112, 76, 145, 93, 92, 60,
fwd_walk_main:
SPEED 14
'left up
MOVE24 90, 107, 105, 105, 114, 60, 90, 40, 80, , , , 100, 40, 80, , , , 114, 76, 145, 93, 90, 60,
'---------------------------------------
'left down
MOVE24 90, 56, 143, 122, 114, 60, 80, 40, 80, , , , 105, 40, 80, , , , 113, 80, 145, 90, 90, 60,
MOVE24 90, 46, 163, 112, 114, 60, 80, 40, 80, , , , 105, 40, 80, , , , 112, 80, 145, 90, 90, 60,
SPEED 10
'left center
MOVE24 100, 66, 141, 113, 100, 100, 90, 40, 80, , , , 100, 40, 80, , , , 100, 83, 156, 80, 100, 100,
MOVE24 113, 78, 142, 105, 90, 60, 100, 40, 80, , , , 100, 40, 80, , , , 90, 102, 136, 85, 114, 60,
SPEED 14
'right up
MOVE24 113, 76, 145, 93, 90, 60, 100, 40, 80, , , , 90, 40, 80, , , , 90, 107, 105, 105, 114, 60,
'right down
MOVE24 113, 80, 145, 90, 90, 60, 105, 40, 80, , , , 80, 40, 80, , , , 90, 56, 143, 122, 114, 60,
SPEED 10
'right center
MOVE24 100, 83, 156, 80, 100, 100, 100, 40, 80, , , , 90, 40, 80, , , , 100, 66, 141, 113, 100, 100,
MOVE24 90, 102, 136, 85, 114, 60, 100, 40, 80, , , , 100, 40, 80, , , , 113, 78, 142, 105, 90, 60,
RCX = RCIN(3)
RCY = RCIN(1)
IF RCX >= 75 AND RCX <= 125 THEN
IF RCY <= 75 THEN
GOTO fwd_walk_main
ENDIF
SPEED 5
MOVE24 85, 71, 152, 91, 112, 60, 100, 40, 80, , , , 100, 40, 80, , , , 112, 76, 145, 93, 92, 60,
RETURN
'================================================
'================================================
left_turn:
SPEED 6
MOVE G6D, 85, 71, 152, 91, 112, 60
MOVE G6A, 112, 76, 145, 93, 92, 60
MOVE G6C, 100, 40, 80, , , ,
MOVE G6B, 100, 40, 80, , , ,
WAIT
SPEED 9
MOVE G6A, 113, 75, 145, 97, 93, 60
MOVE G6D, 90, 50, 157, 115, 112, 60
MOVE G6B, 105, 40, 70, , , ,
MOVE G6C, 90, 40, 70, , , ,
WAIT
MOVE G6A, 108, 78, 145, 98, 93, 60
MOVE G6D, 95, 43, 169, 110, 110, 60
MOVE G6B, 105, 40, 70, , , ,
MOVE G6C, 80, 40, 70, , , ,
WAIT
RETURN
'================================================
'================================================
right_turn:
SPEED 6
MOVE G6A, 85, 71, 152, 91, 112, 60
MOVE G6D, 112, 76, 145, 93, 92, 60
MOVE G6B, 100, 40, 80, , , ,
MOVE G6C, 100, 40, 80, , , ,
WAIT
SPEED 9
MOVE G6D, 113, 75, 145, 97, 93, 60
MOVE G6A, 90, 50, 157, 115, 112, 60
MOVE G6C, 105, 40, 70, , , ,
MOVE G6B, 90, 40, 70, , , ,
WAIT
MOVE G6D, 108, 78, 145, 98, 93, 60
MOVE G6A, 95, 43, 169, 110, 110, 60
MOVE G6C, 105, 40, 70, , , ,
MOVE G6B, 80, 40, 70, , , ,
WAIT
RETURN
'================================================
'================================================
backward_walk:
SPEED 5
GOSUB backward_walk1
SPEED 13
GOSUB backward_walk2
SPEED 7
GOSUB backward_walk3
GOSUB backward_walk4
GOSUB backward_walk5
SPEED 13
GOSUB backward_walk6
SPEED 7
GOSUB backward_walk7
GOSUB backward_walk8
GOSUB backward_walk9
SPEED 13
GOSUB backward_walk2
SPEED 5
GOSUB backward_walk1
RETURN
'================================================
backward_walk1:
MOVE G6A, 85, 71, 152, 91, 112, 60
MOVE G6D,112, 76, 145, 93, 92, 60
MOVE G6B,100, 40, 80, , , ,
MOVE G6C,100, 40, 80, , , ,
WAIT
RETURN
backward_walk2:
MOVE G6A, 90, 107, 105, 105, 114, 60
MOVE G6D,113, 78, 145, 93, 90, 60
MOVE G6B, 90, 40, 80, , , ,
MOVE G6C,100, 40, 80, , , ,
WAIT
RETURN
backward_walk9:
MOVE G6A, 90, 56, 143, 122, 114, 60
MOVE G6D,113, 80, 145, 90, 90, 60
MOVE G6B, 80, 40, 80, , , ,
MOVE G6C,105, 40, 80, , , ,
WAIT
RETURN
backward_walk8:
MOVE G6A,100, 62, 146, 108, 100, 100
MOVE G6D,100, 88, 140, 86, 100, 100
MOVE G6B, 90, 40, 80, , , ,
MOVE G6C,100, 40, 80, , , ,
WAIT
RETURN
backward_walk7:
MOVE G6A,113, 76, 142, 105, 90, 60
MOVE G6D,90, 96, 136, 85, 114, 60
MOVE G6B,100, 40, 80, , , ,
MOVE G6C,100, 40, 80, , , ,
WAIT
RETURN
backward_walk6:
MOVE G6D,90, 107, 105, 105, 114, 60
MOVE G6A,113, 78, 145, 93, 90, 60
MOVE G6C,90, 40, 80, , , ,
MOVE G6B,100, 40, 80, , , ,
WAIT
RETURN
backward_walk5:
MOVE G6D,90, 56, 143, 122, 114, 60
MOVE G6A,113, 80, 145, 90, 90, 60
MOVE G6C,80, 40, 80, , , ,
MOVE G6B,105, 40, 80, , , ,
WAIT
RETURN
backward_walk4:
MOVE G6D,100, 62, 146, 108, 100, 100
MOVE G6A,100, 88, 140, 86, 100, 100
MOVE G6C,90, 40, 80, , ,,
MOVE G6B,100, 40, 80, , , ,
WAIT
RETURN
backward_walk3:
MOVE G6D,113, 76, 142, 105, 90, 60
MOVE G6A, 90, 96, 136, 85, 114, 60
MOVE G6C,100, 40, 80, , , ,
MOVE G6B,100, 40, 80, , , ,
WAIT
RETURN
'================================================
'================================================
standard_pose:
MOVE G6A,100, 76, 145, 93, 100, 100
MOVE G6D,100, 76, 145, 93, 100, 100
MOVE G6B,100, 30, 80, 100, 100, 100
MOVE G6C,100, 30, 80, 100, 100, 100
WAIT
RETURN
'================================================
Best,
Mo