controls  3.0.0
PolyTrajectoryFactory.h
Go to the documentation of this file.
1 #ifndef POLY_TRAJECTORY_FACTORY_H
2 #define POLY_TRAJECTORY_FACTORY_H
3 
6 #include <utils/Transforms.h>
7 
8 #include <bb_controls_msgs/action/locomotion.hpp>
9 #include <bb_controls_msgs/srv/spline_traj.hpp>
10 #include <memory>
11 #include <string>
12 #include <vector>
13 
26 public:
27  using Request = bb_controls_msgs::srv::SplineTraj::Request;
28  using Locomotion = bb_controls_msgs::action::Locomotion;
29 
37  PolyTrajectoryFactory(const Request& req, const State& origin, std::shared_ptr<Trajectory6DOFLimits> limits);
38 
46  PolyTrajectoryFactory(const Locomotion::Goal& goal, const State& origin,
47  std::shared_ptr<Trajectory6DOFLimits> limits);
48 
57 
65  PolyTrajectoryFactory& with_frame_id(const std::string& frame_id);
66 
74  PolyTrajectoryFactory& with_angle_unwrapping(bool needs_angle_unwrapping = true);
75 
81  std::unique_ptr<TrajectoryBase> build() override;
82 
83 private:
84  State origin_;
85  std::shared_ptr<Trajectory6DOFLimits> limits_;
86  std::vector<Pose> raw_goals_;
87  double origin_twist_norm_threshold_ = 0.03;
88  bool relative_xy_ = false;
89  bool relative_z_ = false;
90  bool relative_heading_ = false;
91  bool interpolate_heading_ = false;
92  bool needs_angle_unwrapping_ = true;
93  std::string frame_id_ = "world_ned";
94  bool is_valid_ = true;
95 
101  std::vector<Pose> compute_absolute_goals() const;
102 
110  std::vector<Pose> add_heading_interpolation(const std::vector<Pose>& goals) const;
111 };
112 
113 #endif // POLY_TRAJECTORY_FACTORY_H
Factory that builds polynomial waypoint-following trajectories.
Definition: PolyTrajectoryFactory.h:25
bb_controls_msgs::srv::SplineTraj::Request Request
Definition: PolyTrajectoryFactory.h:27
PolyTrajectoryFactory & with_frame_id(const std::string &frame_id)
Sets the TF world frame ID embedded in visualisation messages.
Definition: PolyTrajectoryFactory.cpp:109
bb_controls_msgs::action::Locomotion Locomotion
Definition: PolyTrajectoryFactory.h:28
PolyTrajectoryFactory & with_angle_unwrapping(bool needs_angle_unwrapping=true)
Controls whether yaw angles are unwrapped across consecutive waypoints.
Definition: PolyTrajectoryFactory.cpp:114
PolyTrajectoryFactory & with_origin_twist_threshold(double max_norm)
Sets the origin twist norm threshold below which the initial twist is zeroed.
Definition: PolyTrajectoryFactory.cpp:104
std::unique_ptr< TrajectoryBase > build() override
Builds and returns the configured trajectory.
Definition: PolyTrajectoryFactory.cpp:119
PolyTrajectoryFactory(const Request &req, const State &origin, std::shared_ptr< Trajectory6DOFLimits > limits)
Constructs the factory from a SplineTraj service request.
Definition: PolyTrajectoryFactory.cpp:10
Abstract factory interface for constructing TrajectoryBase instances.
Definition: TrajectoryFactoryInterface.h:15
Full kinematic state of the vehicle.
Definition: Types.h:63