Thunderbots Project
Loading...
Searching...
No Matches
BangBangTrajectory2D Class Reference
Inheritance diagram for BangBangTrajectory2D:
Collaboration diagram for BangBangTrajectory2D:

Public Member Functions

 BangBangTrajectory2D ()=default
 
 BangBangTrajectory2D (const Point &initial_pos, const Point &final_pos, const Vector &initial_vel, const KinematicConstraints &constraints)
 
void generate (const Point &initial_pos, const Point &final_pos, const Vector &initial_vel, double max_vel, double max_accel, double max_decel)
 
Point getPosition (double t_sec) const override
 
Vector getVelocity (double t_sec) const override
 
Vector getAcceleration (double t_sec) const override
 
double getTotalTime () const override
 
std::vector< RectanglegetBoundingBoxes () const override
 
- Public Member Functions inherited from Trajectory< Point, Vector, Vector >
Point getDestination () const
 

Static Public Member Functions

static std::shared_ptr< Trajectory2Dgenerator (const Point &initial_pos, const Point &final_pos, const Vector &initial_vel, const KinematicConstraints &constraints)
 

Constructor & Destructor Documentation

◆ BangBangTrajectory2D() [1/2]

BangBangTrajectory2D ( )
default

Default constructor. Creates an empty trajectory.

◆ BangBangTrajectory2D() [2/2]

BangBangTrajectory2D ( const Point initial_pos,
const Point final_pos,
const Vector initial_vel,
const KinematicConstraints constraints 
)

Generate a 2D trajectory from the initial position to the final position with the given initial velocity and kinematic constraints.

Parameters
initial_posStarting position of the trajectory
final_posDestination. Where the trajectory should end at
initial_velThe initial velocity of the trajectory
constraintsKinematic constraints of the new generated trajectory

Member Function Documentation

◆ generate()

void generate ( const Point initial_pos,
const Point final_pos,
const Vector initial_vel,
double  max_vel,
double  max_accel,
double  max_decel 
)

Generate a 2D trajectory from the initial position to the final position with the given initial velocity and kinematic constraints.

Note
that calling generate will overwrite the existing trajectory.
Parameters
initial_posStarting position of the trajectory
final_posDestination. Where the trajectory should end at
initial_velThe initial velocity of the trajectory
max_velThe max velocity (in 2D) that the trajectory can reach at any given point
max_accelThe max acceleration (in 2D) that the trajectory can reach at any given point
max_decelThe max deceleration (in 2D) that the trajectory can reach at any given point

The following implementation is based on section IV of the paper "Trajectory generation for four wheeled omnidirectional vehicles"

A 2D trajectories is represented as 2x 1D trajectories (one for x and one for y) which take the same amount of time to reach the destination.

The max velocity, acceleration, and deceleration are assumed to be the kinematic constraints in 2D space, as opposed to the constraints for individual x and y components. To find the components of these constraints for each axis which will give us two trajectories with (almost) equal durations, we will use binary search over the components of the given kinematic constraints.

We will start with alpha = PI/4 (45 deg) which will have the x and y components equivalent to each other. Depending on which 1D trajectory takes longer to reach the destination, we will either increase or decrease alpha by increment (= PI/(8*2^i) where i is the iteration of binary search we're at). This will result in the component which is taking longer to reach the destination to get a larger component of the kinematic constraints relative to the other component which reaches the destination faster.

◆ generator()

std::shared_ptr< Trajectory2D > generator ( const Point initial_pos,
const Point final_pos,
const Vector initial_vel,
const KinematicConstraints constraints 
)
static

Static function for generating a BangBangTrajectory2D pointer with Trajectory2D interface

Parameters
initial_posWhere the trajectory should start at
final_posWhere the trajectory should end at
initial_velThe initial velocity of the trajectory
constraintsThe kinematic constraints of the trajectory
Returns
A shared pointer to a BangBangTrajectory2D

◆ getAcceleration()

Vector getAcceleration ( double  t_sec) const
overridevirtual

Get the acceleration at time t

Parameters
t_secThe time elapsed since the start of the trajectory in seconds
Returns
The acceleration at time t

Implements Trajectory< Point, Vector, Vector >.

◆ getBoundingBoxes()

std::vector< Rectangle > getBoundingBoxes ( ) const
overridevirtual

Get the bounding box of the trajectory

Returns
bounding box which bounds the trajectory

Implements Trajectory2D.

◆ getPosition()

Point getPosition ( double  t_sec) const
overridevirtual

Get the position at time t

Parameters
t_secThe time elapsed since the start of the trajectory in seconds
Returns
The position at time t

Implements Trajectory< Point, Vector, Vector >.

◆ getTotalTime()

double getTotalTime ( ) const
overridevirtual

Get the total duration of the trajectory until it reaches the destination

Returns
The total duration for the trajectory in seconds

Implements Trajectory< Point, Vector, Vector >.

◆ getVelocity()

Vector getVelocity ( double  t_sec) const
overridevirtual

Get the velocity at time t

Parameters
t_secThe time elapsed since the start of the trajectory in seconds
Returns
The velocity at time t

Implements Trajectory< Point, Vector, Vector >.


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