|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectlejos.robotics.MirrorMotor
public class MirrorMotor
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.
| Method Summary | |
|---|---|
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 |
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 maximim speed of the motor. |
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 |
stop()
Causes motor to stop immediately. |
void |
stop(boolean immediateReturn)
Causes motor to stop, pretty much instantaneously. |
void |
waitComplete()
Wait until the current movement operation is complete (this can include the motor stalling). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
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)
RegulatedMotor
addListener in interface RegulatedMotorpublic RegulatedMotorListener removeListener()
RegulatedMotor
removeListener in interface RegulatedMotorpublic void flt(boolean immediateReturn)
RegulatedMotor
flt in interface RegulatedMotorimmediateReturn - If true do not wait for the motor to actually stoppublic int getLimitAngle()
RegulatedMotor
getLimitAngle in interface RegulatedMotorpublic float getMaxSpeed()
RegulatedMotor
getMaxSpeed in interface RegulatedMotorpublic int getSpeed()
RegulatedMotor
getSpeed in interface RegulatedMotorpublic boolean isStalled()
RegulatedMotor
isStalled in interface RegulatedMotorpublic void rotate(int angle)
RegulatedMotor
rotate in interface RegulatedMotorangle - by which the motor will rotate.
public void rotate(int angle,
boolean immediateReturn)
RegulatedMotor
rotate 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)
RegulatedMotor
rotateTo 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)
RegulatedMotor
rotateTo 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)
RegulatedMotor
setAcceleration in interface RegulatedMotorpublic void setSpeed(int speed)
RegulatedMotor
setSpeed in interface RegulatedMotorspeed - in degrees per second.
public void setStallThreshold(int error,
int time)
RegulatedMotor
setStallThreshold in interface RegulatedMotorerror - The error thresholdtime - The time that the error threshold needs to be exceeded for.public void stop(boolean immediateReturn)
RegulatedMotor
stop in interface RegulatedMotorimmediateReturn - if true do not wait for the motor to actually stoppublic void waitComplete()
RegulatedMotor
waitComplete in interface RegulatedMotorpublic void backward()
BaseMotorstop() or flt() is called.
backward in interface BaseMotorpublic void flt()
BaseMotor
flt in interface BaseMotorpublic void forward()
BaseMotorstop() or flt() is called.
forward in interface BaseMotorpublic boolean isMoving()
BaseMotortrue if the motor is moving.
isMoving in interface BaseMotortrue if the motor is currently in motion, false if stopped.public void stop()
BaseMotor
stop in interface BaseMotorpublic int getRotationSpeed()
Tachometer
getRotationSpeed in interface Tachometerpublic int getTachoCount()
Encoder
getTachoCount in interface Encoderpublic void resetTachoCount()
Encoder
resetTachoCount in interface Encoder
public void rotationStarted(RegulatedMotor motor,
int tachoCount,
boolean stalled,
long timeStamp)
RegulatedMotorListener
rotationStarted in interface RegulatedMotorListener
public void rotationStopped(RegulatedMotor motor,
int tachoCount,
boolean stalled,
long timeStamp)
RegulatedMotorListener
rotationStopped in interface RegulatedMotorListener
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||