Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

Handshake code

Hitec robotics including ROBONOVA humanoid, HSR-8498HB servos, MR C-3024 Controllers and RoboBasic
7 postsPage 1 of 1
7 postsPage 1 of 1

Handshake code

Post by DirtyRoboto » Tue Nov 07, 2006 6:18 pm

Post by DirtyRoboto
Tue Nov 07, 2006 6:18 pm

Here is my code for the handshake. when RN1 presents his hand you shake it to make RN1 shake.

Enjoy.

Marcus.

'=====================================================
'hand shake routine. DirtyRobo (Marcus) 2006.
hand_shake:
SPEED 6
DIM s0 AS BYTE
DIM cr AS BYTE
DIM p0 AS BYTE
DIM x0 AS BYTE
cr = 1
rs:
p0 = 1
cr = cr + 1
MUSIC "7cfcfcf"
MOVE G6C,173, , , , ,
DELAY 200
MOTOROFF G6C
fb:
p0 = p0 + 1
s0 = MOTORIN (12)
DELAY 500
x0 = MOTORIN (12)
IF p0 = 20 THEN GOTO rs
IF cr = 7 THEN GOTO out_shake
IF s0 = x0 THEN GOTO fb

MOTOR 12
SPEED 4
MOVE G6C,188, 30, , , ,
MOVE G6C,165, 30, , , ,
MOVE G6C,188, 30, , , ,
MOVE G6C,165, 30, , , ,
MOVE G6C,188, 30, , , ,
MOVE G6C,165, 30, , , ,
MOVE G6C,188, 30, , , ,
MOVE G6C,165, 30, , , ,
MOVE G6C,188, 30, , , ,
MOVE G6C,165, 30, , , ,
MOVE G6C,188, 30, , , ,
MOVE G6C,165, 30, , , ,
DELAY 2000
MOVE G6C,101, 30, , , ,
WAIT
out_shake:
MOTOR 12
MOVE G6C,101, 30, , , ,
cr = 1
GOSUB standard_pose

RETURN
'=============================================
Here is my code for the handshake. when RN1 presents his hand you shake it to make RN1 shake.

Enjoy.

Marcus.

'=====================================================
'hand shake routine. DirtyRobo (Marcus) 2006.
hand_shake:
SPEED 6
DIM s0 AS BYTE
DIM cr AS BYTE
DIM p0 AS BYTE
DIM x0 AS BYTE
cr = 1
rs:
p0 = 1
cr = cr + 1
MUSIC "7cfcfcf"
MOVE G6C,173, , , , ,
DELAY 200
MOTOROFF G6C
fb:
p0 = p0 + 1
s0 = MOTORIN (12)
DELAY 500
x0 = MOTORIN (12)
IF p0 = 20 THEN GOTO rs
IF cr = 7 THEN GOTO out_shake
IF s0 = x0 THEN GOTO fb

MOTOR 12
SPEED 4
MOVE G6C,188, 30, , , ,
MOVE G6C,165, 30, , , ,
MOVE G6C,188, 30, , , ,
MOVE G6C,165, 30, , , ,
MOVE G6C,188, 30, , , ,
MOVE G6C,165, 30, , , ,
MOVE G6C,188, 30, , , ,
MOVE G6C,165, 30, , , ,
MOVE G6C,188, 30, , , ,
MOVE G6C,165, 30, , , ,
MOVE G6C,188, 30, , , ,
MOVE G6C,165, 30, , , ,
DELAY 2000
MOVE G6C,101, 30, , , ,
WAIT
out_shake:
MOTOR 12
MOVE G6C,101, 30, , , ,
cr = 1
GOSUB standard_pose

RETURN
'=============================================
DirtyRoboto
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 412
Joined: Tue Sep 19, 2006 1:00 am
Location: London

Post by DirtyRoboto » Tue Nov 07, 2006 9:16 pm

Post by DirtyRoboto
Tue Nov 07, 2006 9:16 pm

Some feedback please!!!
Some feedback please!!!
DirtyRoboto
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 412
Joined: Tue Sep 19, 2006 1:00 am
Location: London

Post by hivemind » Wed Nov 08, 2006 12:44 am

Post by hivemind
Wed Nov 08, 2006 12:44 am

Well I dont have my RN-1 in default form, so i wont be using your exact code, but just reading it I find what seem to be a few issues.

First off, why do you have the MOTOROFF? and then, why do you have the DELAY ? With a hand straight out, turning the motor off would just make it sag down. Furthermore, you could use a FOR loop for the handshake itself (but i suppose that is just preference).

Is this the same code you used in your video? If so, it seems that your right arm servo is pretty stiff, maybe it just isnt as broken in?

That's a pretty cool concept. Might not be the feedback you are looking for, but perhaps it will help one (or both) of us anyway.

Keep up the hard work.
Well I dont have my RN-1 in default form, so i wont be using your exact code, but just reading it I find what seem to be a few issues.

First off, why do you have the MOTOROFF? and then, why do you have the DELAY ? With a hand straight out, turning the motor off would just make it sag down. Furthermore, you could use a FOR loop for the handshake itself (but i suppose that is just preference).

Is this the same code you used in your video? If so, it seems that your right arm servo is pretty stiff, maybe it just isnt as broken in?

That's a pretty cool concept. Might not be the feedback you are looking for, but perhaps it will help one (or both) of us anyway.

Keep up the hard work.
hivemind
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 211
Joined: Sat Jul 01, 2006 1:00 am
Location: between my computer and robot.

Post by DirtyRoboto » Wed Nov 08, 2006 10:31 am

Post by DirtyRoboto
Wed Nov 08, 2006 10:31 am

The right arm is stiff as the number 4 servo was broken (out of the box) so I am limited in the moves I can try.

The motoroff allows the arm to moved by the spectator doing the shaking. The delay allows the motor to be read at two different points in time and then compared. The servos are stiff enough to keep the arm in place thus making s0 = x0. as soon as you move the arm s0 will not be equal to x0 so the routine goes into the handshake move.

Could have used a loop but the original code has a more varied shake that is not repetative.

Marcus.
The right arm is stiff as the number 4 servo was broken (out of the box) so I am limited in the moves I can try.

The motoroff allows the arm to moved by the spectator doing the shaking. The delay allows the motor to be read at two different points in time and then compared. The servos are stiff enough to keep the arm in place thus making s0 = x0. as soon as you move the arm s0 will not be equal to x0 so the routine goes into the handshake move.

Could have used a loop but the original code has a more varied shake that is not repetative.

Marcus.
DirtyRoboto
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 412
Joined: Tue Sep 19, 2006 1:00 am
Location: London

Post by i-Bot » Thu Nov 09, 2006 1:00 pm

Post by i-Bot
Thu Nov 09, 2006 1:00 pm

I think you will find it is the motorin which allows the arm to move, the motoroff will only stop the motor updates, but will remain in place. Motorin actually turns of the servo h bridge using the hitec protocol

A mix of motorin and motor/motoroff, may allow you to adjust the stiffness
I think you will find it is the motorin which allows the arm to move, the motoroff will only stop the motor updates, but will remain in place. Motorin actually turns of the servo h bridge using the hitec protocol

A mix of motorin and motor/motoroff, may allow you to adjust the stiffness
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by DirtyRoboto » Thu Nov 09, 2006 7:48 pm

Post by DirtyRoboto
Thu Nov 09, 2006 7:48 pm

Your Robot may well be different too mine.

If I remark the hi-lighted sections in the following code then you will see thar the MOTOROFF G6B command stops power to the servos, they now act as input devices that can feed back their position. You can then set conditions based on input positions from the servos and gererate any amount of triggers.

Note this.
Use the MOTORIN command without the MOTOROFF command to trigger weight and stress based decision trees.
Use the MOTORIN command with the MOTOROFF to use triggers by physical input to the servos.

'========================================
Motoff_test:
DIM s0 AS BYTE
DIM x0 AS BYTE
'pose
MOVE G6B,170, 30, 84, 100, 100, 100
MOVE G6C,170, 30, 89, 100, 100, 100
MOVE G6A,100, 76, 145, 89, 100, 100
MOVE G6D,100, 76, 145, 89, 100, 100
WAIT
'motor test
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
'Remark the two motoroff commands and see the difference.
'the MOTORIN command deos not turn the motor off.
MOTOROFF G6B
MOTOROFF G6C
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
loop1:
s0 = MOTORIN (6)
x0 = MOTORIN (12)
IF x0 > 187 THEN GOTO rest
IF s0 > 187 THEN GOTO rest
GOTO loop1



rest:
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
'same here! Remark these two lines.
MOTOR G6C
MOTOR G6B
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
MOVE G6B, 99, 26, 86, 100, 100, 100
MOVE G6C, 95, 30, 91, 100, 100, 100
MOVE G6D,103, 82, 99, 135, 97, 100
MOVE G6A,102, 88, 99, 132, 99, 100
WAIT
GOSUB standard_pose
RETURN
'===========================================

Marcus.
Your Robot may well be different too mine.

If I remark the hi-lighted sections in the following code then you will see thar the MOTOROFF G6B command stops power to the servos, they now act as input devices that can feed back their position. You can then set conditions based on input positions from the servos and gererate any amount of triggers.

Note this.
Use the MOTORIN command without the MOTOROFF command to trigger weight and stress based decision trees.
Use the MOTORIN command with the MOTOROFF to use triggers by physical input to the servos.

'========================================
Motoff_test:
DIM s0 AS BYTE
DIM x0 AS BYTE
'pose
MOVE G6B,170, 30, 84, 100, 100, 100
MOVE G6C,170, 30, 89, 100, 100, 100
MOVE G6A,100, 76, 145, 89, 100, 100
MOVE G6D,100, 76, 145, 89, 100, 100
WAIT
'motor test
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
'Remark the two motoroff commands and see the difference.
'the MOTORIN command deos not turn the motor off.
MOTOROFF G6B
MOTOROFF G6C
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
loop1:
s0 = MOTORIN (6)
x0 = MOTORIN (12)
IF x0 > 187 THEN GOTO rest
IF s0 > 187 THEN GOTO rest
GOTO loop1



rest:
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
'same here! Remark these two lines.
MOTOR G6C
MOTOR G6B
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
MOVE G6B, 99, 26, 86, 100, 100, 100
MOVE G6C, 95, 30, 91, 100, 100, 100
MOVE G6D,103, 82, 99, 135, 97, 100
MOVE G6A,102, 88, 99, 132, 99, 100
WAIT
GOSUB standard_pose
RETURN
'===========================================

Marcus.
DirtyRoboto
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 412
Joined: Tue Sep 19, 2006 1:00 am
Location: London

Post by i-Bot » Thu Nov 09, 2006 8:58 pm

Post by i-Bot
Thu Nov 09, 2006 8:58 pm

I don't think we have any difference.

The Hitec HMI protocol to the servo has two useful interactions, the command instruction, where the position is set, and the input instruction where a position is read. The input instruction also disables the drive to the motor. This will continue until another command instruction which enables the drive to the motor.

The motorin statement makes an input instruction for a servo.

The motor and motor off enable and disable the motion engine which continually send the command phases at 16ms intervals.

Therefore to disable a motor you must stop the commands (motoroff), but it is the motorin wich actually reads and make the servo go off.
I don't think we have any difference.

The Hitec HMI protocol to the servo has two useful interactions, the command instruction, where the position is set, and the input instruction where a position is read. The input instruction also disables the drive to the motor. This will continue until another command instruction which enables the drive to the motor.

The motorin statement makes an input instruction for a servo.

The motor and motor off enable and disable the motion engine which continually send the command phases at 16ms intervals.

Therefore to disable a motor you must stop the commands (motoroff), but it is the motorin wich actually reads and make the servo go off.
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am


7 postsPage 1 of 1
7 postsPage 1 of 1