|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectlejos.nxt.addon.tetrix.TetrixMotor
lejos.nxt.addon.tetrix.TetrixEncoderMotor
lejos.nxt.addon.tetrix.TetrixRegulatedMotor
public class TetrixRegulatedMotor
Tetrix DC motor abstraction with encoder support that implements 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
class instead.
TetrixMotor
Use to retrieve a TetrixMotorController.getRegulatedMotor(int)TetrixRegulatedMotor instance.
| Constructor Summary | |
|---|---|
TetrixRegulatedMotor(TetrixMotorController mc,
int channel)
|
|
| Method Summary | |
|---|---|
void |
addListener(RegulatedMotorListener listener)
Adds a listener object that will be notified when rotation has started or stopped |
void |
backward()
Causes motor to rotate backwards until stop() or flt() is called. |
void |
flt(boolean immediateReturn)
Set the motor into float mode. |
void |
forward()
Causes motor to rotate forward until stop() or flt() is called. |
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 |
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)
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 |
stop(boolean immediateReturn)
Causes motor to stop, pretty much instantaneously. |
void |
waitComplete()
Wait until the current movement operation is complete (this can include the motor stalling). |
| Methods inherited from class lejos.nxt.addon.tetrix.TetrixEncoderMotor |
|---|
getLimitAngle, getTachoCount, resetTachoCount |
| Methods inherited from class lejos.nxt.addon.tetrix.TetrixMotor |
|---|
flt, getPower, isMoving, setPower, setReverse, stop |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface lejos.robotics.RegulatedMotor |
|---|
getLimitAngle |
| Methods inherited from interface lejos.robotics.BaseMotor |
|---|
flt, isMoving, stop |
| Methods inherited from interface lejos.robotics.Encoder |
|---|
getTachoCount, resetTachoCount |
| Constructor Detail |
|---|
public TetrixRegulatedMotor(TetrixMotorController mc,
int channel)
| Method Detail |
|---|
public 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)
RegulatedMotor
addListener in interface RegulatedMotorpublic RegulatedMotorListener removeListener()
RegulatedMotor
removeListener in interface RegulatedMotorpublic void stop(boolean immediateReturn)
RegulatedMotor
stop in interface RegulatedMotorimmediateReturn - if true do not wait for the motor to actually stoppublic void flt(boolean immediateReturn)
RegulatedMotor
flt in interface RegulatedMotorimmediateReturn - If true do not wait for the motor to actually stoppublic void waitComplete()
RegulatedMotor
waitComplete in interface RegulatedMotorpublic void rotate(int angle)
rotate in interface RegulatedMotorangle - number of degrees to rotate relative to the current position.
public void rotate(int degrees,
boolean immediateReturn)
TetrixEncoderMotor
rotate in interface RegulatedMotorrotate in class TetrixEncoderMotordegrees - 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)
rotateTo in interface RegulatedMotorlimitAngle - Angle [in degrees] to rotate to.
public void rotateTo(int limitAngle,
boolean immediateReturn)
TetrixEncoderMotor
rotateTo in interface RegulatedMotorrotateTo in class TetrixEncoderMotorlimitAngle - 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 forward()
BaseMotorstop() or flt() is called.
forward in interface BaseMotorforward in class TetrixMotorpublic void backward()
BaseMotorstop() or flt() is called.
backward in interface BaseMotorbackward in class TetrixMotorpublic 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 int getRotationSpeed()
setSpeed.
getRotationSpeed in interface Tachometerpublic float getMaxSpeed()
getMaxSpeed in interface RegulatedMotorpublic boolean isStalled()
isStalled in interface RegulatedMotorfalse
public 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 - Ignored
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||