@@ -147,6 +147,9 @@ class Recovery : public nav2_core::Recovery
147
147
std::string robot_base_frame_;
148
148
double transform_tolerance_;
149
149
150
+ // Clock
151
+ rclcpp::Clock steady_clock_{RCL_STEADY_TIME};
152
+
150
153
void execute ()
151
154
{
152
155
RCLCPP_INFO (node_->get_logger (), " Attempting %s" , recovery_name_.c_str ());
@@ -167,13 +170,19 @@ class Recovery : public nav2_core::Recovery
167
170
1s,
168
171
[&]() {RCLCPP_INFO (node_->get_logger (), " %s running..." , recovery_name_.c_str ());});
169
172
173
+ auto start_time = steady_clock_.now ();
174
+
175
+ // Initialize the ActionT result
176
+ auto result = std::make_shared<typename ActionT::Result>();
177
+
170
178
rclcpp::Rate loop_rate (cycle_frequency_);
171
179
172
180
while (rclcpp::ok ()) {
173
181
if (action_server_->is_cancel_requested ()) {
174
182
RCLCPP_INFO (node_->get_logger (), " Canceling %s" , recovery_name_.c_str ());
175
183
stopRobot ();
176
- action_server_->terminate_all ();
184
+ result->total_elapsed_time = steady_clock_.now () - start_time;
185
+ action_server_->terminate_all (result);
177
186
return ;
178
187
}
179
188
@@ -184,19 +193,22 @@ class Recovery : public nav2_core::Recovery
184
193
" however feature is currently not implemented. Aborting and stopping." ,
185
194
recovery_name_.c_str ());
186
195
stopRobot ();
187
- action_server_->terminate_current ();
196
+ result->total_elapsed_time = steady_clock_.now () - start_time;
197
+ action_server_->terminate_current (result);
188
198
return ;
189
199
}
190
200
191
201
switch (onCycleUpdate ()) {
192
202
case Status::SUCCEEDED:
193
203
RCLCPP_INFO (node_->get_logger (), " %s completed successfully" , recovery_name_.c_str ());
194
- action_server_->succeeded_current ();
204
+ result->total_elapsed_time = steady_clock_.now () - start_time;
205
+ action_server_->succeeded_current (result);
195
206
return ;
196
207
197
208
case Status::FAILED:
198
209
RCLCPP_WARN (node_->get_logger (), " %s failed" , recovery_name_.c_str ());
199
- action_server_->terminate_current ();
210
+ result->total_elapsed_time = steady_clock_.now () - start_time;
211
+ action_server_->terminate_current (result);
200
212
return ;
201
213
202
214
case Status::RUNNING:
0 commit comments