Skip to content

Commit d5f68ac

Browse files
mitukou1109satoshi-ota
authored andcommitted
feat(obstacle_cruise_planner): prevent chattering when using point cloud (autowarefoundation#7861)
* prevent chattering of stop planning Signed-off-by: mitukou1109 <mitukou1109@gmail.com> * Update planning/autoware_obstacle_cruise_planner/src/node.cpp Co-authored-by: Satoshi OTA <44889564+satoshi-ota@users.noreply.github.com> * fix stop position oscillation Signed-off-by: mitukou1109 <mitukou1109@gmail.com> --------- Signed-off-by: mitukou1109 <mitukou1109@gmail.com> Co-authored-by: Satoshi OTA <44889564+satoshi-ota@users.noreply.github.com>
1 parent 56c7bc6 commit d5f68ac

File tree

2 files changed

+46
-14
lines changed
  • planning/autoware_obstacle_cruise_planner

2 files changed

+46
-14
lines changed

planning/autoware_obstacle_cruise_planner/include/autoware/obstacle_cruise_planner/node.hpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,13 @@ class ObstacleCruisePlannerNode : public rclcpp::Node
192192
// planner
193193
std::unique_ptr<PlannerInterface> planner_ptr_{nullptr};
194194

195-
// previous obstacles
196-
std::vector<StopObstacle> prev_stop_obstacles_;
197-
std::vector<CruiseObstacle> prev_cruise_obstacles_;
198-
std::vector<SlowDownObstacle> prev_slow_down_obstacles_;
195+
// previous PredictedObject-based obstacles
196+
std::vector<StopObstacle> prev_stop_object_obstacles_;
197+
std::vector<CruiseObstacle> prev_cruise_object_obstacles_;
198+
std::vector<SlowDownObstacle> prev_slow_down_object_obstacles_;
199+
200+
// PointCloud-based stop obstacle history
201+
std::vector<StopObstacle> stop_pc_obstacle_history_;
199202

200203
// behavior determination parameter
201204
struct BehaviorDeterminationParam
@@ -303,7 +306,7 @@ class ObstacleCruisePlannerNode : public rclcpp::Node
303306
bool enable_slow_down_planning_{false};
304307
bool use_pointcloud_{false};
305308

306-
std::vector<StopObstacle> prev_closest_stop_obstacles_{};
309+
std::vector<StopObstacle> prev_closest_stop_object_obstacles_{};
307310

308311
std::unique_ptr<autoware::universe_utils::LoggerLevelConfigure> logger_configure_;
309312

planning/autoware_obstacle_cruise_planner/src/node.cpp

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ void ObstacleCruisePlannerNode::onTrajectory(const Trajectory::ConstSharedPtr ms
597597
concatenate(cruise_obstacles, cruise_object_obstacles);
598598
concatenate(slow_down_obstacles, slow_down_object_obstacles);
599599
}
600-
if (pointcloud_ptr && !pointcloud_ptr->data.empty()) {
600+
if (pointcloud_ptr) {
601601
const auto target_obstacles =
602602
convertToObstacles(ego_odom, *pointcloud_ptr, traj_points, msg->header);
603603

@@ -822,7 +822,7 @@ std::vector<Obstacle> ObstacleCruisePlannerNode::convertToObstacles(
822822
transform_stamped = std::nullopt;
823823
}
824824

825-
if (transform_stamped) {
825+
if (!pointcloud.data.empty() && transform_stamped) {
826826
// 1. transform pointcloud
827827
PointCloud::Ptr pointcloud_ptr(new PointCloud);
828828
pcl::fromROSMsg(pointcloud, *pointcloud_ptr);
@@ -1033,9 +1033,9 @@ ObstacleCruisePlannerNode::determineEgoBehaviorAgainstPredictedObjectObstacles(
10331033
checkConsistency(objects.header.stamp, objects, stop_obstacles);
10341034

10351035
// update previous obstacles
1036-
prev_stop_obstacles_ = stop_obstacles;
1037-
prev_cruise_obstacles_ = cruise_obstacles;
1038-
prev_slow_down_obstacles_ = slow_down_obstacles;
1036+
prev_stop_object_obstacles_ = stop_obstacles;
1037+
prev_cruise_object_obstacles_ = cruise_obstacles;
1038+
prev_slow_down_object_obstacles_ = slow_down_obstacles;
10391039

10401040
const double calculation_time = stop_watch_.toc(__func__);
10411041
RCLCPP_INFO_EXPRESSION(
@@ -1052,6 +1052,8 @@ ObstacleCruisePlannerNode::determineEgoBehaviorAgainstPointCloudObstacles(
10521052
{
10531053
stop_watch_.tic(__func__);
10541054

1055+
const auto & p = behavior_determination_param_;
1056+
10551057
// calculated decimated trajectory points and trajectory polygon
10561058
const auto decimated_traj_points = decimateTrajectoryPoints(odometry, traj_points);
10571059
const auto decimated_traj_polys =
@@ -1078,6 +1080,32 @@ ObstacleCruisePlannerNode::determineEgoBehaviorAgainstPointCloudObstacles(
10781080
}
10791081
}
10801082

1083+
std::vector<StopObstacle> past_stop_obstacles;
1084+
for (auto itr = stop_pc_obstacle_history_.begin(); itr != stop_pc_obstacle_history_.end();) {
1085+
const double elapsed_time = (rclcpp::Time(odometry.header.stamp) - itr->stamp).seconds();
1086+
if (elapsed_time >= p.stop_obstacle_hold_time_threshold) {
1087+
itr = stop_pc_obstacle_history_.erase(itr);
1088+
continue;
1089+
}
1090+
1091+
const auto lat_dist_from_obstacle_to_traj =
1092+
autoware::motion_utils::calcLateralOffset(traj_points, itr->collision_point);
1093+
const auto min_lat_dist_to_traj_poly =
1094+
std::abs(lat_dist_from_obstacle_to_traj) - vehicle_info_.vehicle_width_m;
1095+
1096+
if (min_lat_dist_to_traj_poly < p.max_lat_margin_for_stop_against_unknown) {
1097+
auto stop_obstacle = *itr;
1098+
stop_obstacle.dist_to_collide_on_decimated_traj = autoware::motion_utils::calcSignedArcLength(
1099+
decimated_traj_points, 0, stop_obstacle.collision_point);
1100+
past_stop_obstacles.push_back(stop_obstacle);
1101+
}
1102+
1103+
++itr;
1104+
}
1105+
1106+
concatenate(stop_pc_obstacle_history_, stop_obstacles);
1107+
concatenate(stop_obstacles, past_stop_obstacles);
1108+
10811109
const double calculation_time = stop_watch_.toc(__func__);
10821110
RCLCPP_INFO_EXPRESSION(
10831111
rclcpp::get_logger("ObstacleCruisePlanner"), enable_calculation_time_info_, " %s := %f [ms]",
@@ -1308,7 +1336,7 @@ ObstacleCruisePlannerNode::createCollisionPointsForInsideCruiseObstacle(
13081336
// const bool is_prev_obstacle_stop = getObstacleFromUuid(prev_stop_obstacles_,
13091337
// obstacle.uuid).has_value();
13101338
const bool is_prev_obstacle_cruise =
1311-
getObstacleFromUuid(prev_cruise_obstacles_, obstacle.uuid).has_value();
1339+
getObstacleFromUuid(prev_cruise_object_obstacles_, obstacle.uuid).has_value();
13121340

13131341
if (is_prev_obstacle_cruise) {
13141342
if (obstacle_tangent_vel < p.obstacle_velocity_threshold_from_cruise_to_stop) {
@@ -1555,7 +1583,7 @@ std::optional<SlowDownObstacle> ObstacleCruisePlannerNode::createSlowDownObstacl
15551583
slow_down_condition_counter_.addCurrentUuid(obstacle.uuid);
15561584

15571585
const bool is_prev_obstacle_slow_down =
1558-
getObstacleFromUuid(prev_slow_down_obstacles_, obstacle.uuid).has_value();
1586+
getObstacleFromUuid(prev_slow_down_object_obstacles_, obstacle.uuid).has_value();
15591587

15601588
if (!enable_slow_down_planning_ || !isSlowDownObstacle(obstacle.classification.label)) {
15611589
return std::nullopt;
@@ -1694,7 +1722,7 @@ void ObstacleCruisePlannerNode::checkConsistency(
16941722
const rclcpp::Time & current_time, const PredictedObjects & predicted_objects,
16951723
std::vector<StopObstacle> & stop_obstacles)
16961724
{
1697-
for (const auto & prev_closest_stop_obstacle : prev_closest_stop_obstacles_) {
1725+
for (const auto & prev_closest_stop_obstacle : prev_closest_stop_object_obstacles_) {
16981726
const auto predicted_object_itr = std::find_if(
16991727
predicted_objects.objects.begin(), predicted_objects.objects.end(),
17001728
[&prev_closest_stop_obstacle](const PredictedObject & po) {
@@ -1724,7 +1752,8 @@ void ObstacleCruisePlannerNode::checkConsistency(
17241752
}
17251753
}
17261754

1727-
prev_closest_stop_obstacles_ = obstacle_cruise_utils::getClosestStopObstacles(stop_obstacles);
1755+
prev_closest_stop_object_obstacles_ =
1756+
obstacle_cruise_utils::getClosestStopObstacles(stop_obstacles);
17281757
}
17291758

17301759
bool ObstacleCruisePlannerNode::isObstacleCrossing(

0 commit comments

Comments
 (0)