Skip to content

Commit 285f299

Browse files
authored
fix(behavior_velocity_run_out_module): fix slow_down jerk filter (#1744)
Signed-off-by: tomoya.kimura <tomoya.kimura@tier4.jp>
1 parent d593e27 commit 285f299

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

planning/behavior_velocity_run_out_module/src/scene.cpp

+15-19
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,6 @@ bool RunOutModule::modifyPathVelocity(
113113
insertStoppingVelocity(dynamic_obstacle, current_pose, current_vel, current_acc, *path);
114114
}
115115

116-
// apply max jerk limit if the ego can't stop with specified max jerk and acc
117-
if (planner_param_.slow_down_limit.enable) {
118-
applyMaxJerkLimit(current_pose, current_vel, current_acc, *path);
119-
}
120-
121116
publishDebugValue(
122117
trim_smoothed_path, partition_excluded_obstacles, dynamic_obstacle, current_pose);
123118

@@ -585,7 +580,8 @@ boost::optional<geometry_msgs::msg::Pose> RunOutModule::calcStopPoint(
585580

586581
void RunOutModule::insertStopPoint(
587582
const boost::optional<geometry_msgs::msg::Pose> stop_point,
588-
autoware_auto_planning_msgs::msg::PathWithLaneId & path)
583+
autoware_auto_planning_msgs::msg::PathWithLaneId & path,
584+
const geometry_msgs::msg::Pose & current_pose, const float current_vel, const float current_acc)
589585
{
590586
// no stop point
591587
if (!stop_point) {
@@ -610,7 +606,14 @@ void RunOutModule::insertStopPoint(
610606
stop_point_with_lane_id = path.points.at(nearest_seg_idx);
611607
stop_point_with_lane_id.point.pose = *stop_point;
612608

613-
planning_utils::insertVelocity(path, stop_point_with_lane_id, 0.0, insert_idx);
609+
double stop_point_velocity = 0.0;
610+
// apply max jerk limit if the ego can't stop with specified max jerk and acc
611+
if (planner_param_.slow_down_limit.enable) {
612+
stop_point_velocity =
613+
calcMaxJerkLimitedVelocity(current_pose, current_vel, current_acc, path, *stop_point);
614+
}
615+
616+
planning_utils::insertVelocity(path, stop_point_with_lane_id, stop_point_velocity, insert_idx);
614617
}
615618

616619
void RunOutModule::insertVelocityForState(
@@ -679,7 +682,7 @@ void RunOutModule::insertStoppingVelocity(
679682
{
680683
const auto stop_point =
681684
calcStopPoint(dynamic_obstacle, output_path, current_pose, current_vel, current_acc);
682-
insertStopPoint(stop_point, output_path);
685+
insertStopPoint(stop_point, output_path, current_pose, current_vel, current_acc);
683686
}
684687

685688
void RunOutModule::insertApproachingVelocity(
@@ -719,26 +722,19 @@ void RunOutModule::insertApproachingVelocity(
719722
planning_utils::insertVelocity(output_path, stop_point_with_lane_id, 0.0, insert_idx_stop);
720723
}
721724

722-
void RunOutModule::applyMaxJerkLimit(
725+
double RunOutModule::calcMaxJerkLimitedVelocity(
723726
const geometry_msgs::msg::Pose & current_pose, const float current_vel, const float current_acc,
724-
PathWithLaneId & path) const
727+
PathWithLaneId & path, const geometry_msgs::msg::Pose & stop_point) const
725728
{
726-
const auto stop_point_idx = run_out_utils::findFirstStopPointIdx(path.points);
727-
if (!stop_point_idx) {
728-
return;
729-
}
730-
731-
const auto stop_point = path.points.at(stop_point_idx.get()).point.pose.position;
732729
const auto dist_to_stop_point =
733-
motion_utils::calcSignedArcLength(path.points, current_pose.position, stop_point);
730+
motion_utils::calcSignedArcLength(path.points, current_pose.position, stop_point.position);
734731

735732
// calculate desired velocity with limited jerk
736733
const auto jerk_limited_vel = planning_utils::calcDecelerationVelocityFromDistanceToTarget(
737734
planner_param_.slow_down_limit.max_jerk, planner_param_.slow_down_limit.max_acc, current_acc,
738735
current_vel, dist_to_stop_point);
739736

740-
// overwrite velocity with limited velocity
741-
run_out_utils::insertPathVelocityFromIndex(stop_point_idx.get(), jerk_limited_vel, path.points);
737+
return jerk_limited_vel;
742738
}
743739

744740
std::vector<DynamicObstacle> RunOutModule::excludeObstaclesOutSideOfPartition(

planning/behavior_velocity_run_out_module/src/scene.hpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ class RunOutModule : public SceneModuleInterface
113113

114114
void insertStopPoint(
115115
const boost::optional<geometry_msgs::msg::Pose> stop_point,
116-
autoware_auto_planning_msgs::msg::PathWithLaneId & path);
116+
autoware_auto_planning_msgs::msg::PathWithLaneId & path,
117+
const geometry_msgs::msg::Pose & current_pose, const float current_vel,
118+
const float current_acc);
117119

118120
void insertVelocityForState(
119121
const boost::optional<DynamicObstacle> & dynamic_obstacle, const PlannerData planner_data,
@@ -129,9 +131,9 @@ class RunOutModule : public SceneModuleInterface
129131
const DynamicObstacle & dynamic_obstacle, const geometry_msgs::msg::Pose & current_pose,
130132
const float approaching_vel, const float approach_margin, PathWithLaneId & output_path);
131133

132-
void applyMaxJerkLimit(
134+
double calcMaxJerkLimitedVelocity(
133135
const geometry_msgs::msg::Pose & current_pose, const float current_vel, const float current_acc,
134-
PathWithLaneId & path) const;
136+
PathWithLaneId & path, const geometry_msgs::msg::Pose & stop_point) const;
135137

136138
std::vector<DynamicObstacle> excludeObstaclesOutSideOfPartition(
137139
const std::vector<DynamicObstacle> & dynamic_obstacles, const PathWithLaneId & path,

0 commit comments

Comments
 (0)