Skip to content

Commit

Permalink
fix(freespace_planner): fix motion_velocity_smoother error while park…
Browse files Browse the repository at this point in the history
…ing (autowarefoundation#6713)

* 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>
Signed-off-by: vividf <yihsiang.fang@tier4.jp>
  • Loading branch information
ahmeddesokyebrahim authored and vividf committed May 16, 2024
1 parent 1a729a4 commit 1ff6276
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class FreespacePlannerNode : public rclcpp::Node
size_t target_index_;
bool is_completed_ = false;
bool reset_in_progress_ = false;
bool is_new_parking_cycle_ = true;

LaneletRoute::ConstSharedPtr route_;
OccupancyGrid::ConstSharedPtr occupancy_grid_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ void FreespacePlannerNode::onRoute(const LaneletRoute::ConstSharedPtr msg)
goal_pose_.header = msg->header;
goal_pose_.pose = msg->goal_pose;

is_new_parking_cycle_ = true;

reset();
}

Expand Down Expand Up @@ -447,13 +449,16 @@ void FreespacePlannerNode::onTimer()
// Must stop before replanning any new trajectory
const bool is_reset_required = !reset_in_progress_ && isPlanRequired();
if (is_reset_required) {
// Stop before planning new trajectory
const auto stop_trajectory = partial_trajectory_.points.empty()
? createStopTrajectory(current_pose_)
: createStopTrajectory(partial_trajectory_);
trajectory_pub_->publish(stop_trajectory);
debug_pose_array_pub_->publish(trajectory2PoseArray(stop_trajectory));
debug_partial_pose_array_pub_->publish(trajectory2PoseArray(stop_trajectory));
// Stop before planning new trajectory, except in a new parking cycle as the vehicle already
// stops.
if (!is_new_parking_cycle_) {
const auto stop_trajectory = partial_trajectory_.points.empty()
? createStopTrajectory(current_pose_)
: createStopTrajectory(partial_trajectory_);
trajectory_pub_->publish(stop_trajectory);
debug_pose_array_pub_->publish(trajectory2PoseArray(stop_trajectory));
debug_partial_pose_array_pub_->publish(trajectory2PoseArray(stop_trajectory));
}

reset();

Expand All @@ -476,6 +481,7 @@ void FreespacePlannerNode::onTimer()

// StopTrajectory
if (trajectory_.points.size() <= 1) {
is_new_parking_cycle_ = false;
return;
}

Expand All @@ -487,6 +493,8 @@ void FreespacePlannerNode::onTimer()
trajectory_pub_->publish(partial_trajectory_);
debug_pose_array_pub_->publish(trajectory2PoseArray(trajectory_));
debug_partial_pose_array_pub_->publish(trajectory2PoseArray(partial_trajectory_));

is_new_parking_cycle_ = false;
}

void FreespacePlannerNode::planTrajectory()
Expand Down

0 comments on commit 1ff6276

Please sign in to comment.