60 using control::QuadrotorControl;
61 using control::QuadrotorControlBoundCylinder;
62 using state::PlanarDubins3D;
63 using state::PositionVelocity;
64 using state::PositionVelocityRelPlanarDubins3D;
68 std::unique_ptr<RelativeState<PositionVelocity, PlanarDubins3D>>
70 const PositionVelocity& tracker_x,
const QuadrotorControl& tracker_u,
71 const PlanarDubins3D& planner_x,
const double& planner_u)
const {
73 const PositionVelocityRelPlanarDubins3D relative_x(tracker_x, planner_x);
79 const auto net_tangent_velocity =
80 relative_x.TangentVelocity() - planner_x.V();
83 const double distance_dot =
84 net_tangent_velocity * std::cos(relative_x.Bearing()) +
85 relative_x.NormalVelocity() * std::sin(relative_x.Bearing());
88 const double bearing_dot =
90 (-net_tangent_velocity * std::sin(relative_x.Bearing()) +
91 relative_x.NormalVelocity() * std::cos(relative_x.Bearing())) /
92 relative_x.Distance();
95 const double tracker_accel_x =
constants::G * std::tan(tracker_u.pitch);
96 const double tracker_accel_y = -
constants::G * std::tan(tracker_u.roll);
100 const double c = std::cos(planner_x.Theta());
101 const double s = std::sin(planner_x.Theta());
103 const double tangent_velocity_dot = tracker_accel_x * c +
104 tracker_accel_y * s +
105 planner_u * relative_x.NormalVelocity();
106 const double normal_velocity_dot = -tracker_accel_x * s +
107 tracker_accel_y * c -
108 planner_u * relative_x.TangentVelocity();
110 return std::unique_ptr<PositionVelocityRelPlanarDubins3D>(
111 new PositionVelocityRelPlanarDubins3D(distance_dot, bearing_dot,
112 tangent_velocity_dot,
113 normal_velocity_dot));
120 const PositionVelocity& tracker_x,
const PlanarDubins3D& planner_x,
121 const RelativeState<PositionVelocity, PlanarDubins3D>& value_gradient,
122 const ControlBound<QuadrotorControl>& tracker_u_bound,
123 const ControlBound<double>& planner_u_bound)
const {
127 static_cast<const PositionVelocityRelPlanarDubins3D&
>(value_gradient);
130 const double c = std::cos(planner_x.Theta());
131 const double s = std::sin(planner_x.Theta());
133 QuadrotorControl negative_grad;
134 negative_grad.pitch =
135 -(grad.TangentVelocity() * c - grad.NormalVelocity() * s);
137 -(-grad.TangentVelocity() * s - grad.NormalVelocity() * c);
138 negative_grad.thrust = 0.0;
139 negative_grad.yaw_rate = 0.0;
142 QuadrotorControl u = tracker_u_bound.ProjectToSurface(negative_grad);
146 constexpr
double k_p = 1.5;
147 constexpr
double k_d = 1.0;
150 k_d * (planner_x.Vz() - tracker_x.Vz());
std::unique_ptr< RelativeState< PositionVelocity, PlanarDubins3D > > Evaluate(const PositionVelocity &tracker_x, const QuadrotorControl &tracker_u, const PlanarDubins3D &planner_x, const double &planner_u) const
QuadrotorControl OptimalControl(const PositionVelocity &tracker_x, const PlanarDubins3D &planner_x, const RelativeState< PositionVelocity, PlanarDubins3D > &value_gradient, const ControlBound< QuadrotorControl > &tracker_u_bound, const ControlBound< double > &planner_u_bound) const
static constexpr double G