44 #ifndef FASTRACK_DYNAMICS_QUADROTOR_DECOUPLED_6D_REL_KINEMATICS_H 45 #define FASTRACK_DYNAMICS_QUADROTOR_DECOUPLED_6D_REL_KINEMATICS_H 60 using control::QuadrotorControl;
61 using dynamics::Kinematics;
62 using dynamics::QuadrotorDecoupled6D;
63 using state::PositionVelocity;
64 using state::PositionVelocityRelPositionVelocity;
65 using state::RelativeState;
67 template <
typename CB>
70 PositionVelocity, VectorXd> {
79 inline std::unique_ptr<RelativeState<PositionVelocity, PositionVelocity>>
80 Evaluate(
const PositionVelocity& tracker_x,
const QuadrotorControl& tracker_u,
81 const PositionVelocity& planner_x,
const VectorXd& planner_u)
const {
82 if (planner_u.size() != PositionVelocity::ConfigurationDimension())
83 throw std::runtime_error(
"Bad planner control size.");
89 return std::unique_ptr<PositionVelocityRelPositionVelocity>(
90 new PositionVelocityRelPositionVelocity(
91 quad_dynamics.
Evaluate(tracker_x, tracker_u),
92 quad_kinematics.
Evaluate(planner_x, planner_u)));
99 const PositionVelocity& tracker_x,
const PositionVelocity& planner_x,
100 const RelativeState<PositionVelocity, PositionVelocity>& value_gradient,
101 const ControlBound<QuadrotorControl>& tracker_u_bound,
102 const ControlBound<VectorXd>& planner_u_bound)
const {
105 const auto& cast =
static_cast<const PositionVelocityRelPositionVelocity&
>(
108 const auto& grad = cast.State();
109 QuadrotorControl negative_grad;
110 negative_grad.yaw_rate = 0.0;
111 negative_grad.pitch = -grad.Vx();
112 negative_grad.roll = grad.Vy();
113 negative_grad.thrust = -grad.Vz();
116 QuadrotorControl c = tracker_u_bound.ProjectToSurface(negative_grad);
S Evaluate(const S &x, const VectorXd &u) const
~QuadrotorDecoupled6DRelKinematics()
PositionVelocity Evaluate(const PositionVelocity &x, const QuadrotorControl &u) const
std::unique_ptr< RelativeState< PositionVelocity, PositionVelocity > > Evaluate(const PositionVelocity &tracker_x, const QuadrotorControl &tracker_u, const PositionVelocity &planner_x, const VectorXd &planner_u) const
QuadrotorDecoupled6DRelKinematics()
QuadrotorControl OptimalControl(const PositionVelocity &tracker_x, const PositionVelocity &planner_x, const RelativeState< PositionVelocity, PositionVelocity > &value_gradient, const ControlBound< QuadrotorControl > &tracker_u_bound, const ControlBound< VectorXd > &planner_u_bound) const