TrajoptLib
Library for generating time-optimal trajectories for FRC robots.
Loading...
Searching...
No Matches
trajopt::PathBuilder< Drivetrain, Solution > Class Template Reference

#include <trajopt/path/path_builder.hpp>

Public Member Functions

void set_drivetrain (Drivetrain drivetrain)
void set_bumpers (double front, double left, double right, double back)
void set_control_interval_counts (std::vector< size_t > &&counts)
const std::vector< size_t > & get_control_interval_counts () const
void sgmt_initial_guess_points (size_t from_index, std::span< const Pose2d > guess_points)
void pose_wpt (size_t index, const Pose2d &pose)
void translation_wpt (size_t index, const Translation2d &translation, double heading_guess=0.0)
void empty_wpt (size_t index, const Pose2d &pose_guess)
void wpt_linear_velocity_direction (size_t index, double angle)
void wpt_linear_velocity_max_magnitude (size_t index, double magnitude)
void wpt_angular_velocity_max_magnitude (size_t index, double magnitude)
void wpt_linear_acceleration_max_magnitude (size_t index, double magnitude)
void wpt_point_at (size_t index, const Translation2d &field_point, double heading_tolerance, bool flip)
void wpt_keep_in_circle (size_t index, const Translation2d &center, double radius)
void wpt_keep_in_polygon (size_t index, std::span< Translation2d > field_points)
void wpt_keep_in_lane (size_t index, const Translation2d &center_line_start, const Translation2d &center_line_end, double tolerance)
void wpt_keep_out_circle (size_t index, const Translation2d &center, double radius)
void sgmt_linear_velocity_direction (size_t from_index, size_t to_index, double angle)
void sgmt_linear_velocity_max_magnitude (size_t from_index, size_t to_index, double magnitude)
void sgmt_angular_velocity_max_magnitude (size_t from_index, size_t to_index, double magnitude)
void sgmt_linear_acceleration_max_magnitude (size_t from_index, size_t to_index, double magnitude)
void sgmt_point_at (size_t from_index, size_t to_index, Translation2d field_point, double heading_tolerance, bool flip)
void sgmt_keep_in_circle (size_t from_index, size_t to_index, const Translation2d &center, double radius)
void sgmt_keep_in_polygon (size_t from_index, size_t to_index, std::span< Translation2d > field_points)
void sgmt_keep_in_lane (size_t from_index, size_t to_index, const Translation2d &center_line_start, const Translation2d &center_line_end, double tolerance)
void sgmt_keep_out_circle (size_t from_index, size_t to_index, Translation2d center, double radius)
void add_callback (const std::function< void(const Solution &solution, int64_t handle)> callback)
Path< Drivetrain, Solution > & get_path ()
Solution calculate_linear_initial_guess () const
Solution calculate_spline_initial_guess () const

Detailed Description

template<typename Drivetrain, typename Solution>
class trajopt::PathBuilder< Drivetrain, Solution >

Path builder.

Template Parameters
DrivetrainThe drivetrain type (e.g., swerve, differential).
SolutionThe solution type (e.g., swerve, differential).

Member Function Documentation

◆ add_callback()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::add_callback ( const std::function< void(const Solution &solution, int64_t handle)> callback)
inline

Adds a callback to retrieve the state of the solver as a Solution.

This callback will run on every iteration of the solver.

Parameters
callbackA callback whose first parameter is the Solution based on the solver's state at that iteration, and second parameter is the handle passed into Generate().

◆ calculate_linear_initial_guess()

template<typename Drivetrain, typename Solution>
Solution trajopt::PathBuilder< Drivetrain, Solution >::calculate_linear_initial_guess ( ) const
inline

Calculates a discrete, linear initial guess of the x, y, and heading of the robot that goes through each segment.

Returns
The initial guess, as a solution.

◆ calculate_spline_initial_guess()

template<typename Drivetrain, typename Solution>
Solution trajopt::PathBuilder< Drivetrain, Solution >::calculate_spline_initial_guess ( ) const
inline

Calculates a discrete, spline initial guess of the x, y, and heading of the robot that goes through each segment.

Returns
The initial guess, as a solution.

◆ empty_wpt()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::empty_wpt ( size_t index,
const Pose2d & pose_guess )
inline

Sets a waypoint's pose initial guess.

Parameters
indexThe waypoint's index.
pose_guessThe pose initial guess.

◆ get_control_interval_counts()

template<typename Drivetrain, typename Solution>
const std::vector< size_t > & trajopt::PathBuilder< Drivetrain, Solution >::get_control_interval_counts ( ) const
inline

Gets the control interval counts.

Returns
Control interval counts.

◆ get_path()

template<typename Drivetrain, typename Solution>
Path< Drivetrain, Solution > & trajopt::PathBuilder< Drivetrain, Solution >::get_path ( )
inline

Gets the DifferentialPath being constructed.

Returns
The path.

◆ pose_wpt()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::pose_wpt ( size_t index,
const Pose2d & pose )
inline

Applies a pose constraint to a waypoint, and adds an initial guess with the same pose.

Parameters
indexThe waypoint's index.
poseThe pose.

◆ set_bumpers()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::set_bumpers ( double front,
double left,
double right,
double back )
inline

Adds a rectangular bumper to a list used when applying keep-out constraints.

Parameters
frontDistance in meters from center to front bumper edge.
leftDistance in meters from center to left bumper edge.
rightDistance in meters from center to right bumper edge.
backDistance in meters from center to back bumper edge.

◆ set_control_interval_counts()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::set_control_interval_counts ( std::vector< size_t > && counts)
inline

Sets the number of discrete samples for each trajectory segment.

Parameters
countsThe sequence of control interval counts per segment. Length is number of waypoints - 1.

◆ set_drivetrain()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::set_drivetrain ( Drivetrain drivetrain)
inline

Sets the Drivetrain object.

Parameters
drivetrainThe drivetrain.

◆ sgmt_angular_velocity_max_magnitude()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::sgmt_angular_velocity_max_magnitude ( size_t from_index,
size_t to_index,
double magnitude )
inline

Applies an angular velocity max magnitude constraint between two waypoints.

Parameters
from_indexThe first waypoint's index.
to_indexThe second waypoint's index.
magnitudeThe magnitude.

◆ sgmt_initial_guess_points()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::sgmt_initial_guess_points ( size_t from_index,
std::span< const Pose2d > guess_points )
inline

Adds a sequence of initial guess points between two waypoints.

The points are inserted between the waypoints at fromIndex and fromIndex + 1. Linear interpolation between the waypoint initial guess points and these segment initial guess points is used as the initial guess of the robot's pose over the trajectory.

Parameters
from_indexThe index of the waypoint the initial guess point comes after.
guess_pointsThe sequence of initial guess points.

◆ sgmt_keep_in_circle()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::sgmt_keep_in_circle ( size_t from_index,
size_t to_index,
const Translation2d & center,
double radius )
inline

Applies a keep-in circle constraint between two waypoints.

Applies to the robot bumpers.

Parameters
from_indexThe first waypoint's index.
to_indexThe second waypoint's index.
centerThe circle's center.
radiusThe circle's radius.

◆ sgmt_keep_in_lane()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::sgmt_keep_in_lane ( size_t from_index,
size_t to_index,
const Translation2d & center_line_start,
const Translation2d & center_line_end,
double tolerance )
inline

Applies a keep-in lane constraint between two waypoints.

Applies to the robot center.

Parameters
from_indexThe first waypoint's index.
to_indexThe second waypoint's index.
center_line_startThe center line's start point.
center_line_endThe center line's end point.
toleranceThe distance from the center line to each lane edge.

◆ sgmt_keep_in_polygon()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::sgmt_keep_in_polygon ( size_t from_index,
size_t to_index,
std::span< Translation2d > field_points )
inline

Applies a keep-in polygon constraint between two waypoints.

Applies to the robot bumpers.

Parameters
from_indexThe first waypoint's index.
to_indexThe second waypoint's index.
field_pointsThe points defining the keep-in polygon (must wind counterclockwise).

◆ sgmt_keep_out_circle()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::sgmt_keep_out_circle ( size_t from_index,
size_t to_index,
Translation2d center,
double radius )
inline

Applies a keep-out circle constraint between two waypoints.

Applies to the robot bumpers.

Parameters
from_indexThe first waypoint's index.
to_indexThe second waypoint's index.
centerThe circle's center.
radiusThe circle's radius.

◆ sgmt_linear_acceleration_max_magnitude()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::sgmt_linear_acceleration_max_magnitude ( size_t from_index,
size_t to_index,
double magnitude )
inline

Applies a linear acceleration max magnitude constraint between two waypoints.

Parameters
from_indexThe first waypoint's index.
to_indexThe second waypoint's index.
magnitudeThe magnitude.

◆ sgmt_linear_velocity_direction()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::sgmt_linear_velocity_direction ( size_t from_index,
size_t to_index,
double angle )
inline

Applies a linear velocity direction constraint between two waypoints.

Parameters
from_indexThe first waypoint's index.
to_indexThe second waypoint's index.
angleThe angle in radians.

◆ sgmt_linear_velocity_max_magnitude()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::sgmt_linear_velocity_max_magnitude ( size_t from_index,
size_t to_index,
double magnitude )
inline

Applies a linear velocity max magnitude constraint between two waypoints.

Parameters
from_indexThe first waypoint's index.
to_indexThe second waypoint's index.
magnitudeThe magnitude.

◆ sgmt_point_at()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::sgmt_point_at ( size_t from_index,
size_t to_index,
Translation2d field_point,
double heading_tolerance,
bool flip )
inline

Applies a point-at constraint between two waypoints.

Parameters
from_indexThe first waypoint's index.
to_indexThe second waypoint's index.
field_pointThe field point to point at.
heading_toleranceThe heading tolerance.
flipWhether to point away from the field point.

◆ translation_wpt()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::translation_wpt ( size_t index,
const Translation2d & translation,
double heading_guess = 0.0 )
inline

Applies a translation constraint to a waypoint, and adds an initial guess point with the same translation.

Parameters
indexThe waypoint's index.
translationThe translation.
heading_guessThe heading initial guess.

◆ wpt_angular_velocity_max_magnitude()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::wpt_angular_velocity_max_magnitude ( size_t index,
double magnitude )
inline

Applies an angular velocity max magnitude constraint to a waypoint.

Parameters
indexThe waypoint's index.
magnitudeThe magnitude.

◆ wpt_keep_in_circle()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::wpt_keep_in_circle ( size_t index,
const Translation2d & center,
double radius )
inline

Applies a keep-in circle constraint to a waypoint.

Applies to the robot bumpers.

Parameters
indexThe waypoint's index.
centerThe circle's center.
radiusThe circle's radius.

◆ wpt_keep_in_lane()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::wpt_keep_in_lane ( size_t index,
const Translation2d & center_line_start,
const Translation2d & center_line_end,
double tolerance )
inline

Applies a keep-in lane constraint to a waypoint.

Applies to the robot center.

Parameters
indexThe waypoint's index.
center_line_startThe center line's start point.
center_line_endThe center line's end point.
toleranceThe distance from the center line to each lane edge.

◆ wpt_keep_in_polygon()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::wpt_keep_in_polygon ( size_t index,
std::span< Translation2d > field_points )
inline

Applies a keep-in polygon constraint to a waypoint.

Applies to the robot bumpers.

Parameters
indexThe waypoint's index.
field_pointsThe points defining the keep-in polygon (must wind counterclockwise).

◆ wpt_keep_out_circle()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::wpt_keep_out_circle ( size_t index,
const Translation2d & center,
double radius )
inline

Applies a keep-out circle constraint to a waypoint.

Applies to the robot bumpers.

Parameters
indexThe waypoint's index.
centerThe circle's center.
radiusThe circle's radius.

◆ wpt_linear_acceleration_max_magnitude()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::wpt_linear_acceleration_max_magnitude ( size_t index,
double magnitude )
inline

Applies a linear acceleration max magnitude constraint to a waypoint.

Parameters
indexThe waypoint's index.
magnitudeThe magnitude.

◆ wpt_linear_velocity_direction()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::wpt_linear_velocity_direction ( size_t index,
double angle )
inline

Applies a linear velocity direction constraint to a waypoint.

Parameters
indexThe waypoint's index.
angleThe angle in radians.

◆ wpt_linear_velocity_max_magnitude()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::wpt_linear_velocity_max_magnitude ( size_t index,
double magnitude )
inline

Applies a linear velocity max magnitude constraint to a waypoint.

Parameters
indexThe waypoint's index.
magnitudeThe magnitude.

◆ wpt_point_at()

template<typename Drivetrain, typename Solution>
void trajopt::PathBuilder< Drivetrain, Solution >::wpt_point_at ( size_t index,
const Translation2d & field_point,
double heading_tolerance,
bool flip )
inline

Applies a point-at constraint to a waypoint.

Parameters
indexThe waypoint's index.
field_pointThe field point to point at.
heading_toleranceThe heading tolerance.
flipWhether to point away from the field point.

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