Skip to content

Commit 6ab7e05

Browse files
committed
added exception on runtime calls
1 parent 3a0eaae commit 6ab7e05

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

nav2_costmap_2d/plugins/costmap_filters/binary_filter.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,11 @@ void BinaryFilter::initializeFilter(
122122
if (!change_parameters_client->wait_for_service(
123123
std::chrono::milliseconds(change_parameter_timeout_)))
124124
{
125-
if (param.is_critical){
126-
throw std::runtime_error("BinaryFilter: Service " +
127-
std::string(change_parameters_client->get_service_name()) +
128-
"not available!");
125+
if (param.is_critical) {
126+
throw std::runtime_error(
127+
"BinaryFilter: Service " +
128+
std::string(change_parameters_client->get_service_name()) +
129+
"not available!");
129130
}
130131
RCLCPP_ERROR(
131132
logger_, "BinaryFilter: service %s not available. Skipping ...",
@@ -356,10 +357,11 @@ void BinaryFilter::changeParameters(const bool state)
356357
if (return_code == rclcpp::FutureReturnCode::SUCCESS) {
357358
auto result = future_result.get();
358359
if (!result->results.at(0).successful) {
359-
if (binary_parameter_info.is_critical){
360-
throw std::runtime_error("BinaryFilter: Could not change parameter " +
361-
std::string(binary_parameter_info.param_name) + " from node " +
362-
std::string(binary_parameter_info.node_name));
360+
if (binary_parameter_info.is_critical) {
361+
throw std::runtime_error(
362+
"BinaryFilter: Could not change parameter " +
363+
std::string(binary_parameter_info.param_name) + " from node " +
364+
std::string(binary_parameter_info.node_name));
363365
}
364366
RCLCPP_ERROR(
365367
logger_, "BinaryFilter: Failed to change parameter %s",
@@ -370,9 +372,13 @@ void BinaryFilter::changeParameters(const bool state)
370372
bool_param.value.bool_value ? "true" : "false");
371373
}
372374
} else if (return_code == rclcpp::FutureReturnCode::INTERRUPTED) {
373-
throw std::runtime_error("BinaryFilter: Interruped while spinning for parameter update!");
375+
if (binary_parameter_info.is_critical) {
376+
throw std::runtime_error("BinaryFilter: Interruped while spinning for parameter update!");
377+
}
374378
} else {
375-
throw std::runtime_error("BinaryFilter: Spinning for parameter update went wrong !");
379+
if (binary_parameter_info.is_critical) {
380+
throw std::runtime_error("BinaryFilter: Spinning for parameter update timeout!");
381+
}
376382
}
377383
}
378384
}

0 commit comments

Comments
 (0)