RoboJDETM v2.0

com.ridgesoft.robotics
Class OdometricLocalizer

java.lang.Object
  extended by java.lang.Thread
      extended by com.ridgesoft.robotics.OdometricLocalizer
All Implemented Interfaces:
Localizer, Runnable

public class OdometricLocalizer
extends Thread
implements Localizer

This class implements a localizer for position tracking of a two wheel differential-drive robot using odometry.

This class keeps track of the robot's position using ShaftEncoder objects to monitor movements of the robot's left and right wheels.

This class extends the thread class enabling it to use it's own thread to monitor and integrate movement of the wheels to track the robot's position.

See Also:
ShaftEncoder, AnalogShaftEncoder

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
OdometricLocalizer(ShaftEncoder leftEncoder, ShaftEncoder rightEncoder, float wheelDiameter, float trackWidth, int countsPerRevolution, int threadPriority, int period)
          Constructs an OdometricLocalizer object.
 
Method Summary
 Pose getPose()
          Gets the robot's pose (x, y position and heading).
 void run()
          Run method for the localizer thread.
 void setHeading(float heading)
          Sets the robot's current heading.
 void setPose(float x, float y, float heading)
          Sets the robot's current pose.
 void setPose(Pose pose)
          Sets the robot's current pose.
 void setPosition(float x, float y)
          Sets the robot's current x and y coordinates.
 String toString()
          Returns a String indicating the current pose.
 
Methods inherited from class java.lang.Thread
activeCount, currentThread, dumpStack, getName, getPriority, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, setDaemon, setName, setPriority, sleep, start, yield
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait
 

Constructor Detail

OdometricLocalizer

public OdometricLocalizer(ShaftEncoder leftEncoder,
                          ShaftEncoder rightEncoder,
                          float wheelDiameter,
                          float trackWidth,
                          int countsPerRevolution,
                          int threadPriority,
                          int period)
Constructs an OdometricLocalizer object.

Parameters:
leftEncoder - reference to the left wheel's shaft encoder object
rightEncoder - reference to the right wheel's shaft encoder object
wheelDiameter - diameter of the wheels
trackWidth - distance between the centerlines of the wheels
countsPerRevolution - number of encoder counts per one wheel revolution
threadPriority - priority of the thread
period - period of thread in milliseconds
Method Detail

getPose

public Pose getPose()
Gets the robot's pose (x, y position and heading).

Specified by:
getPose in interface Localizer
Returns:
Pose object containing the robot's current position and heading

run

public void run()
Run method for the localizer thread.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

setHeading

public void setHeading(float heading)
Sets the robot's current heading.

Specified by:
setHeading in interface Localizer
Parameters:
heading - heading in radians

setPose

public void setPose(float x,
                    float y,
                    float heading)
Sets the robot's current pose.

Specified by:
setPose in interface Localizer
Parameters:
x - x coordiante in whatever units the localizer uses
y - y coordinate in whatever units the localizer uses
heading - heading in radians

setPose

public void setPose(Pose pose)
Sets the robot's current pose.

Specified by:
setPose in interface Localizer
Parameters:
pose - a Pose object containing the new pose

setPosition

public void setPosition(float x,
                        float y)
Sets the robot's current x and y coordinates.

Specified by:
setPosition in interface Localizer
Parameters:
x - x coordiante in whatever units the localizer uses
y - y coordinate in whatever units the localizer uses

toString

public String toString()
Returns a String indicating the current pose.

Overrides:
toString in class Thread
Returns:
string

RoboJDETM v2.0

Copyright (c) 2003-2009 RidgeSoft, LLC. All rights reserved.
www.ridgesoft.com