17#ifndef HARDWARE_INTERFACE__INTROSPECTION_HPP_
18#define HARDWARE_INTERFACE__INTROSPECTION_HPP_
23#include "hardware_interface/types/statistic_data.hpp"
24#include "pal_statistics/pal_statistics_macros.hpp"
25#include "pal_statistics/pal_statistics_utils.hpp"
30inline IdType customRegister(
31 StatisticsRegistry & registry,
const std::string & name,
34 registry.registerVariable(name +
"/max", &variable->
max, bookkeeping, enabled);
35 registry.registerVariable(name +
"/min", &variable->
min, bookkeeping, enabled);
36 registry.registerVariable(name +
"/average", &variable->
average, bookkeeping, enabled);
37 registry.registerVariable(
39 std::function<double()> sample_func = [variable]
41 return registry.registerFunction(name +
"/sample_count", sample_func, bookkeeping, enabled);
47constexpr char DEFAULT_REGISTRY_KEY[] =
"ros2_control";
48constexpr char DEFAULT_INTROSPECTION_TOPIC[] =
"~/introspection_data";
49constexpr char CM_STATISTICS_KEY[] =
"cm_execution_statistics";
50constexpr char CM_STATISTICS_TOPIC[] =
"~/statistics";
52#define REGISTER_ROS2_CONTROL_INTROSPECTION(ID, ENTITY) \
54 hardware_interface::DEFAULT_REGISTRY_KEY, get_name() + "." + ID, ENTITY, \
55 &stats_registrations_, false);
57#define UNREGISTER_ROS2_CONTROL_INTROSPECTION(ID) \
58 UNREGISTER_ENTITY(DEFAULT_REGISTRY_KEY, get_name() + "." + ID);
60#define CLEAR_ALL_ROS2_CONTROL_INTROSPECTION_REGISTRIES() CLEAR_ALL_REGISTRIES();
62#define INITIALIZE_ROS2_CONTROL_INTROSPECTION_REGISTRY(node, topic, registry_key) \
63 INITIALIZE_REGISTRY(node, topic, registry_key);
65#define START_ROS2_CONTROL_INTROSPECTION_PUBLISHER_THREAD(registry_key) \
66 START_PUBLISH_THREAD(registry_key);
68#define PUBLISH_ROS2_CONTROL_INTROSPECTION_DATA_ASYNC(registry_key) \
69 PUBLISH_ASYNC_STATISTICS(registry_key);
71#define DEFAULT_REGISTER_ROS2_CONTROL_INTROSPECTION(ID, ENTITY) \
72 REGISTER_ENTITY(DEFAULT_REGISTRY_KEY, ID, ENTITY);
74#define DEFAULT_UNREGISTER_ROS2_CONTROL_INTROSPECTION(ID) \
75 UNREGISTER_ENTITY(DEFAULT_REGISTRY_KEY, ID);
Definition mujoco_system_interface.hpp:57
Definition introspection.hpp:28
Definition statistic_data.hpp:34
double min
min value of the observations
Definition statistic_data.hpp:38
double standard_deviation
standard_deviation of the observations
Definition statistic_data.hpp:42
double max
max value of the observations
Definition statistic_data.hpp:40
double average
average of the observations
Definition statistic_data.hpp:36
uint64_t sample_count
number of samples of the observation
Definition statistic_data.hpp:44