25 const size_t horizon,
const double ts,
const Eigen::MatrixXd& ego,
26 const Eigen::MatrixXd& xWS,
const Eigen::MatrixXd& uWS,
27 const Eigen::MatrixXd& l_warm_up,
const Eigen::MatrixXd& n_warm_up,
28 const Eigen::MatrixXd& x0,
const Eigen::MatrixXd& xf,
29 const Eigen::MatrixXd& last_time_u,
const std::vector<double>& XYbounds,
30 const Eigen::MatrixXi& obstacles_edges_num,
const size_t obstacles_num,
31 const Eigen::MatrixXd& obstacles_A,
const Eigen::MatrixXd& obstacles_b,
37 l_warm_up_(l_warm_up),
38 n_warm_up_(n_warm_up),
41 last_time_u_(last_time_u),
43 obstacles_edges_num_(obstacles_edges_num),
44 obstacles_A_(obstacles_A),
45 obstacles_b_(obstacles_b) {
46 ACHECK(horizon < std::numeric_limits<int>::max())
47 <<
"Invalid cast on horizon in open space planner";
48 horizon_ =
static_cast<int>(horizon);
49 ACHECK(obstacles_num < std::numeric_limits<int>::max())
50 <<
"Invalid cast on obstacles_num in open space planner";
52 obstacles_num_ =
static_cast<int>(obstacles_num);
53 w_ev_ = ego_(1, 0) + ego_(3, 0);
54 l_ev_ = ego_(0, 0) + ego_(2, 0);
55 g_ = {l_ev_ / 2, w_ev_ / 2, l_ev_ / 2, w_ev_ / 2};
56 offset_ = (ego_(0, 0) + ego_(2, 0)) / 2 - ego_(2, 0);
57 obstacles_edges_sum_ = obstacles_edges_num_.sum();
58 state_result_ = Eigen::MatrixXd::Zero(4, horizon_ + 1);
59 dual_l_result_ = Eigen::MatrixXd::Zero(obstacles_edges_sum_, horizon_ + 1);
60 dual_n_result_ = Eigen::MatrixXd::Zero(4 * obstacles_num_, horizon_ + 1);
61 control_result_ = Eigen::MatrixXd::Zero(2, horizon_ + 1);
62 time_result_ = Eigen::MatrixXd::Zero(1, horizon_ + 1);
63 state_start_index_ = 0;
64 control_start_index_ = 4 * (horizon_ + 1);
65 time_start_index_ = control_start_index_ + 2 * horizon_;
66 l_start_index_ = time_start_index_;
67 n_start_index_ = l_start_index_ + obstacles_edges_sum_ * (horizon_ + 1);
69 planner_open_space_config_ = planner_open_space_config;
70 distance_approach_config_ =
71 planner_open_space_config_.distance_approach_config();
72 weight_state_x_ = distance_approach_config_.
weight_x();
73 weight_state_y_ = distance_approach_config_.
weight_y();
74 weight_state_phi_ = distance_approach_config_.
weight_phi();
75 weight_state_v_ = distance_approach_config_.
weight_v();
76 weight_input_steer_ = distance_approach_config_.
weight_steer();
77 weight_input_a_ = distance_approach_config_.
weight_a();
82 weight_first_order_time_ =
84 weight_second_order_time_ =
91 max_acceleration_forward_ =
93 max_acceleration_reverse_ =
95 min_time_sample_scaling_ =
97 max_time_sample_scaling_ =
101 use_fix_time_ = distance_approach_config_.
use_fix_time();
103 enable_constraint_check_ =
108 int& n,
int& m,
int& nnz_jac_g,
int& nnz_h_lag,
109 IndexStyleEnum& index_style) {
112 int n1 = 4 * (horizon_ + 1);
115 int n2 = 2 * horizon_;
118 lambda_horizon_ = obstacles_edges_num_.sum() * (horizon_ + 1);
119 ADEBUG <<
"lambda_horizon_: " << lambda_horizon_;
121 miu_horizon_ = obstacles_num_ * 4 * (horizon_ + 1);
122 ADEBUG <<
"miu_horizon_: " << miu_horizon_;
125 int m1 = 4 * horizon_;
131 int m4 = 4 * obstacles_num_ * (horizon_ + 1);
134 num_of_variables_ = n1 + n2 + lambda_horizon_ + miu_horizon_;
135 num_of_constraints_ = m1 + m2 + m4 + (num_of_variables_ - (horizon_ + 1) + 2);
138 n = num_of_variables_;
139 ADEBUG <<
"num_of_variables_ " << num_of_variables_;
141 m = num_of_constraints_;
142 ADEBUG <<
"num_of_constraints_ " << num_of_constraints_;
146 index_style = IndexStyleEnum::C_STYLE;
154 ADEBUG <<
"get_bounds_info";
155 ACHECK(XYbounds_.size() == 4)
156 <<
"XYbounds_ size is not 4, but" << XYbounds_.size();
161 int variable_index = 0;
162 for (
int i = 0; i < 4; ++i) {
169 for (
int i = 1; i < horizon_; ++i) {
171 x_l[variable_index] = -2e19;
172 x_u[variable_index] = 2e19;
175 x_l[variable_index + 1] = -2e19;
176 x_u[variable_index + 1] = 2e19;
179 x_l[variable_index + 2] = -2e19;
180 x_u[variable_index + 2] = 2e19;
183 x_l[variable_index + 3] = -2e19;
184 x_u[variable_index + 3] = 2e19;
190 for (
int i = 0; i < 4; ++i) {
191 x_l[variable_index + i] = -2e19;
192 x_u[variable_index + i] = 2e19;
195 ADEBUG <<
"variable_index after adding state variables : " << variable_index;
198 for (
int i = 0; i < horizon_; ++i) {
200 x_l[variable_index] = -2e19;
201 x_u[variable_index] = 2e19;
204 x_l[variable_index + 1] = -2e19;
205 x_u[variable_index + 1] = 2e19;
209 ADEBUG <<
"variable_index after adding control variables : "
214 for (
int i = 0; i < horizon_ + 1; ++i) {
215 for (
int j = 0; j < obstacles_edges_sum_; ++j) {
216 x_l[variable_index] = 0.0;
217 x_u[variable_index] = 2e19;
221 ADEBUG <<
"variable_index after adding lagrange l : " << variable_index;
224 for (
int i = 0; i < horizon_ + 1; ++i) {
225 for (
int j = 0; j < 4 * obstacles_num_; ++j) {
226 x_l[variable_index] = 0.0;
227 x_u[variable_index] = 2e19;
232 ADEBUG <<
"variable_index after adding lagrange n : " << variable_index;
238 int constraint_index = 0;
239 for (
int i = 0; i < 4 * horizon_; ++i) {
243 constraint_index += 4 * horizon_;
245 ADEBUG <<
"constraint_index after adding Euler forward dynamics constraints: "
250 for (
int i = 0; i < horizon_; ++i) {
251 g_l[constraint_index] = -max_steer_rate_;
252 g_u[constraint_index] = max_steer_rate_;
256 ADEBUG <<
"constraint_index after adding steering rate constraints: "
261 for (
int i = 0; i < horizon_ + 1; ++i) {
262 for (
int j = 0; j < obstacles_num_; ++j) {
264 g_l[constraint_index] = -2e19;
265 g_u[constraint_index] = 1.0;
268 g_l[constraint_index + 1] = 0.0;
269 g_u[constraint_index + 1] = 0.0;
270 g_l[constraint_index + 2] = 0.0;
271 g_u[constraint_index + 2] = 0.0;
274 g_l[constraint_index + 3] = min_safety_distance_;
275 g_u[constraint_index + 3] = 2e19;
276 constraint_index += 4;
279 ADEBUG <<
"constraints_index after adding obstacles related constraints: "
284 g_l[constraint_index] = x0_(0, 0);
285 g_u[constraint_index] = x0_(0, 0);
286 g_l[constraint_index + 1] = x0_(1, 0);
287 g_u[constraint_index + 1] = x0_(1, 0);
288 g_l[constraint_index + 2] = x0_(2, 0);
289 g_u[constraint_index + 2] = x0_(2, 0);
290 g_l[constraint_index + 3] = x0_(3, 0);
291 g_u[constraint_index + 3] = x0_(3, 0);
292 constraint_index += 4;
294 for (
int i = 1; i < horizon_; ++i) {
295 g_l[constraint_index] = XYbounds_[0];
296 g_u[constraint_index] = XYbounds_[1];
297 g_l[constraint_index + 1] = XYbounds_[2];
298 g_u[constraint_index + 1] = XYbounds_[3];
299 g_l[constraint_index + 2] = -max_speed_reverse_;
300 g_u[constraint_index + 2] = max_speed_forward_;
301 constraint_index += 3;
305 g_l[constraint_index] = xf_(0, 0);
306 g_u[constraint_index] = xf_(0, 0);
307 g_l[constraint_index + 1] = xf_(1, 0);
308 g_u[constraint_index + 1] = xf_(1, 0);
309 g_l[constraint_index + 2] = xf_(2, 0);
310 g_u[constraint_index + 2] = xf_(2, 0);
311 g_l[constraint_index + 3] = xf_(3, 0);
312 g_u[constraint_index + 3] = xf_(3, 0);
313 constraint_index += 4;
315 for (
int i = 0; i < horizon_; ++i) {
316 g_l[constraint_index] = -max_steer_angle_;
317 g_u[constraint_index] = max_steer_angle_;
318 g_l[constraint_index + 1] = -max_acceleration_reverse_;
319 g_u[constraint_index + 1] = max_acceleration_forward_;
320 constraint_index += 2;
323 for (
int i = 0; i < lambda_horizon_; ++i) {
324 g_l[constraint_index] = 0.0;
325 g_u[constraint_index] = 2e19;
329 for (
int i = 0; i < miu_horizon_; ++i) {
330 g_l[constraint_index] = 0.0;
331 g_u[constraint_index] = 2e19;
335 ADEBUG <<
"constraint_index after adding obstacles constraints: "
337 ADEBUG <<
"get_bounds_info_ out";
342 int n,
bool init_x,
double* x,
bool init_z,
double* z_L,
double* z_U,
int m,
343 bool init_lambda,
double* lambda) {
344 ADEBUG <<
"get_starting_point";
345 ACHECK(init_x) <<
"Warm start init_x setting failed";
347 CHECK_EQ(horizon_, uWS_.cols());
348 CHECK_EQ(horizon_ + 1, xWS_.cols());
351 for (
int i = 0; i < horizon_ + 1; ++i) {
353 for (
int j = 0; j < 4; ++j) {
354 x[index + j] = xWS_(j, i);
359 for (
int i = 0; i < horizon_; ++i) {
361 x[control_start_index_ + index] = uWS_(0, i);
362 x[control_start_index_ + index + 1] = uWS_(1, i);
366 for (
int i = 0; i < horizon_ + 1; ++i) {
367 int index = i * obstacles_edges_sum_;
368 for (
int j = 0; j < obstacles_edges_sum_; ++j) {
369 x[l_start_index_ + index + j] = l_warm_up_(j, i);
374 for (
int i = 0; i < horizon_ + 1; ++i) {
375 int index = i * 4 * obstacles_num_;
376 for (
int j = 0; j < 4 * obstacles_num_; ++j) {
377 x[n_start_index_ + index + j] = n_warm_up_(j, i);
381 if (enable_constraint_check_) {
384 ADEBUG <<
"initial points constraint checking";
389 ADEBUG <<
"get_starting_point out";
403 gradient(
tag_f, n, x, grad_f);
411 if (enable_constraint_check_) {
419 int nele_jac,
int* iRow,
422 if (values ==
nullptr) {
424 for (
int idx = 0; idx < nnz_jac; idx++) {
425 iRow[idx] = rind_g[idx];
426 jCol[idx] = cind_g[idx];
430 sparse_jac(
tag_g, m, n, 1, x, &nnz_jac, &rind_g, &cind_g, &jacval,
432 for (
int idx = 0; idx < nnz_jac; idx++) {
433 values[idx] = jacval[idx];
441 int n,
const double* x,
bool new_x,
int m,
int nele_jac,
int* iRow,
442 int* jCol,
double* values) {
443 AERROR <<
"NOT VALID NOW";
448 int n,
const double* x,
bool new_x,
double obj_factor,
int m,
449 const double* lambda,
bool new_lambda,
int nele_hess,
int* iRow,
int* jCol,
451 if (values ==
nullptr) {
455 for (
int idx = 0; idx < nnz_L; idx++) {
456 iRow[idx] = rind_L[idx];
457 jCol[idx] = cind_L[idx];
463 obj_lam[0] = obj_factor;
465 for (
int idx = 0; idx < m; idx++) {
466 obj_lam[1 + idx] = lambda[idx];
469 set_param_vec(
tag_L, m + 1, obj_lam);
470 sparse_hess(
tag_L, n, 1,
const_cast<double*
>(x), &nnz_L, &rind_L, &cind_L,
471 &hessval, options_L);
473 for (
int idx = 0; idx < nnz_L; idx++) {
474 values[idx] = hessval[idx];
482 Ipopt::SolverReturn status,
int n,
const double* x,
const double* z_L,
483 const double* z_U,
int m,
const double* g,
const double* lambda,
484 double obj_value,
const Ipopt::IpoptData* ip_data,
485 Ipopt::IpoptCalculatedQuantities* ip_cq) {
486 int state_index = state_start_index_;
487 int control_index = control_start_index_;
489 int dual_l_index = l_start_index_;
490 int dual_n_index = n_start_index_;
493 if (enable_constraint_check_) {
494 ADEBUG <<
"final resolution constraint checking";
502 for (
int i = 0; i < horizon_; ++i) {
503 state_result_(0, i) = x[state_index];
504 state_result_(1, i) = x[state_index + 1];
505 state_result_(2, i) = x[state_index + 2];
506 state_result_(3, i) = x[state_index + 3];
507 control_result_(0, i) = x[control_index];
508 control_result_(1, i) = x[control_index + 1];
509 time_result_(0, i) = ts_;
510 for (
int j = 0; j < obstacles_edges_sum_; ++j) {
511 dual_l_result_(j, i) = x[dual_l_index + j];
513 for (
int k = 0; k < 4 * obstacles_num_; k++) {
514 dual_n_result_(k, i) = x[dual_n_index + k];
519 dual_l_index += obstacles_edges_sum_;
520 dual_n_index += 4 * obstacles_num_;
522 state_result_(0, 0) = x0_(0, 0);
523 state_result_(1, 0) = x0_(1, 0);
524 state_result_(2, 0) = x0_(2, 0);
525 state_result_(3, 0) = x0_(3, 0);
527 state_result_(0, horizon_) = xf_(0, 0);
528 state_result_(1, horizon_) = xf_(1, 0);
529 state_result_(2, horizon_) = xf_(2, 0);
530 state_result_(3, horizon_) = xf_(3, 0);
531 time_result_(0, horizon_) = ts_;
533 for (
int j = 0; j < obstacles_edges_sum_; ++j) {
534 dual_l_result_(j, horizon_) = x[dual_l_index + j];
536 for (
int k = 0; k < 4 * obstacles_num_; k++) {
537 dual_n_result_(k, horizon_) = x[dual_n_index + k];
550 Eigen::MatrixXd* state_result, Eigen::MatrixXd* control_result,
551 Eigen::MatrixXd* time_result, Eigen::MatrixXd* dual_l_result,
552 Eigen::MatrixXd* dual_n_result)
const {
553 ADEBUG <<
"get_optimization_results";
554 *state_result = state_result_;
555 *control_result = control_result_;
556 *time_result = time_result_;
557 *dual_l_result = dual_l_result_;
558 *dual_n_result = dual_n_result_;
563 CHECK_EQ(state_result_.cols(), xWS_.cols());
564 CHECK_EQ(state_result_.rows(), xWS_.rows());
565 double state_diff_max = 0.0;
566 for (
int i = 0; i < horizon_ + 1; ++i) {
567 for (
int j = 0; j < 4; ++j) {
569 std::max(std::abs(xWS_(j, i) - state_result_(j, i)), state_diff_max);
574 CHECK_EQ(control_result_.rows(), uWS_.rows());
575 double control_diff_max = 0.0;
576 for (
int i = 0; i < horizon_; ++i) {
577 control_diff_max = std::max(std::abs(uWS_(0, i) - control_result_(0, i)),
579 control_diff_max = std::max(std::abs(uWS_(1, i) - control_result_(1, i)),
584 CHECK_EQ(dual_l_result_.cols(), l_warm_up_.cols());
585 CHECK_EQ(dual_l_result_.rows(), l_warm_up_.rows());
586 double l_diff_max = 0.0;
587 for (
int i = 0; i < horizon_ + 1; ++i) {
588 for (
int j = 0; j < obstacles_edges_sum_; ++j) {
589 l_diff_max = std::max(std::abs(l_warm_up_(j, i) - dual_l_result_(j, i)),
595 CHECK_EQ(n_warm_up_.cols(), dual_n_result_.cols());
596 CHECK_EQ(n_warm_up_.rows(), dual_n_result_.rows());
597 double n_diff_max = 0.0;
598 for (
int i = 0; i < horizon_ + 1; ++i) {
599 for (
int j = 0; j < 4 * obstacles_num_; ++j) {
600 n_diff_max = std::max(std::abs(n_warm_up_(j, i) - dual_n_result_(j, i)),
605 ADEBUG <<
"state_diff_max: " << state_diff_max;
606 ADEBUG <<
"control_diff_max: " << control_diff_max;
607 ADEBUG <<
"dual_l_diff_max: " << l_diff_max;
608 ADEBUG <<
"dual_n_diff_max: " << n_diff_max;
620 DCHECK(ts_ != 0) <<
"ts in distance_approach_ is 0";
621 int control_index = control_start_index_;
623 int state_index = state_start_index_;
630 for (
int i = 0; i < horizon_ + 1; ++i) {
631 T x1_diff = x[state_index] - xWS_(0, i);
632 T x2_diff = x[state_index + 1] - xWS_(1, i);
633 T x3_diff = x[state_index + 2] - xWS_(2, i);
634 T x4_abs = x[state_index + 3];
635 *obj_value += weight_state_x_ * x1_diff * x1_diff +
636 weight_state_y_ * x2_diff * x2_diff +
637 weight_state_phi_ * x3_diff * x3_diff +
638 weight_state_v_ * x4_abs * x4_abs;
643 for (
int i = 0; i < horizon_; ++i) {
644 *obj_value += weight_input_steer_ * x[control_index] * x[control_index] +
645 weight_input_a_ * x[control_index + 1] * x[control_index + 1];
650 control_index = control_start_index_;
651 T last_time_steer_rate = (x[control_index] - last_time_u_(0, 0)) / ts_;
652 T last_time_a_rate = (x[control_index + 1] - last_time_u_(1, 0)) / ts_;
655 weight_stitching_steer_ * last_time_steer_rate * last_time_steer_rate +
656 weight_stitching_a_ * last_time_a_rate * last_time_a_rate;
659 for (
int i = 0; i < horizon_ - 1; ++i) {
660 T steering_rate = (x[control_index + 2] - x[control_index]) / ts_;
661 T a_rate = (x[control_index + 3] - x[control_index + 1]) / ts_;
662 *obj_value += weight_rate_steer_ * steering_rate * steering_rate +
663 weight_rate_a_ * a_rate * a_rate;
672 int state_index = state_start_index_;
675 int control_index = control_start_index_;
680 int constraint_index = 0;
684 for (
int i = 0; i < horizon_; ++i) {
696 g[constraint_index] =
698 (x[state_index] + ts_ * x[state_index + 3] * cos(x[state_index + 2]));
711 g[constraint_index + 1] =
712 x[state_index + 5] - (x[state_index + 1] + ts_ * x[state_index + 3] *
713 sin(x[state_index + 2]));
728 g[constraint_index + 2] =
730 (x[state_index + 2] +
731 ts_ * x[state_index + 3] * tan(x[control_index]) / wheelbase_);
739 g[constraint_index + 3] =
740 x[state_index + 7] - (x[state_index + 3] + ts_ * x[control_index + 1]);
743 constraint_index += 4;
747 ADEBUG <<
"constraint_index after adding Euler forward dynamics constraints "
753 control_index = control_start_index_;
756 g[constraint_index] = (x[control_index] - last_time_u_(0, 0)) / ts_;
760 for (
int i = 1; i < horizon_; ++i) {
761 g[constraint_index] = (x[control_index] - x[control_index - 2]) / ts_;
768 state_index = state_start_index_;
769 int l_index = l_start_index_;
770 int n_index = n_start_index_;
772 for (
int i = 0; i < horizon_ + 1; ++i) {
773 int edges_counter = 0;
774 for (
int j = 0; j < obstacles_num_; ++j) {
775 int current_edges_num = obstacles_edges_num_(j, 0);
777 obstacles_A_.block(edges_counter, 0, current_edges_num, 2);
779 obstacles_b_.block(edges_counter, 0, current_edges_num, 1);
784 for (
int k = 0; k < current_edges_num; ++k) {
786 tmp1 += Aj(k, 0) * x[l_index + k];
787 tmp2 += Aj(k, 1) * x[l_index + k];
789 g[constraint_index] = tmp1 * tmp1 + tmp2 * tmp2;
792 g[constraint_index + 1] = x[n_index] - x[n_index + 2] +
793 cos(x[state_index + 2]) * tmp1 +
794 sin(x[state_index + 2]) * tmp2;
796 g[constraint_index + 2] = x[n_index + 1] - x[n_index + 3] -
797 sin(x[state_index + 2]) * tmp1 +
798 cos(x[state_index + 2]) * tmp2;
802 for (
int k = 0; k < 4; ++k) {
803 tmp3 += -g_[k] * x[n_index + k];
807 for (
int k = 0; k < current_edges_num; ++k) {
808 tmp4 += bj(k, 0) * x[l_index + k];
811 g[constraint_index + 3] =
812 tmp3 + (x[state_index] + cos(x[state_index + 2]) * offset_) * tmp1 +
813 (x[state_index + 1] + sin(x[state_index + 2]) * offset_) * tmp2 -
817 edges_counter += current_edges_num;
818 l_index += current_edges_num;
820 constraint_index += 4;
824 ADEBUG <<
"constraint_index after obstacles avoidance constraints "
829 state_index = state_start_index_;
830 control_index = control_start_index_;
832 l_index = l_start_index_;
833 n_index = n_start_index_;
836 g[constraint_index] = x[state_index];
837 g[constraint_index + 1] = x[state_index + 1];
838 g[constraint_index + 2] = x[state_index + 2];
839 g[constraint_index + 3] = x[state_index + 3];
840 constraint_index += 4;
844 for (
int i = 1; i < horizon_; ++i) {
845 g[constraint_index] = x[state_index];
846 g[constraint_index + 1] = x[state_index + 1];
847 g[constraint_index + 2] = x[state_index + 3];
848 constraint_index += 3;
853 g[constraint_index] = x[state_index];
854 g[constraint_index + 1] = x[state_index + 1];
855 g[constraint_index + 2] = x[state_index + 2];
856 g[constraint_index + 3] = x[state_index + 3];
857 constraint_index += 4;
860 for (
int i = 0; i < horizon_; ++i) {
861 g[constraint_index] = x[control_index];
862 g[constraint_index + 1] = x[control_index + 1];
863 constraint_index += 2;
867 for (
int i = 0; i < lambda_horizon_; ++i) {
868 g[constraint_index] = x[l_index];
873 for (
int i = 0; i < miu_horizon_; ++i) {
874 g[constraint_index] = x[n_index];
881 int m,
const double* g) {
891 const double delta_v = 1e-4;
892 for (
int idx = 0; idx < n; ++idx) {
893 x_u_tmp[idx] = x_u_tmp[idx] + delta_v;
894 x_l_tmp[idx] = x_l_tmp[idx] - delta_v;
895 if (x[idx] > x_u_tmp[idx] || x[idx] < x_l_tmp[idx]) {
896 AINFO <<
"x idx unfeasible: " << idx <<
", x: " << x[idx]
897 <<
", lower: " << x_l_tmp[idx] <<
", upper: " << x_u_tmp[idx];
902 int m1 = 4 * horizon_;
905 int m2 = m1 + horizon_;
911 int m4 = m3 + 4 * obstacles_num_ * (horizon_ + 1);
918 int m6 = m5 + 3 * (horizon_ - 1);
924 int m8 = m7 + 2 * horizon_;
930 int m10 = m9 + lambda_horizon_;
933 int m11 = m10 + miu_horizon_;
935 CHECK_EQ(m11, num_of_constraints_);
937 AINFO <<
"dynamics constatins to: " << m1;
938 AINFO <<
"control rate constraints (only steering) to: " << m2;
939 AINFO <<
"sampling time equality constraints to: " << m3;
940 AINFO <<
"obstacle constraints to: " << m4;
941 AINFO <<
"start conf constraints to: " << m5;
942 AINFO <<
"constraints on x,y,v to: " << m6;
943 AINFO <<
"end constraints to: " << m7;
944 AINFO <<
"control bnd to: " << m8;
945 AINFO <<
"time interval constraints to: " << m9;
946 AINFO <<
"lambda constraints to: " << m10;
947 AINFO <<
"miu constraints to: " << m11;
948 AINFO <<
"total constraints: " << num_of_constraints_;
950 for (
int idx = 0; idx < m; ++idx) {
951 if (g[idx] > g_u_tmp[idx] + delta_v || g[idx] < g_l_tmp[idx] - delta_v) {
952 AINFO <<
"constratins idx unfeasible: " << idx <<
", g: " << g[idx]
953 <<
", lower: " << g_l_tmp[idx] <<
", upper: " << g_u_tmp[idx];
962 std::vector<double> xp(n);
963 std::vector<double> lamp(m);
964 std::vector<double> zl(m);
965 std::vector<double> zu(m);
966 std::vector<adouble> xa(n);
967 std::vector<adouble> g(m);
968 std::vector<double> lam(m);
973 obj_lam =
new double[m + 1];
977 for (
int idx = 0; idx < n; idx++) {
985 for (
int idx = 0; idx < n; idx++) {
989 for (
int idx = 0; idx < m; idx++) {
995 for (
int idx = 0; idx < n; idx++) {
998 for (
int idx = 0; idx < m; idx++) {
1003 obj_value *= mkparam(sig);
1005 for (
int idx = 0; idx < m; idx++) {
1006 obj_value += g[idx] * mkparam(lam[idx]);
1008 obj_value >>= dummy;
1023 sparse_jac(
tag_g, m, n, 0, &xp[0], &nnz_jac, &rind_g, &cind_g, &jacval,
1025 *nnz_jac_g = nnz_jac;
1029 sparse_hess(
tag_L, n, 0, &xp[0], &nnz_L, &rind_L, &cind_L, &hessval,
bool eval_jac_g_ser(int n, const double *x, bool new_x, int m, int nele_jac, int *iRow, int *jCol, double *values) override
DistanceApproachIPOPTFixedTsInterface(const size_t horizon, const double ts, const Eigen::MatrixXd &ego, const Eigen::MatrixXd &xWS, const Eigen::MatrixXd &uWS, const Eigen::MatrixXd &l_warm_up, const Eigen::MatrixXd &n_warm_up, const Eigen::MatrixXd &x0, const Eigen::MatrixXd &xf, const Eigen::MatrixXd &last_time_u, const std::vector< double > &XYbounds, const Eigen::MatrixXi &obstacles_edges_num, const size_t obstacles_num, const Eigen::MatrixXd &obstacles_A, const Eigen::MatrixXd &obstacles_b, const PlannerOpenSpaceConfig &planner_open_space_config)
void eval_obj(int n, const T *x, T *obj_value)
Template to return the objective value
bool get_bounds_info(int n, double *x_l, double *x_u, int m, double *g_l, double *g_u) override
Method to return the bounds for my problem
bool eval_f(int n, const double *x, bool new_x, double &obj_value) override
Method to return the objective value
bool check_g(int n, const double *x, int m, const double *g)
Check unfeasible constraints for further study
bool get_starting_point(int n, bool init_x, double *x, bool init_z, double *z_L, double *z_U, int m, bool init_lambda, double *lambda) override
Method to return the starting point for the algorithm
void eval_constraints(int n, const T *x, int m, T *g)
Template to compute constraints
void generate_tapes(int n, int m, int *nnz_jac_g, int *nnz_h_lag)
Method to generate the required tapes by ADOL-C
void get_optimization_results(Eigen::MatrixXd *state_result, Eigen::MatrixXd *control_result, Eigen::MatrixXd *time_result, Eigen::MatrixXd *dual_l_result, Eigen::MatrixXd *dual_n_result) const override
bool get_nlp_info(int &n, int &m, int &nnz_jac_g, int &nnz_h_lag, IndexStyleEnum &index_style) override
Method to return some info about the nlp
bool eval_g(int n, const double *x, bool new_x, int m, double *g) override
Method to return the constraint residuals
bool eval_h(int n, const double *x, bool new_x, double obj_factor, int m, const double *lambda, bool new_lambda, int nele_hess, int *iRow, int *jCol, double *values) override
Method to return: 1) The structure of the hessian of the lagrangian (if "values" is nullptr) 2) The v...
bool eval_grad_f(int n, const double *x, bool new_x, double *grad_f) override
Method to return the gradient of the objective
bool eval_jac_g(int n, const double *x, bool new_x, int m, int nele_jac, int *iRow, int *jCol, double *values) override
Method to return: 1) The structure of the jacobian (if "values" is nullptr) 2) The values of the jaco...
void finalize_solution(Ipopt::SolverReturn status, int n, const double *x, const double *z_L, const double *z_U, int m, const double *g, const double *lambda, double obj_value, const Ipopt::IpoptData *ip_data, Ipopt::IpoptCalculatedQuantities *ip_cq) override
This method is called when the algorithm is complete so the TNLP can store/write the solution
Planning module main class.
optional double max_steer_angle
optional double steer_ratio
optional double max_steer_angle_rate
optional double wheel_base
optional double weight_second_order_time
optional bool use_fix_time
optional double max_speed_forward
optional double weight_first_order_time
optional double min_safety_distance
optional double max_acceleration_forward
optional double max_acceleration_reverse
optional double weight_steer
optional double weight_phi
optional double max_time_sample_scaling
optional bool enable_initial_final_check
optional double min_time_sample_scaling
optional double weight_a_rate
optional bool enable_constraint_check
optional double weight_a_stitching
optional double weight_steer_stitching
optional double weight_steer_rate
optional double max_speed_reverse