(normally only three are used). The remainder of
the routine initializes the arm itself.
Most commands for controlling the
servomotors require an index value to specify which
joint parameter is being addressed. Once set, the
index automatically increments each time a
command is issued, making it very efficient to
control an arm with multiple motors.
Since this arm has only one joint motor, the
index is constantly set back to zero in the routines.
Using an index of one allows control of the
gripper’s servomotor.
The RROS arm controller allows you to set a
minimum and maximum point for each servomotor.
Once set, the motor position (0-255) specifies a
position between these limits. This means you have
excellent resolution even if a particular servo only
moves a small fraction of its typical 180º range.
This method also helps prevent a faulty
program from moving a joint out of its preset
range.
The demo program in Figure 7 allows the
robot to find an object that will fit into the hand
and move it to a beacon as depicted by Figure 8.
The variable HandPosition is set in the HandClose
routine. Its value represents how far the fingers
were closed before the finger-mounted switch
indicated pressure from the object.
You can use this value to help identify the size
of the object. If desired, the object could then be
moved to various places by using different beacons
to identify the possible destinations.
The RROS manual explains how RobotBASIC
can identify 15 different beacons.
Conclusion
This article and the one from last month have
shown how sensors can be used to locate and
identify objects, so they can be manipulated by a
mobile robot using a simple trap or arm to acquire
the object and move it to a desired destination.
After experimenting with the principles
demonstrated here, we suggest adding additional
sensors (such as a color sensor) to allow your robot
to identify and distinguish even more objects within
its environment.
Since the arm can be raised to allow full use of
the robot’s perimeter sensors, this month’s robot is
ready for more complex experimentation. You could,
for example, have the robot avoid objects in its path
as it makes its way to the beacon. SV
#include "RROScommands.bas"
#Include "InitializationRoutines.bas"
gosub InitRROScommands
gosub InitRB9Chassis
main:
gosub ArmInit
gosub GetObject // find something to pickup
gosub HandClose
gosub ArmUp
gosub MoveToBeacon
gosub ArmDown
gosub HandOpen
gosub ArmUp
end
FIGURE 7.
ArmInit:
rCommand(ExpansionSetup,ARM)
rCommand(SetSenseInvMask,15)
rSenseType 5 // allows more sensors
rCommand(SetServoIndex,0) // index auto-incr.
rCommand(SetServoSpeed,3) //arm
rCommand(SetServoSpeed,3) //gripper
// set minimums
rCommand(SetServoIndex,0)
rCommand(SetServoMin,150)
rCommand(SetServoMin,110)
// set maximums
rCommand(SetServoIndex,0)
rCommand(SetServoMax,45)
rCommand(SetServoMax,35)
gosub ArmHome //set home position & enable
return
ArmHome:
rCommand(SetServoIndex,0)
rCommand(SetServoPosition,0) // arm
rCommand(SetServoPosition,0) // gripper
rCommand(EnableServos,1)
delay 2000 // allow time for movement
// remove strain on the hand by
// moving the fingers slightly
rCommand(SetServoIndex,1)
rCommand(SetServoPosition,20)
return
ArmDown:
rCommand(SetServoIndex,0)
rCommand(SetServoPosition,250)
delay 2000
return
ArmUp:
rCommand(SetServoIndex,0)
rCommand(SetServoPosition,0)
delay 2000
return
HandOpen:
rCommand(SetServoIndex,1) // index for the hand
rCommand(SetServoPosition,0)
delay 2000
rCommand(SetServoPosition,20)
return
HandClose:
for HandPosition=0 to 250 step 3
rCommand(SetServoIndex,1)
rCommand(SetServoPosition,HandPosition)
rforward 0
if rSense()&8 then break // check for switch
next
//HandPosition now indicates size of object
return
SERVO 04.2013 51