ukcrobots.core
Class Motor

java.lang.Object
  |
  +--ukcrobots.core.Motor

public class Motor
extends Object

A delegating wrapper around the OutputDevice class. All methods delegate to the associated device. Multiple motors may be connected to the same device, if required. This class is based on josx.platform.rcx.Motor

Version:
2001.12.20

Constructor Summary
Motor(char id)
          Create a motor.
 
Method Summary
 void backward()
          Causes the device to rotate backwards.
 void flt()
          Causes the device to float.
 void forward()
          Causes the device to rotate forward.
 int getPower()
          Returns the current device power.
 boolean isFloating()
           
 boolean isMoving()
           
 void reverse()
          Reverses direction of the device.
 void setPower(int power)
          Sets the device power to a value between 0 and 7.
 void stop()
          Causes the device to stop, pretty much instantaneously.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait
 

Constructor Detail

Motor

public Motor(char id)
      throws NoSuchDeviceException
Create a motor.

Parameters:
id - Which output port the motor is attached to. This should have a value of 'A', 'B', or 'C'.
Throws:
NoSuchDeviceException - If the value of id is incorrect.
Method Detail

setPower

public void setPower(int power)
Sets the device power to a value between 0 and 7.


forward

public void forward()
Causes the device to rotate forward.


backward

public void backward()
Causes the device to rotate backwards.


reverse

public void reverse()
Reverses direction of the device. It only has effect if the device is moving.


getPower

public int getPower()
Returns the current device power.


isMoving

public boolean isMoving()
Returns:
true iff the device is currently in motion.

isFloating

public boolean isFloating()
Returns:
true iff the device is currently in float mode.

stop

public void stop()
Causes the device to stop, pretty much instantaneously. In other words, the device doesn't just stop; it will resist any further motion.


flt

public void flt()
Causes the device to float. The device will lose all power, but this is not the same as stopping. Use this method if you don't want your robot to trip in abrupt turns.