Skip to content

Commit

Permalink
Add macro with also enable argument
Browse files Browse the repository at this point in the history
  • Loading branch information
saikishor committed Dec 9, 2024
1 parent 177328d commit 3573d98
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion hardware_interface/include/hardware_interface/introspection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,28 @@ namespace hardware_interface
constexpr char DEFAULT_REGISTRY_KEY[] = "ros2_control";
constexpr char DEFAULT_INTROSPECTION_TOPIC[] = "~/introspection_data";

#define REGISTER_ROS2_CONTROL_INTROSPECTION(ID, ENTITY) \
#define REGISTER_ROS2_CONTROL_INTROSPECTION_2_ARGS(ID, ENTITY) \
REGISTER_ENTITY( \
hardware_interface::DEFAULT_REGISTRY_KEY, get_name() + "." + ID, ENTITY, \
&stats_registrations_, false)

#define REGISTER_ROS2_CONTROL_INTROSPECTION_3_ARGS(ID, ENTITY, ENABLE) \
REGISTER_ENTITY( \
hardware_interface::DEFAULT_REGISTRY_KEY, get_name() + "." + ID, ENTITY, \
&stats_registrations_, ENABLE)

#ifndef GET_4TH_ARG
#define GET_4TH_ARG(arg1, arg2, arg3, arg4, ...) arg4
#endif

#define REGISTER_ROS2_CONTROL_INTROSPECTION_MACRO_CHOOSER(...) \
GET_4TH_ARG( \
__VA_ARGS__, REGISTER_ROS2_CONTROL_INTROSPECTION_3_ARGS, \
REGISTER_ROS2_CONTROL_INTROSPECTION_2_ARGS)

#define REGISTER_ROS2_CONTROL_INTROSPECTION(...) \
REGISTER_ROS2_CONTROL_INTROSPECTION_MACRO_CHOOSER(__VA_ARGS__)(__VA_ARGS__)

} // namespace hardware_interface

#endif // HARDWARE_INTERFACE__INTROSPECTION_HPP_

0 comments on commit 3573d98

Please sign in to comment.