@@ -60,7 +60,7 @@ bool RunOutModule::modifyPathVelocity(
60
60
PathWithLaneId * path, [[maybe_unused]] StopReason * stop_reason)
61
61
{
62
62
// timer starts
63
- const auto t1_modify_path = std::chrono::system_clock::now ();
63
+ const auto t_start = std::chrono::system_clock::now ();
64
64
65
65
// set planner data
66
66
const auto current_vel = planner_data_->current_velocity ->twist .linear .x ;
@@ -70,20 +70,27 @@ bool RunOutModule::modifyPathVelocity(
70
70
// set height of debug data
71
71
debug_ptr_->setHeight (current_pose.position .z );
72
72
73
- // smooth velocity of the path to calculate time to collision accurately
74
- PathWithLaneId smoothed_path;
75
- if (!smoothPath (*path, smoothed_path, planner_data_)) {
76
- return true ;
77
- }
78
-
79
73
// extend path to consider obstacles after the goal
80
- const auto extended_smoothed_path =
81
- run_out_utils::extendPath (smoothed_path , planner_param_.vehicle_param .base_to_front );
74
+ const auto extended_path =
75
+ run_out_utils::extendPath (*path , planner_param_.vehicle_param .base_to_front );
82
76
83
77
// trim path ahead of the base_link to make calculation easier
84
78
const double trim_distance = planner_param_.run_out .detection_distance ;
85
- const auto trim_smoothed_path =
86
- run_out_utils::trimPathFromSelfPose (extended_smoothed_path, current_pose, trim_distance);
79
+ const auto trim_path =
80
+ run_out_utils::trimPathFromSelfPose (extended_path, current_pose, trim_distance);
81
+
82
+ // smooth velocity of the path to calculate time to collision accurately
83
+ PathWithLaneId extended_smoothed_path;
84
+ if (!smoothPath (trim_path, extended_smoothed_path, planner_data_)) {
85
+ return true ;
86
+ }
87
+
88
+ // record time for path processing
89
+ const auto t_path_processing = std::chrono::system_clock::now ();
90
+ const auto elapsed_path_processing =
91
+ std::chrono::duration_cast<std::chrono::microseconds>(t_path_processing - t_start);
92
+ debug_ptr_->setDebugValues (
93
+ DebugValues::TYPE::CALCULATION_TIME_PATH_PROCESSING, elapsed_path_processing.count () / 1000.0 );
87
94
88
95
// create abstracted dynamic obstacles from objects or points
89
96
dynamic_obstacle_creator_->setData (*planner_data_, planner_param_, *path, extended_smoothed_path);
@@ -92,18 +99,24 @@ bool RunOutModule::modifyPathVelocity(
92
99
93
100
// extract obstacles using lanelet information
94
101
const auto partition_excluded_obstacles =
95
- excludeObstaclesOutSideOfPartition (dynamic_obstacles, trim_smoothed_path , current_pose);
102
+ excludeObstaclesOutSideOfPartition (dynamic_obstacles, extended_smoothed_path , current_pose);
96
103
97
- // timer starts
98
- const auto t1_collision_check = std::chrono::system_clock::now ();
104
+ // record time for obstacle creation
105
+ const auto t_obstacle_creation = std::chrono::system_clock::now ();
106
+ const auto elapsed_obstacle_creation =
107
+ std::chrono::duration_cast<std::chrono::microseconds>(t_obstacle_creation - t_path_processing);
108
+ debug_ptr_->setDebugValues (
109
+ DebugValues::TYPE::CALCULATION_TIME_OBSTACLE_CREATION,
110
+ elapsed_obstacle_creation.count () / 1000.0 );
99
111
100
112
// detect collision with dynamic obstacles using velocity planning of ego
101
- const auto dynamic_obstacle = detectCollision (partition_excluded_obstacles, trim_smoothed_path);
113
+ const auto dynamic_obstacle =
114
+ detectCollision (partition_excluded_obstacles, extended_smoothed_path);
102
115
103
- // timer ends
104
- const auto t2_collision_check = std::chrono::system_clock::now ();
116
+ // record time for collision check
117
+ const auto t_collision_check = std::chrono::system_clock::now ();
105
118
const auto elapsed_collision_check =
106
- std::chrono::duration_cast<std::chrono::microseconds>(t2_collision_check - t1_collision_check );
119
+ std::chrono::duration_cast<std::chrono::microseconds>(t_collision_check - t_obstacle_creation );
107
120
debug_ptr_->setDebugValues (
108
121
DebugValues::TYPE::CALCULATION_TIME_COLLISION_CHECK, elapsed_collision_check.count () / 1000.0 );
109
122
@@ -112,7 +125,7 @@ bool RunOutModule::modifyPathVelocity(
112
125
// after a certain amount of time has elapsed since the ego stopped,
113
126
// approach the obstacle with slow velocity
114
127
insertVelocityForState (
115
- dynamic_obstacle, *planner_data_, planner_param_, trim_smoothed_path , *path);
128
+ dynamic_obstacle, *planner_data_, planner_param_, extended_smoothed_path , *path);
116
129
} else {
117
130
// just insert zero velocity for stopping
118
131
insertStoppingVelocity (dynamic_obstacle, current_pose, current_vel, current_acc, *path);
@@ -124,14 +137,19 @@ bool RunOutModule::modifyPathVelocity(
124
137
}
125
138
126
139
publishDebugValue (
127
- trim_smoothed_path , partition_excluded_obstacles, dynamic_obstacle, current_pose);
140
+ extended_smoothed_path , partition_excluded_obstacles, dynamic_obstacle, current_pose);
128
141
129
- // timer ends
130
- const auto t2_modify_path = std::chrono::system_clock::now ();
131
- const auto elapsed_modify_path =
132
- std::chrono::duration_cast<std::chrono::microseconds>(t2_modify_path - t1_modify_path );
142
+ // record time for collision check
143
+ const auto t_path_planning = std::chrono::system_clock::now ();
144
+ const auto elapsed_path_planning =
145
+ std::chrono::duration_cast<std::chrono::microseconds>(t_path_planning - t_collision_check );
133
146
debug_ptr_->setDebugValues (
134
- DebugValues::TYPE::CALCULATION_TIME, elapsed_modify_path.count () / 1000.0 );
147
+ DebugValues::TYPE::CALCULATION_TIME_PATH_PLANNING, elapsed_path_planning.count () / 1000.0 );
148
+
149
+ // record time for the function
150
+ const auto t_end = std::chrono::system_clock::now ();
151
+ const auto elapsed_all = std::chrono::duration_cast<std::chrono::microseconds>(t_end - t_start);
152
+ debug_ptr_->setDebugValues (DebugValues::TYPE::CALCULATION_TIME, elapsed_all.count () / 1000.0 );
135
153
136
154
return true ;
137
155
}
0 commit comments