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, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getTachoCount, resetTachoCount
public void addListener(RegulatedMotorListener listener)
RegulatedMotor
addListener
in interface RegulatedMotor
public RegulatedMotorListener removeListener()
RegulatedMotor
removeListener
in interface RegulatedMotor
public int getRotationSpeed()
setSpeed
.getRotationSpeed
in interface Tachometer
public void stop(boolean immediateReturn)
RegulatedMotor
stop
in interface RegulatedMotor
immediateReturn
- if true do not wait for the motor to actually stoppublic void flt(boolean immediateReturn)
RegulatedMotor
flt
in interface RegulatedMotor
immediateReturn
- If true do not wait for the motor to actually stoppublic void waitComplete()
RegulatedMotor
waitComplete
in interface RegulatedMotor
public void rotate(int angle)
rotate
in interface RegulatedMotor
angle
- number of degrees to rotate relative to the current position.public void rotateTo(int limitAngle)
rotateTo
in interface RegulatedMotor
limitAngle
- Angle [in degrees] to rotate to.public void rotate(int degrees, boolean immediateReturn)
rotate
in interface RegulatedMotor
degrees
- 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 RegulatedMotor
limitAngle
- 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 RegulatedMotor
speed
- Motor speed in degrees per secondgetSpeed()
,
MMXMotor.setPower(int)
public int getSpeed()
getSpeed
in interface RegulatedMotor
setSpeed(int)
,
MMXMotor.getPower()
public float getMaxSpeed()
RegulatedMotor
getMaxSpeed
in interface RegulatedMotor
public boolean isStalled()
RegulatedMotor
isStalled
in interface RegulatedMotor
public void setStallThreshold(int error, int time)
setStallThreshold
in interface RegulatedMotor
error
- 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 RegulatedMotor
acceleration
- >0 means NXTMMX internal ramping is enabled otherwise disabledMMXMotor.setRamping(boolean)
public int getLimitAngle()
getLimitAngle
in interface RegulatedMotor
public void close()
RegulatedMotor
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface RegulatedMotor
public void synchronizeWith(RegulatedMotor[] syncList)
RegulatedMotor
synchronizeWith
in interface RegulatedMotor
syncList
- an array of motors to synchronize with.public void startSynchronization()
RegulatedMotor
startSynchronization
in interface RegulatedMotor
public void endSynchronization()
RegulatedMotor
endSynchronization
in interface RegulatedMotor