56 const ros::NodeHandle& n) {
57 ros::NodeHandle nl(n);
60 QuadrotorControl qc_lower, qc_upper;
61 qc_lower.yaw_rate = 0.0;
62 qc_upper.yaw_rate = 0.0;
64 if (!nl.getParam(
"tracker/upper/pitch", qc_upper.pitch))
return false;
65 if (!nl.getParam(
"tracker/upper/roll", qc_upper.roll))
return false;
66 if (!nl.getParam(
"tracker/upper/thrust", qc_upper.thrust))
return false;
67 if (!nl.getParam(
"tracker/lower/thrust", qc_lower.thrust))
return false;
68 qc_lower.pitch = -qc_upper.pitch;
69 qc_lower.roll = -qc_upper.roll;
73 VectorXd max_planner_speed(3);
74 if (!nl.getParam(
"planner/vx", max_planner_speed(0)))
return false;
75 if (!nl.getParam(
"planner/vy", max_planner_speed(1)))
return false;
76 if (!nl.getParam(
"planner/vz", max_planner_speed(2)))
return false;
79 VectorBoundBox(-max_planner_speed, max_planner_speed));
82 relative_dynamics_.reset(
new QuadrotorDecoupled6DRelKinematics<QuadrotorControlBoundBox>);
86 PositionVelocity(Vector3d::Zero(), Vector3d::Zero()), qc_upper);
94 if (!nl.getParam(
"disturbance/velocity/x",
vel_dist_(0)))
return false;
95 if (!nl.getParam(
"disturbance/velocity/y",
vel_dist_(1)))
return false;
96 if (!nl.getParam(
"disturbance/velocity/z",
vel_dist_(2)))
return false;
97 if (!nl.getParam(
"disturbance/acceleration/x",
acc_dist_(0)))
return false;
98 if (!nl.getParam(
"disturbance/acceleration/y",
acc_dist_(1)))
return false;
99 if (!nl.getParam(
"disturbance/acceleration/z",
acc_dist_(2)))
return false;
102 if (!nl.getParam(
"expansion/velocity/x",
vel_exp_(0)))
return false;
103 if (!nl.getParam(
"expansion/velocity/y",
vel_exp_(1)))
return false;
104 if (!nl.getParam(
"expansion/velocity/z",
vel_exp_(2)))
return false;
124 const ros::NodeHandle& n) {
130 const PositionVelocity& tracker_x,
131 const PositionVelocity& planner_x)
const {
133 const PositionVelocityRelPositionVelocity relative_x(tracker_x, planner_x);
134 const Vector3d& rx_position = relative_x.State().Position();
135 const Vector3d& rx_velocity = relative_x.State().Velocity();
138 const auto& control_bound =
140 const auto& max_planner_u = control_bound.Max();
143 double value = -std::numeric_limits<double>::infinity();
144 for (
size_t ii = 0; ii < 3; ii++) {
145 const double x = rx_position(ii);
146 const double v = rx_velocity(ii);
147 const double v_p = max_planner_u(ii);
150 const double value_A = -x -
pos_exp_(ii) +
151 (0.5 * (v - v_p) * (v - v_p) - v_p * v_p) /
155 const double value_B = x +
pos_exp_(ii) -
156 (-0.5 * (v + v_p) * (v + v_p) + v_p * v_p) /
160 value = std::max(value, std::max(value_A, value_B));
167 std::unique_ptr<RelativeState<PositionVelocity, PositionVelocity>>
169 const PositionVelocity& tracker_x,
170 const PositionVelocity& planner_x)
const {
172 const PositionVelocityRelPositionVelocity relative_x(tracker_x, planner_x);
173 const Vector3d& rx_position = relative_x.State().Position();
174 const Vector3d& rx_velocity = relative_x.State().Velocity();
177 const auto& control_bound =
179 const auto& max_planner_u = control_bound.Max();
182 Vector3d pos_grad, vel_grad;
183 for (
size_t ii = 0; ii < 3; ii++) {
184 const double x = rx_position(ii);
185 const double v = rx_velocity(ii);
186 const double v_p = max_planner_u(ii);
189 const double value_A = -x -
pos_exp_(ii) +
190 (0.5 * (v - v_p) * (v - v_p) - v_p * v_p) /
194 const double value_B = x +
pos_exp_(ii) -
195 (-0.5 * (v + v_p) * (v + v_p) + v_p * v_p) /
200 if (value_A > value_B) {
209 return std::unique_ptr<RelativeState<PositionVelocity, PositionVelocity>>(
210 new PositionVelocityRelPositionVelocity(pos_grad, vel_grad));
218 const PositionVelocity& tracker_x,
219 const PositionVelocity& planner_x)
const {
221 const double value =
Value(tracker_x, planner_x);
224 const double relative_high = 0.20;
225 const double relative_low = 0.05;
229 const double value_high = relative_high * max_value;
230 const double value_low = relative_low * max_value;
232 const double priority =
235 std::min((value - value_low) / (value_high - value_low), 1.0));
double Value(const PositionVelocity &vehicle_x, const PositionVelocity &planner_x) const
bool RegisterCallbacks(const ros::NodeHandle &n)
Kinematics< PositionVelocity > planner_dynamics_
bool LoadParameters(const ros::NodeHandle &n)
QuadrotorDecoupled6D< QuadrotorControlBoundBox > tracker_dynamics_
double Priority(const PositionVelocity &vehicle_x, const PositionVelocity &planner_x) const
std::unique_ptr< RelativeDynamics< PositionVelocity, QuadrotorControl, PositionVelocity, VectorXd > > relative_dynamics_
std::unique_ptr< RelativeState< PositionVelocity, PositionVelocity > > Gradient(const PositionVelocity &vehicle_x, const PositionVelocity &planner_x) const