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

rviz2 via composition #1114

Open
mhubii opened this issue Dec 29, 2023 · 9 comments
Open

rviz2 via composition #1114

mhubii opened this issue Dec 29, 2023 · 9 comments
Labels

Comments

@mhubii
Copy link

mhubii commented Dec 29, 2023

From the CMake it appears rviz2 is compiled into an executable, refer

add_executable(${PROJECT_NAME}

Are there plans to provide composition in the future?

@roncapat
Copy link
Contributor

Subscribing here. As soon as I get some free time I may give a look to evaluate the required effort to do so, but I would also like to know from the maintainers their opinion on such a possible development.

@clalancette
Copy link
Contributor

I'm not opposed to it, but I'd like to hear what the use case is. I mean, yes, it will be more efficient to compose it with the thing it is debugging. But the "typical" deployment is to have rviz2 on a separate machine from the robot, so I'd want to hear about the cases where that is not happening.

@mhubii
Copy link
Author

mhubii commented Dec 30, 2023

was just thinking that this could enable intra-process communication to rviz, although inter-process works just fine.

The rclcpp_components_register_node cmake macro https://github.com/ros2/rclcpp/blob/5d2b32b5c3e5bbf538807779a7151ac1363002d2/rclcpp_components/cmake/rclcpp_components_register_node.cmake#L25C4-L25C4 lets users compile into a component and (I think) also compiles an executable.

@roncapat
Copy link
Contributor

@mhubii I think @clalancette is asking for a real use cases. I can propose a few to start with:

  • simulations: for example, I have an E2E perception stack simulator that runs 100% composed; to view the point clouds in real time I might like to include Rviz in the component container & enable intra-process to avoid to slow down my simulation (because when I subscribe to a point cloud topic via classic Rviz, serialization/deserialization kicks in and I "loose" benefits of intra-process on that topic.
  • post-processing of real robot data: suppose you receive some kind of data from a robot (which is a different machine, so no way to leverage composition here from the start) and you want to post-process it before display. This means you may need some control-station-side nodes for data processing, and you might like to compose them with Rviz
  • playback: recently, I helped implement Rosbag2 composition. So, assume you have a large bag to play... Well, you might like to compose the rosbag2_transport::Player with Rviz to reduce the overhead displaying what is inside the bag.

Of course, I think these are not beginner setups, but may come handy.

@clalancette
Copy link
Contributor

OK, fair enough. I've put this on the backlog, since the core team likely won't be addressing it in the near future. But please feel free to open pull requests in that direction. Thanks!

@roncapat
Copy link
Contributor

roncapat commented Jan 5, 2024

Here is a little assessment of what's currently going on, and how the above objective coud be achieved.

As I was expecting, here we have a Qt Application along with its own startup logic.
The actual rclcpp::Node is created as an object by the application.

/// Creates a ros node with the given name
/**
* Internally a rclcpp::Node is created.
* If a rclcpp::Node with the given name already exists a node abstraction for this already
* existing node is created.
*
* \param node_name name of the node to create
*/
RVIZ_COMMON_PUBLIC
explicit RosNodeAbstraction(const std::string & node_name);

RosNodeAbstraction::RosNodeAbstraction(const std::string & node_name)
: raw_node_(rclcpp::Node::make_shared(node_name))
{}

This is almost the same pattern used for example by gazebo_ros_pkgs and makes just sense.
It would be too complicated to transform Rviz in an rclcpp_component with a Qt GUI.
What it can become, instead, is a Qt GUI with a component_container.

Let me exaplain this. Rviz could:

  • host a rclcpp_components::ComponentManager
  • attach its current node instance to the same executor of the component manager

Then, users could call the component manager services to do run-time composition (i.e. inject components in the Rviz instance).

I did the same locally with gazebo_ros_pkgs some time ago to circumvent point_cloud transform limitation. Useless to say, it worked very well (much faster fps).

@ahcorde
Copy link
Contributor

ahcorde commented Jan 25, 2024

Hi @roncapat,

Can you provide any pointer to your changes in gazebo_ros_pkgs ?

@roncapat
Copy link
Contributor

roncapat commented Feb 7, 2024

Here you are @ahcorde:
Fixit-Davide/gazebo_ros_pkgs@a51a193
Fixit-Davide/gazebo_ros_pkgs@b93a2f3
CC: @Fixit-Davide

Edit: it is unmaintained and commits may be cleaner overall, but it may serve as a starting point POC.

@ahcorde
Copy link
Contributor

ahcorde commented Feb 15, 2024

I created a draft PR #1140

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants