Skip to content

Commit 76f84aa

Browse files
kosuke55boyali
authored andcommitted
feat(obstacle_avoidance_planner): add options for plan_from_ego (tier4#1191)
* feat(obstacle_avoidance_planner): add options for plan_from_ego Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> * Remove adjust weight when planning from ego Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> * Readd near_kinematic_state_while_planning_from_ego as comment Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> * Use calcArcLength Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> * Remove max_plan_from_ego_length from ReferecncePoint Signed-off-by: kosuke55 <kosuke.tnp@gmail.com>
1 parent 691fa14 commit 76f84aa

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

planning/obstacle_avoidance_planner/config/obstacle_avoidance_planner.param.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
option:
5959
steer_limit_constraint: true
6060
fix_points_around_ego: true
61-
# plan_from_ego: false
61+
plan_from_ego: false
62+
max_plan_from_ego_length: 10.0
6263
visualize_sampling_num: 1
6364
enable_manual_warm_start: true
6465
enable_warm_start: true # false

planning/obstacle_avoidance_planner/include/obstacle_avoidance_planner/common_structs.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ struct MPTParam
254254
bool l_inf_norm;
255255
bool two_step_soft_constraint;
256256
bool plan_from_ego;
257+
double max_plan_from_ego_length;
257258
};
258259

259260
#endif // OBSTACLE_AVOIDANCE_PLANNER__COMMON_STRUCTS_HPP_

planning/obstacle_avoidance_planner/src/mpt_optimizer.cpp

+16-18
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,11 @@ void MPTOptimizer::calcPlanningFromEgo(std::vector<ReferencePoint> & ref_points)
411411
{
412412
// if plan from ego
413413
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;
416419
if (plan_from_ego) {
417420
for (auto & ref_point : ref_points) {
418421
ref_point.fix_kinematic_state = boost::none;
@@ -634,24 +637,19 @@ MPTOptimizer::ValueMatrix MPTOptimizer::generateValueMatrix(
634637
std::vector<Eigen::Triplet<double>> Qex_triplet_vec;
635638
for (size_t i = 0; i < N_ref; ++i) {
636639
// 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+
// }();
647650

648651
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) {
655653
return {
656654
mpt_param_.obstacle_avoid_lat_error_weight, mpt_param_.obstacle_avoid_yaw_error_weight};
657655
} else if (i == N_ref - 1 && is_containing_path_terminal_point) {

planning/obstacle_avoidance_planner/src/node.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,9 @@ ObstacleAvoidancePlanner::ObstacleAvoidancePlanner(const rclcpp::NodeOptions & n
383383

384384
// option
385385
// TODO(murooka) implement plan_from_ego
386-
mpt_param_.plan_from_ego = false;
387-
// mpt_param_.plan_from_ego = declare_parameter<bool>("mpt.option.plan_from_ego");
386+
mpt_param_.plan_from_ego = declare_parameter<bool>("mpt.option.plan_from_ego");
387+
mpt_param_.max_plan_from_ego_length =
388+
declare_parameter<double>("mpt.option.max_plan_from_ego_length");
388389
mpt_param_.steer_limit_constraint =
389390
declare_parameter<bool>("mpt.option.steer_limit_constraint");
390391
mpt_param_.fix_points_around_ego = declare_parameter<bool>("mpt.option.fix_points_around_ego");
@@ -643,7 +644,9 @@ rcl_interfaces::msg::SetParametersResult ObstacleAvoidancePlanner::paramCallback
643644

644645
{ // mpt param
645646
// option
646-
// updateParam<bool>(parameters, "mpt.option.plan_from_ego", mpt_param_.plan_from_ego);
647+
updateParam<bool>(parameters, "mpt.option.plan_from_ego", mpt_param_.plan_from_ego);
648+
updateParam<double>(
649+
parameters, "mpt.option.max_plan_from_ego_length", mpt_param_.max_plan_from_ego_length);
647650
updateParam<bool>(
648651
parameters, "mpt.option.steer_limit_constraint", mpt_param_.steer_limit_constraint);
649652
updateParam<bool>(

0 commit comments

Comments
 (0)