|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lejos.nxt.remote.RemoteMotor
public class RemoteMotor
Motor class. Contains three instances of Motor. Usage: Motor.A.forward(500);
Field Summary | |
---|---|
protected RegulatedMotorListener |
listener
|
byte |
turnRatio
|
Constructor Summary | |
---|---|
RemoteMotor(NXTCommand nxtCommand,
int id)
|
Method Summary | |
---|---|
void |
addListener(RegulatedMotorListener listener)
Currently not completely implemented in RemoteMotor! |
void |
backward()
Causes motor to rotate backwards until stop() or flt() is called. |
void |
flt()
Motor loses all power, causing the rotor to float freely to a stop. |
void |
flt(boolean returnNow)
Set the motor into float mode. |
void |
forward()
Causes motor to rotate forward until stop() or flt() is called. |
int |
getBlockTacho()
Deprecated. |
char |
getId()
Get the ID of the motor. |
int |
getLimitAngle()
RegulatedMotor for NXT need this |
float |
getMaxSpeed()
Returns the maximim speed of the motor. |
int |
getPower()
Return the power that the motor is set to |
int |
getRotationCount()
Deprecated. |
int |
getRotationSpeed()
Returns the actual speed. |
int |
getSpeed()
Returns the current motor speed. |
int |
getTachoCount()
Returns the tachometer count. |
boolean |
isMoving()
Return true if the motor is moving. |
boolean |
isRotating()
CURRENTLY NOT IMPLEMENTED! Use isMoving() for now. |
boolean |
isStalled()
returns true if motor is stalled |
void |
regulateSpeed(boolean yes)
|
RegulatedMotorListener |
removeListener()
Removes the RegulatedMotorListener from this class. |
int |
resetBlockTacho()
Deprecated. |
void |
resetTachoCount()
Reset the tachometer count. |
void |
rotate(int count)
Causes motor to rotate by a specified angle. |
void |
rotate(int count,
boolean returnNow)
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. |
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 |
void |
rotateTo(int limitAngle,
boolean returnNow)
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. |
void |
setAcceleration(int acceleration)
Set the required rate of acceleration degrees/s/s |
void |
setPower(int power)
Sets the power of the motor |
void |
setRegulationMode(int mode)
This method determines if and how the motor will be regulated. |
void |
setSpeed(int speed)
Set motor speed. |
void |
setStallThreshold(int error,
int time)
Set the parameters for detecting a stalled motor. |
void |
smoothAcceleration(boolean yes)
|
void |
stop()
Causes motor to stop immediately. |
void |
stop(boolean returnNow)
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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public byte turnRatio
protected RegulatedMotorListener listener
Constructor Detail |
---|
public RemoteMotor(NXTCommand nxtCommand, int id)
Method Detail |
---|
public final char getId()
public void forward()
BaseMotor
stop()
or flt()
is called.
forward
in interface BaseMotor
public void backward()
BaseMotor
stop()
or flt()
is called.
backward
in interface BaseMotor
public void setSpeed(int speed)
RegulatedMotor
setSpeed
in interface RegulatedMotor
speed
- in degrees per second.public void setPower(int power)
setPower
in interface DCMotor
power
- the power (-100 to +100)public int getSpeed()
RegulatedMotor
getSpeed
in interface RegulatedMotor
public int getPower()
getPower
in interface DCMotor
public int getTachoCount()
Encoder
getTachoCount
in interface Encoder
@Deprecated public int getRotationCount()
@Deprecated public int getBlockTacho()
public void rotate(int count, boolean returnNow)
RegulatedMotor
rotate
in interface RegulatedMotor
count
- through which the motor will rotatereturnNow
- iff true, method returns immediately, thus allowing monitoring of sensors in the calling thread.RegulatedMotor.rotate(int, boolean)
public boolean isMoving()
BaseMotor
true
if the motor is moving.
isMoving
in interface BaseMotor
true
if the motor is currently in motion, false
if stopped.public void waitComplete()
RegulatedMotor
waitComplete
in interface RegulatedMotor
public boolean isRotating()
public void rotate(int count)
RegulatedMotor
rotate
in interface RegulatedMotor
count
- by which the motor will rotate.public void setRegulationMode(int mode)
mode
- See NXTProtocol for enumerations: REGULATION_MODE_MOTOR_SYNC,
REGULATION_MODE_MOTOR_SPEED, REGULATION_MODE_IDLEpublic void rotateTo(int limitAngle)
RegulatedMotor
rotateTo
in interface RegulatedMotor
limitAngle
- to which the motor will rotate, and then stop (in degrees). Includes any positive or negative int, even values > 360.public void rotateTo(int limitAngle, boolean returnNow)
RegulatedMotor
rotateTo
in interface RegulatedMotor
limitAngle
- to which the motor will rotate, and then stop (in degrees). Includes any positive or negative int, even values > 360.returnNow
- iff true, method returns immediately, thus allowing monitoring of sensors in the calling thread.public int getLimitAngle()
getLimitAngle
in interface RegulatedMotor
public void resetTachoCount()
Encoder
resetTachoCount
in interface Encoder
@Deprecated public int resetBlockTacho()
public void stop(boolean returnNow)
RegulatedMotor
stop
in interface RegulatedMotor
returnNow
- if true do not wait for the motor to actually stoppublic void stop()
BaseMotor
stop
in interface BaseMotor
public void flt(boolean returnNow)
RegulatedMotor
flt
in interface RegulatedMotor
returnNow
- If true do not wait for the motor to actually stoppublic void flt()
BaseMotor
flt
in interface BaseMotor
public void regulateSpeed(boolean yes)
public void smoothAcceleration(boolean yes)
public int getRotationSpeed()
Tachometer
getRotationSpeed
in interface Tachometer
public void addListener(RegulatedMotorListener listener)
addListener
in interface RegulatedMotor
public RegulatedMotorListener removeListener()
RegulatedMotor
removeListener
in interface RegulatedMotor
public boolean isStalled()
RegulatedMotor
isStalled
in interface RegulatedMotor
public void setAcceleration(int acceleration)
RegulatedMotor
setAcceleration
in interface RegulatedMotor
public float getMaxSpeed()
RegulatedMotor
getMaxSpeed
in interface RegulatedMotor
public void setStallThreshold(int error, int time)
RegulatedMotor
setStallThreshold
in interface RegulatedMotor
error
- The error thresholdtime
- The time that the error threshold needs to be exceeded for.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |