de.jaetzold.art
Class Servo
java.lang.Object
|
+--de.jaetzold.art.RawSensor
|
+--de.jaetzold.art.RawActuator
|
+--de.jaetzold.art.Motor
|
+--de.jaetzold.art.StepperMotor
|
+--de.jaetzold.art.Servo
- All Implemented Interfaces:
- Actuator, EventListener, PropertyChangeListener, Sensor, SensorPeer
- public class Servo
- extends StepperMotor
A Servo gives control over the absolute position of an axle. It is calibrated so that positions are the same even when initializing in different starting-positions. A Servo has a moving range in which it should stay. That means the AngleSensor representing the position of the Servo won't have values out of this range.
When simulating a Servo without a special ServoPeer this class needs an AngleSensor and a BooleanSensor.
The BooleanSensor is associated with a specific position which the Servo is at, wehn the BooleanSensor is true. Together with a direction where the BooleanSensor can be "found" the calibration to an absolute position is done by just moving into that direction until the BooleanSensor becomes true. Usually this is achieved by placing the BooleanSensor on one end of the moving range.
The AngleSensor is pretty much used in the same way as the CountSensor in the superclass StepperMotor. In fact it just scales the CountSensors value so that it represents the correct angle.
- See Also:
ServoPeer
,
AngleSensor
,
BooleanSensor
Constructor Summary |
Servo()
Constructs a new Servo. |
Servo(AngleSensor angleSensor,
BooleanSensor positionSwitch,
double positionSwitchAngle,
double positiveBorderAngle,
double negativeBorderAngle,
int searchDirection)
Constructs a new Servo. |
Method Summary |
void |
calibrate()
This method is called when (re)calibration is required. |
void |
connectWith(ActuatorPort port)
Connects this Object with the given Port. |
void |
disconnect()
Disconnects this Sensor from it's Peer and it's Port. |
AngleSensor |
getAngleSensor()
Returns the AngleSensor representing the position of this Servo. |
void |
setAngleSensor(AngleSensor sensor)
Sets the AngleSensor for representing the position of this Servo. |
void |
setCountSensor(CountSensor sensor)
Sets the CountSensor for representing the position of this StepperMotor. |
void |
setPositionSwitch(BooleanSensor positionSwitch,
double positionSwitchAngle,
double positiveBorderAngle,
double negativeBorderAngle,
int searchDirection)
Sets the the BooleanSensor an other required parameters for calibrating this Servo to an absolute position. |
void |
setValue(double value)
Sets the position the StepperMotor currently wants to be at. |
Methods inherited from class de.jaetzold.art.StepperMotor |
getCountSensor, getPositionReachedSensor, getPrecision, getSpeed, isPositionedAt, keepCurrentPosition, setBackward, setOn, setPrecision, setSpeed, step |
Methods inherited from class de.jaetzold.art.RawActuator |
addVetoableChangeListener, connectWith, convertToActuatorIncoming, convertToActuatorOutgoing, getActuatorIncomingConversionDelegate, getActuatorOutgoingConversionDelegate, getLocalReturn, getValue, getWaitForCompletion, removeVetoableChangeListener, setActuatorIncomingConversionDelegate, setActuatorOutgoingConversionDelegate, setLocalReturn, setReversed, setValue, setWaitForCompletion |
Methods inherited from class de.jaetzold.art.RawSensor |
addPropertyChangeListener, addSensorListener, addSensorListener, connectWith, convertToIncoming, convertToOutgoing, disableEvent, enableEvent, getChangeEventsEnabled, getDeliversFloatingPoint, getIncomingConversionDelegate, getIntValue, getOutgoingConversionDelegate, getPeer, getPeerCacheEnabled, getPort, getSensorPort, isConnected, isIncomingConversionCacheable, isOutgoingConversionCacheable, isReversed, processEvent, propertyChange, removePropertyChangeListener, removeSensorListener, removeSensorListener, setChangeEventsEnabled, setIncomingConversionDelegate, setOutgoingConversionDelegate, setPeerCacheEnabled, update |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface de.jaetzold.art.Sensor |
addPropertyChangeListener, addSensorListener, connectWith, getIntValue, getPort, getSensorPort, isConnected, processEvent, propertyChange, removePropertyChangeListener, removeSensorListener, update |
Servo
public Servo()
- Constructs a new Servo.
It is not specified whether it will have a ServoPeer or will be used as a simulating servo.
Servo
public Servo(AngleSensor angleSensor,
BooleanSensor positionSwitch,
double positionSwitchAngle,
double positiveBorderAngle,
double negativeBorderAngle,
int searchDirection)
- Constructs a new Servo.
It uses the given parameters for simulating the usual Servo-behavior without having a ServoPeer.
- Parameters:
angleSensor
- the AngleSensor for measuring the relative position of the ServopositionSwitch
- the BooleanSensor for noticing the absolute position given by positionSwitchAnglepositionSwitchAngle
- the absolute angle the positionSwitch is atpositiveBorderAngle
- the positive border of the moving rangenegativeBorderAngle
- the negative border of the moving rangesearchDirection
- the direction in which to move for always reaching positionSwitchAngle. Positive values mean "forward".
setPositionSwitch
public void setPositionSwitch(BooleanSensor positionSwitch,
double positionSwitchAngle,
double positiveBorderAngle,
double negativeBorderAngle,
int searchDirection)
- Sets the the BooleanSensor an other required parameters for calibrating this Servo to an absolute position. This is not required if the Servo is used in conjunction with a ServoPeer.
- Parameters:
positionSwitch
- the BooleanSensor for noticing the absolute position given by positionSwitchAnglepositionSwitchAngle
- the absolute angle the positionSwitch is atpositiveBorderAngle
- the positive border of the moving rangenegativeBorderAngle
- the negative border of the moving rangesearchDirection
- the direction in which to move for always reaching positionSwitchAngle. Positive values mean "forward".
calibrate
public void calibrate()
- Description copied from class:
StepperMotor
- This method is called when (re)calibration is required. This may take a while. It is called implicitly when initializing with a new Peer.
- Overrides:
calibrate
in class StepperMotor
setValue
public void setValue(double value)
- Description copied from class:
StepperMotor
- Sets the position the StepperMotor currently wants to be at. That means it repositions itself as long as the value of it's CountSensor does not match value in terms of precision. A call to Motor-specific methods like
forward()
stops the positioning until the next call to setValue(double)
, step(double)
or calibrate()
.
- Overrides:
setValue
in class StepperMotor
- Following copied from class:
de.jaetzold.art.StepperMotor
- See Also:
StepperMotor.step(double)
,
StepperMotor.desiredCount
getAngleSensor
public AngleSensor getAngleSensor()
- Returns the AngleSensor representing the position of this Servo. It may be the one used for simulating the servo-behavior or the one directly from the ServoPeer.
Keep in mind that it is possible that this Servo gets a new Peer in which case the AngleSensor returned by this method may not be valid anymore for this Servo. It is possible that future versions don't have this limitation.
- See Also:
setAngleSensor(AngleSensor)
setAngleSensor
public void setAngleSensor(AngleSensor sensor)
- Sets the AngleSensor for representing the position of this Servo.
It is not required to set the AngleSensor when using a Servo as long as it has a ServoPeer. Otherwise the given AngleSensor is used in conjunction with a BooleanSensor to simulate the servo-behavior.
- See Also:
setPositionSwitch(BooleanSensor,double,double,double,int)
,
ServoPeer.getAngleSensor()
setCountSensor
public void setCountSensor(CountSensor sensor)
- Description copied from class:
StepperMotor
- Sets the CountSensor for representing the position of this StepperMotor.
It is not required to set the CountSensor when using a StepperMotor as long as it has a StepperMotorPeer. Otherwise the given CountSensor is used to simulate the step-behavior.
- Overrides:
setCountSensor
in class StepperMotor
- Following copied from class:
de.jaetzold.art.StepperMotor
- See Also:
StepperMotorPeer.getCountSensor()
connectWith
public void connectWith(ActuatorPort port)
- Description copied from class:
Motor
- Connects this Object with the given Port.
This sets the peer for this Object and is therefore required before
it can be properly used.
- Overrides:
connectWith
in class StepperMotor
disconnect
public void disconnect()
- Description copied from interface:
Sensor
- Disconnects this Sensor from it's Peer and it's Port.
This is implicitly called when the Sensor is already connected and asked to connect with another Port.
- Overrides:
disconnect
in class StepperMotor
- Following copied from interface:
de.jaetzold.art.Sensor
- See Also:
Sensor.connectWith(Port)