7#ifndef _SQUIGGLES_SPLINE_HPP_
8#define _SQUIGGLES_SPLINE_HPP_
10#include <initializer_list>
33 std::shared_ptr<PhysicalModel> imodel =
34 std::make_shared<PassthroughModel>(),
48 std::vector<ProfilePoint>
generate(std::vector<Pose> iwaypoints,
50 std::vector<ProfilePoint>
generate(std::initializer_list<Pose> iwaypoints,
61 std::vector<ProfilePoint>
generate(std::vector<ControlVector> iwaypoints);
62 std::vector<ProfilePoint>
63 generate(std::initializer_list<ControlVector> iwaypoints);
75 std::shared_ptr<PhysicalModel>
model;
114 ", curvature: " + std::to_string(
curvature) +
"}";
140 ", vel: " + std::to_string(
vel) +
141 ", accel: " + std::to_string(
accel) +
142 ", jerk: " + std::to_string(
jerk) +
"}";
158 std::vector<GeneratedPoint>
190 return "ConstrainedState: {x: " + std::to_string(
pose.
x) +
191 ", y: " + std::to_string(
pose.
y) +
192 ", yaw: " + std::to_string(
pose.
yaw) +
194 ", dist: " + std::to_string(
distance) +
195 ", v: " + std::to_string(
max_vel) +
196 ", min_a: " + std::to_string(
min_accel) +
197 ", max_a: " + std::to_string(
max_accel) +
"}";
209 template <
class Iter>
210 std::vector<ProfilePoint>
_generate(Iter start, Iter end,
bool fast);
220 std::vector<GeneratedPoint>
229 std::vector<ProfilePoint>
232 const std::vector<GeneratedPoint>& raw_path,
233 const double preferred_start_vel,
234 const double preferred_end_vel,
235 const double start_time);
241 std::vector<ProfilePoint>
252 std::vector<ProfilePoint> points,
269 const double duration);
272 const double duration);
295 double vf(
double vi,
double a,
double ds);
301 double ai(
double vf,
double vi,
double s);
std::string to_string() const
Serializes the Pose data for debugging.
ProfilePoint get_point_at_time(const ControlVector start, const ControlVector end, std::vector< ProfilePoint > points, double t)
Finds the ProfilePoint on the profiled curve for the given timestamp.
Constraints constraints
The maximum allowable values for the robot's motion.
const double K_DEFAULT_VEL
This is factor is used to create a "dummy velocity" in the initial path generation step one or both o...
double ai(double vf, double vi, double s)
Calculates the initial acceleration needed to match the segments' velocities.
ProfilePoint lerp_point(QuinticPolynomial x_qp, QuinticPolynomial y_qp, ProfilePoint start, ProfilePoint end, double i)
Linearly interpolates between points along the profiled curve.
std::vector< ProfilePoint > parameterize(const ControlVector start, const ControlVector end, const std::vector< GeneratedPoint > &raw_path, const double preferred_start_vel, const double preferred_end_vel, const double start_time)
Imposes a linear motion profile on the raw path.
const int T_MIN
The minimum and maximum durations for a path to take.
std::vector< GeneratedPoint > gen_raw_path(ControlVector &start, ControlVector &end, bool fast)
Performs the "naive" generation step.
void enforce_accel_lims(ConstrainedState *state)
Applies the general constraints and model constraints to the given state.
std::vector< ProfilePoint > generate(std::vector< ControlVector > iwaypoints)
Creates a motion profiled path between the given waypoints.
double dt
The time difference between each value in the generated path.
void forward_pass(ConstrainedState *predecessor, ConstrainedState *successor)
Imposes the motion profile constraints on a segment of the path from the perspective of iterating for...
std::vector< ProfilePoint > generate(std::vector< Pose > iwaypoints, bool fast=false)
Creates a motion profiled path between the given waypoints.
QuinticPolynomial get_y_spline(const ControlVector start, const ControlVector end, const double duration)
std::vector< ProfilePoint > generate(std::initializer_list< ControlVector > iwaypoints)
std::vector< GeneratedPoint > gradient_descent(ControlVector &start, ControlVector &end, bool fast)
Runs a Gradient Descent algorithm to minimize the linear acceleration, linear jerk,...
std::vector< ProfilePoint > _generate(Iter start, Iter end, bool fast)
The actual function called by the "generate" functions.
std::shared_ptr< PhysicalModel > model
Defines the physical structure of the robot and translates the linear kinematics to wheel velocities.
static constexpr double K_EPSILON
Values that are closer to each other than this value are considered equal.
void backward_pass(ConstrainedState *predecessor, ConstrainedState *successor)
Imposes the motion profile constraints on a segment of the path from the perspective of iterating bac...
SplineGenerator(Constraints iconstraints, std::shared_ptr< PhysicalModel > imodel=std::make_shared< PassthroughModel >(), double idt=0.1)
Generates curves that match the given motion constraints.
QuinticPolynomial get_x_spline(const ControlVector start, const ControlVector end, const double duration)
Returns the spline curve for the given control vectors and path duration.
double vf(double vi, double a, double ds)
Calculates the final velocity for a path segment.
std::vector< ProfilePoint > integrate_constrained_states(std::vector< ConstrainedState > constrainedStates)
Finds the new timestamps for each point along the curve based on the motion profile.
std::vector< GeneratedVector > gen_single_raw_path(ControlVector start, ControlVector end, int duration, double start_vel, double end_vel)
std::vector< ProfilePoint > generate(std::initializer_list< Pose > iwaypoints, bool fast=false)
const int MAX_GRAD_DESCENT_ITERATIONS
Copyright 2020 Jonathan Bayless.
An intermediate value used in the parameterization step.
std::string to_string() const
ConstrainedState(Pose ipose, double icurvature, double idistance, double imax_vel, double imin_accel, double imax_accel)
ConstrainedState()=default
The output of the initial, "naive" generation step.
GeneratedPoint(Pose ipose, double icurvature=0.0)
std::string to_string() const
An intermediate value used in the "naive" generation step.
std::string to_string() const
GeneratedVector(GeneratedPoint ipoint, double ivel, double iaccel, double ijerk)