Package lejos.robotics
Interface RegulatedMotor
-
- All Superinterfaces:
java.lang.AutoCloseable,BaseMotor,java.io.Closeable,Encoder,Tachometer
- All Known Implementing Classes:
BaseRegulatedMotor,EV3LargeRegulatedMotor,EV3MediumRegulatedMotor,MindsensorsGlideWheelMRegulatedMotor,MindsensorsGlideWheelXLRegulatedMotor,MirrorMotor,MMXRegulatedMotor,NXTRegulatedMotor,RemoteRequestRegulatedMotor,TetrixRegulatedMotor
public interface RegulatedMotor extends BaseMotor, Tachometer, java.io.Closeable
Interface for encoded motors without limited range of movement (e.g. NXT motor). TODO: Alternate names: EncodedMotor,EncoderMotor.- Author:
- dsturze
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddListener(RegulatedMotorListener listener)Adds a listener object that will be notified when rotation has started or stoppedvoidclose()Close the port, the port can not be used after this call.voidendSynchronization()Complete a set of synchronized motor operations.voidflt(boolean immediateReturn)Set the motor into float mode.intgetLimitAngle()Return the limit angle (if any)floatgetMaxSpeed()Returns the maximum speed that can be maintained by the regulation system based upon the current state of the battery.intgetSpeed()Returns the current motor speed.booleanisStalled()returns true if motor is stalledRegulatedMotorListenerremoveListener()Removes the RegulatedMotorListener from this class.voidrotate(int angle)Causes motor to rotate by a specified angle.voidrotate(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.voidrotateTo(int limitAngle)Causes motor to rotate to limitAngle;
Then getTachoCount should be within +- 2 degrees of the limit angle when the method returnsvoidrotateTo(int limitAngle, 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.voidsetAcceleration(int acceleration)Set the required rate of acceleration degrees/s/svoidsetSpeed(int speed)Set motor speed.voidsetStallThreshold(int error, int time)Set the parameters for detecting a stalled motor.voidstartSynchronization()Begin a set of synchronized motor operationsvoidstop(boolean immediateReturn)Causes motor to stop, pretty much instantaneously.voidsynchronizeWith(RegulatedMotor[] syncList)Specify a set of motors that should be kept in synchronization with this one.voidwaitComplete()Wait until the current movement operation is complete (this can include the motor stalling).-
Methods inherited from interface lejos.robotics.Encoder
getTachoCount, resetTachoCount
-
Methods inherited from interface lejos.robotics.Tachometer
getRotationSpeed
-
-
-
-
Method Detail
-
addListener
void addListener(RegulatedMotorListener listener)
Adds a listener object that will be notified when rotation has started or stopped- Parameters:
listener-
-
removeListener
RegulatedMotorListener removeListener()
Removes the RegulatedMotorListener from this class.- Returns:
- The RegulatedMotorListener that was removed, if any. Null if none existed.
-
stop
void stop(boolean immediateReturn)
Causes motor to stop, pretty much instantaneously. In other words, the motor doesn't just stop; it will resist any further motion. Cancels any rotate() orders in progress- Parameters:
immediateReturn- if true do not wait for the motor to actually stop
-
flt
void flt(boolean immediateReturn)
Set the motor into float mode. This will stop the motor without braking and the position of the motor will not be maintained.- Parameters:
immediateReturn- If true do not wait for the motor to actually stop
-
waitComplete
void waitComplete()
Wait until the current movement operation is complete (this can include the motor stalling).
-
rotate
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. When the angle is reached, the method isMoving() returns false;- Parameters:
angle- through which the motor will rotateimmediateReturn- iff true, method returns immediately, thus allowing monitoring of sensors in the calling thread.- See Also:
rotate(int, boolean)
-
rotate
void rotate(int angle)
Causes motor to rotate by a specified angle. The resulting tachometer count should be within +- 2 degrees on the NXT. This method does not return until the rotation is completed.- Parameters:
angle- by which the motor will rotate.
-
rotateTo
void rotateTo(int limitAngle)
Causes motor to rotate to limitAngle;
Then getTachoCount should be within +- 2 degrees of the limit angle when the method returns- Parameters:
limitAngle- to which the motor will rotate, and then stop (in degrees). Includes any positive or negative int, even values > 360.
-
rotateTo
void rotateTo(int limitAngle, 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. When the angle is reached, the method isMoving() returns false;- Parameters:
limitAngle- 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.
-
getLimitAngle
int getLimitAngle()
Return the limit angle (if any)- Returns:
- the current limit angle
-
setSpeed
void setSpeed(int speed)
Set motor speed. As a rule of thumb 100 degrees per second are possible for each volt on an NXT motor. Therefore, disposable alkaline batteries can achieve a top speed of 900 deg/sec, while a rechargable lithium battery pack can achieve 740 deg/sec.- Parameters:
speed- in degrees per second.
-
getSpeed
int getSpeed()
Returns the current motor speed.- Returns:
- motor speed in degrees per second
-
getMaxSpeed
float getMaxSpeed()
Returns the maximum speed that can be maintained by the regulation system based upon the current state of the battery.- Returns:
- the maximum speed of the Motor in degrees per second.
-
isStalled
boolean isStalled()
returns true if motor is stalled- Returns:
- true if stalled
-
setStallThreshold
void setStallThreshold(int error, int time)Set the parameters for detecting a stalled motor. A motor will be recognized as stalled if the movement error (the amount the motor lags the regulated position) is greater than error for a period longer than time.- Parameters:
error- The error thresholdtime- The time that the error threshold needs to be exceeded for.
-
setAcceleration
void setAcceleration(int acceleration)
Set the required rate of acceleration degrees/s/s- Parameters:
acceleration-
-
synchronizeWith
void synchronizeWith(RegulatedMotor[] syncList)
Specify a set of motors that should be kept in synchronization with this one. The synchronization mechanism simply ensures that operations between a startSynchronization call and an endSynchronization call will all be executed at the same time (when the endSynchronization method is called). This is all that is needed to ensure that motors will operate in a synchronized fashion. The start/end methods can also be used to ensure that reads of the motor state will also be consistent.- Parameters:
syncList- an array of motors to synchronize with.
-
startSynchronization
void startSynchronization()
Begin a set of synchronized motor operations
-
endSynchronization
void endSynchronization()
Complete a set of synchronized motor operations.
-
close
void close()
Close the port, the port can not be used after this call.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
-