Resurgence (PY2022)
Codebase for the Husky Robotics 2021-2022 rover Resurgence
Loading...
Searching...
No Matches
control::SingleDimTrapezoidalVelocityProfile Class Reference

Trapezoidal velocity profile in a single dimension. More...

#include <TrapezoidalVelocityProfile.h>

Public Member Functions

 SingleDimTrapezoidalVelocityProfile (double maxVel, double maxAccel)
 Construct a new velocity profile.
 
void setTarget (robot::types::datatime_t currTime, double startPos, double endPos)
 Calculate a profile, assuming the mechanism begins and ends at rest.
 
bool hasTarget () const
 Check if a profile has been calculated.
 
double getCommand (robot::types::datatime_t currTime) const
 Get the target position.
 
void reset ()
 Reset the profile and clear any calculated profile.
 
std::optional< util::dsecondsgetTotalTime () const
 Get the total time it takes to perform the profile.
 

Detailed Description

Trapezoidal velocity profile in a single dimension.

See also
https://robotacademy.net.au/lesson/1d-trapezoidal-trajectory/

Constructor & Destructor Documentation

◆ SingleDimTrapezoidalVelocityProfile()

control::SingleDimTrapezoidalVelocityProfile::SingleDimTrapezoidalVelocityProfile ( double maxVel,
double maxAccel )

Construct a new velocity profile.

Parameters
maxVelThe maximum velocity the profile should attain.
maxAccelThe maximum acceleration the profile should use.

Member Function Documentation

◆ getCommand()

double control::SingleDimTrapezoidalVelocityProfile::getCommand ( robot::types::datatime_t currTime) const

Get the target position.

Parameters
currTimeThe current timestamp.
Returns
double The target position if hasTarget() is true, else 0.

◆ getTotalTime()

std::optional< util::dseconds > control::SingleDimTrapezoidalVelocityProfile::getTotalTime ( ) const

Get the total time it takes to perform the profile.

Returns
std::optional<util::dseconds> The total time. If hasTarget() is false, returns empty optional.

◆ hasTarget()

bool control::SingleDimTrapezoidalVelocityProfile::hasTarget ( ) const

Check if a profile has been calculated.

Returns
bool True iff setTarget() has been called since construction or the last reset.

◆ setTarget()

void control::SingleDimTrapezoidalVelocityProfile::setTarget ( robot::types::datatime_t currTime,
double startPos,
double endPos )

Calculate a profile, assuming the mechanism begins and ends at rest.

Parameters
currTimeThe current timestamp.
startPosThe position the profile starts at.
endPosThe position the profile ends at.

The documentation for this class was generated from the following files: