Skip to content
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

Update documentation about recorder and player creation via composition #1510

Merged
merged 10 commits into from
Apr 10, 2024

Conversation

roncapat
Copy link
Contributor

@roncapat roncapat commented Dec 12, 2023

Closes #1509.

Feedbacks welcomed :)

@roncapat roncapat marked this pull request as ready for review December 17, 2023 08:50
@roncapat roncapat requested a review from a team as a code owner December 17, 2023 08:50
@roncapat roncapat requested review from MichaelOrlov and hidmic and removed request for a team December 17, 2023 08:50
Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roncapat Thanks for updating documentation and sorry for my late response. It was a new year holidays.
Overall looks good to me. I have only a few minor comments and suggestions.

README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@MichaelOrlov MichaelOrlov changed the title Composition documentation Update documentation about recorder and player creation via composition Jan 18, 2024
@ros-discourse
Copy link

This pull request has been mentioned on ROS Discourse. There might be relevant details there:

https://discourse.ros.org/t/ros-2-tsc-meeting-minutes-for-2024-01-18/35779/1

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Comment on lines +368 to +385
Play and record are fundamental tasks of `rosbag2`. However, playing or recording data at high rates may have limitations (e.g. spurious packet drops) due to one of the following:
- low network bandwith
- high CPU load
- slow mass memory
- ROS 2 middleware serialization/deserialization delays & overhead

ROS 2 C++ nodes can benefit from intra-process communication to partially or completely bypass network transport of messages between two nodes.

Multiple _components_ can be _composed_, either [statically](https://docs.ros.org/en/rolling/Tutorials/Intermediate/Composition.html#compile-time-composition-using-ros-services) or [dynamically](https://docs.ros.org/en/rolling/Tutorials/Intermediate/Composition.html#run-time-composition-using-ros-services-with-a-publisher-and-subscriber): all the composed component will share the same address space because they will be loaded in a single process.

A prerequirement is for each C++ node to be [_composable_](https://docs.ros.org/en/rolling/Concepts/Intermediate/About-Composition.html?highlight=composition) and to follow the [guidelines](https://docs.ros.org/en/rolling/Tutorials/Demos/Intra-Process-Communication.html?highlight=intra) for efficient publishing & subscription.

With the above requirements met, the user can:
- compose multiple nodes together
- explicitly enable intra-process communication

Whenever a publisher and a subscriber on the same topic belong to the same _composed_ process, and intra-process is enabled for both, `rclcpp` completely bypasses RMW layer and below transport layer (i.e. DDS). Instead, messages are shared via process memory and *potentially* never copied. Some exception hold, so please have a look to the [IPC guidelines](https://docs.ros.org/en/rolling/Tutorials/Demos/Intra-Process-Communication.html?highlight=intra).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we want to re-explain the benefits from Composition in general, which is described in https://docs.ros.org/en/rolling/Concepts/Intermediate/About-Composition.html#ros-2-unified-api good.
I would refer to this link, and keep this doc to how to use player and recorder as components only in rosbag2 package.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, i just tried with the following. this is not expected result, i may be mistaken?

root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 component load /ComponentManager composition rosbag2_transport::Player
Failed to load component: Failed to find class with the requested plugin name.
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 component load /ComponentManager composition rosbag2_transport::Recorder
Failed to load component: Failed to find class with the requested plugin name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fujitatomoya It works with

ros2 component load /ComponentManager rosbag2_transport rosbag2_transport::Player

need to use rosbag2_transport instead of composition.
It seems to be able to use it as you expected with ros2 component load /ComponentManager composition rosbag2_transport::Player will need to use composition instead of the ${PROJECT_NAME} here

rclcpp_components_register_node(
${PROJECT_NAME} PLUGIN "rosbag2_transport::Player" EXECUTABLE player)
rclcpp_components_register_node(
${PROJECT_NAME} PLUGIN "rosbag2_transport::Recorder" EXECUTABLE recorder)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As regards to the

I am not sure if we want to re-explain the benefits from Composition in general, which is described in https://docs.ros.org/en/rolling/Concepts/Intermediate/About-Composition.html#ros-2-unified-api good.
I would refer to this link, and keep this doc to how to use player and recorder as components only in rosbag2 package.

I have an opposite opinion and think it would be very useful to have a brief introduction with an explanation of why it is needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As regards composition name. Me and @fujitatomoya think it would be better to use rosbag2 name instead of rosbag2_transport or composition.
i.e. to be

ros2 component load /ComponentManager rosbag2 rosbag2_transport::Player

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not easy, if you remember we already discussed during implementation. Current CMake registration macro doesn't allow as far as I understand to change package name when registering components in ament.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@roncapat roncapat Feb 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most trivial way to achieve so would be to register the components in rosbag2 package, adding something like (draft code here):

#include "rosbag2_transport/player.hpp"

namespace rosbag2 {

class Player : rosbag2_transport::Player {
  using rosbag2_transport::Player::Player;
};

}

#include "rclcpp_components/register_node_macro.hpp"

// Register the component with class_loader.
// This acts as a sort of entry point, allowing the component to be
// discoverable when its library is being loaded into a running process.
RCLCPP_COMPONENTS_REGISTER_NODE(rosbag2::Player)

Then build and register it inside rosbag2 package CMakeLists.txt. Still unclear then if some component load tests would need to be moved out from rosbag2_transport too then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roncapat Thanks for the proposal with a workaround in the `rosbag2 package.
I would appreciate it if you could try to make prototype changes for that.

I am sorry, that I don't have the capacity for such an experiment by myself for a while.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible approach here #1603

@roncapat
Copy link
Contributor Author

roncapat commented Apr 8, 2024

@MichaelOrlov may I ask to briefly review again? Is there something else I can do?

Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roncapat Thanks for the updates.
I would shorten example yaml files to a bare minimum with essential parameters and put links on the full yaml config files in our tests.
See my comments:

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Comment on lines +368 to +385
Play and record are fundamental tasks of `rosbag2`. However, playing or recording data at high rates may have limitations (e.g. spurious packet drops) due to one of the following:
- low network bandwith
- high CPU load
- slow mass memory
- ROS 2 middleware serialization/deserialization delays & overhead

ROS 2 C++ nodes can benefit from intra-process communication to partially or completely bypass network transport of messages between two nodes.

Multiple _components_ can be _composed_, either [statically](https://docs.ros.org/en/rolling/Tutorials/Intermediate/Composition.html#compile-time-composition-using-ros-services) or [dynamically](https://docs.ros.org/en/rolling/Tutorials/Intermediate/Composition.html#run-time-composition-using-ros-services-with-a-publisher-and-subscriber): all the composed component will share the same address space because they will be loaded in a single process.

A prerequirement is for each C++ node to be [_composable_](https://docs.ros.org/en/rolling/Concepts/Intermediate/About-Composition.html?highlight=composition) and to follow the [guidelines](https://docs.ros.org/en/rolling/Tutorials/Demos/Intra-Process-Communication.html?highlight=intra) for efficient publishing & subscription.

With the above requirements met, the user can:
- compose multiple nodes together
- explicitly enable intra-process communication

Whenever a publisher and a subscriber on the same topic belong to the same _composed_ process, and intra-process is enabled for both, `rclcpp` completely bypasses RMW layer and below transport layer (i.e. DDS). Instead, messages are shared via process memory and *potentially* never copied. Some exception hold, so please have a look to the [IPC guidelines](https://docs.ros.org/en/rolling/Tutorials/Demos/Intra-Process-Communication.html?highlight=intra).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@roncapat Thanks for the proposal with a workaround in the `rosbag2 package.
I would appreciate it if you could try to make prototype changes for that.

I am sorry, that I don't have the capacity for such an experiment by myself for a while.

README.md Show resolved Hide resolved
Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roncapat and others added 10 commits April 9, 2024 18:25
Signed-off-by: Patrick Roncagliolo <[email protected]>
Signed-off-by: Patrick Roncagliolo <[email protected]>
Co-authored-by: Tomoya Fujita <[email protected]>
Signed-off-by: Patrick Roncagliolo <[email protected]>
Co-authored-by: Tomoya Fujita <[email protected]>
Signed-off-by: Patrick Roncagliolo <[email protected]>
Co-authored-by: Michael Orlov <[email protected]>
Signed-off-by: Patrick Roncagliolo <[email protected]>
Signed-off-by: Patrick Roncagliolo <[email protected]>
Co-authored-by: Michael Orlov <[email protected]>
Signed-off-by: Patrick Roncagliolo <[email protected]>
Co-authored-by: Michael Orlov <[email protected]>
Signed-off-by: Patrick Roncagliolo <[email protected]>
Co-authored-by: Michael Orlov <[email protected]>
Signed-off-by: Patrick Roncagliolo <[email protected]>
Signed-off-by: Patrick Roncagliolo <[email protected]>
Copy link
Contributor

@MichaelOrlov MichaelOrlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@MichaelOrlov
Copy link
Contributor

Going to merge without CI since changes only in the README.md file.

@MichaelOrlov MichaelOrlov merged commit 1bfe305 into ros2:rolling Apr 10, 2024
12 of 14 checks passed
@roncapat roncapat deleted the rolling branch April 10, 2024 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Composition documentation
5 participants