public class MMXRegulatedMotor extends MMXMotor implements RegulatedMotor
Use the NXTMMX.getRegulatedMotor() factory method to retrieve an instance of this class.
NXTMMX| 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 |
close()
Close the port, the port can not be used after this call.
|
void |
endSynchronization()
Complete a set of synchronized motor operations.
|
void |
flt(boolean immediateReturn)
Set the motor into float mode.
|
int |
getLimitAngle()
Return the angle that this Motor is rotating to or last rotated to.
|
float |
getMaxSpeed()
Returns the maximum speed that can be maintained by the regulation system based upon the
current state of the battery.
|
int |
getRotationSpeed()
Return the current rotational speed calculated from the encoder position every 100 ms.
|
int |
getSpeed()
Return the current target speed.
|
boolean |
isStalled()
returns true if motor is stalled
|
RegulatedMotorListener |
removeListener()
Removes the RegulatedMotorListener from this class.
|
void |
rotate(int angle)
Rotate by the requested number of degrees while blocking until completion.
|
void |
rotate(int degrees,
boolean immediateReturn)
Rotate by the requested number of degrees with option for wait until completion or immediate return where the motor
completes its rotation asynchronously.
|
void |
rotateTo(int limitAngle)
Rotate to the target angle while blocking until completion.
|
void |
rotateTo(int limitAngle,
boolean immediateReturn)
Rotate to the target angle with option for wait until completion or immediate return where the motor
completes its rotation asynchronously.
|
void |
setAcceleration(int acceleration)
Sets speed ramping is enabled/disabled for this motor.
|
void |
setSpeed(int speed)
Sets desired motor speed, in degrees per second.
|
void |
setStallThreshold(int error,
int time)
NOT IMPLEMENTED as the NXTMMX motor controller does not support this command.
|
void |
startSynchronization()
Begin a set of synchronized motor operations
|
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).
|
backward, flt, forward, getPower, getTachoCount, isMoving, resetTachoCount, setPower, setRamping, setRegulate, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetTachoCount, resetTachoCountpublic void addListener(RegulatedMotorListener listener)
RegulatedMotoraddListener in interface RegulatedMotorpublic RegulatedMotorListener removeListener()
RegulatedMotorremoveListener in interface RegulatedMotorpublic int getRotationSpeed()
setSpeed.getRotationSpeed in interface Tachometerpublic void stop(boolean immediateReturn)
RegulatedMotorstop in interface RegulatedMotorimmediateReturn - if true do not wait for the motor to actually stoppublic void flt(boolean immediateReturn)
RegulatedMotorflt in interface RegulatedMotorimmediateReturn - If true do not wait for the motor to actually stoppublic void waitComplete()
RegulatedMotorwaitComplete in interface RegulatedMotorpublic void rotate(int angle)
rotate in interface RegulatedMotorangle - number of degrees to rotate relative to the current position.public void rotateTo(int limitAngle)
rotateTo in interface RegulatedMotorlimitAngle - Angle [in degrees] to rotate to.public void rotate(int degrees,
boolean immediateReturn)
rotate in interface RegulatedMotordegrees - number of degrees to rotate relative to the current position.immediateReturn - if true, do not wait for the move to complete. false will block
until the rotation completes.RegulatedMotor.rotate(int, boolean)public void rotateTo(int limitAngle,
boolean immediateReturn)
rotateTo in interface RegulatedMotorlimitAngle - Angle [in degrees] to rotate to.immediateReturn - if true, do not wait for the move to complete. false will block
until the rotation completes.public void setSpeed(int speed)
The NXTMMX does not provide speed control per se (just power) so we approximate the power value used
based on the requested degress/sec (dps) passed in speed. This means if you request 400 dps,
the actual dps value
may not reflect that. Setting speed during a rotate method will have no effect on the running rotate
but will on the next rotate
method call.
experimental data gives: dps=8.1551*power+32.253 (unloaded @ 8.83V)
Note:The NXTMMX doesn't seem to want to drive the standard NXT motor below ~40 dps.
setSpeed in interface RegulatedMotorspeed - Motor speed in degrees per secondgetSpeed(),
MMXMotor.setPower(int)public int getSpeed()
getSpeed in interface RegulatedMotorsetSpeed(int),
MMXMotor.getPower()public float getMaxSpeed()
RegulatedMotorgetMaxSpeed in interface RegulatedMotorpublic boolean isStalled()
RegulatedMotorisStalled in interface RegulatedMotorpublic void setStallThreshold(int error,
int time)
setStallThreshold in interface RegulatedMotorerror - The error thresholdtime - The time that the error threshold needs to be exceeded for.public void setAcceleration(int acceleration)
RegulatedMotor interface
specifies this in degrees/sec/sec
but the NXTMMX does not allow the rate to be changed, just if the motor uses smooth
acceleration or not so we use the acceleration
parameter to specify ramping state. Default at instantiation is ramping enabled.
setAcceleration in interface RegulatedMotoracceleration - >0 means NXTMMX internal ramping is enabled otherwise disabledMMXMotor.setRamping(boolean)public int getLimitAngle()
getLimitAngle in interface RegulatedMotorpublic 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