lejos.robotics.navigation
Class LegacyPilot

java.lang.Object
  extended by lejos.robotics.navigation.LegacyPilot

Deprecated. This class will disappear in NXJ version 1.0. Use an implementing class of MoveController instead.

@Deprecated
public class LegacyPilot
extends Object

The LegacyPilot class is a renamed version the TachoPilot class in the 0.85 release. It is a software abstraction of a NXT robot with two independently controlled wheels, on opposite sides of the robot, with colinear axles. This design permits the robot to rotate within its own footprint (i.e. turn on one spot without changing its location).
It contains methods to control basic robot movements: travel forward or backward in a straight line or a circular path or rotate to a new direction.
It can be used with robots that have reversed motor design: the robot moves in the direction opposite to the the direction of motor rotation.
About angles: LegacyPilot uses the Navigation package standard mathematical convention for angles in the plane. The direction of the X axis is 0 degrees, the direction of the Y axis is 90 degrees. Therefore, a positive angle is a counter clockwise change of direction, and a negative angle is clockwise.
Some methods optionally return immediately so the thread that called the method can monitor sensors and call stop() if necessary.
Example:

 LegacyPilot pilot = new LegacyPilot(2.1f, 4.4f, Motor.A, Motor.C, true);  // parameters in inches
 pilot.setTravelSpeed(10);                                           // inches per second
 pilot.travel(12);                                                  // inches
 pilot.rotate(-90);                                                 // degree clockwise
 pilot.travel(-12,true);
 while(pilot.isMoving())Thread.yield();
 pilot.steer(-50,180,true);
 while(pilot.isMoving())Thread.yield();
 pilot.steer(100);
 Delay.msDelay(1000);
 pilot.stop();
 

Note: if you are sure you do not want to use any other part of navigation you can as well use "LegacyPilot pilot = new LegacyPilot(...)" instead of "LegacyPilot pilot = new LegacyPilot(...)"

See Also:
MoveController

Field Summary
protected  RegulatedMotor _inside
          Deprecated. The motor at the inside of the turn.
protected  RegulatedMotor _left
          Deprecated. Left motor.
protected  float _leftDegPerDistance
          Deprecated. Left motor degrees per unit of travel.
protected  float _leftTurnRatio
          Deprecated. Left motor revolutions for 360 degree rotation of robot (motors running in opposite directions).
protected  float _leftWheelDiameter
          Deprecated. Diameter of left wheel.
protected  int _motorSpeed
          Deprecated. Motor speed degrees per second.
protected  RegulatedMotor _outside
          Deprecated. The motor at the outside of the turn.
protected  RegulatedMotor _right
          Deprecated. Right motor.
protected  float _rightDegPerDistance
          Deprecated. Right motor degrees per unit of travel.
protected  float _rightTurnRatio
          Deprecated. Right motor revolutions for 360 degree rotation of robot (motors running in opposite directions).
protected  float _rightWheelDiameter
          Deprecated. Diameter of right wheel.
protected  float _robotRotateSpeed
          Deprecated. Speed of robot for turning in degree per seconds.
protected  float _robotTravelSpeed
          Deprecated. Speed of robot for moving in wheel diameter units per seconds.
protected  float _steerRatio
          Deprecated. ratio of inside/outside motor speeds set by steer(turnRate) used by other steer methods;
protected  float _trackWidth
          Deprecated. Distance between wheels.
 
Constructor Summary
LegacyPilot(float leftWheelDiameter, float rightWheelDiameter, float trackWidth, RegulatedMotor leftMotor, RegulatedMotor rightMotor, boolean reverse)
          Deprecated. Allocates a LegacyPilot object, and sets the physical parameters of the NXT robot.
LegacyPilot(float wheelDiameter, float trackWidth, RegulatedMotor leftMotor, RegulatedMotor rightMotor)
          Deprecated. Allocates a LegacyPilot object, and sets the physical parameters of the NXT robot.
Assumes Motor.forward() causes the robot to move forward.
LegacyPilot(float wheelDiameter, float trackWidth, RegulatedMotor leftMotor, RegulatedMotor rightMotor, boolean reverse)
          Deprecated. Allocates a LegacyPilot object, and sets the physical parameters of the NXT robot.
 
Method Summary
 void arc(float radius)
          Deprecated.  
 void arc(float radius, float angle)
          Deprecated.  
 void arc(float radius, float angle, boolean immediateReturn)
          Deprecated.  
 void backward()
          Deprecated.  
 void forward()
          Deprecated.  
 float getAngle()
          Deprecated.  
 RegulatedMotor getLeft()
          Deprecated. Returns the left motor.
 int getLeftCount()
          Deprecated. Returns the tachoCount of the left motor
 float getMaxRotateSpeed()
          Deprecated.  
 float getMaxTravelSpeed()
          Deprecated.  
 float getMoveMaxSpeed()
          Deprecated. 
 float getMoveSpeed()
          Deprecated. 
 RegulatedMotor getRight()
          Deprecated. returns the right motor.
 int getRightCount()
          Deprecated. Returns the tachoCount of the right motor
 float getRotateSpeed()
          Deprecated.  
 float getTravelDistance()
          Deprecated.  
 float getTravelSpeed()
          Deprecated.  
 float getTurnRatio()
          Deprecated. Returns the ratio of motor revolutions per 360 degree rotation of the robot
 float getTurnSpeed()
          Deprecated. 
 boolean isMoving()
          Deprecated.  
 void reset()
          Deprecated. Resets tacho count for both motors.
 void rotate(float angle)
          Deprecated.  
 void rotate(float angle, boolean immediateReturn)
          Deprecated.  
 void setMoveSpeed(float speed)
          Deprecated. 
 void setRotateSpeed(float rotateSpeed)
          Deprecated.  
 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(float travelSpeed)
          Deprecated. also sets _motorSpeed
 void setTurnSpeed(float speed)
          Deprecated. 
 boolean stalled()
          Deprecated.  
 void steer(float turnRate)
          Deprecated.  
 void steer(float turnRate, float angle)
          Deprecated.  
 void steer(float turnRate, float angle, boolean immediateReturn)
          Deprecated.  
protected  void steerPrep(float turnRate)
          Deprecated. helper method used by steer(float) and steer(float,float,boolean)
 void stop()
          Deprecated. Stops the NXT robot.
 void travel(float distance)
          Deprecated. Moves the NXT robot a specific distance in an (hopefully) straight line.
A positive distance causes forward motion, a negative distance moves backward.
 void travel(float distance, boolean immediateReturn)
          Deprecated. Moves the NXT robot a specific distance in an (hopefully) straight line.
A positive distance causes forward motion, a negative distance moves backward.
 void travelArc(float radius, float distance)
          Deprecated.  
 void travelArc(float radius, float distance, boolean immediateReturn)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_left

protected final RegulatedMotor _left
Deprecated. 
Left motor.


_right

protected final RegulatedMotor _right
Deprecated. 
Right motor.


_inside

protected RegulatedMotor _inside
Deprecated. 
The motor at the inside of the turn. set by steer(turnRate) used by other steer methods


_outside

protected RegulatedMotor _outside
Deprecated. 
The motor at the outside of the turn. set by steer(turnRate) used by other steer methods


_steerRatio

protected float _steerRatio
Deprecated. 
ratio of inside/outside motor speeds set by steer(turnRate) used by other steer methods;


_leftDegPerDistance

protected final float _leftDegPerDistance
Deprecated. 
Left motor degrees per unit of travel.


_rightDegPerDistance

protected final float _rightDegPerDistance
Deprecated. 
Right motor degrees per unit of travel.


_leftTurnRatio

protected final float _leftTurnRatio
Deprecated. 
Left motor revolutions for 360 degree rotation of robot (motors running in opposite directions). Calculated from wheel diameter and track width. Used by rotate() and steer() methods.


_rightTurnRatio

protected final float _rightTurnRatio
Deprecated. 
Right motor revolutions for 360 degree rotation of robot (motors running in opposite directions). Calculated from wheel diameter and track width. Used by rotate() and steer() methods.


_robotTravelSpeed

protected float _robotTravelSpeed
Deprecated. 
Speed of robot for moving in wheel diameter units per seconds. Set by setSpeed(), setTravelSpeed()


_robotRotateSpeed

protected float _robotRotateSpeed
Deprecated. 
Speed of robot for turning in degree per seconds.


_motorSpeed

protected int _motorSpeed
Deprecated. 
Motor speed degrees per second. Used by forward(),backward() and steer().


_trackWidth

protected final float _trackWidth
Deprecated. 
Distance between wheels. Used in steer() and rotate().


_leftWheelDiameter

protected final float _leftWheelDiameter
Deprecated. 
Diameter of left wheel.


_rightWheelDiameter

protected final float _rightWheelDiameter
Deprecated. 
Diameter of right wheel.

Constructor Detail

LegacyPilot

public LegacyPilot(float wheelDiameter,
                   float trackWidth,
                   RegulatedMotor leftMotor,
                   RegulatedMotor rightMotor)
Deprecated. 
Allocates a LegacyPilot object, and sets the physical parameters of the NXT robot.
Assumes Motor.forward() causes the robot to move forward.

Parameters:
wheelDiameter - Diameter of the tire, in any convenient units (diameter in mm is usually printed on the tire).
trackWidth - Distance between center of right tire and center of left tire, in same units as wheelDiameter.
leftMotor - The left Motor (e.g., Motor.C).
rightMotor - The right Motor (e.g., Motor.A).

LegacyPilot

public LegacyPilot(float wheelDiameter,
                   float trackWidth,
                   RegulatedMotor leftMotor,
                   RegulatedMotor rightMotor,
                   boolean reverse)
Deprecated. 
Allocates a LegacyPilot object, and sets the physical parameters of the NXT robot.

Parameters:
wheelDiameter - Diameter of the tire, in any convenient units (diameter in mm is usually printed on the tire).
trackWidth - Distance between center of right tire and center of left tire, in same units as wheelDiameter.
leftMotor - The left Motor (e.g., Motor.C).
rightMotor - The right Motor (e.g., Motor.A).
reverse - If true, the NXT robot moves forward when the motors are running backward.

LegacyPilot

public LegacyPilot(float leftWheelDiameter,
                   float rightWheelDiameter,
                   float trackWidth,
                   RegulatedMotor leftMotor,
                   RegulatedMotor rightMotor,
                   boolean reverse)
Deprecated. 
Allocates a LegacyPilot object, and sets the physical parameters of the NXT robot.

Parameters:
leftWheelDiameter - Diameter of the left wheel, in any convenient units (diameter in mm is usually printed on the tire).
rightWheelDiameter - Diameter of the right wheel. You can actually fit intentionally wheels with different size to your robot. If you fitted wheels with the same size, but your robot is not going straight, try swapping the wheels and see if it deviates into the other direction. That would indicate a small difference in wheel size. Adjust wheel size accordingly. The minimum change in wheel size which will actually have an effect is given by minChange = A*wheelDiameter*wheelDiameter/(1-(A*wheelDiameter) where A = PI/(TravelSpeed*360). Thus for a TravelSpeed of 25 cm/second and a wheelDiameter of 5,5 cm the minChange is about 0,01058 cm. The reason for this is, that different while sizes will result in different motor speed. And that is given as an integer in degree per second.
trackWidth - Distance between center of right tire and center of left tire, in same units as wheelDiameter.
leftMotor - The left Motor (e.g., Motor.C).
rightMotor - The right Motor (e.g., Motor.A).
reverse - If true, the NXT robot moves forward when the motors are running backward.
Method Detail

getLeft

public RegulatedMotor getLeft()
Deprecated. 
Returns the left motor.

Returns:
left motor.

getRight

public RegulatedMotor getRight()
Deprecated. 
returns the right motor.

Returns:
right motor.

getLeftCount

public int getLeftCount()
Deprecated. 
Returns the tachoCount of the left motor

Returns:
tachoCount of left motor. Positive value means motor has moved the robot forward.

getRightCount

public int getRightCount()
Deprecated. 
Returns the tachoCount of the right motor

Returns:
tachoCount of the right motor. Positive value means motor has moved the robot forward.

getTurnRatio

public float getTurnRatio()
Deprecated. 
Returns the ratio of motor revolutions per 360 degree rotation of the robot

Returns:
ratio of motor revolutions per 360 degree rotation of the robot. If your robot has wheels with different size, it is the average.

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 speed of the drive motor(s) in degree per second.

setMoveSpeed

@Deprecated
public void setMoveSpeed(float speed)
Deprecated. 

use setTravelSpeed()


setTravelSpeed

public void setTravelSpeed(float travelSpeed)
Deprecated. 
also sets _motorSpeed


getTravelSpeed

public float getTravelSpeed()
Deprecated. 

getMoveSpeed

@Deprecated
public float getMoveSpeed()
Deprecated. 

use getTraveleSpeed()


getMaxTravelSpeed

public float getMaxTravelSpeed()
Deprecated. 

getMoveMaxSpeed

@Deprecated
public float getMoveMaxSpeed()
Deprecated. 

use getMoveMaxSpeed()


setRotateSpeed

public void setRotateSpeed(float rotateSpeed)
Deprecated. 

setTurnSpeed

@Deprecated
public void setTurnSpeed(float speed)
Deprecated. 

use setRotateSpeed()


getTurnSpeed

@Deprecated
public float getTurnSpeed()
Deprecated. 

use getRotateSpeed()


getRotateSpeed

public float getRotateSpeed()
Deprecated. 

getMaxRotateSpeed

public float getMaxRotateSpeed()
Deprecated. 

forward

public void forward()
Deprecated. 

backward

public void backward()
Deprecated. 

rotate

public void rotate(float angle)
Deprecated. 

rotate

public void rotate(float angle,
                   boolean immediateReturn)
Deprecated. 

getAngle

public float getAngle()
Deprecated. 
Returns:
the angle of rotation of the robot since last call to reset of tacho count;

stop

public void stop()
Deprecated. 
Stops the NXT robot.


isMoving

public boolean isMoving()
Deprecated. 
Returns:
true if the NXT robot is moving.

reset

public void reset()
Deprecated. 
Resets tacho count for both motors.


getTravelDistance

public float getTravelDistance()
Deprecated. 
Returns:
distance traveled since last reset of tacho count.

travel

public void travel(float distance)
Deprecated. 
Moves the NXT robot a specific distance in an (hopefully) straight line.
A positive distance causes forward motion, a negative distance moves backward. If a drift correction has been specified in the constructor it will be applied to the left motor.

Parameters:
distance - The distance to move. Unit of measure for distance must be same as wheelDiameter and trackWidth.

travel

public void travel(float distance,
                   boolean immediateReturn)
Deprecated. 
Moves the NXT robot a specific distance in an (hopefully) straight line.
A positive distance causes forward motion, a negative distance moves backward. If a drift correction has been specified in the constructor it will be applied to the left motor.

Parameters:
distance - The distance to move. Unit of measure for distance must be same as wheelDiameter and trackWidth.
immediateReturn - If true this method returns immediately.

steerPrep

protected void steerPrep(float turnRate)
Deprecated. 
helper method used by steer(float) and steer(float,float,boolean)

Parameters:
turnRate -

steer

public void steer(float turnRate)
Deprecated. 

steer

public void steer(float turnRate,
                  float angle)
Deprecated. 

steer

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

stalled

public boolean stalled()
Deprecated. 

arc

public void arc(float radius)
Deprecated. 

arc

public void arc(float radius,
                float angle)
Deprecated. 

arc

public void arc(float radius,
                float angle,
                boolean immediateReturn)
Deprecated. 

travelArc

public void travelArc(float radius,
                      float distance)
Deprecated. 

travelArc

public void travelArc(float radius,
                      float distance,
                      boolean immediateReturn)
Deprecated.