Start of Tutorial > Start of Trail |
josx.platform.rcx.Servo
class is a utility to encapsulate a common task of
navigation: to rotate your robot to a given position.
The class uses a rotation sensor in connection with a motor, so an instance is constructed by
public Servo(Sensor aSensor,Motor aMotor,int aSlack)
where aSlack
is the amount of deviation accepted when rotating.
To rotate,
public boolean rotateTo(int aPosition)
is used: the robot will rotate to the given position (+/- the slack).
The value depends on the gearing between the motor and the sensor
as well as between the motor and the wheels.
Note that rotateTo
returns immediately: it doesn't block until the
robot has in fact rotated to the desired position.
Start of Tutorial > Start of Trail |