Skip to content

Commit 023cfb3

Browse files
fix(freespace_planner): prevent publishing stop trajectory with only one point in a new parking cycle
Signed-off-by: Ahmed Ebrahim <ahmed.ebrahim@leodrive.ai> fix(freespace_planner): prevent publishing stop trajectory with only one point in a new parking cycle Signed-off-by: Ahmed Ebrahim <ahmed.ebrahim@leodrive.ai>
1 parent 031c873 commit 023cfb3

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

planning/freespace_planner/include/freespace_planner/freespace_planner_node.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class FreespacePlannerNode : public rclcpp::Node
133133
size_t prev_target_index_;
134134
size_t target_index_;
135135
bool is_completed_ = false;
136+
bool is_new_parking_cycle_ = true;
136137

137138
LaneletRoute::ConstSharedPtr route_;
138139
OccupancyGrid::ConstSharedPtr occupancy_grid_;

planning/freespace_planner/src/freespace_planner/freespace_planner_node.cpp

+14-8
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ void FreespacePlannerNode::onRoute(const LaneletRoute::ConstSharedPtr msg)
321321
goal_pose_.header = msg->header;
322322
goal_pose_.pose = msg->goal_pose;
323323

324+
is_new_parking_cycle_ = true;
325+
324326
reset();
325327
}
326328

@@ -445,14 +447,16 @@ void FreespacePlannerNode::onTimer()
445447
}
446448

447449
if (isPlanRequired()) {
448-
// Stop before planning new trajectory
449-
const auto stop_trajectory = partial_trajectory_.points.empty()
450-
? createStopTrajectory(current_pose_)
451-
: createStopTrajectory(partial_trajectory_);
452-
trajectory_pub_->publish(stop_trajectory);
453-
debug_pose_array_pub_->publish(trajectory2PoseArray(stop_trajectory));
454-
debug_partial_pose_array_pub_->publish(trajectory2PoseArray(stop_trajectory));
455-
450+
// Stop before planning new trajectory, except in a new parking cycle as the vehicle already
451+
// stops.
452+
if (!is_new_parking_cycle_) {
453+
const auto stop_trajectory = partial_trajectory_.points.empty()
454+
? createStopTrajectory(current_pose_)
455+
: createStopTrajectory(partial_trajectory_);
456+
trajectory_pub_->publish(stop_trajectory);
457+
debug_pose_array_pub_->publish(trajectory2PoseArray(stop_trajectory));
458+
debug_partial_pose_array_pub_->publish(trajectory2PoseArray(stop_trajectory));
459+
}
456460
reset();
457461

458462
// Plan new trajectory
@@ -472,6 +476,8 @@ void FreespacePlannerNode::onTimer()
472476
trajectory_pub_->publish(partial_trajectory_);
473477
debug_pose_array_pub_->publish(trajectory2PoseArray(trajectory_));
474478
debug_partial_pose_array_pub_->publish(trajectory2PoseArray(partial_trajectory_));
479+
480+
is_new_parking_cycle_ = false;
475481
}
476482

477483
void FreespacePlannerNode::planTrajectory()

0 commit comments

Comments
 (0)