|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ridgesoft.robotics.ContinuousRotationServo
public class ContinuousRotationServo
This class implements the Motor interface to a servo that has been manufactured or modified to support continuous rotation.
Servos that have been manufactured or modified to support continuous rotation function similar to conventional motors. However, they are still controlled using the servo control signal and built-in electronics. This class creates a facade around a Servo object so the servo can be controlled in the same manner as a conventional DC motor.
Inorder to work properly with this class, the continuous rotation servo must be calibrated such that when its position is set to the midpoint, 50, its output shaft does not move. Calibration can be accomplished using a simple program to set the position of the servo to 50 and then using a screwdriver to adjust the position potentiometer such that the shaft does not rotate.
Once modified and calibrated, the power of the servo can be controlled based on how far from the midpoint the position signal is set. For example, setting the position to the maximum value, 100, will cause the servo to rotate forward at maximum power. Setting the position to the minimum value, 0, will cause the servo to rotate backward at maximum power. Unfortunately, the power ramp up or down does not typically extend over the entire range of the position signal and is dependant on the particular model of servo. Therefore, the motor power settings have to be scaled to match the behavior of the particular model of servo. For example, for Parallax continuous rotation servos, the power ramps to its maximum or minimum value over a range of +/-14 around the midpoint. Therefore, this class must scale motor power settings over the range 36 to 64 when used with Parallax continuous rotation servos.
Servo
Field Summary |
---|
Fields inherited from interface com.ridgesoft.robotics.Motor |
---|
MAX_FORWARD, MAX_REVERSE, STOP |
Constructor Summary | |
---|---|
ContinuousRotationServo(Servo servo,
boolean reverse)
Constructs a ContinuousRotationServo object. |
|
ContinuousRotationServo(Servo servo,
boolean reverse,
int range)
Constructs a ContinuousRotationServo object. |
|
ContinuousRotationServo(Servo servo,
boolean reverse,
int range,
DirectionListener directionListener)
Constructs a ContinuousRotationServo object. |
Method Summary | |
---|---|
void |
brake()
Active braking is not supported. |
void |
setDirectionListener(DirectionListener directionListener)
Sets a DirectionListener. |
void |
setPower(int power)
Sets the power. |
void |
stop()
Turns the servo off. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait |
Constructor Detail |
---|
public ContinuousRotationServo(Servo servo, boolean reverse)
This constructor sets the range scaling to 50, which will scale the power over the full range of the servo control signal.
servo
- reference to the Servo to controlreverse
- true if the drive direction of the servo is reversedpublic ContinuousRotationServo(Servo servo, boolean reverse, int range)
Note: 14 is normally a good range value for Parallax continuous rotation servos
servo
- reference to the Servo to controlreverse
- true if the drive direction of the servo is reversedrange
- the range to scale motor power values overpublic ContinuousRotationServo(Servo servo, boolean reverse, int range, DirectionListener directionListener)
Note: 14 is normally a good range value for Parallax continuous rotation servos
servo
- reference to the Servo to controlreverse
- true if the drive direction of the servo is reversedrange
- the range to scale motor power values overdirectionListener
- direction listener to notify when the direction changes -
initial direction defaults to forwardMethod Detail |
---|
public void brake()
This method has the same effect as the stop method.
brake
in interface Motor
public void setDirectionListener(DirectionListener directionListener)
This listener is notified each time the servo direction changes.
directionListener
- direction listener to notify when the direction changes -
initial direction defaults to forwardpublic void setPower(int power)
setPower
in interface Motor
power
- The power level to set.
public void stop()
This method has the same effect as setPower(Motor.STOP) or setPower(0).
stop
in interface Motor
|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |