controls  3.0.0
PolyTrajectory.h
Go to the documentation of this file.
1 #ifndef POLY_TRAJECTORY_H
2 #define POLY_TRAJECTORY_H
3 
4 #include <mav_trajectory_generation/motion_defines.h>
5 #include <mav_trajectory_generation/trajectory.h>
7 
8 #include <optional>
9 #include <string>
10 #include <vector>
11 
21 public:
31  PolyTrajectory(const State& origin, const std::vector<Pose>& targets,
32  std::shared_ptr<Trajectory6DOFLimits> vehicle_limits,
33  const std::string& world_frame_id = "world_ned", bool needs_angle_unwrapping = true);
34 
40  bool is_valid() const;
41 
49  bool is_finished(double t) const override;
50 
58  double get_progress(double t) const override;
59 
65  double get_expected_total_time() const override;
66 
72  int get_total_num_waypoints() const;
73 
75  static constexpr double DEFAULT_MIN_SEGMENT_TIME = 0.01;
76 
78  static constexpr int DEFAULT_DERIVATIVE_TO_OPTIMIZE = mav_trajectory_generation::derivative_order::ACCELERATION;
79 
80 protected:
88  State get_model_world(double t) const override;
89 
90 private:
91  State start_state_;
92  mav_trajectory_generation::Trajectory trajectory_;
93  std::vector<VectorXd> waypoints_;
94  bool valid_ = false;
95  bool needs_angle_unwrapping_;
96 
104  double calculate_progress(double t) const;
105 
111  static void unwrap_angles(std::vector<VectorXd>& waypoints);
112 
121  std::vector<VectorXd> create_waypoints(const State& origin, const std::vector<Pose>& targets) const;
122 
131  std::optional<mav_trajectory_generation::Trajectory> plan_trajectory(const std::vector<VectorXd>& waypoints,
132  const State& start_state) const;
133 };
134 
135 #endif // POLY_TRAJECTORY_H
Polynomial-optimised trajectory through a sequence of 6DOF waypoints.
Definition: PolyTrajectory.h:20
State get_model_world(double t) const override
Evaluates the planned polynomial trajectory at the given time.
Definition: PolyTrajectory.cpp:53
static constexpr double DEFAULT_MIN_SEGMENT_TIME
Minimum segment duration used when inserting constant-position segments (s)
Definition: PolyTrajectory.h:75
bool is_valid() const
Returns true if trajectory planning succeeded.
Definition: PolyTrajectory.cpp:27
double get_progress(double t) const override
Returns trajectory progress as a fractional segment index.
Definition: PolyTrajectory.cpp:38
PolyTrajectory(const State &origin, const std::vector< Pose > &targets, std::shared_ptr< Trajectory6DOFLimits > vehicle_limits, const std::string &world_frame_id="world_ned", bool needs_angle_unwrapping=true)
Constructs and plans the trajectory from an origin state to a list of target poses.
Definition: PolyTrajectory.cpp:11
bool is_finished(double t) const override
Returns true if the elapsed time has reached or exceeded the trajectory duration.
Definition: PolyTrajectory.cpp:31
int get_total_num_waypoints() const
Returns the number of inter-waypoint segments in the trajectory.
Definition: PolyTrajectory.cpp:49
static constexpr int DEFAULT_DERIVATIVE_TO_OPTIMIZE
Derivative order minimised by the polynomial optimiser (acceleration)
Definition: PolyTrajectory.h:78
double get_expected_total_time() const override
Returns the total planned trajectory duration.
Definition: PolyTrajectory.cpp:45
Abstract base class for all trajectory representations.
Definition: TrajectoryBase.h:18
Full kinematic state of the vehicle.
Definition: Types.h:63