diff --git a/nav2_behavior_tree/plugins/condition/transform_available_condition.cpp b/nav2_behavior_tree/plugins/condition/transform_available_condition.cpp index ddc67534469..8daca5afede 100644 --- a/nav2_behavior_tree/plugins/condition/transform_available_condition.cpp +++ b/nav2_behavior_tree/plugins/condition/transform_available_condition.cpp @@ -39,7 +39,7 @@ TransformAvailableCondition::TransformAvailableCondition( RCLCPP_FATAL( node_->get_logger(), "Child frame (%s) or parent frame (%s) were empty.", child_frame_.c_str(), parent_frame_.c_str()); - exit(-1); + throw std::runtime_error("TransformAvailableCondition: Child or parent frames not provided!"); } RCLCPP_DEBUG(node_->get_logger(), "Initialized an TransformAvailableCondition BT node"); diff --git a/nav2_behaviors/src/behavior_server.cpp b/nav2_behaviors/src/behavior_server.cpp index b5ec19ba626..c7beffd7862 100644 --- a/nav2_behaviors/src/behavior_server.cpp +++ b/nav2_behaviors/src/behavior_server.cpp @@ -105,13 +105,13 @@ BehaviorServer::loadBehaviorPlugins() auto node = shared_from_this(); for (size_t i = 0; i != behavior_ids_.size(); i++) { - behavior_types_[i] = nav2_util::get_plugin_type_param(node, behavior_ids_[i]); try { + behavior_types_[i] = nav2_util::get_plugin_type_param(node, behavior_ids_[i]); RCLCPP_INFO( get_logger(), "Creating behavior plugin %s of type %s", behavior_ids_[i].c_str(), behavior_types_[i].c_str()); behaviors_.push_back(plugin_loader_.createUniqueInstance(behavior_types_[i])); - } catch (const pluginlib::PluginlibException & ex) { + } catch (const std::exception & ex) { RCLCPP_FATAL( get_logger(), "Failed to create behavior %s of type %s." " Exception: %s", behavior_ids_[i].c_str(), behavior_types_[i].c_str(), diff --git a/nav2_bt_navigator/src/bt_navigator.cpp b/nav2_bt_navigator/src/bt_navigator.cpp index c83ccd8b23d..82beb939994 100644 --- a/nav2_bt_navigator/src/bt_navigator.cpp +++ b/nav2_bt_navigator/src/bt_navigator.cpp @@ -161,8 +161,8 @@ BtNavigator::on_configure(const rclcpp_lifecycle::State & /*state*/) // Load navigator plugins for (size_t i = 0; i != navigator_ids.size(); i++) { - std::string navigator_type = nav2_util::get_plugin_type_param(node, navigator_ids[i]); try { + std::string navigator_type = nav2_util::get_plugin_type_param(node, navigator_ids[i]); RCLCPP_INFO( get_logger(), "Creating navigator id %s of type %s", navigator_ids[i].c_str(), navigator_type.c_str()); @@ -173,11 +173,10 @@ BtNavigator::on_configure(const rclcpp_lifecycle::State & /*state*/) { return nav2_util::CallbackReturn::FAILURE; } - } catch (const pluginlib::PluginlibException & ex) { + } catch (const std::exception & ex) { RCLCPP_FATAL( - get_logger(), "Failed to create navigator id %s of type %s." - " Exception: %s", navigator_ids[i].c_str(), navigator_type.c_str(), - ex.what()); + get_logger(), "Failed to create navigator id %s." + " Exception: %s", navigator_ids[i].c_str(), ex.what()); return nav2_util::CallbackReturn::FAILURE; } } diff --git a/nav2_collision_monitor/src/collision_detector_node.cpp b/nav2_collision_monitor/src/collision_detector_node.cpp index 29d380fa054..6a5aca7dfec 100644 --- a/nav2_collision_monitor/src/collision_detector_node.cpp +++ b/nav2_collision_monitor/src/collision_detector_node.cpp @@ -224,7 +224,6 @@ bool CollisionDetector::configurePolygons( polygon_name.c_str()); return false; } - } } catch (const std::exception & ex) { RCLCPP_ERROR(get_logger(), "Error while getting parameters: %s", ex.what()); diff --git a/nav2_controller/src/controller_server.cpp b/nav2_controller/src/controller_server.cpp index 69b06e3128e..d0460c9d4ed 100644 --- a/nav2_controller/src/controller_server.cpp +++ b/nav2_controller/src/controller_server.cpp @@ -142,7 +142,7 @@ ControllerServer::on_configure(const rclcpp_lifecycle::State & /*state*/) progress_checker_ids_[i].c_str(), progress_checker_types_[i].c_str()); progress_checker->initialize(node, progress_checker_ids_[i]); progress_checkers_.insert({progress_checker_ids_[i], progress_checker}); - } catch (const pluginlib::PluginlibException & ex) { + } catch (const std::exception & ex) { RCLCPP_FATAL( get_logger(), "Failed to create progress_checker. Exception: %s", ex.what()); diff --git a/nav2_costmap_2d/include/nav2_costmap_2d/cost_values.hpp b/nav2_costmap_2d/include/nav2_costmap_2d/cost_values.hpp index 6fbb5352440..7ae3f4d1c76 100644 --- a/nav2_costmap_2d/include/nav2_costmap_2d/cost_values.hpp +++ b/nav2_costmap_2d/include/nav2_costmap_2d/cost_values.hpp @@ -72,5 +72,5 @@ static constexpr unsigned char LETHAL_OBSTACLE = 254; static constexpr unsigned char INSCRIBED_INFLATED_OBSTACLE = 253; static constexpr unsigned char MAX_NON_OBSTACLE = 252; static constexpr unsigned char FREE_SPACE = 0; -} +} // namespace nav2_costmap_2d #endif // NAV2_COSTMAP_2D__COST_VALUES_HPP_ diff --git a/nav2_costmap_2d/include/nav2_costmap_2d/denoise/image_processing.hpp b/nav2_costmap_2d/include/nav2_costmap_2d/denoise/image_processing.hpp index 4527e07fdd3..96a13b8c7c9 100644 --- a/nav2_costmap_2d/include/nav2_costmap_2d/denoise/image_processing.hpp +++ b/nav2_costmap_2d/include/nav2_costmap_2d/denoise/image_processing.hpp @@ -21,6 +21,8 @@ #include #include #include +#include +#include namespace nav2_costmap_2d { @@ -77,7 +79,7 @@ void morphologyOperation( const Image & input, Image & output, const Image & shape, AggregateFn aggregate); -using ShapeBuffer3x3 = std::array; +using ShapeBuffer3x3 = std::array; // NOLINT inline Image createShape(ShapeBuffer3x3 & buffer, ConnectivityType connectivity); } // namespace imgproc_impl @@ -95,7 +97,7 @@ inline void dilate( const Image & input, Image & output, ConnectivityType connectivity, Max && max_function) { - using namespace imgproc_impl; + using namespace imgproc_impl; // NOLINT ShapeBuffer3x3 shape_buffer; Image shape = createShape(shape_buffer, connectivity); morphologyOperation(input, output, shape, max_function); @@ -376,7 +378,7 @@ struct EquivalenceLabelTreesBase struct LabelOverflow : public std::runtime_error { - LabelOverflow(const std::string & message) + explicit LabelOverflow(const std::string & message) : std::runtime_error(message) {} }; @@ -464,7 +466,6 @@ class EquivalenceLabelTrees : public EquivalenceLabelTreesBase { Label k = 1; for (Label i = 1; i < next_free_; ++i) { - if (labels_[i] < i) { labels_[i] = labels_[labels_[i]]; } else { @@ -504,7 +505,7 @@ class EquivalenceLabelTrees : public EquivalenceLabelTreesBase * '~' - row continuation in the same style */ max_labels = (rows * columns) / 3 + 1; } - ++max_labels; // add zero label + ++max_labels; // add zero label max_labels = std::min(max_labels, size_t(std::numeric_limits