public class MirrorMotor extends java.lang.Object implements RegulatedMotor, RegulatedMotorListener
This class returns a motor that rotates in the reverse direction of a regular motor. All tachometer readings are also reversed.
Use the factory method MirrorMotor.invertMotor(RegulatedMotor) to retrieve an inverted motor.
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(RegulatedMotorListener listener)
Adds a listener object that will be notified when rotation has started or stopped
|
void |
backward()
Causes motor to rotate backwards until
stop() or flt() is called. |
void |
close()
Close the port, the port can not be used after this call.
|
void |
endSynchronization()
Complete a set of synchronized motor operations.
|
void |
flt()
Motor loses all power, causing the rotor to float freely to a stop.
|
void |
flt(boolean immediateReturn)
Set the motor into float mode.
|
void |
forward()
Causes motor to rotate forward until
stop() or flt() is called. |
int |
getLimitAngle()
Return the limit angle (if any)
|
float |
getMaxSpeed()
Returns the maximum speed that can be maintained by the regulation system based upon the
current state of the battery.
|
int |
getRotationSpeed()
Returns the actual speed.
|
int |
getSpeed()
Returns the current motor speed.
|
int |
getTachoCount()
Returns the tachometer count.
|
static EncoderMotor |
invertMotor(EncoderMotor motor)
Returns an inverted EncoderMotor.
|
static RegulatedMotor |
invertMotor(RegulatedMotor motor)
Returns an inverted RegulatedMotor.
|
boolean |
isMoving()
Return
true if the motor is moving. |
boolean |
isStalled()
returns true if motor is stalled
|
RegulatedMotorListener |
removeListener()
Removes the RegulatedMotorListener from this class.
|
void |
resetTachoCount()
Reset the tachometer count.
|
void |
rotate(int angle)
Causes motor to rotate by a specified angle.
|
void |
rotate(int angle,
boolean immediateReturn)
causes motor to rotate through angle;
iff immediateReturn is true, method returns immediately and the motor stops by itself If any motor method is called before the limit is reached, the rotation is canceled. |
void |
rotateTo(int angle)
Causes motor to rotate to limitAngle;
Then getTachoCount should be within +- 2 degrees of the limit angle when the method returns |
void |
rotateTo(int angle,
boolean immediateReturn)
causes motor to rotate to limitAngle;
if immediateReturn is true, method returns immediately and the motor stops by itself and getTachoCount should be within +- 2 degrees if the limit angle If any motor method is called before the limit is reached, the rotation is canceled. |
void |
rotationStarted(RegulatedMotor motor,
int tachoCount,
boolean stalled,
long timeStamp)
Called when the motor starts rotating.
|
void |
rotationStopped(RegulatedMotor motor,
int tachoCount,
boolean stalled,
long timeStamp)
Called when the motor stops rotating.
|
void |
setAcceleration(int acceleration)
Set the required rate of acceleration degrees/s/s
|
void |
setSpeed(int speed)
Set motor speed.
|
void |
setStallThreshold(int error,
int time)
Set the parameters for detecting a stalled motor.
|
void |
startSynchronization()
Begin a set of synchronized motor operations
|
void |
stop()
Causes motor to stop immediately.
|
void |
stop(boolean immediateReturn)
Causes motor to stop, pretty much
instantaneously.
|
void |
synchronizeWith(RegulatedMotor[] syncList)
Specify a set of motors that should be kept in synchronization with this one.
|
void |
waitComplete()
Wait until the current movement operation is complete (this can include
the motor stalling).
|
public static RegulatedMotor invertMotor(RegulatedMotor motor)
motor - A RegulatedMotor, such as Motor.A.public static EncoderMotor invertMotor(EncoderMotor motor)
motor - An EncoderMotor, such as NXTMotor.public void addListener(RegulatedMotorListener listener)
RegulatedMotoraddListener in interface RegulatedMotorpublic RegulatedMotorListener removeListener()
RegulatedMotorremoveListener in interface RegulatedMotorpublic void flt(boolean immediateReturn)
RegulatedMotorflt in interface RegulatedMotorimmediateReturn - If true do not wait for the motor to actually stoppublic int getLimitAngle()
RegulatedMotorgetLimitAngle in interface RegulatedMotorpublic float getMaxSpeed()
RegulatedMotorgetMaxSpeed in interface RegulatedMotorpublic int getSpeed()
RegulatedMotorgetSpeed in interface RegulatedMotorpublic boolean isStalled()
RegulatedMotorisStalled in interface RegulatedMotorpublic void rotate(int angle)
RegulatedMotorrotate in interface RegulatedMotorangle - by which the motor will rotate.public void rotate(int angle,
boolean immediateReturn)
RegulatedMotorrotate in interface RegulatedMotorangle - through which the motor will rotateimmediateReturn - iff true, method returns immediately, thus allowing monitoring of sensors in the calling thread.RegulatedMotor.rotate(int, boolean)public void rotateTo(int angle)
RegulatedMotorrotateTo in interface RegulatedMotorangle - to which the motor will rotate, and then stop (in degrees). Includes any positive or negative int, even values > 360.public void rotateTo(int angle,
boolean immediateReturn)
RegulatedMotorrotateTo in interface RegulatedMotorangle - to which the motor will rotate, and then stop (in degrees). Includes any positive or negative int, even values > 360.immediateReturn - iff true, method returns immediately, thus allowing monitoring of sensors in the calling thread.public void setAcceleration(int acceleration)
RegulatedMotorsetAcceleration in interface RegulatedMotorpublic void setSpeed(int speed)
RegulatedMotorsetSpeed in interface RegulatedMotorspeed - in degrees per second.public void setStallThreshold(int error,
int time)
RegulatedMotorsetStallThreshold in interface RegulatedMotorerror - The error thresholdtime - The time that the error threshold needs to be exceeded for.public void stop(boolean immediateReturn)
RegulatedMotorstop in interface RegulatedMotorimmediateReturn - if true do not wait for the motor to actually stoppublic void waitComplete()
RegulatedMotorwaitComplete in interface RegulatedMotorpublic void backward()
BaseMotorstop() or flt() is called.public void flt()
BaseMotorpublic void forward()
BaseMotorstop() or flt() is called.public boolean isMoving()
BaseMotortrue if the motor is moving.public void stop()
BaseMotorpublic int getRotationSpeed()
TachometergetRotationSpeed in interface Tachometerpublic int getTachoCount()
EncodergetTachoCount in interface Encoderpublic void resetTachoCount()
EncoderresetTachoCount in interface Encoderpublic void rotationStarted(RegulatedMotor motor, int tachoCount, boolean stalled, long timeStamp)
RegulatedMotorListenerrotationStarted in interface RegulatedMotorListenerpublic void rotationStopped(RegulatedMotor motor, int tachoCount, boolean stalled, long timeStamp)
RegulatedMotorListenerrotationStopped in interface RegulatedMotorListenerpublic void close()
RegulatedMotorclose in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface RegulatedMotorpublic void synchronizeWith(RegulatedMotor[] syncList)
RegulatedMotorsynchronizeWith in interface RegulatedMotorsyncList - an array of motors to synchronize with.public void startSynchronization()
RegulatedMotorstartSynchronization in interface RegulatedMotorpublic void endSynchronization()
RegulatedMotorendSynchronization in interface RegulatedMotor