pub struct DifferentialTrajectoryGenerator { /* private fields */ }Expand description
This trajectory generator class contains functions to generate time-optimal trajectories for differential drivetrain types.
Implementations§
Source§impl DifferentialTrajectoryGenerator
impl DifferentialTrajectoryGenerator
Sourcepub fn new() -> DifferentialTrajectoryGenerator
pub fn new() -> DifferentialTrajectoryGenerator
Constructs a new differential trajectory optimization problem.
Sourcepub fn set_drivetrain(&mut self, drivetrain: &DifferentialDrivetrain)
pub fn set_drivetrain(&mut self, drivetrain: &DifferentialDrivetrain)
Sets the Drivetrain object.
drivetrain- The drivetrain.
Sourcepub fn set_bumpers(&mut self, front: f64, left: f64, right: f64, back: f64)
pub fn set_bumpers(&mut self, front: f64, left: f64, right: f64, back: f64)
Adds a rectangular bumper to a list used when applying keep-out constraints.
front- Distance in meters from center to front bumper edge.left- Distance in meters from center to left bumper edge.right- Distance in meters from center to right bumper edge.back- Distance in meters from center to back bumper edge.
Sourcepub fn set_control_interval_counts(&mut self, counts: Vec<usize>)
pub fn set_control_interval_counts(&mut self, counts: Vec<usize>)
Sets the number of discrete samples for each trajectory segment.
counts- The sequence of control interval counts per segment. Length is number of waypoints - 1.
Sourcepub fn pose_wpt(&mut self, index: usize, pose: Pose2d)
pub fn pose_wpt(&mut self, index: usize, pose: Pose2d)
Applies a pose constraint to a waypoint, and adds an initial guess with the same pose.
index- The waypoint’s index.pose- The pose.
Sourcepub fn translation_wpt(
&mut self,
index: usize,
translation: Translation2d,
heading_guess: f64,
)
pub fn translation_wpt( &mut self, index: usize, translation: Translation2d, heading_guess: f64, )
Applies a translation constraint to a waypoint, and adds an initial guess point with the same translation.
index- The waypoint’s index.translation- The translation.heading_guess- The heading initial guess.
Sourcepub fn empty_wpt(&mut self, index: usize, pose_guess: Pose2d)
pub fn empty_wpt(&mut self, index: usize, pose_guess: Pose2d)
Sets a waypoint’s pose initial guess.
index- The waypoint’s index.pose_guess- The pose initial guess.
Sourcepub fn sgmt_initial_guess_points(
&mut self,
from_index: usize,
guess_points: &Vec<Pose2d>,
)
pub fn sgmt_initial_guess_points( &mut self, from_index: usize, guess_points: &Vec<Pose2d>, )
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.
from_index- The index of the waypoint the initial guess point comes after.guess_points- The sequence of initial guess points.
Sourcepub fn wpt_linear_velocity_direction(&mut self, index: usize, angle: f64)
pub fn wpt_linear_velocity_direction(&mut self, index: usize, angle: f64)
Applies a linear velocity direction constraint to a waypoint.
index- The waypoint’s index.angle- The angle in radians.
Sourcepub fn wpt_linear_velocity_max_magnitude(
&mut self,
index: usize,
magnitude: f64,
)
pub fn wpt_linear_velocity_max_magnitude( &mut self, index: usize, magnitude: f64, )
Applies a linear velocity max magnitude constraint to a waypoint.
index- The waypoint’s index.magnitude- The magnitude.
Sourcepub fn wpt_angular_velocity_max_magnitude(
&mut self,
index: usize,
magnitude: f64,
)
pub fn wpt_angular_velocity_max_magnitude( &mut self, index: usize, magnitude: f64, )
Applies an angular velocity max magnitude constraint to a waypoint.
index- The waypoint’s index.magnitude- The magnitude.
Sourcepub fn wpt_linear_acceleration_max_magnitude(
&mut self,
index: usize,
magnitude: f64,
)
pub fn wpt_linear_acceleration_max_magnitude( &mut self, index: usize, magnitude: f64, )
Applies a linear acceleration max magnitude constraint to a waypoint.
index- The waypoint’s index.magnitude- The magnitude.
Sourcepub fn wpt_point_at(
&mut self,
index: usize,
field_point: Translation2d,
heading_tolerance: f64,
flip: bool,
)
pub fn wpt_point_at( &mut self, index: usize, field_point: Translation2d, heading_tolerance: f64, flip: bool, )
Applies a point-at constraint to a waypoint.
index- The waypoint’s index.field_point- The field point to point at.heading_tolerance- The heading tolerance.flip- Whether to point away from the field point.
Sourcepub fn wpt_keep_in_circle(
&mut self,
index: usize,
center: Translation2d,
radius: f64,
)
pub fn wpt_keep_in_circle( &mut self, index: usize, center: Translation2d, radius: f64, )
Applies a keep-in circle constraint to a waypoint.
Applies to the robot bumpers.
index- The waypoint’s index.center- The circle’s center.radius- The circle’s radius.
Sourcepub fn wpt_keep_in_polygon(
&mut self,
index: usize,
field_points: Vec<Translation2d>,
)
pub fn wpt_keep_in_polygon( &mut self, index: usize, field_points: Vec<Translation2d>, )
Applies a keep-in polygon constraint to a waypoint.
Applies to the robot bumpers.
index- The waypoint’s index.field_points- The points defining the keep-in polygon (must wind counterclockwise).
Sourcepub fn wpt_keep_in_lane(
&mut self,
index: usize,
center_line_start: Translation2d,
center_line_end: Translation2d,
tolerance: f64,
)
pub fn wpt_keep_in_lane( &mut self, index: usize, center_line_start: Translation2d, center_line_end: Translation2d, tolerance: f64, )
Applies a keep-in lane constraint to a waypoint.
Applies to the robot center.
index- The waypoint’s index.center_line_start- The center line’s start point.center_line_end- The center line’s end point.tolerance- The distance from the center line to each lane edge.
Sourcepub fn wpt_keep_out_circle(
&mut self,
index: usize,
center: Translation2d,
radius: f64,
)
pub fn wpt_keep_out_circle( &mut self, index: usize, center: Translation2d, radius: f64, )
Applies a keep-out circle constraint to a waypoint.
Applies to the robot bumpers.
index- The waypoint’s index.center- The circle’s center.radius- The circle’s radius.
Sourcepub fn sgmt_linear_velocity_direction(
&mut self,
from_index: usize,
to_index: usize,
angle: f64,
)
pub fn sgmt_linear_velocity_direction( &mut self, from_index: usize, to_index: usize, angle: f64, )
Applies a linear velocity direction constraint between two waypoints.
from_index- The first waypoint’s index.to_index- The second waypoint’s index.angle- The angle in radians.
Sourcepub fn sgmt_linear_velocity_max_magnitude(
&mut self,
from_index: usize,
to_index: usize,
magnitude: f64,
)
pub fn sgmt_linear_velocity_max_magnitude( &mut self, from_index: usize, to_index: usize, magnitude: f64, )
Applies a linear velocity max magnitude constraint between two waypoints.
from_index- The first waypoint’s index.to_index- The second waypoint’s index.magnitude- The magnitude.
Sourcepub fn sgmt_angular_velocity_max_magnitude(
&mut self,
from_index: usize,
to_index: usize,
magnitude: f64,
)
pub fn sgmt_angular_velocity_max_magnitude( &mut self, from_index: usize, to_index: usize, magnitude: f64, )
Applies an angular velocity max magnitude constraint between two waypoints.
from_index- The first waypoint’s index.to_index- The second waypoint’s index.magnitude- The magnitude.
Sourcepub fn sgmt_linear_acceleration_max_magnitude(
&mut self,
from_index: usize,
to_index: usize,
magnitude: f64,
)
pub fn sgmt_linear_acceleration_max_magnitude( &mut self, from_index: usize, to_index: usize, magnitude: f64, )
Applies a linear acceleration max magnitude constraint between two waypoints.
from_index- The first waypoint’s index.to_index- The second waypoint’s index.magnitude- The magnitude.
Sourcepub fn sgmt_keep_in_circle(
&mut self,
from_index: usize,
to_index: usize,
center: Translation2d,
radius: f64,
)
pub fn sgmt_keep_in_circle( &mut self, from_index: usize, to_index: usize, center: Translation2d, radius: f64, )
Applies a keep-in circle constraint between two waypoints.
Applies to the robot bumpers.
from_index- The first waypoint’s index.to_index- The second waypoint’s index.center- The circle’s center.radius- The circle’s radius.
Sourcepub fn sgmt_keep_in_polygon(
&mut self,
from_index: usize,
to_index: usize,
field_points: Vec<Translation2d>,
)
pub fn sgmt_keep_in_polygon( &mut self, from_index: usize, to_index: usize, field_points: Vec<Translation2d>, )
Applies a keep-in polygon constraint between two waypoints.
Applies to the robot bumpers.
from_index- The first waypoint’s index.to_index- The second waypoint’s index.field_points- The points defining the keep-in polygon (must wind counterclockwise).
Sourcepub fn sgmt_keep_in_lane(
&mut self,
from_index: usize,
to_index: usize,
center_line_start: Translation2d,
center_line_end: Translation2d,
tolerance: f64,
)
pub fn sgmt_keep_in_lane( &mut self, from_index: usize, to_index: usize, center_line_start: Translation2d, center_line_end: Translation2d, tolerance: f64, )
Applies a keep-in lane constraint between two waypoints.
Applies to the robot center.
from_index- The first waypoint’s index.to_index- The second waypoint’s index.center_line_start- The center line’s start point.center_line_end- The center line’s end point.tolerance- The distance from the center line to each lane edge.
Sourcepub fn sgmt_keep_out_circle(
&mut self,
from_index: usize,
to_index: usize,
center: Translation2d,
radius: f64,
)
pub fn sgmt_keep_out_circle( &mut self, from_index: usize, to_index: usize, center: Translation2d, radius: f64, )
Applies a keep-out circle constraint between two waypoints.
Applies to the robot bumpers.
from_index- The first waypoint’s index.to_index- The second waypoint’s index.center- The circle’s center.radius- The circle’s radius.
Sourcepub fn add_callback(&mut self, callback: fn(DifferentialTrajectory, i64))
pub fn add_callback(&mut self, callback: fn(DifferentialTrajectory, i64))
Adds a callback that will be called on each iteration of the solver.
callback- afn(not a closure) to be executed. The callback’s first parameter will be atrajopt::DifferentialTrajectory, and the second parameter will be ani64equal to the handle passed ingenerate()
This function can be called multiple times to add multiple callbacks.
Sourcepub fn generate(
&self,
diagnostics: bool,
handle: i64,
) -> Result<DifferentialTrajectory, TrajoptError>
pub fn generate( &self, diagnostics: bool, handle: i64, ) -> Result<DifferentialTrajectory, TrajoptError>
Generates the trajectory.
diagnostics- If true, prints per-iteration details of the solver to stdout.handle- A number used to identify results from this generation in theadd_callbackcallback. Ifadd_callbackhas not been called, this value has no significance.
Returns a result with either the final
trajopt::DifferentialTrajectory, or TrajoptError
generation failed.