ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Without (quite) some trickery, writing RViz panels in Python is probably going to be difficult.

Dynamically subscribing to topics can be done both in Python as well as in C++ though, I don't immediately see why that would be any more difficult. Almost all RViz display plugins and quite some Panel plugins do it. See rviz/default_plugin/marker_display.cpp for instance.

Without (quite) some trickery, writing RViz panels in Python is probably going to be difficult.

Dynamically subscribing to topics can be done both in Python as well as in C++ though, I don't immediately see why that would be any more difficult. Almost all RViz display plugins and quite some Panel plugins do it. See rviz/default_plugin/marker_display.cpp for instance.


It would be somewhat involved, but one way to get this info into RViz could be to write a Python publisher that wraps rostopic.ROSTopicHz, publishes the data your after and then write a regular C++ panel plugin (something like InstitutMaupertuis/simple_rviz_plugin) to display it inside RViz.

If you don't absolutely need it to be an RViz panel, you could perhaps take a look at rqt_topic, which shows the same statistics (and more), but is an rqt plugin. RQT can also host an RViz instance.

Without (quite) some trickery, writing RViz panels in Python is probably going to be difficult.

Dynamically subscribing to topics can be done both in Python as well as in C++ though, I don't immediately see why that would be any more difficult. Almost all RViz display plugins and quite some Panel plugins do it. See rviz/default_plugin/marker_display.cpp for instance.


It would be somewhat involved, but one way to get this info into RViz could be to write a Python publisher that wraps rostopic.ROSTopicHz, publishes the data your after and then write a regular C++ panel plugin (something like InstitutMaupertuis/simple_rviz_plugin) to display it inside RViz.

If you don't absolutely need it to be an RViz panel, you could perhaps take a look at rqt_topic, which shows the same statistics (and more), but is an rqt plugin. RQT can also host an RViz instance.


Edit:

Thank you for your great answer! The problem I am seeing with C++ is that I need to create callback functions on runtime for new subscribers (so I can distinguish them for measuring publishing rate) because the messages have different types. I don't know at compile time the message types.

The topic_tools pkg also has a C++ side to it. That provides the ShapeShifter class, which allows you to subscribe to any topic at runtime. See also ros_type_introspection/Tutorials/GenericTopicSubscriber.

To clarify my idea a bit more: I have a system with quite many devices (all of them are publishing data in ROS) and several people are working on the system. Sometimes one or two devices are not running (because somene forgot to plug in a cable again for example). Since we don't have a mechanism to track these problems down with the nodes directly (legacy code problems) we just check with rostopic hz if there is data on the desired topics. So the panel should be reconfigurable to measure the publishing rate on all types of topics.

I should've asked you why you wanted to this, but reading this description makes me wonder whether we're not solving an xy-problem.

What you're describing sounds more like a task for diagnostics.

Without (quite) some trickery, writing RViz panels in Python is probably going to be difficult.

Dynamically subscribing to topics can be done both in Python as well as in C++ though, I don't immediately see why that would be any more difficult. Almost all RViz display plugins and quite some Panel plugins do it. See rviz/default_plugin/marker_display.cpp for instance.


It would be somewhat involved, but one way to get this info into RViz could be to write a Python publisher that wraps rostopic.ROSTopicHz, publishes the data your you're after and then write a regular C++ panel plugin (something like InstitutMaupertuis/simple_rviz_plugin) to display it inside RViz.

If you don't absolutely need it to be an RViz panel, you could perhaps take a look at rqt_topic, which shows the same statistics (and more), but is an rqt plugin. RQT can also host an RViz instance.


Edit:

Thank you for your great answer! The problem I am seeing with C++ is that I need to create callback functions on runtime for new subscribers (so I can distinguish them for measuring publishing rate) because the messages have different types. I don't know at compile time the message types.

The topic_tools pkg also has a C++ side to it. That provides the ShapeShifter class, which allows you to subscribe to any topic at runtime. See also ros_type_introspection/Tutorials/GenericTopicSubscriber.

To clarify my idea a bit more: I have a system with quite many devices (all of them are publishing data in ROS) and several people are working on the system. Sometimes one or two devices are not running (because somene forgot to plug in a cable again for example). Since we don't have a mechanism to track these problems down with the nodes directly (legacy code problems) we just check with rostopic hz if there is data on the desired topics. So the panel should be reconfigurable to measure the publishing rate on all types of topics.

I should've asked you why you wanted to this, but reading this description makes me wonder whether we're not solving an xy-problem.

What you're describing sounds more like a task for diagnostics.