public class TetrixRegulatedMotor extends TetrixEncoderMotor implements RegulatedMotor
RegulatedMotor. The Tetrix motor must have an
encoder installed and connected to
the controller for the methods in this class to work. If an encoder is not installed, use the TetrixMotor
class instead.
Use to retrieve a TetrixMotorController.getRegulatedMotor(int)TetrixRegulatedMotor instance.
| 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.
|
float |
getMaxSpeed()
NOT IMPLEMENTED as the TEXTRIX motor controller does not support this command.
|
int |
getRotationSpeed()
Return the current rotational speed calculated from the encoder position every 100 ms.
|
int |
getSpeed()
Return the speed value calculated from the actual power value as:
|
boolean |
isStalled()
NOT IMPLEMENTED as the TEXTRIX motor controller does not support this command.
|
RegulatedMotorListener |
removeListener()
Removes the RegulatedMotorListener from this class.
|
void |
rotate(int angle)
Rotate by the requested number of degrees while blocking until completion.
|
void |
rotateTo(int limitAngle)
Rotate to the target angle while blocking until completion.
|
void |
setAcceleration(int acceleration)
NOT IMPLEMENTED as the TEXTRIX motor controller does not support this command.
|
void |
setRegulate(boolean regulate)
OVERRIDDEN TO NOT ALLOW CHANGE OF REGULATED STATE as the
TetrixRegulatedMotor class must use regulation. |
void |
setSpeed(int speed)
Sets desired motor speed, in degrees per second.
|
void |
setStallThreshold(int error,
int time)
NOT IMPLEMENTED as the TEXTRIX 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).
|
getLimitAngle, getTachoCount, resetTachoCount, rotate, rotateTobackward, flt, forward, getPower, isMoving, setPower, setReverse, stopclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLimitAngle, rotate, rotateTogetTachoCount, resetTachoCountpublic void setRegulate(boolean regulate)
TetrixRegulatedMotor class must use regulation.
Motors are always in
regulated mode when using the TetrixRegulatedMotor class.setRegulate in class TetrixEncoderMotorregulate - Ignoredpublic 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 setSpeed(int speed)
speed value as:
power = Math.round((speed - 0.5553f) * 0.102247398f);and as such, the actual speed value will not be exact.
The maximum reliably sustainable velocity for the TETRIX DC Gear motor P/N 739023 (which was used as the test case for creating this class) is 154 RPM => 924 degs/sec.
setSpeed in interface RegulatedMotorspeed - value in degrees/secgetSpeed()public int getSpeed()
speed = Math.round(9.7802f * super.getPower() + 0.5553f);and as such, the actual speed value may not be what was set with
setSpeed.getSpeed in interface RegulatedMotorsetSpeed(int)public float getMaxSpeed()
getMaxSpeed in interface RegulatedMotorpublic boolean isStalled()
isStalled in interface RegulatedMotorfalsepublic 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)
setAcceleration in interface RegulatedMotoracceleration - Ignoredpublic 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