5 #ifndef MPL_TRAJ_SOLVER_H 6 #define MPL_TRAJ_SOLVER_H 22 if (control == Control::VEL || control == Control::VELxYAW)
24 else if (control == Control::ACC || control == Control::ACCxYAW)
26 else if (control == Control::JRK || control == Control::JRKxYAW)
31 if (yaw_control == Control::VEL)
33 else if (yaw_control == Control::ACC)
35 else if (yaw_control == Control::JRK)
41 path_.resize(ws.size());
42 for (
size_t i = 0; i < ws.size(); i++)
path_[i] = ws[i].pos;
51 void setDts(
const std::vector<decimal_t>& dts) {
dts_ = dts; }
59 for (
size_t i = 0; i <
waypoints_.size(); i++) {
77 for (
const auto& it :
dts_) std::cout <<
"dt: " << it << std::endl;
99 auto yaw_prs =
yaw_solver_->getTrajectory()->toPrimitives();
100 for (
size_t i = 0; i < traj.segs.size(); i++)
101 traj.segs[i].pr_yaw_ = yaw_prs[i].prs_[0];
123 if (pts.size() < 2 || v <= 0) return std::vector<decimal_t>();
124 std::vector<decimal_t> dts(pts.size() - 1);
125 for (
unsigned int i = 1; i < pts.size(); i++) {
126 decimal_t d = (pts[i] - pts[i - 1]).
template lpNorm<Eigen::Infinity>();
void setWaypoints(const vec_E< Waypoint< Dim >> &ws)
Set Waypoint array directly, overwrite global vars.
Definition: traj_solver.h:40
std::unique_ptr< PolySolver< 1 > > yaw_solver_
Poly solver for yaw only.
Definition: traj_solver.h:154
vec_E< Waypoint< Dim > > getWaypoints() const
Get the Waypoint array used to solve trajectory.
Definition: traj_solver.h:115
vec_E< Waypoint< Dim > > waypoints_
Intermediate waypoints.
Definition: traj_solver.h:136
std::unique_ptr< PolySolver< Dim > > poly_solver_
Poly solver.
Definition: traj_solver.h:151
Vecf< Dim > jrk
jerk in
Definition: waypoint.h:35
#define ANSI_COLOR_RED
Set red font in printf funtion.
Definition: data_type.h:16
Waypoint base class.
Definition: waypoint.h:23
Trajectory class.
Definition: trajectory.h:43
void setPath(const vec_Vecf< Dim > &path)
Definition: traj_solver.h:55
decimal_t v_
Velocity used for internal time allocation.
Definition: traj_solver.h:142
vec_Vecf< Dim > getPath() const
Get the path used for time allocation.
Definition: traj_solver.h:112
Control
Enum for control input.
Definition: control.h:10
std::vector< decimal_t > dts_
Time allocation.
Definition: traj_solver.h:139
void setDts(const std::vector< decimal_t > &dts)
Definition: traj_solver.h:51
Vecf< Dim > acc
acceleration in
Definition: waypoint.h:34
std::vector< T, Eigen::aligned_allocator< T > > vec_E
Pre-allocated std::vector for Eigen using vec_E.
Definition: data_type.h:53
Control::Control yaw_control_
Control constraints for start and goal yaw.
Definition: traj_solver.h:148
vec_E< Vecf< N > > vec_Vecf
Vector of Eigen 1D float vector.
Definition: data_type.h:70
Vecf< Dim > vel
velocity in
Definition: waypoint.h:33
TrajSolver< 2 > TrajSolver2D
TrajSolver for 2D.
Definition: traj_solver.h:158
Control::Control control_
Control constraints for start and goal.
Definition: traj_solver.h:145
vec_Vecf< Dim > path_
Intermediate pos.
Definition: traj_solver.h:133
Trajectory generator from given waypoints.
double decimal_t
Rename the float type used in lib.
Definition: data_type.h:49
Trajectory< Dim > solve(bool verbose=false)
Solve for trajectory.
Definition: traj_solver.h:73
std::vector< decimal_t > getDts() const
Get the time allocation.
Definition: traj_solver.h:118
#define ANSI_COLOR_RESET
Reset font color in printf funtion.
Definition: data_type.h:40
Eigen::Matrix< decimal_t, N, 1 > Vecf
Eigen 1D float vector of size N.
Definition: data_type.h:56
TrajSolver< 3 > TrajSolver3D
TrajSolver for 3D.
Definition: traj_solver.h:161
TrajSolver(Control::Control control, Control::Control yaw_control=Control::VEL, bool debug=false)
Constructor.
Definition: traj_solver.h:19
Trajectory generator.
Definition: traj_solver.h:12
Vecf< Dim > pos
position in
Definition: waypoint.h:32
std::vector< decimal_t > allocate_time(const vec_Vecf< Dim > &pts, decimal_t v)
Internal time allocation from path and vel using L-inf.
Definition: traj_solver.h:122
Trajectory generator back-end class.
Definition: poly_solver.h:21
void setV(decimal_t v)
Set velocity used for internal time allocation.
Definition: traj_solver.h:47