ros / ros_comm

ROS communications-related packages, including core client libraries (roscpp, rospy, roslisp) and graph introspection tools (rostopic, rosnode, rosservice, rosparam).
http://wiki.ros.org/ros_comm
747 stars 914 forks source link

Cache parameters to enable and configure topic statistics? #2292

Open meyerj opened 1 year ago

meyerj commented 1 year ago

Checking the ROS parameters related to topic statistics (https://github.com/ros/ros_comm/pull/398) takes quite some time if the ROS master is remote, and only reachable via a comparatively slow link.

One example is starting up rviz with a config file and many pre-configured displays: The communication with the ROS master to check the /enable_statistics and other parameters can take up to several minutes, while the actual subscriptions involve only a fraction of XML-RPC requests to the ROS master and after rviz started up even image streams work fine. I checked the communication with Wireshark, but did not do a detailed timing analysis yet.

Would it be straitht-forward to use param::getCached() here? Any disadvantage?

https://github.com/ros/ros_comm/blob/f5fa3a168760d62e9693f10dcb9adfffc6132d22/clients/roscpp/src/libros/statistics.cpp#L44-L51

Note that each subscription has its own instance of StatisticsLogger, but the parameters are global and hence would only need to be checked once per process.

Same for rospy, where the rospy.get_param() calls could be replaced by rospy.get_param_cached() in rospy/impl/statistics.py?