|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ch.aplu.nxt.Part ch.aplu.nxt.Motor
public class Motor
Class that represents one of the NXT motors. Most methods will call connect, if not yet connected.
Field Summary |
---|
Fields inherited from class ch.aplu.nxt.Part |
---|
robot |
Constructor Summary | |
---|---|
Motor(MotorPort port)
Creates a motor instance that is plugged into given port. |
Method Summary | |
---|---|
void |
addMotionListener(MotionListener motionListener)
Registers the given motion listener. |
Motor |
backward()
Starts the backward rotation with preset speed. |
protected Motor |
backward(boolean rampup)
|
protected void |
cleanup()
|
Motor |
continueTo(int count)
Same as rotateTo(int count), but the rotation counter is not set to zero. |
Motor |
continueTo(int count,
boolean blocking)
Same as rotateTo(int count, boolean blocking), but the rotation counter is not set to zero. |
Motor |
forward()
Starts the forward rotation with preset speed. |
protected Motor |
forward(boolean rampup)
|
int |
getPortId()
Returns the port number. |
java.lang.String |
getPortLabel()
Returns the port label. |
int |
getSpeed()
Returns the current speed (arbitrary units). |
double |
getVelocity()
Returns the current velocity. |
protected void |
init()
|
boolean |
isMoving()
Checks if the motor is rotating. |
void |
resetMotorCount()
Resets the rotation counter to zero. |
Motor |
rotateTo(int count)
Sets the rotation counter to zero and rotates the motor until the given count is reached. |
Motor |
rotateTo(int count,
boolean blocking)
Sets the rotation counter to zero and rotates the motor until the given count is reached. |
Motor |
setSpeed(int speed)
Sets the speed to the given value (arbitrary units). |
void |
setSpeedFactor(double value)
Sets the motor speed factor to given value. |
Motor |
setVelocity(double velocity)
Sets the velocity to the given value. |
double |
speedToVelocity(int speed)
Conversion from speed to velocity. |
protected void |
startMotionDetector()
|
Motor |
stop()
Stops the motor. |
protected void |
stopMotionDetector()
|
int |
velocityToSpeed(double velocity)
Conversion from velocity to speed. |
Methods inherited from class ch.aplu.nxt.Part |
---|
setRobot |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Motor(MotorPort port)
port
- the port where the motor is plugged-in (MotorPort.A, MotorPort.B, MotorPort.C)Method Detail |
---|
public int getPortId()
public java.lang.String getPortLabel()
protected void init()
init
in class Part
protected void cleanup()
cleanup
in class Part
public void addMotionListener(MotionListener motionListener)
motionListener
- a reference to a MotionListenerMotionListener
,
rotateTo(int count, boolean blocking)
protected void startMotionDetector()
protected void stopMotionDetector()
public Motor forward()
protected Motor forward(boolean rampup)
public Motor backward()
protected Motor backward(boolean rampup)
public Motor setSpeed(int speed)
speed
- the speed 0..100
public int getSpeed()
public Motor setVelocity(double velocity)
velocity
- the velocity in m/s
public double getVelocity()
public Motor stop()
public void setSpeedFactor(double value)
value
- the velocity per speed unitpublic double speedToVelocity(int speed)
speed
- the speed as set in setSpeed()
setSpeedFactor(double value)
public int velocityToSpeed(double velocity)
velocity
- the velocity in m/s
setSpeedFactor(double value)
public void resetMotorCount()
rotateTo(int count)
public Motor rotateTo(int count)
addMotionListener(MotionListener motionListener)
,
rotateTo(int count, boolean blocking)
public Motor rotateTo(int count, boolean blocking)
addMotionListener(MotionListener motionListener)
,
rotateTo(int count)
public Motor continueTo(int count)
rotateTo(int count)
public Motor continueTo(int count, boolean blocking)
rotateTo(int count, boolean blocking)
public boolean isMoving()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |