by zapod » Thu May 17, 2007 8:13 pm
by zapod
Thu May 17, 2007 8:13 pm
Here is the code I promised earlier. It's very simple. I cut down the supplied template code, removed the voltage check loop (because I don't have that circuit installed in the RN), then added a simple arm wave motion with captured moves.
I kept the standard_pose code because it's useful to have RN stand upright again after a move goes horribly wrong, without switching him off and on.
So, the program basically loops around Main and Main1, checking for a keypress on the remote. Variables A and RR carry the remote code. A value of zero means no key pressed - so repeat the loop.
Press 1 on the remote, the program jumps to K1, which plays a note then jumps again to the wave routine. After the wave routine, the program returns to the next instruction in K1, GOTO main_exit, which (after resetting the RR variable to 0) returns the program to looping round checking the input from the remote.
To do your own move, remove the code between wave_right_arm and RETURN, go into capture mode in Robobasic, move a limb or two, then click 'insert move'.
Compile and send your move to the RN, press 1 on the remote and see RN do what he's told!
From here you can build ever more complex routines.
Have fun!
Example code:
GOTO AUTO
FILL 255,10000
DIM RR AS BYTE
DIM A AS BYTE
DIM A16 AS BYTE
DIM A26 AS BYTE
DIM n AS INTEGER
CONST ID = 0 ' 1:0, 2:32, 3:64, 4:96,
'== Action command check (50 - 82)
'IF RR > 50 AND RR < 83 THEN GOTO action_proc
RR = 0
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
'================================================
MAIN:
'-----------------------------
IF RR = 0 THEN GOTO MAIN1
ON RR GOTO MAIN,K1,K2
GOTO main_exit
'-----------------------------
MAIN1:
A = REMOCON(1)
A = A - ID
ON A GOTO MAIN,K1,K2
GOTO MAIN
main_exit:
RR = 0
GOTO MAIN
standard_pose:
SPEED 5
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
'================================================
k1:
TEMPO 230
MUSIC "D"
GOSUB wave_right_arm
GOTO main_exit
k2:
TEMPO 230
MUSIC "D"
GOSUB standard_pose
GOTO main_exit
wave_right_arm:
SPEED 5
MOVE G6C,102, 125, 130, 100, 100, 100
SPEED 7
FOR n = 1 TO 5
MOVE G6C,103, 126, 169, 100, 100, 100
MOVE G6C,103, 126, 130, 100, 100, 100
NEXT n
RETURN
Here is the code I promised earlier. It's very simple. I cut down the supplied template code, removed the voltage check loop (because I don't have that circuit installed in the RN), then added a simple arm wave motion with captured moves.
I kept the standard_pose code because it's useful to have RN stand upright again after a move goes horribly wrong, without switching him off and on.
So, the program basically loops around Main and Main1, checking for a keypress on the remote. Variables A and RR carry the remote code. A value of zero means no key pressed - so repeat the loop.
Press 1 on the remote, the program jumps to K1, which plays a note then jumps again to the wave routine. After the wave routine, the program returns to the next instruction in K1, GOTO main_exit, which (after resetting the RR variable to 0) returns the program to looping round checking the input from the remote.
To do your own move, remove the code between wave_right_arm and RETURN, go into capture mode in Robobasic, move a limb or two, then click 'insert move'.
Compile and send your move to the RN, press 1 on the remote and see RN do what he's told!
From here you can build ever more complex routines.
Have fun!
Example code:
GOTO AUTO
FILL 255,10000
DIM RR AS BYTE
DIM A AS BYTE
DIM A16 AS BYTE
DIM A26 AS BYTE
DIM n AS INTEGER
CONST ID = 0 ' 1:0, 2:32, 3:64, 4:96,
'== Action command check (50 - 82)
'IF RR > 50 AND RR < 83 THEN GOTO action_proc
RR = 0
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
'================================================
MAIN:
'-----------------------------
IF RR = 0 THEN GOTO MAIN1
ON RR GOTO MAIN,K1,K2
GOTO main_exit
'-----------------------------
MAIN1:
A = REMOCON(1)
A = A - ID
ON A GOTO MAIN,K1,K2
GOTO MAIN
main_exit:
RR = 0
GOTO MAIN
standard_pose:
SPEED 5
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
'================================================
k1:
TEMPO 230
MUSIC "D"
GOSUB wave_right_arm
GOTO main_exit
k2:
TEMPO 230
MUSIC "D"
GOSUB standard_pose
GOTO main_exit
wave_right_arm:
SPEED 5
MOVE G6C,102, 125, 130, 100, 100, 100
SPEED 7
FOR n = 1 TO 5
MOVE G6C,103, 126, 169, 100, 100, 100
MOVE G6C,103, 126, 130, 100, 100, 100
NEXT n
RETURN