18#ifndef EASYNAV_COMMON__ROBOTGEOMETRY_HPP_
19#define EASYNAV_COMMON__ROBOTGEOMETRY_HPP_
25#include "rclcpp/rclcpp.hpp"
49 std::lock_guard<std::mutex> lock(mutex_);
56 std::lock_guard<std::mutex> lock(mutex_);
57 return configured_.count(field) > 0;
63 std::lock_guard<std::mutex> lock(
mutex_);
65 configured_ = configured;
70 std::set<std::string> configured_;
86template<
typename NodeT>
92 auto apply = [&](
const std::string & name,
const std::string & field,
double & value) {
96 const auto & overrides = node.get_node_parameters_interface()->get_parameter_overrides();
97 if (overrides.count(name) == 0 && !node.has_parameter(name)) {
100 double legacy_value = value;
102 node.get_parameter(name, legacy_value);
104 const auto replacement =
"system_node.robot_geometry." + field;
105 if (registry->is_configured(field)) {
107 node.get_logger(),
"'%s' is deprecated and ignored: '%s' takes precedence",
108 name.c_str(), replacement.c_str());
112 node.get_logger(),
"'%s' is deprecated: configure '%s' instead. It will stop working soon.",
113 name.c_str(), replacement.c_str());
114 value = legacy_value;
117 apply(legacy.radius,
"radius", geometry.
radius);
118 apply(legacy.inscribed_radius,
"inscribed_radius", geometry.
inscribed_radius);
119 apply(legacy.height,
"height", geometry.
height);
Parameter helpers for plugins that may be initialized several times on the same node.
#define SINGLETON_DEFINITIONS(ClassName)
Definition Singleton.hpp:82
void set_geometry(const RobotGeometry &geometry, const std::set< std::string > &configured={})
Sets the robot's geometry, and which fields were configured explicitly.
Definition RobotGeometry.hpp:61
RobotGeometry get_geometry() const
The robot's geometry.
Definition RobotGeometry.hpp:47
bool is_configured(const std::string &field) const
Whether "robot_geometry.<field>" was configured explicitly.
Definition RobotGeometry.hpp:54
RobotGeometryRegistry()=default
static RobotGeometryRegistry * getInstance(Args &&... args)
Definition Singleton.hpp:30
Definition CircularBuffer.hpp:24
RobotGeometry get_robot_geometry(NodeT &node, const LegacyRobotGeometryNames &legacy={})
The robot's geometry ("system_node.robot_geometry.*").
Definition RobotGeometry.hpp:87
void declare_parameter_if_absent(NodeT &node, const std::string &name, const T &default_value)
Declares name with default_value unless it already exists.
Definition Parameters.hpp:34
std::mutex Singleton< C >::mutex_
Definition Singleton.hpp:80
The robot's shape, shared by everything that needs it.
Definition RobotGeometry.hpp:34
double inscribed_radius
Largest circle inside the robot (m). Defaults to radius.
Definition RobotGeometry.hpp:36
double radius
Circumscribed: smallest circle containing the robot (m).
Definition RobotGeometry.hpp:35
double height
Top of the robot, above the robot frame (m).
Definition RobotGeometry.hpp:37
Deprecated parameter names (full names on the node, "" = none) for each field.
Definition RobotGeometry.hpp:48
The robot's shape, shared by everything that needs it.
Definition RobotGeometry.hpp:34
Declaration of RobotGeometry and LegacyRobotGeometryNames.