Trajectory
The Trajectory
class is used to create a trajectory for a differential
drive robot that can be used by a path/trajectory following algorithm.
Creating a Trajectory
The constructor for Trajectory
will automatically compute the
trajectory. The constructor takes the following arguments:
std::vector<LouLib::Math::Pose2D> waypoints
List of poses that the robot should drive through.
LouLib::Units::Velocity maxVel
Maximum velocity the robot should reach while driving on the path.
LouLib::Units::Acceleration maxAccel
Maximum acceleration the robot should reach while driving on the path.
LouLib::Units::Length maxFullSpeedTurnRadius
Smallest radius circle that the robot can travel around while driving at maxVel. A smaller value will result in the robot slowing down more while turning.
LouLib::Units::Velocity finalVel
(optional)The velocity the robot should be traveling at the end of the path. If this value of not provided, it will default to zero (the robot will stop at the end of the path)
Using the Trajectory
The final computed trajectory will contain a set of x-positions, y-positions, headings, velocities, and angular velocities, with 10 milliseconds between each.
The following methods can be used to access the calculated trajectory:
int size()
Returns the number of samples in the calculated trajectory
LouLib::Units::Length getX(int i)
Returns the i-th x-position
LouLib::Units::Length getY(int i)
Returns the i-th y-position
LouLib::Units::Angle getTheta(int i)
Returns the i-th heading
LouLib::Units::Velocity getVelocity(int i)
Returns the i-th velocity
LouLib::Units::AngularVelocity getAngularVelocity(int i)
Returns the i-th angular velocity
LouLib::Units::Length getDistFromStart(int i)
Returns the distance from the start of the trajectory to the i-th sample. This returns the arc length of the trajectory, and not the point-to-point distance.