Skip to content

Commit 771f71d

Browse files
authored
feat(autoware_behavior_path_planner_common,autoware_behavior_path_lane_change_module): add time_keeper to bpp (autowarefoundation#8004)
* feat(autoware_behavior_path_planner_common,autoware_behavior_path_lane_change_module): add time_keeper to bpp Signed-off-by: Y.Hisaki <yhisaki31@gmail.com> * update Signed-off-by: Y.Hisaki <yhisaki31@gmail.com> --------- Signed-off-by: Y.Hisaki <yhisaki31@gmail.com>
1 parent f1dff45 commit 771f71d

File tree

7 files changed

+49
-2
lines changed

7 files changed

+49
-2
lines changed

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/include/autoware/behavior_path_lane_change_module/interface.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "autoware/behavior_path_planner_common/turn_signal_decider.hpp"
2424
#include "autoware/behavior_path_planner_common/utils/path_shifter/path_shifter.hpp"
2525

26+
#include <autoware/universe_utils/system/time_keeper.hpp>
2627
#include <rclcpp/rclcpp.hpp>
2728

2829
#include <geometry_msgs/msg/pose.hpp>
@@ -108,6 +109,7 @@ class LaneChangeInterface : public SceneModuleInterface
108109
const double start_distance, const double finish_distance, const bool safe,
109110
const uint8_t & state)
110111
{
112+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
111113
for (const auto & [module_name, ptr] : rtc_interface_ptr_map_) {
112114
if (ptr) {
113115
ptr->updateCooperateStatus(

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/include/autoware/behavior_path_lane_change_module/utils/base_class.hpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "autoware/behavior_path_planner_common/utils/path_shifter/path_shifter.hpp"
2424
#include "autoware/universe_utils/system/stop_watch.hpp"
2525

26+
#include <autoware/universe_utils/system/time_keeper.hpp>
2627
#include <magic_enum.hpp>
2728
#include <rclcpp/rclcpp.hpp>
2829

@@ -53,7 +54,8 @@ class LaneChangeBase
5354
: lane_change_parameters_{std::move(parameters)},
5455
common_data_ptr_{std::make_shared<lane_change::CommonData>()},
5556
direction_{direction},
56-
type_{type}
57+
type_{type},
58+
time_keeper_(std::make_shared<universe_utils::TimeKeeper>())
5759
{
5860
}
5961

@@ -167,6 +169,11 @@ class LaneChangeBase
167169
common_data_ptr_->direction = direction_;
168170
}
169171

172+
void setTimeKeeper(const std::shared_ptr<universe_utils::TimeKeeper> & time_keeper)
173+
{
174+
time_keeper_ = time_keeper;
175+
}
176+
170177
void toNormalState() { current_lane_change_state_ = LaneChangeStates::Normal; }
171178

172179
void toStopState() { current_lane_change_state_ = LaneChangeStates::Stop; }
@@ -252,6 +259,8 @@ class LaneChangeBase
252259

253260
rclcpp::Logger logger_ = utils::lane_change::getLogger(getModuleTypeStr());
254261
mutable rclcpp::Clock clock_{RCL_ROS_TIME};
262+
263+
mutable std::shared_ptr<universe_utils::TimeKeeper> time_keeper_;
255264
};
256265
} // namespace autoware::behavior_path_planner
257266
#endif // AUTOWARE__BEHAVIOR_PATH_LANE_CHANGE_MODULE__UTILS__BASE_CLASS_HPP_

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/interface.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "autoware/behavior_path_planner_common/marker_utils/utils.hpp"
2222

2323
#include <autoware/universe_utils/ros/marker_helper.hpp>
24+
#include <autoware/universe_utils/system/time_keeper.hpp>
2425

2526
#include <algorithm>
2627
#include <memory>
@@ -43,6 +44,7 @@ LaneChangeInterface::LaneChangeInterface(
4344
module_type_{std::move(module_type)},
4445
prev_approved_path_{std::make_unique<PathWithLaneId>()}
4546
{
47+
module_type_->setTimeKeeper(getTimeKeeper());
4648
steering_factor_interface_ptr_ = std::make_unique<SteeringFactorInterface>(&node, name);
4749
logger_ = utils::lane_change::getLogger(module_type_->getModuleTypeStr());
4850
}
@@ -71,6 +73,7 @@ bool LaneChangeInterface::isExecutionReady() const
7173

7274
void LaneChangeInterface::updateData()
7375
{
76+
universe_utils::ScopedTimeTrack st(__func__, *getTimeKeeper());
7477
module_type_->setPreviousModuleOutput(getPreviousModuleOutput());
7578
module_type_->updateSpecialData();
7679

@@ -94,6 +97,7 @@ void LaneChangeInterface::postProcess()
9497

9598
BehaviorModuleOutput LaneChangeInterface::plan()
9699
{
100+
universe_utils::ScopedTimeTrack st(__func__, *getTimeKeeper());
97101
resetPathCandidate();
98102
resetPathReference();
99103

@@ -165,6 +169,7 @@ BehaviorModuleOutput LaneChangeInterface::planWaitingApproval()
165169

166170
CandidateOutput LaneChangeInterface::planCandidate() const
167171
{
172+
universe_utils::ScopedTimeTrack st(__func__, *getTimeKeeper());
168173
const auto selected_path = module_type_->getLaneChangePath();
169174

170175
if (selected_path.path.points.empty()) {
@@ -340,6 +345,7 @@ MarkerArray LaneChangeInterface::getModuleVirtualWall()
340345

341346
void LaneChangeInterface::updateSteeringFactorPtr(const BehaviorModuleOutput & output)
342347
{
348+
universe_utils::ScopedTimeTrack st(__func__, *getTimeKeeper());
343349
const auto steering_factor_direction = std::invoke([&]() {
344350
if (module_type_->getDirection() == Direction::LEFT) {
345351
return SteeringFactor::LEFT;

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/src/scene.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "autoware/behavior_path_planner_common/utils/utils.hpp"
2424

2525
#include <autoware/universe_utils/geometry/boost_polygon_utils.hpp>
26+
#include <autoware/universe_utils/system/time_keeper.hpp>
2627
#include <autoware_lanelet2_extension/utility/message_conversion.hpp>
2728
#include <autoware_lanelet2_extension/utility/utilities.hpp>
2829

@@ -55,6 +56,7 @@ NormalLaneChange::NormalLaneChange(
5556

5657
void NormalLaneChange::updateLaneChangeStatus()
5758
{
59+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
5860
updateStopTime();
5961
const auto [found_valid_path, found_safe_path] = getSafePath(status_.lane_change_path);
6062

@@ -263,6 +265,7 @@ BehaviorModuleOutput NormalLaneChange::getTerminalLaneChangePath() const
263265

264266
BehaviorModuleOutput NormalLaneChange::generateOutput()
265267
{
268+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
266269
if (!status_.is_valid_path) {
267270
RCLCPP_DEBUG(logger_, "No valid path found. Returning previous module's path as output.");
268271
return prev_module_output_;
@@ -308,6 +311,7 @@ BehaviorModuleOutput NormalLaneChange::generateOutput()
308311

309312
void NormalLaneChange::extendOutputDrivableArea(BehaviorModuleOutput & output) const
310313
{
314+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
311315
const auto & dp = planner_data_->drivable_area_expansion_parameters;
312316

313317
const auto drivable_lanes = utils::lane_change::generateDrivableLanes(
@@ -327,6 +331,7 @@ void NormalLaneChange::extendOutputDrivableArea(BehaviorModuleOutput & output) c
327331
void NormalLaneChange::insertStopPoint(
328332
const lanelet::ConstLanelets & lanelets, PathWithLaneId & path)
329333
{
334+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
330335
if (lanelets.empty()) {
331336
return;
332337
}
@@ -468,6 +473,7 @@ void NormalLaneChange::insertStopPoint(
468473

469474
PathWithLaneId NormalLaneChange::getReferencePath() const
470475
{
476+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
471477
lanelet::ConstLanelet closest_lanelet;
472478
if (!lanelet::utils::query::getClosestLanelet(
473479
status_.lane_change_path.info.target_lanes, getEgoPose(), &closest_lanelet)) {
@@ -482,6 +488,7 @@ PathWithLaneId NormalLaneChange::getReferencePath() const
482488

483489
std::optional<PathWithLaneId> NormalLaneChange::extendPath()
484490
{
491+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
485492
const auto path = status_.lane_change_path.path;
486493
const auto lc_start_point = status_.lane_change_path.info.lane_changing_start.position;
487494

@@ -560,6 +567,7 @@ void NormalLaneChange::resetParameters()
560567

561568
TurnSignalInfo NormalLaneChange::updateOutputTurnSignal() const
562569
{
570+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
563571
const auto & pose = getEgoPose();
564572
const auto & current_lanes = status_.current_lanes;
565573
const auto & shift_line = status_.lane_change_path.info.shift_line;
@@ -584,6 +592,7 @@ lanelet::ConstLanelets NormalLaneChange::getCurrentLanes() const
584592
lanelet::ConstLanelets NormalLaneChange::getLaneChangeLanes(
585593
const lanelet::ConstLanelets & current_lanes, Direction direction) const
586594
{
595+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
587596
if (current_lanes.empty()) {
588597
return {};
589598
}
@@ -1832,6 +1841,7 @@ PathSafetyStatus NormalLaneChange::evaluateApprovedPathWithUnsafeHysteresis(
18321841

18331842
bool NormalLaneChange::isValidPath(const PathWithLaneId & path) const
18341843
{
1844+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
18351845
const auto & route_handler = planner_data_->route_handler;
18361846
const auto & dp = planner_data_->drivable_area_expansion_parameters;
18371847

@@ -1869,6 +1879,7 @@ bool NormalLaneChange::isValidPath(const PathWithLaneId & path) const
18691879

18701880
bool NormalLaneChange::isRequiredStop(const bool is_object_coming_from_rear)
18711881
{
1882+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
18721883
const auto threshold = lane_change_parameters_->backward_length_buffer_for_end_of_lane;
18731884
if (
18741885
isNearEndOfCurrentLanes(status_.current_lanes, status_.target_lanes, threshold) &&
@@ -1882,6 +1893,7 @@ bool NormalLaneChange::isRequiredStop(const bool is_object_coming_from_rear)
18821893

18831894
bool NormalLaneChange::calcAbortPath()
18841895
{
1896+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
18851897
const auto & route_handler = getRouteHandler();
18861898
const auto & common_param = getCommonParam();
18871899
const auto current_velocity =
@@ -2025,6 +2037,7 @@ PathSafetyStatus NormalLaneChange::isLaneChangePathSafe(
20252037
const utils::path_safety_checker::RSSparams & rss_params,
20262038
CollisionCheckDebugMap & debug_data) const
20272039
{
2040+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
20282041
PathSafetyStatus path_safety_status;
20292042

20302043
if (collision_check_objects.empty()) {
@@ -2108,6 +2121,7 @@ PathSafetyStatus NormalLaneChange::isLaneChangePathSafe(
21082121
bool NormalLaneChange::isVehicleStuck(
21092122
const lanelet::ConstLanelets & current_lanes, const double obstacle_check_distance) const
21102123
{
2124+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
21112125
// Ego is still moving, not in stuck
21122126
if (std::abs(getEgoVelocity()) > lane_change_parameters_->stop_velocity_threshold) {
21132127
RCLCPP_DEBUG(logger_, "Ego is still moving, not in stuck");
@@ -2163,6 +2177,7 @@ bool NormalLaneChange::isVehicleStuck(
21632177

21642178
double NormalLaneChange::get_max_velocity_for_safety_check() const
21652179
{
2180+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
21662181
const auto external_velocity_limit_ptr = planner_data_->external_limit_max_velocity;
21672182
if (external_velocity_limit_ptr) {
21682183
return std::min(
@@ -2174,6 +2189,7 @@ double NormalLaneChange::get_max_velocity_for_safety_check() const
21742189

21752190
bool NormalLaneChange::isVehicleStuck(const lanelet::ConstLanelets & current_lanes) const
21762191
{
2192+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
21772193
if (current_lanes.empty()) {
21782194
lane_change_debug_.is_stuck = false;
21792195
return false; // can not check
@@ -2208,6 +2224,7 @@ void NormalLaneChange::setStopPose(const Pose & stop_pose)
22082224

22092225
void NormalLaneChange::updateStopTime()
22102226
{
2227+
universe_utils::ScopedTimeTrack st(__func__, *time_keeper_);
22112228
const auto current_vel = getEgoVelocity();
22122229

22132230
if (std::abs(current_vel) > lane_change_parameters_->stop_velocity_threshold) {

planning/behavior_path_planner/autoware_behavior_path_planner/include/autoware/behavior_path_planner/planner_manager.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "autoware/universe_utils/ros/debug_publisher.hpp"
2222
#include "autoware/universe_utils/system/stop_watch.hpp"
2323

24+
#include <autoware/universe_utils/system/time_keeper.hpp>
2425
#include <pluginlib/class_loader.hpp>
2526
#include <rclcpp/rclcpp.hpp>
2627

@@ -277,6 +278,7 @@ class PlannerManager
277278
const SceneModulePtr & module_ptr, const std::shared_ptr<PlannerData> & planner_data,
278279
const BehaviorModuleOutput & previous_module_output) const
279280
{
281+
universe_utils::ScopedTimeTrack st(module_ptr->name() + "=>run", *module_ptr->getTimeKeeper());
280282
stop_watch_.tic(module_ptr->name());
281283

282284
module_ptr->setData(planner_data);

planning/behavior_path_planner/autoware_behavior_path_planner_common/include/autoware/behavior_path_planner_common/interface/scene_module_interface.hpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <autoware/universe_utils/geometry/geometry.hpp>
3232
#include <autoware/universe_utils/ros/marker_helper.hpp>
3333
#include <autoware/universe_utils/ros/uuid_helper.hpp>
34+
#include <autoware/universe_utils/system/time_keeper.hpp>
3435
#include <magic_enum.hpp>
3536
#include <rclcpp/rclcpp.hpp>
3637

@@ -97,7 +98,8 @@ class SceneModuleInterface
9798
objects_of_interest_marker_interface_ptr_map_(
9899
std::move(objects_of_interest_marker_interface_ptr_map)),
99100
steering_factor_interface_ptr_(
100-
std::make_unique<SteeringFactorInterface>(&node, utils::convertToSnakeCase(name)))
101+
std::make_unique<SteeringFactorInterface>(&node, utils::convertToSnakeCase(name))),
102+
time_keeper_(std::make_shared<universe_utils::TimeKeeper>())
101103
{
102104
for (const auto & [module_name, ptr] : rtc_interface_ptr_map_) {
103105
uuid_map_.emplace(module_name, generateUUID());
@@ -244,6 +246,8 @@ class SceneModuleInterface
244246
previous_module_output_ = previous_module_output;
245247
}
246248

249+
std::shared_ptr<universe_utils::TimeKeeper> getTimeKeeper() const { return time_keeper_; }
250+
247251
/**
248252
* @brief set planner data
249253
*/
@@ -641,6 +645,8 @@ class SceneModuleInterface
641645
mutable MarkerArray debug_marker_;
642646

643647
mutable MarkerArray drivable_lanes_marker_;
648+
649+
mutable std::shared_ptr<universe_utils::TimeKeeper> time_keeper_;
644650
};
645651

646652
} // namespace autoware::behavior_path_planner

planning/behavior_path_planner/autoware_behavior_path_planner_common/include/autoware/behavior_path_planner_common/interface/scene_module_manager_interface.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class SceneModuleManagerInterface
8585

8686
observer.lock()->setData(planner_data_);
8787
observer.lock()->setPreviousModuleOutput(previous_module_output);
88+
observer.lock()->getTimeKeeper()->add_reporter(this->pub_processing_time_);
8889
observer.lock()->onEntry();
8990

9091
observers_.push_back(observer);
@@ -318,6 +319,8 @@ class SceneModuleManagerInterface
318319
pub_debug_marker_ = node->create_publisher<MarkerArray>("~/debug/" + name_, 20);
319320
pub_virtual_wall_ = node->create_publisher<MarkerArray>("~/virtual_wall/" + name_, 20);
320321
pub_drivable_lanes_ = node->create_publisher<MarkerArray>("~/drivable_lanes/" + name_, 20);
322+
pub_processing_time_ = node->create_publisher<universe_utils::ProcessingTimeDetail>(
323+
"~/processing_time/" + name_, 20);
321324
}
322325

323326
// misc
@@ -338,6 +341,8 @@ class SceneModuleManagerInterface
338341

339342
rclcpp::Publisher<MarkerArray>::SharedPtr pub_drivable_lanes_;
340343

344+
rclcpp::Publisher<universe_utils::ProcessingTimeDetail>::SharedPtr pub_processing_time_;
345+
341346
std::string name_;
342347

343348
std::shared_ptr<PlannerData> planner_data_;

0 commit comments

Comments
 (0)