GT RoboCup SSL
Soccer software, robot firmware
Planning::InterpolatedPath Class Reference

Represents a motion path as a series of {pos, vel} pairs. More...

Classes

struct  Entry
 Each entry in InterpolatedPath is a MotionInstant and the time that the robot should be at that position and velocity. More...
 

Public Member Functions

 InterpolatedPath ()
 default path is empty
 
 InterpolatedPath (Geometry2d::Point p0)
 constructor with a single point
 
 InterpolatedPath (Geometry2d::Point p0, Geometry2d::Point p1)
 constructor from two points
 
void addInstant (RJ::Seconds time, MotionInstant instant)
 Adds an instant at the end of the path for the given time. More...
 
virtual RobotInstant start () const override
 Start instant of the path.
 
virtual RobotInstant end () const override
 Destination instant of the path.
 
virtual bool hit (const Geometry2d::ShapeSet &obstacles, RJ::Seconds startTimeIntoPath, RJ::Seconds *hitTime) const override
 Returns true if the path hits an obstacle. More...
 
virtual std::unique_ptr< PathsubPath (RJ::Seconds startTime=RJ::Seconds::zero(), RJ::Seconds endTime=RJ::Seconds::max()) const override
 Returns a subPath. More...
 
virtual void draw (DebugDrawer *constdebug_drawer, const QColor &color, const QString &layer) const override
 Draws the path. More...
 
virtual RJ::Seconds getDuration () const override
 Returns how long it would take for the entire path to be traversed. More...
 
virtual std::unique_ptr< Pathclone () const override
 Returns a deep copy of the Path.
 
bool empty () const
 
void clear ()
 Erase all path contents.
 
float length (unsigned int start=0) const
 Calulates the length of the path. More...
 
float length (unsigned int start, unsigned int end) const
 Calulates the length of the path. More...
 
float length (Geometry2d::Point pt) const
 Returns the length of the path from the closet point found to pt.
 
size_t size () const
 Returns number of waypoints.
 
int nearestIndex (Geometry2d::Point pt) const
 
Geometry2d::Segment nearestSegment (Geometry2d::Point pt) const
 returns the nearest segement of pt to the path
 
float distanceTo (Geometry2d::Point pt) const
 
RJ::Seconds getTime (int index) const
 Estimates how long it would take for the robot to get to a certain point in the path using Trapezoidal motion. More...
 
- Public Member Functions inherited from Planning::Path
 Path (RJ::Time startTime=RJ::now())
 
std::optional< RobotInstantevaluate (RJ::Seconds t) const
 This method evaluates the path at a given time and returns the target angle, position, and velocity of the robot. More...
 
RJ::Seconds getSlowedDuration () const
 
virtual void setDebugText (QString string)
 
virtual void drawDebugText (DebugDrawer *debug_drawer, const QColor &color=Qt::darkCyan, const QString &layer="PathDebugText") const
 
virtual RJ::Time startTime () const
 The time the path starts at.
 
virtual void setStartTime (RJ::Time t)
 
virtual bool pathsIntersect (const std::vector< DynamicObstacle > &paths, RJ::Time startTime, Geometry2d::Point *hitLocation, RJ::Seconds *hitTime) const
 
virtual std::unique_ptr< ConstPathIteratoriterator (RJ::Time startTime, RJ::Seconds deltaT) const
 
void slow (float multiplier, RJ::Seconds timeInto=RJ::Seconds::zero())
 

Static Public Member Functions

static std::unique_ptr< PathemptyPath (Geometry2d::Point pos)
 

Public Attributes

std::vector< Entrywaypoints
 

Protected Member Functions

virtual std::optional< RobotInstanteval (RJ::Seconds t) const override
 

Additional Inherited Members

- Protected Attributes inherited from Planning::Path
double evalRate = 1.0
 
RJ::Time _startTime
 
std::optional< QString > _debugText
 

Detailed Description

Represents a motion path as a series of {pos, vel} pairs.

The path represents a function of position given time that the robot should follow. A line-segment-based path comes from the planner, then we use cubic bezier curves to interpolate and smooth it out. This is done via the evaulate() method.

+ Inheritance diagram for Planning::InterpolatedPath:
+ Collaboration diagram for Planning::InterpolatedPath:

Member Function Documentation

◆ addInstant()

void Planning::InterpolatedPath::addInstant ( RJ::Seconds  time,
MotionInstant  instant 
)
inline

Adds an instant at the end of the path for the given time.

Time should not bet less than the last time.

◆ draw()

void Planning::InterpolatedPath::draw ( DebugDrawer debug_drawer,
const QColor &  color = Qt::black,
const QString &  layer = "Motion" 
) const
overridevirtual

Draws the path.

The default implementation adds a DebugRobotPath to the SystemState that interpolates points along the path.

Parameters
debug_drawerThe SystemState to draw the path on
colorThe color the path should be drawn
layerThe layer to draw the path on

Reimplemented from Planning::Path.

◆ getDuration()

RJ::Seconds Planning::InterpolatedPath::getDuration ( ) const
overridevirtual

Returns how long it would take for the entire path to be traversed.

Returns
The time from start to path completion or infinity if it never stops

Implements Planning::Path.

◆ getTime()

RJ::Seconds Planning::InterpolatedPath::getTime ( int  index) const

Estimates how long it would take for the robot to get to a certain point in the path using Trapezoidal motion.

Parameters
indexIndex of the point on the path
Returns
The estimated time it would take for the robot to a point on the path starting from the start of the path

◆ hit()

bool Planning::InterpolatedPath::hit ( const Geometry2d::ShapeSet obstacles,
RJ::Seconds  startTimeIntoPath,
RJ::Seconds *  hitTime 
) const
overridevirtual

Returns true if the path hits an obstacle.

Parameters
[in]shapeThe obstacles on the field
[out]hitTimethe approximate time when the path hits an obstacle. If no obstacles are hit, behavior is undefined for the final value.
[in]startTimeIntoPathThe time on the path to start checking from
Returns
true if it hits an obstacle, otherwise false

Implements Planning::Path.

◆ length() [1/2]

float Planning::InterpolatedPath::length ( unsigned int  start = 0) const

Calulates the length of the path.

Parameters
[in]startIndex of point in path to use at start point.
Returns
the length of the path starting at point (start).

◆ length() [2/2]

float Planning::InterpolatedPath::length ( unsigned int  start,
unsigned int  end 
) const

Calulates the length of the path.

Parameters
[in]startIndex of point in path to use at start point.
[in]endIndex of point in path to use at end point.
Returns
the length of the path starting at point (start) and ending at point [end].

◆ subPath()

unique_ptr< Path > Planning::InterpolatedPath::subPath ( RJ::Seconds  startTime = RJ::Seconds::zero(),
RJ::Seconds  endTime = RJ::Seconds::max() 
) const
overridevirtual

Returns a subPath.

Parameters
startTimeThe startTime for from which the subPath should be taken.
endTimeThe endTime from which the subPath should be taken. If it is greater than the duration fo the path, it should go to the end of the path.
Returns
A unique_ptr to the new subPath

Implements Planning::Path.


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