-
Notifications
You must be signed in to change notification settings - Fork 348
Integrate pal_statistics for introspection of controllers, hardware components and more #1918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
christophfroehlich
merged 36 commits into
ros-controls:master
from
pal-robotics-forks:integrate/pal_statistics
Feb 12, 2025
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
1b503d3
add first integration of pal_statistics
saikishor aca20e4
namespace the introspection_data to the controller_manager node naming
saikishor 07334de
Add integration into the controller and hardware components base clas…
saikishor 884c080
remove execution time introspection
saikishor c181b5d
handle cases when the value_ptr_ is invalid
saikishor a107a99
add CLEAR_ALL_REGISTRIES macro in destructor
saikishor 180b127
disable introspection on cleanup
saikishor 6581204
rename macro to REGISTER_ROS2_CONTROL_INTROSPECTION
saikishor 4eee6ad
update release_notes
saikishor 7e22d6a
add missing header in controller_interface_base.hpp
saikishor a57b973
Update debugging docs
saikishor f2c4e0e
add more documentation about the topics
saikishor 719c747
delete the move constructors
saikishor 6ed4be6
Add macro with also enable argument
saikishor 81c0277
place dependencies alphabetically
saikishor 10fe456
Update doc/debugging.rst
saikishor 870da8a
move the documentation to introspection.rst
saikishor 612158d
update docs on the third argument to enable introspection
saikishor d4923ae
use clang jobs from christoph
saikishor 447a273
Revert "Add macro with also enable argument"
saikishor bc04f2a
Update doc/introspection.rst
saikishor aa19ef9
Use the master CI for clang
saikishor 3838f45
remove the visibility_macro on get_name method
saikishor f201856
return std::string instead of const ref as char * are returned by lif…
saikishor fb80164
Apply suggestions from code review
saikishor 5f91488
Add changes from Denis review comments
saikishor d398ea7
Merge branch 'master' into integrate/pal_statistics
saikishor b72f313
Merge branch 'master' into integrate/pal_statistics
saikishor c0df59d
Merge branch 'master' into integrate/pal_statistics
saikishor 0904ee1
Merge branch 'master' into integrate/pal_statistics
saikishor 877ce1e
Merge branch 'master' into integrate/pal_statistics
saikishor a89b26e
Merge branch 'master' into integrate/pal_statistics
saikishor 9b750b1
Merge branch 'master' into integrate/pal_statistics
saikishor 904065d
Merge branch 'master' into integrate/pal_statistics
saikishor dbaa9be
Merge branch 'master' into integrate/pal_statistics
destogl af69bf2
Merge branch 'master' into integrate/pal_statistics
destogl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
|
||
Introspection of the ros2_control setup | ||
*************************************** | ||
|
||
With the integration of the ``pal_statistics`` package, the ``controller_manager`` node publishes the registered variables within the same process to the ``~/introspection_data`` topics. | ||
By default, all ``State`` and ``Command`` interfaces in the ``controller_manager`` are registered when they are added, and are unregistered when they are removed from the ``ResourceManager``. | ||
The state of the all the registered entities are published at the end of every ``update`` cycle of the ``controller_manager``. For instance, In a complete synchronous ros2_control setup (with synchronous controllers and hardware components), this data in the ``Command`` interface is the command used by the hardware components to command the hardware. | ||
saikishor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
All the registered variables are published over 3 topics: ``~/introspection_data/full``, ``~/introspection_data/names``, and ``~/introspection_data/values``. | ||
- The ``~/introspection_data/full`` topic publishes the full introspection data along with names and values in a single message. This can be useful to track or view variables and information from command line. | ||
- The ``~/introspection_data/names`` topic publishes the names of the registered variables. This topic contains the names of the variables registered. This is only published every time a a variables is registered and unregistered. | ||
- The ``~/introspection_data/values`` topic publishes the values of the registered variables. This topic contains the values of the variables registered. | ||
|
||
The topics ``~/introspection_data/full`` and ``~/introspection_data/values`` are always published on every update cycle asynchronously, provided that there is at least one subscriber to these topics. | ||
|
||
The topic ``~/introspection_data/full`` can be used to integrate with your custom visualization tools or to track the variables from the command line. The topic ``~/introspection_data/names`` and ``~/introspection_data/values`` are to be used for visualization tools like `PlotJuggler <https://plotjuggler.io/>`_ or `RQT plot <http://wiki.ros.org/rqt_plot>`_ to visualize the data. | ||
|
||
.. note:: | ||
If you have a high frequency of data, it is recommended to use the ``~/introspection_data/names`` and ``~/introspection_data/values`` topic. So, that the data transferred and stored is minimized. | ||
|
||
How to introspect internal variables of controllers and hardware components | ||
============================================================================ | ||
|
||
Any member variable of a controller or hardware component can be registered for the introspection. It is very important that the lifetime of this variable exists as long as the controller or hardware component is available. | ||
|
||
.. note:: | ||
If a variable's lifetime is not properly managed, it may be attempted to read, which in the worst case scenario will cause a segmentation fault. | ||
|
||
How to register a variable for introspection | ||
--------------------------------------------- | ||
|
||
1. Include the necessary headers in the controller or hardware component header file. | ||
|
||
.. code-block:: cpp | ||
|
||
#include <hardware_interface/introspection.hpp> | ||
|
||
2. Register the variable in the configure method of the controller or hardware component. | ||
|
||
.. code-block:: cpp | ||
|
||
void MyController::on_configure() | ||
{ | ||
... | ||
// Register the variable for introspection (disabled by default) | ||
// The variable is introspected only when the controller is active and | ||
// then deactivated when the controller is deactivated. | ||
REGISTER_ROS2_CONTROL_INTROSPECTION("my_variable_name", &my_variable_); | ||
destogl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
... | ||
} | ||
|
||
3. By default, the introspection of all the registered variables of the controllers and the hardware components is only activated, when they are active and it is deactivated when the controller or hardware component is deactivated. | ||
|
||
.. note:: | ||
If you want to keep the introspection active even when the controller or hardware component is not active, you can do that by calling ``this->enable_introspection(true)`` in the ``on_configure`` and ``on_deactivate`` method of the controller or hardware component after registering the variables. | ||
saikishor marked this conversation as resolved.
Show resolved
Hide resolved
saikishor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Types of entities that can be introspected | ||
------------------------------------------- | ||
|
||
- Any variable that can be cast to a double is suitable for registration. | ||
- A function that returns a value that can be cast to a double is also suitable for registration. | ||
- Variables of complex structures can be registered by having defined introspection for their every internal variable. | ||
- Introspection of custom types can be done by defining a `custom introspection function <https://github.com/pal-robotics/pal_statistics/blob/humble-devel/pal_statistics/include/pal_statistics/registration_utils.hpp>`_. | ||
|
||
.. note:: | ||
Registering the variables for introspection is not real-time safe. It is recommended to register the variables in the ``on_configure`` method only. | ||
|
||
Data Visualization | ||
******************* | ||
|
||
Data can be visualized with any tools that display ROS topics, but we recommend `PlotJuggler <https://plotjuggler.io/>`_ for viewing high resolution live data, or data in bags. | ||
|
||
1. Open ``PlotJuggler`` running ``ros2 run plotjuggler plotjuggler``. | ||
.. image:: images/plotjuggler.png | ||
2. Visualize the data: | ||
- Importing from the ros2bag | ||
- Subscribing to the ROS2 topics live with the ``ROS2 Topic Subscriber`` option under ``Streaming`` header. | ||
3. Choose the topics ``~/introspection_data/names`` and ``~/introspection_data/values`` from the popup window. | ||
.. image:: images/plotjuggler_select_topics.png | ||
4. Now, select the variables that are of your interest and drag them to the plot. | ||
.. image:: images/plotjuggler_visualizing_data.png |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.