Package lejos.hardware.motor
Interface MotorRegulator
-
- All Known Implementing Classes:
JavaMotorRegulator
public interface MotorRegulatorInterface for motor regulation regulate velocity; also stop motor at desired rotation angle.
-
-
Field Summary
Fields Modifier and Type Field Description static intNO_LIMIT
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddListener(RegulatedMotor motor, RegulatedMotorListener listener)Add a motor listener.voidadjustAcceleration(int newAcc)The target acceleration has been changed.voidadjustSpeed(float newSpeed)The target speed has been changed.voidendSynchronization(boolean b)Complete a set of synchronized motor operations.floatgetCurrentVelocity()Return the current velocity (in degrees/second) that the motor is currently running at.intgetLimitAngle()Return the angle that this Motor is rotating to.floatgetPosition()return the regulations models current position.intgetTachoCount()Get the current hardware tachometer reading for the motor,booleanisMoving()Return true if the motor is currently activebooleanisStalled()Return true if the motor is currently stalled.voidnewMove(float speed, int acceleration, int limit, boolean hold, boolean waitComplete)Initiate a new move and optionally wait for it to complete.RegulatedMotorListenerremoveListener()voidresetTachoCount()Reset the tachometer base value, after this call the tachometer will return zero for the current position.voidsetControlParamaters(int typ, float moveP, float moveI, float moveD, float holdP, float holdI, float holdD, int offset)Set the motion control parameters used by the regulator.voidsetStallThreshold(int error, int time)Set the stall detection parameters.voidstartSynchronization()Begin a set of synchronized motor operationsvoidsynchronizeWith(MotorRegulator[] rl)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).
-
-
-
Field Detail
-
NO_LIMIT
static final int NO_LIMIT
- See Also:
- Constant Field Values
-
-
Method Detail
-
setControlParamaters
void setControlParamaters(int typ, float moveP, float moveI, float moveD, float holdP, float holdI, float holdD, int offset)Set the motion control parameters used by the regulator.- Parameters:
typ- The type of motormoveP- The Proportional control value used while movingmoveI- The integral control parameter used while movingmoveD- The differential control parameter used while movingholdP- The Proportional control value used while holding positionholdI- The integral control value used while holding positionholdD- The differential control value used while holding positionoffset- Motor PWM offset value range 0-10000.
-
getTachoCount
int getTachoCount()
Get the current hardware tachometer reading for the motor,- Returns:
- hardware reading
-
resetTachoCount
void resetTachoCount()
Reset the tachometer base value, after this call the tachometer will return zero for the current position. Note that any in progress movements will be aborted.
-
isMoving
boolean isMoving()
Return true if the motor is currently active- Returns:
- True if the motor is moving.
-
getCurrentVelocity
float getCurrentVelocity()
Return the current velocity (in degrees/second) that the motor is currently running at. Note that this value may be supplied from the internal control model not from actually measuring the rotation speed. If the regulator is functioning correctly this will closely match the actual velocity- Returns:
- velocity
-
setStallThreshold
void setStallThreshold(int error, int time)Set the stall detection parameters. The motor will be declared as stalled if the error in the motor position exceeds the specified value for longer than the given time.- Parameters:
error-time-
-
getPosition
float getPosition()
return the regulations models current position.- Returns:
- the models current position
-
newMove
void newMove(float speed, int acceleration, int limit, boolean hold, boolean waitComplete)Initiate a new move and optionally wait for it to complete. If some other move is currently executing then ensure that this move is terminated correctly and then start the new move operation.- Parameters:
speed-acceleration-limit-hold-waitComplete-
-
adjustSpeed
void adjustSpeed(float newSpeed)
The target speed has been changed. Reflect this change in the regulator.- Parameters:
newSpeed- new target speed.
-
adjustAcceleration
void adjustAcceleration(int newAcc)
The target acceleration has been changed. Updated the regulator.- Parameters:
newAcc-
-
waitComplete
void waitComplete()
Wait until the current movement operation is complete (this can include the motor stalling).
-
addListener
void addListener(RegulatedMotor motor, RegulatedMotorListener listener)
Add a motor listener. Move operations will be reported to this object.- Parameters:
motor-listener-
-
removeListener
RegulatedMotorListener removeListener()
-
getLimitAngle
int getLimitAngle()
Return the angle that this Motor is rotating to.- Returns:
- angle in degrees
-
isStalled
boolean isStalled()
Return true if the motor is currently stalled.- Returns:
- true if the motor is stalled, else false
-
startSynchronization
void startSynchronization()
Begin a set of synchronized motor operations
-
endSynchronization
void endSynchronization(boolean b)
Complete a set of synchronized motor operations.
-
synchronizeWith
void synchronizeWith(MotorRegulator[] rl)
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:
rl- an array of motors to synchronize with.
-
-