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, rotateTo
backward, flt, forward, getPower, isMoving, setPower, setReverse, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLimitAngle, rotate, rotateTo
getTachoCount, resetTachoCount
public void setRegulate(boolean regulate)
TetrixRegulatedMotor
class must use regulation.
Motors are always in
regulated mode when using the TetrixRegulatedMotor
class.setRegulate
in class TetrixEncoderMotor
regulate
- Ignoredpublic 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 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 RegulatedMotor
speed
- 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 RegulatedMotor
setSpeed(int)
public float getMaxSpeed()
getMaxSpeed
in interface RegulatedMotor
public boolean isStalled()
isStalled
in interface RegulatedMotor
false
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)
setAcceleration
in interface RegulatedMotor
acceleration
- Ignoredpublic 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