This library has been developed by Jae Hyeon An for the Computer Aided Design Innovation & Engineering Lab at Stony Brook University under professor Anurag Purwar.
The original purpose of this library was to provide position estimation without a external reference (dead reckoning) for the PreciseMovement-libray. It is now available as standalone library. It is available as an Arduino library, but since it is a C++ library, you can use it for non-Arduino projects as well.
The library uses wheel encoder data to estimate the position. It can also be used with a gyroscope for higher directional accuracy. The library is useful in scenarios where wheel slippage is unlikely such as a robot toy moving on a hard surface. The program by default does not assume wheel slippage by default, but it is flexible enough so that you can update and correct the position by using an external reference as needed.
DeadReckoner(volatile unsigned long *leftTicks, volatile unsigned long *rightTicks, int ticksPerRev, double radius, double length)
void computePosition()
- Compute the estimates of angular velocity of wheels and position of robot.
double getX()
- Returns the x coordinate of the latest position estimate.
double getY()
- Returns the y coordinate of the latest position estimate.
double getWl()
- Returns the last computed angular velocity of the left wheel.
double getWr()
- Returns the last computed angular velocity of the right wheel.
double getTheta()
- Returns the latest orientation angle estimate. Theta is measured from the x-axis to the center of the robot. Theta is taken to be zero before the robot starts moving.
The accuracy of the position estimates will drift overtime. To correct for this, you can use an external reference (like a GPS) and update the position using these methods. When using a gyroscope, the setTheta can be called periodically for greater directional accuracy.
double setX(double x)
- Sets the x coordinate of the position.
double setY(double y)
- Sets the y coordinate of the position.
double setTheta(double theta)
- Returns the latest orientation angle estimate. Theta is measured from the x-axis to the center of the robot. Theta is taken to be zero before the robot starts moving.