icommand.navigation
Class CompassPilot

java.lang.Object
  extended by icommand.navigation.Pilot
      extended by icommand.navigation.CompassPilot

public class CompassPilot
extends Pilot

The iCommand CompassPilot is simpler than the NXJ CompassPilot. This version rotates using the compass but does not move forward/backward with compass assistance.

Author:
BB

Field Summary
protected  CompassSensor compass
           
 
Fields inherited from class icommand.navigation.Pilot
_degPerDistance, _left, _right, _speed, _trackWidth, _wheelDiameter
 
Constructor Summary
CompassPilot(CompassSensor compass, double wheelDiameter, double trackWidth, Motor leftMotor, Motor rightMotor)
          Allocates a CompasPilot object, and sets the physical parameters of the NXT robot.
CompassPilot(CompassSensor compass, double wheelDiameter, double trackWidth, Motor leftMotor, Motor rightMotor, boolean reverse)
          Allocates a CompasPilot object, and sets the physical parameters of the NXT robot.
CompassPilot(SensorPort compassPort, double wheelDiameter, double trackWidth, Motor leftMotor, Motor rightMotor)
          Allocates a CompasPilot object, and sets the physical parameters of the NXT robot.
CompassPilot(SensorPort compassPort, double wheelDiameter, double trackWidth, Motor leftMotor, Motor rightMotor, boolean reverse)
          Allocates a CompasPilot object, and sets the physical parameters of the NXT robot.
 
Method Summary
 void calibrate()
          Slowly rotates twice while in calibration mode.
 int getAngle()
          returns the angle of rotation of the robot since last call to reset of tacho count;
 void rotate(int angle, boolean immediateReturn)
          The rotate method takes a current reading from the compass then rotates the desired number of degrees.
 void rotateTo(int heading)
          robot rotates to the specified compass heading;
 void rotateTo(int angle, boolean immediateReturn)
          robot rotates to the specified compass heading;
 
Methods inherited from class icommand.navigation.Pilot
backward, forward, getLeftCount, getRightCount, getSpeed, getTravelDistance, getTurnRatio, isMoving, resetTachoCount, rotate, setSpeed, steer, steer, steer, stop, travel, travel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

compass

protected CompassSensor compass
Constructor Detail

CompassPilot

public CompassPilot(SensorPort compassPort,
                    double wheelDiameter,
                    double trackWidth,
                    Motor leftMotor,
                    Motor rightMotor)
Allocates a CompasPilot object, and sets the physical parameters of the NXT robot.
Assumes Motor.forward() causes the robot to move forward);

Parameters:
compassPort - the sensor port connected to the CompassSensor e.g. SensorPort.S1
wheelDiameter - Diameter of the tire, in any convenient units. (The 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

CompassPilot

public CompassPilot(SensorPort compassPort,
                    double wheelDiameter,
                    double trackWidth,
                    Motor leftMotor,
                    Motor rightMotor,
                    boolean reverse)
Allocates a CompasPilot object, and sets the physical parameters of the NXT robot.
Assumes Motor.forward() causes the robot to move forward); Parameters

Parameters:
compassPort - : the compass sensor is connected to this port;
wheelDiameter - Diameter of the tire, in any convenient units. (The 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 -
rightMotor -
reverse - if true of motor.forward() drives the robot backwards

CompassPilot

public CompassPilot(CompassSensor compass,
                    double wheelDiameter,
                    double trackWidth,
                    Motor leftMotor,
                    Motor rightMotor)
Allocates a CompasPilot object, and sets the physical parameters of the NXT robot.
Assumes Motor.forward() causes the robot to move forward); Parameters

Parameters:
compass - : a compass sensor;
wheelDiameter - Diameter of the tire, in any convenient units. (The 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 -
rightMotor -

CompassPilot

public CompassPilot(CompassSensor compass,
                    double wheelDiameter,
                    double trackWidth,
                    Motor leftMotor,
                    Motor rightMotor,
                    boolean reverse)
Allocates a CompasPilot object, and sets the physical parameters of the NXT robot.
Assumes Motor.forward() causes the robot to move forward); Parameters

Parameters:
compass - : a compass sensor;
wheelDiameter - Diameter of the tire, in any convenient units. (The 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 -
rightMotor -
reverse - if true of motor.forward() drives the robot backwards
Method Detail

calibrate

public void calibrate()
Slowly rotates twice while in calibration mode.


rotateTo

public void rotateTo(int angle,
                     boolean immediateReturn)
robot rotates to the specified compass heading;

Parameters:
angle - Desired compass heading
immediateReturn - if TRUE, method returns immediately; robot stops facing in specified direction

rotateTo

public void rotateTo(int heading)
robot rotates to the specified compass heading;

Parameters:
heading - Desired compass heading

getAngle

public int getAngle()
Description copied from class: Pilot
returns the angle of rotation of the robot since last call to reset of tacho count;

Overrides:
getAngle in class Pilot

rotate

public void rotate(int angle,
                   boolean immediateReturn)
The rotate method takes a current reading from the compass then rotates the desired number of degrees. NOTE: immediateReturn is not functional currently (always waits until done rotating).

Overrides:
rotate in class Pilot
Parameters:
angle - degrees. Positive angle rotates to the left; negative to the right.
Requires correct values for wheel diameter and track width.
immediateReturn - if true this method returns immediately


Copyright © 2006. All Rights Reserved.