lejos.robotics.navigation
Class OmniPilot

java.lang.Object
  extended by lejos.robotics.navigation.OmniPilot
All Implemented Interfaces:
ArcMoveController, ArcRotateMoveController, MoveController, MoveProvider, RotateMoveController, RegulatedMotorListener

public class OmniPilot
extends Object
implements ArcRotateMoveController, RegulatedMotorListener

Use the OmniPilot class to control holonomic vehicles with three omnidirectional wheels that allow the robot to move in any direction without changing heading. The robot can also spin while driving straight, and perform any kind of maneuvre the other steering and differential drive vehicles can do. The odometry is computed by this class directly. For the class to work properly, take care to design the robot simmetrically, so that the three wheel axes meet in the center of the robot.

Author:
Daniele Benedettelli

Field Summary
 
Fields inherited from interface lejos.robotics.navigation.MoveController
WHEEL_SIZE_NXT1, WHEEL_SIZE_NXT2, WHEEL_SIZE_RCX
 
Fields inherited from interface lejos.robotics.navigation.MoveController
WHEEL_SIZE_NXT1, WHEEL_SIZE_NXT2, WHEEL_SIZE_RCX
 
Constructor Summary
OmniPilot(float wheelDistanceFromCenter, float wheelDiameter, RegulatedMotor centralMotor, RegulatedMotor CW120degMotor, RegulatedMotor CCW120degMotor, boolean centralWheelFrontal, boolean motorReverse)
          Instantiates a new omnidirectional pilot.
OmniPilot(float wheelDistanceFromCenter, float wheelDiameter, RegulatedMotor centralMotor, RegulatedMotor CW120degMotor, RegulatedMotor CCW120degMotor, boolean centralWheelFrontal, boolean motorReverse, SensorPort gyroPort)
          Instantiates a new omnidirectional pilot.
 
Method Summary
 void addMoveListener(MoveListener listener)
          Adds a MoveListener that will be notified of all movement events.
 void arc(double radius, double angle)
          Moves the NXT robot along an arc with a specified radius and angle, after which the robot stops moving.
 void arc(double radius, double angle, boolean immediateReturn)
          Moves the NXT robot along an arc with a specified radius and angle, after which the robot stops moving.
 void arc(double radius, double angle, double direction)
          This method moves the robot in an arc, similar to the other arc(double, double) methods, except you can choose any of the 360 degree directions relative to the current heading (0) of the robot, while keeping the heading of the robot pointed in the same direction during the move.
 void arc(double radius, double angle, double direction, boolean immediateReturn)
          This method moves the robot in an arc, similar to the other arc(double, double) methods, except you can choose any of the 360 degree directions relative to the current heading (0) of the robot, while keeping the heading of the robot pointed in the same direction during the move.
 void arcBackward(double radius)
          Starts the NXT robot moving backward along an arc with a specified radius.
 void arcForward(double radius)
          Starts the NXT robot moving forward along an arc with a specified radius.
 void backward()
          Starts the NXT robot moving backwards.
 void forward()
          Starts the NXT robot moving forward.
 double getMaxTravelSpeed()
          Returns the maximum speed at which this robot is capable of traveling forward and backward.
 double getMinRadius()
          The minimum steering radius this vehicle is capable of when traveling in an arc.
 float getMoveDirection()
          Gets the move direction.
 Move getMovement()
          Returns the move made since the move started, but before it has completed.
 double getRotateMaxSpeed()
          returns the maximum value of the rotation speed;
 double getRotateSpeed()
          Returns the value of the rotation speed
 double getTravelSpeed()
          Returns the speed at which the robot will travel forward and backward (and to some extent arcs, although actual arc speed is slightly less).
 boolean isMoving()
          true if the robot is moving
 void moveStraight(float linSpeed, int direction)
          This method causes the robot to move in a direction while keeping the front of the robot pointed in the current direction it is facing.
 void reset()
          Reset all tacho counts.
 void rotate(double angle)
          Rotates the NXT robot the specified number of degrees; direction determined by the sign of the parameter.
 void rotate(double angle, boolean immediateReturn)
          Rotates the NXT robot the specified number of degrees; direction determined by the sign of the parameter.
 void rotationStarted(RegulatedMotor motor, int tachoCount, boolean stalled, long timeStamp)
          Called when the motor starts rotating.
 void rotationStopped(RegulatedMotor motor, int tachoCount, boolean stalled, long timeStamp)
          Notify the MoveListeners when a move is completed.
 void setAcceleration(int accel)
          Sets the acceleration.
 void setMinRadius(double radius)
          Set the radius of the minimum turning circle.
 void setMoveDirection(int dir)
          Sets the move direction.
 void setRotateSpeed(double speed)
          sets the rotation speed of the robot (the angular velocity of the rotate() methods)
 void setSpeed(int speed)
          Deprecated. in 0.8, use setRotateSpeed() and setTravelSpeed(). The method was deprecated, as this it requires knowledge of the robots physical construction, which this interface should hide!
 void setTravelSpeed(double speed)
          Sets the speed at which the robot will travel forward and backward (and to some extent arcs, although actual arc speed is slightly less).
 void spinningMove(float linSpeed, int angSpeed, int direction)
          Causes the robot to spin while moving along a linear path.
 void steer(float turnRate)
          Steer.
 void steer(float linSpeed, float angSpeed)
          Steer.
 void steer(float turnRate, float angle, boolean immediateReturn)
          Steer.
 void stop()
          Halts the NXT robot
 void travel(double distance)
          Moves the NXT robot a specific distance.
 void travel(double distance, boolean immediateReturn)
          Moves the NXT robot a specific distance.
 void travel(double distance, double direction)
          This method causes the robot to travel in a linear path, similar to other travel() methods, except you can specify which direction to move (relative to the current robot heading).
 void travel(double distance, double direction, boolean immediateReturn)
          This method causes the robot to travel in a linear path, similar to other travel() methods, except you can specify which direction to move (relative to the current robot heading).
 void travelArc(double radius, double distance)
          Moves the NXT robot a specified distance along an arc of specified radius, after which the robot stops moving.
 void travelArc(double radius, double distance, boolean immediateReturn)
          Moves the NXT robot a specified distance along an arc of specified radius, after which the robot stops moving.
 void travelArc(double radius, double distance, float direction)
          This method moves the robot in an arc, similar to the other travelArc(double, double) methods, except you can choose any of the 360 degree directions relative to the current heading (0) of the robot, while keeping the heading of the robot pointed in the same direction during the move.
 void travelArc(double radius, double distance, float direction, boolean immediateReturn)
          This method moves the robot in an arc, similar to the other travelArc(double, double) methods, except you can choose any of the 360 degree directions relative to the current heading (0) of the robot, while keeping the heading of the robot pointed in the same direction during the move.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OmniPilot

public OmniPilot(float wheelDistanceFromCenter,
                 float wheelDiameter,
                 RegulatedMotor centralMotor,
                 RegulatedMotor CW120degMotor,
                 RegulatedMotor CCW120degMotor,
                 boolean centralWheelFrontal,
                 boolean motorReverse)
Instantiates a new omnidirectional pilot. This class also keeps track of the odometry Express the distances in the units you prefer (mm, in, cm ...)

Parameters:
wheelDistanceFromCenter - the wheel distance from center
wheelDiameter - the wheel diameter
centralMotor - the central motor
CW120degMotor - the motor at 120 degrees clockwise from front
CCW120degMotor - the motor at 120 degrees counter-clockwise from front
centralWheelFrontal - if true, the central wheel frontal else it is facing back
motorReverse - if motors are mounted reversed

OmniPilot

public OmniPilot(float wheelDistanceFromCenter,
                 float wheelDiameter,
                 RegulatedMotor centralMotor,
                 RegulatedMotor CW120degMotor,
                 RegulatedMotor CCW120degMotor,
                 boolean centralWheelFrontal,
                 boolean motorReverse,
                 SensorPort gyroPort)
Instantiates a new omnidirectional pilot. This class also keeps track of the odometry Express the distances in the units you prefer (mm, in, cm ...) This constructor allows you to add a cruizcore gyro for accurate odometry and spinning

Parameters:
wheelDistanceFromCenter - the wheel distance from center
wheelDiameter - the wheel diameter
centralMotor - the central motor
CW120degMotor - the motor at 120 degrees clockwise from front
CCW120degMotor - the motor at 120 degrees counter-clockwise from front
centralWheelFrontal - if true, the central wheel frontal else it is facing back
motorReverse - if motors are mounted reversed
gyroPort - the gyro port
Method Detail

setAcceleration

public void setAcceleration(int accel)
Sets the acceleration.

Parameters:
accel - the new acceleration

forward

public void forward()
Description copied from interface: MoveController
Starts the NXT robot moving forward.

Specified by:
forward in interface MoveController

backward

public void backward()
Description copied from interface: MoveController
Starts the NXT robot moving backwards.

Specified by:
backward in interface MoveController

moveStraight

public void moveStraight(float linSpeed,
                         int direction)
This method causes the robot to move in a direction while keeping the front of the robot pointed in the current direction it is facing.

Parameters:
linSpeed - the lin speed
direction - the direction relative to the current direction the robot is facing

spinningMove

public void spinningMove(float linSpeed,
                         int angSpeed,
                         int direction)
Causes the robot to spin while moving along a linear path. This method is similar to moveStraight(float, int) except the robot will spin instead of holding the robot in the current direction.

Parameters:
linSpeed - the linear speed [units/s]
angSpeed - the angular speed [deg/s]
direction - the direction [deg]

stop

public void stop()
Description copied from interface: MoveController
Halts the NXT robot

Specified by:
stop in interface MoveController

isMoving

public boolean isMoving()
Description copied from interface: MoveController
true if the robot is moving

Specified by:
isMoving in interface MoveController
Returns:
true if the robot is moving under power.

setTravelSpeed

public void setTravelSpeed(double speed)
Description copied from interface: MoveController
Sets the speed at which the robot will travel forward and backward (and to some extent arcs, although actual arc speed is slightly less). Speed is measured in units/second. e.g. If wheel diameter is cm, then speed is cm/sec.

Specified by:
setTravelSpeed in interface MoveController
Parameters:
speed - In chosen units per second (e.g. cm/sec)

getTravelSpeed

public double getTravelSpeed()
Description copied from interface: MoveController
Returns the speed at which the robot will travel forward and backward (and to some extent arcs, although actual arc speed is slightly less). Speed is measured in units/second. e.g. If wheel diameter is cm, then speed is cm/sec.

Specified by:
getTravelSpeed in interface MoveController
Returns:
Speed in chosen units per second (e.g. cm/sec)

setMoveDirection

public void setMoveDirection(int dir)
Sets the move direction. This value is then used by subsequent calls to steer(float) (all three overloaded methods).

Parameters:
dir - the new move direction

getMoveDirection

public float getMoveDirection()
Gets the move direction.

Returns:
the move direction

getMaxTravelSpeed

public double getMaxTravelSpeed()
Description copied from interface: MoveController
Returns the maximum speed at which this robot is capable of traveling forward and backward. Speed is measured in units/second. e.g. If wheel diameter is cm, then speed is cm/sec.

Specified by:
getMaxTravelSpeed in interface MoveController
Returns:
Speed in chosen units per second (e.g. cm/sec)

setRotateSpeed

public void setRotateSpeed(double speed)
Description copied from interface: RotateMoveController
sets the rotation speed of the robot (the angular velocity of the rotate() methods)

Specified by:
setRotateSpeed in interface RotateMoveController
Parameters:
speed - in degrees per second

getRotateSpeed

public double getRotateSpeed()
Description copied from interface: RotateMoveController
Returns the value of the rotation speed

Specified by:
getRotateSpeed in interface RotateMoveController
Returns:
the rotate speed in degrees per second

getRotateMaxSpeed

public double getRotateMaxSpeed()
Description copied from interface: RotateMoveController
returns the maximum value of the rotation speed;

Specified by:
getRotateMaxSpeed in interface RotateMoveController
Returns:
max rotation speed

travel

public void travel(double distance)
Description copied from interface: MoveController
Moves the NXT robot a specific distance. A positive value moves it forward and a negative value moves it backward. Method returns when movement is done.

Specified by:
travel in interface MoveController
Parameters:
distance - The positive or negative distance to move the robot.

travel

public void travel(double distance,
                   double direction)
This method causes the robot to travel in a linear path, similar to other travel() methods, except you can specify which direction to move (relative to the current robot heading). NOTE: This method is not part of the MoveController interface.

Parameters:
distance -
direction -

travel

public void travel(double distance,
                   boolean immediateReturn)
Description copied from interface: MoveController
Moves the NXT robot a specific distance. A positive value moves it forward and a negative value moves it backward.

Specified by:
travel in interface MoveController
Parameters:
distance - The positive or negative distance to move the robot, in wheel diameter units.
immediateReturn - If immediateReturn is true then the method returns immediately.

travel

public void travel(double distance,
                   double direction,
                   boolean immediateReturn)
This method causes the robot to travel in a linear path, similar to other travel() methods, except you can specify which direction to move (relative to the current robot heading). NOTE: This method is not part of the MoveController interface.

Parameters:
distance -
direction -
immediateReturn -

rotate

public void rotate(double angle)
Description copied from interface: RotateMoveController
Rotates the NXT robot the specified number of degrees; direction determined by the sign of the parameter. Method returns when rotation is done.

Specified by:
rotate in interface RotateMoveController
Parameters:
angle - The angle to rotate in degrees. A positive value rotates left, a negative value right (clockwise).

rotate

public void rotate(double angle,
                   boolean immediateReturn)
Description copied from interface: RotateMoveController
Rotates the NXT robot the specified number of degrees; direction determined by the sign of the parameter. Motion stops when rotation is done.

Specified by:
rotate in interface RotateMoveController
Parameters:
angle - The angle to rotate in degrees. A positive value rotates left, a negative value right (clockwise).
immediateReturn - If immediateReturn is true then the method returns immediately

steer

public void steer(float turnRate)
Steer.

Parameters:
turnRate - the turn rate

steer

public void steer(float linSpeed,
                  float angSpeed)
Steer.

Parameters:
linSpeed - the lin speed
angSpeed - the ang speed

steer

public void steer(float turnRate,
                  float angle,
                  boolean immediateReturn)
Steer.

Parameters:
turnRate - the turn rate
angle - the angle
immediateReturn - the immediate return

travelArc

public void travelArc(double radius,
                      double distance)
Description copied from interface: ArcMoveController
Moves the NXT robot a specified distance along an arc of specified radius, after which the robot stops moving. This method does not return until the robot has completed moving distance along the arc. The units (inches, cm) for distance must be the same as the units used for radius.

If radius is positive, the robot arcs left, and the center of the turning circle is on the left side of the robot.
If radius is negative, the robot arcs right, and the center of the turning circle is on the right side of the robot.
If radius is zero, the robot rotates in place

The robot will stop when it has moved along the arc distance units.
If distance is positive, the robot will move travel forwards.
If distance is negative, the robot will move travel backwards.
If distance is zero, the robot will not move and the method returns immediately.

Postcondition: Motor speeds are unpredictable.

Specified by:
travelArc in interface ArcMoveController
Parameters:
radius - of the arc path. If positive, the left side of the robot is on the inside of the turn. If negative, the left side of the robot is on the outside of the turn.
distance - to travel, in same units as radius. The sign of the distance determines the direction of robot motion. Positive drives the robot forward, negative drives it backward.
See Also:
ArcMoveController.arc(double, double)

travelArc

public void travelArc(double radius,
                      double distance,
                      boolean immediateReturn)
Description copied from interface: ArcMoveController
Moves the NXT robot a specified distance along an arc of specified radius, after which the robot stops moving. This method has the ability to return immediately by using the immediateReturn parameter. The units (inches, cm) for distance should be the same as the units used for radius.

If radius is positive, the robot arcs left, and the center of the turning circle is on the left side of the robot.
If radius is negative, the robot arcs right, and the center of the turning circle is on the right side of the robot.
If radius is zero, the robot rotates in place.

The robot will stop when it has moved along the arc distance units.
If distance is positive, the robot will move travel forwards.
If distance is negative, the robot will move travel backwards.
If distance is zero, the robot will not move and the method returns immediately.

Postcondition: Motor speeds are unpredictable.

Specified by:
travelArc in interface ArcMoveController
Parameters:
radius - of the arc path. If positive, the left side of the robot is on the inside of the turn. If negative, the left side of the robot is on the outside of the turn.
distance - to travel, in same units as radius. The sign of the distance determines the direction of robot motion. Positive drives the robot forward, negative drives it backward.
immediateReturn - If immediateReturn is true then the method returns immediately.
See Also:
ArcMoveController.arc(double, double, boolean)

travelArc

public void travelArc(double radius,
                      double distance,
                      float direction)
This method moves the robot in an arc, similar to the other travelArc(double, double) methods, except you can choose any of the 360 degree directions relative to the current heading (0) of the robot, while keeping the heading of the robot pointed in the same direction during the move. NOTE: This method is not part of the MoveController interface.

Parameters:
radius -
distance -
direction -

travelArc

public void travelArc(double radius,
                      double distance,
                      float direction,
                      boolean immediateReturn)
This method moves the robot in an arc, similar to the other travelArc(double, double) methods, except you can choose any of the 360 degree directions relative to the current heading (0) of the robot, while keeping the heading of the robot pointed in the same direction during the move. NOTE: This method is not part of the MoveController interface.

Parameters:
radius -
distance -
direction -
immediateReturn -

arc

public void arc(double radius,
                double angle)
Description copied from interface: ArcMoveController
Moves the NXT robot along an arc with a specified radius and angle, after which the robot stops moving. This method does not return until the robot has completed moving angle degrees along the arc.

If radius is positive, the robot arcs left, and the center of the turning circle is on the left side of the robot.
If radius is negative, the robot arcs right, and the center of the turning circle is on the right side of the robot.
If radius is zero, is zero, the robot rotates in place.

Robot will stop when the degrees it has moved along the arc equals angle.
If angle is positive, the robot will move travel forwards.
If angle is negative, the robot will move travel backwards. If angle is zero, the robot will not move and the method returns immediately.

Postcondition: Motor speeds are unpredictable.

Note: If you have specified a drift correction in the constructor it will not be applied in this method.

Specified by:
arc in interface ArcMoveController
Parameters:
radius - of the arc path. If positive, the left side of the robot is on the inside of the turn. If negative, the left side of the robot is on the outside of the turn.
angle - The sign of the angle determines the direction of robot motion. Positive drives the robot forward, negative drives it backward.
See Also:
ArcMoveController.travelArc(double, double)

arc

public void arc(double radius,
                double angle,
                double direction)
This method moves the robot in an arc, similar to the other arc(double, double) methods, except you can choose any of the 360 degree directions relative to the current heading (0) of the robot, while keeping the heading of the robot pointed in the same direction during the move. NOTE: This method is not part of the MoveController interface.

Parameters:
radius -
angle -
direction -

arc

public void arc(double radius,
                double angle,
                boolean immediateReturn)
Description copied from interface: ArcMoveController
Moves the NXT robot along an arc with a specified radius and angle, after which the robot stops moving. This method has the ability to return immediately by using the immediateReturn parameter.

If radius is positive, the robot arcs left, and the center of the turning circle is on the left side of the robot.
If radius is negative, the robot arcs right, and the center of the turning circle is on the right side of the robot.
If radius is zero, is zero, the robot rotates in place.

The robot will stop when the degrees it has moved along the arc equals angle.
If angle is positive, the robot will move travel forwards.
If angle is negative, the robot will move travel backwards. If angle is zero, the robot will not move and the method returns immediately.

Postcondition: Motor speeds are unpredictable.

Note: If you have specified a drift correction in the constructor it will not be applied in this method.

Specified by:
arc in interface ArcMoveController
Parameters:
radius - of the arc path. If positive, the left side of the robot is on the inside of the turn. If negative, the left side of the robot is on the outside of the turn.
angle - The sign of the angle determines the direction of robot motion. Positive drives the robot forward, negative drives it backward.
immediateReturn - If immediateReturn is true then the method returns immediately.
See Also:
ArcMoveController.travelArc(double, double, boolean)

arc

public void arc(double radius,
                double angle,
                double direction,
                boolean immediateReturn)
This method moves the robot in an arc, similar to the other arc(double, double) methods, except you can choose any of the 360 degree directions relative to the current heading (0) of the robot, while keeping the heading of the robot pointed in the same direction during the move. NOTE: This method is not part of the MoveController interface.

Parameters:
radius -
angle -
direction -
immediateReturn -

reset

public void reset()
Reset all tacho counts. TODO: Delete this method? Unused by any other method or class.


setSpeed

@Deprecated
public void setSpeed(int speed)
Deprecated. in 0.8, use setRotateSpeed() and setTravelSpeed(). The method was deprecated, as this it requires knowledge of the robots physical construction, which this interface should hide!

Sets drive motor speed.

Parameters:
speed - the new speed

arcBackward

public void arcBackward(double radius)
Description copied from interface: ArcMoveController
Starts the NXT robot moving backward along an arc with a specified radius.

If radius is positive, the robot arcs left, and the center of the turning circle is on the left side of the robot.
If radius is negative, the robot arcs right, and the center of the turning circle is on the right side of the robot.
If radius is zero, the robot rotates in place.

Postcondition: Motor speeds are unpredictable.

Note: If you have specified a drift correction in the constructor it will not be applied in this method.

Specified by:
arcBackward in interface ArcMoveController
Parameters:
radius - of the arc path. If positive, the left side of the robot is on the inside of the turn. If negative, the left side of the robot is on the outside of the turn.

arcForward

public void arcForward(double radius)
Description copied from interface: ArcMoveController
Starts the NXT robot moving forward along an arc with a specified radius.

If radius is positive, the robot arcs left, and the center of the turning circle is on the left side of the robot.
If radius is negative, the robot arcs right, and the center of the turning circle is on the right side of the robot.
If radius is zero, the robot rotates in place.

Postcondition: Motor speeds are unpredictable.

Note: If you have specified a drift correction in the constructor it will not be applied in this method.

Specified by:
arcForward in interface ArcMoveController
Parameters:
radius - of the arc path. If positive, the left side of the robot is on the inside of the turn. If negative, the left side of the robot is on the outside of the turn.

getMinRadius

public double getMinRadius()
Description copied from interface: ArcMoveController
The minimum steering radius this vehicle is capable of when traveling in an arc. Theoretically this should be identical for both forward and reverse travel. In practice?

Specified by:
getMinRadius in interface ArcMoveController
Returns:
the radius in degrees

setMinRadius

public void setMinRadius(double radius)
Description copied from interface: ArcMoveController
Set the radius of the minimum turning circle.

Specified by:
setMinRadius in interface ArcMoveController
Parameters:
radius - the radius in degrees

addMoveListener

public void addMoveListener(MoveListener listener)
Description copied from interface: MoveProvider
Adds a MoveListener that will be notified of all movement events.

Specified by:
addMoveListener in interface MoveProvider
Parameters:
listener - the move listener

getMovement

public Move getMovement()
Description copied from interface: MoveProvider
Returns the move made since the move started, but before it has completed. This method is used by GUI maps to display the movement of a robot in real time. The robot must be capable of determining the move while it is in motion.

Specified by:
getMovement in interface MoveProvider
Returns:
The move made since the move started.

rotationStarted

public void rotationStarted(RegulatedMotor motor,
                            int tachoCount,
                            boolean stalled,
                            long timeStamp)
Description copied from interface: RegulatedMotorListener
Called when the motor starts rotating.

Specified by:
rotationStarted in interface RegulatedMotorListener

rotationStopped

public void rotationStopped(RegulatedMotor motor,
                            int tachoCount,
                            boolean stalled,
                            long timeStamp)
Notify the MoveListeners when a move is completed.

Specified by:
rotationStopped in interface RegulatedMotorListener