Odometry¶
General¶
-
void lemlib::update()¶
Update the pose of the robot.
-
void lemlib::init()¶
Initialize the odometry system.
Pose¶
-
class Pose¶
A pose in 2D space.
A pose is a position and heading in 2D space. Representing a pose as a single object makes it easier to work with, especially in motion algorithms and position tracking.
The Pose class overloads operators so you can easily add, subtract, multiply, etc.
Public Functions
-
Pose(float x, float y, float theta = 0)¶
Create a new pose.
Example
// create a pose lemlib::Pose poseA(5, // x position 10, // y position 1.57); // heading // create a pose lemlib::Pose poseB(5.2, 22); // x and y position, heading defaults to 0
Note
Pose is unitless. It is up to the user to ensure that the units are consistent.
- Parameters:
x – component
y – component
theta – heading. Defaults to 0
-
Pose operator+(const Pose &other) const¶
Add a pose to this pose.
Example
// create a pose lemlib::Pose poseA(5, 10, 1.57); // create a pose lemlib::Pose poseB(5.2, 22, 2.22); // add the two poses lemlib::Pose poseC = poseA + poseB; // poseC.x = 10.2, poseC.y = 32, poseC.theta = 1.57
Note
heading is not modified, and is taken from this pose
- Parameters:
other – other pose
- Returns:
-
Pose operator-(const Pose &other) const¶
Subtract a pose from this pose.
Example
// create a pose lemlib::Pose poseA(5, 10, 1.57); // create a pose lemlib::Pose poseB(5.2, 22, 2.22); // subtract the two poses lemlib::Pose poseC = poseA - poseB; // poseC.x = -0.2, poseC.y = -12, poseC.theta = 1.57
Note
heading is not modified, and is taken from this pose
- Parameters:
other – other pose
- Returns:
-
float operator*(const Pose &other) const¶
Multiply a pose by this pose (dot product)
Example
// create a pose lemlib::Pose poseA(5, 10, 1.57); // create a pose lemlib::Pose poseB(5.2, 22, 2.22); // multiply the two poses float result = poseA * poseB; // 246
Note
heading is not considered in this operation
- Parameters:
other – other pose
- Returns:
-
Pose operator*(const float &other) const¶
Multiply a pose by a float.
Example
// create a pose lemlib::Pose pose(1, 2); // multiply the pose by 4.0 lemlib::Pose result = pose * 4.0; // result.x = 4, result.y = 8
Note
heading is not considered in this operation
- Parameters:
other – float
- Returns:
-
Pose operator/(const float &other) const¶
Divide a pose by a float.
Example
// create a pose lemlib::Pose pose(6, 8); // divide the pose by 2 lemlib::Pose result = pose / 2; // result.x = 3, result.y = 4
Note
heading is not considered in this operation
- Parameters:
other – float
- Returns:
-
Pose lerp(Pose other, float t) const¶
Linearly interpolate between two poses.
Example
// create poses lemlib::Pose poseA(0, 0); lemlib::Pose poseB(0, 2); // find the pose in between the 2 poses lemlib::Pose result = poseA.lerp(poseB, 0.5); // result.x = 0, result.y = 1
Note
heading is not considered in this operation
- Parameters:
other – the other pose
t – t value
- Returns:
-
float distance(Pose other) const¶
Get the distance between two poses.
Example
// create poses lemlib::Pose poseA(0, 0); lemlib::Pose poseB(3, 4); // find the distance between the poses float result = poseA.distance(poseB); // result = 5
Note
heading is not considered in this operation
- Parameters:
other – the other pose
- Returns:
float
-
float angle(Pose other) const¶
Get the angle between two poses.
Example
// create poses lemlib::Pose poseA(-1, -2); lemlib::Pose poseB(2, 1); // find angle between poses float result = poseA.angle(poseB); // result = 0.785398
Note
heading is not considered in this operation
- Parameters:
other – the other pose
- Returns:
float in radians
-
Pose(float x, float y, float theta = 0)¶