Skip to content

Commit cabb15d

Browse files
fix freequent route handler construction
Signed-off-by: Yuki Takagi <yuki.takagi@tier4.jp>
1 parent c3270d2 commit cabb15d

File tree

2 files changed

+5
-3
lines changed
  • planning/obstacle_cruise_planner

2 files changed

+5
-3
lines changed

planning/obstacle_cruise_planner/include/obstacle_cruise_planner/node.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class ObstacleCruisePlannerNode : public rclcpp::Node
145145
AccelWithCovarianceStamped::ConstSharedPtr ego_accel_ptr_{nullptr};
146146
HADMapBin::ConstSharedPtr vector_map_ptr_{nullptr};
147147

148-
std::shared_ptr<route_handler::RouteHandler> route_handler_;
148+
std::unique_ptr<route_handler::RouteHandler> route_handler_;
149149

150150
// Vehicle Parameters
151151
VehicleInfo vehicle_info_;

planning/obstacle_cruise_planner/src/node.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -515,16 +515,18 @@ rcl_interfaces::msg::SetParametersResult ObstacleCruisePlannerNode::onParam(
515515

516516
void ObstacleCruisePlannerNode::onTrajectory(const Trajectory::ConstSharedPtr msg)
517517
{
518+
stop_watch_.tic(__func__);
518519
const auto traj_points = motion_utils::convertToTrajectoryPointArray(*msg);
519520

520521
// check if subscribed variables are ready
521522
if (
522523
traj_points.empty() || !ego_odom_ptr_ || !ego_accel_ptr_ || !objects_ptr_ || !vector_map_ptr_) {
523524
return;
524525
}
525-
route_handler_ = std::make_shared<route_handler::RouteHandler>(*vector_map_ptr_);
526+
if (route_handler_ == nullptr) {
527+
route_handler_ = std::make_unique<route_handler::RouteHandler>(*vector_map_ptr_);
528+
}
526529

527-
stop_watch_.tic(__func__);
528530
*debug_data_ptr_ = DebugData();
529531

530532
const auto is_driving_forward = motion_utils::isDrivingForwardWithTwist(traj_points);

0 commit comments

Comments
 (0)