@@ -411,8 +411,11 @@ void MPTOptimizer::calcPlanningFromEgo(std::vector<ReferencePoint> & ref_points)
411
411
{
412
412
// if plan from ego
413
413
constexpr double epsilon = 1e-04 ;
414
- const bool plan_from_ego =
415
- mpt_param_.plan_from_ego && std::abs (current_ego_vel_) < epsilon && ref_points.size () > 1 ;
414
+ const double trajectory_length = tier4_autoware_utils::calcArcLength (ref_points);
415
+
416
+ const bool plan_from_ego = mpt_param_.plan_from_ego && std::abs (current_ego_vel_) < epsilon &&
417
+ ref_points.size () > 1 &&
418
+ trajectory_length < mpt_param_.max_plan_from_ego_length ;
416
419
if (plan_from_ego) {
417
420
for (auto & ref_point : ref_points) {
418
421
ref_point.fix_kinematic_state = boost::none;
@@ -634,24 +637,19 @@ MPTOptimizer::ValueMatrix MPTOptimizer::generateValueMatrix(
634
637
std::vector<Eigen::Triplet<double >> Qex_triplet_vec;
635
638
for (size_t i = 0 ; i < N_ref; ++i) {
636
639
// this is for plan_from_ego
637
- const bool near_kinematic_state_while_planning_from_ego = [&]() {
638
- const size_t min_idx = static_cast <size_t >(std::max (0 , static_cast <int >(i) - 20 ));
639
- const size_t max_idx = std::min (ref_points.size () - 1 , i + 20 );
640
- for (size_t j = min_idx; j <= max_idx; ++j) {
641
- if (ref_points.at (j).plan_from_ego && ref_points.at (j).fix_kinematic_state ) {
642
- return true ;
643
- }
644
- }
645
- return false ;
646
- }();
640
+ // const bool near_kinematic_state_while_planning_from_ego = [&]() {
641
+ // const size_t min_idx = static_cast<size_t>(std::max(0, static_cast<int>(i) - 20));
642
+ // const size_t max_idx = std::min(ref_points.size() - 1, i + 20);
643
+ // for (size_t j = min_idx; j <= max_idx; ++j) {
644
+ // if (ref_points.at(j).plan_from_ego && ref_points.at(j).fix_kinematic_state) {
645
+ // return true;
646
+ // }
647
+ // }
648
+ // return false;
649
+ // }();
647
650
648
651
const auto adaptive_error_weight = [&]() -> std::array<double , 2 > {
649
- if (near_kinematic_state_while_planning_from_ego) {
650
- constexpr double obstacle_avoid_error_weight_ratio = 1 / 100.0 ;
651
- return {
652
- mpt_param_.obstacle_avoid_lat_error_weight * obstacle_avoid_error_weight_ratio,
653
- mpt_param_.obstacle_avoid_yaw_error_weight * obstacle_avoid_error_weight_ratio};
654
- } else if (ref_points.at (i).near_objects ) {
652
+ if (ref_points.at (i).near_objects ) {
655
653
return {
656
654
mpt_param_.obstacle_avoid_lat_error_weight , mpt_param_.obstacle_avoid_yaw_error_weight };
657
655
} else if (i == N_ref - 1 && is_containing_path_terminal_point) {
0 commit comments