Implement ROS bridge for calling set_rate on cameras and lidars #791
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.
Depends on release of gazebosim/gz-sensors#95 in ign-sensors4.
This PR adds ROS services
.../set_rate
to cameras and lidars which can be used to call their Ignition counterparts. This is to allow users to deliberately lower the FPS of the rendering sensors, speeding up the simulation. It doesn't change the default behavior of the sensors in any way (i.e. until the ROS service is called, the sensors publish at the rate specified in SDF).gazebosim/gz-sensors#95 makes sure it is not possible to set the rate higher than what it specified in SDF (special case 0 is only allowed to be set if SDF contains 0). Negative set_rate requests are ignored.
Each time the set_rate request is processed by the simulator, it emits a debug message like
It also checks whether the Ignition service is available. If it's not, it emits this kind of warning once per minute:
Moreover, if
IGN_TRANSPORT_TOPIC_STATISTICS=1
, the warning will also include this text:The ROS service is only advertised after existence of the Ignition service is confirmed.
So far I added the services mostly to robots we regularly use. There's no reason not to add it to other robots, too, but it needs to be tested a bit (whether you connected the ROS service to the correct Ignition service) and that would take time, so I first want to get a thumbs up on how this is implemented, and when the implementation is agreed upon, I can try to fix the other robots.
There is an alternative implementation, which would not need changing all robot launchers. It would be a node that would periodically list all ignition services and create the set_rate ROS counterparts on-the-fly as the Ignition services appear. But I didn't like this solution that much because it's not really transparent (automagic) and it would create weird service names (we would need to name them after the Ignition services because there is no other hint for a name). It would also create the services for sensors where it doesn't make sense to lower the rate because generating their data is not expensive (IMUs, pressure sensors, magnetometers).
I also probably found a bug in
subt/subt_ros/launch/vehicle_topics.launch
Lines 140 to 166 in 6bd98e3
It begins with a block
unless="$(arg stereo_cam)"
and adds a RGB camera. But the models which use RGBD camera do not include this additional RGB camera (i.e. X4_SENSOR_CONFIG_2). However, bridges for the RGB cam are created. I only protected the set_rate bridge with the additionalunless="$(arg rgbd_cam)"
, but I think the whole RGB camera block should be excluded when the RGBD is present. But I felt that doing such change could break something I did not foresee, so I did not do it.I also fixed some package.xml's which apparently mistakenly used
<buildtool_depend>
instead of<exec_depend>
(because I needed to add<exec_depend>subt_ros</exec_depend>
and it seemed to me this is a good opprotunity to fix the package.xml).Finally, I noticed there's a large room for code reuse in the model launch files.
rgb_cam_bridge.launch
which could be included, given a few args, and would bring in all the required nodes like cam info bridge, image bridge, optical frame publisher, set_rate bridge etc.)All of this would ease the development of new robot models and maintenance of the existing ones and decrease the reviewer's load. But I don't think I have the time for such large refactoring. I'm also not sure if it'd be allowed/ethical to do such large changes to other teams' robot packages. And it would need extensive testing (which could be automated a bit e.g. comparing the "resolved" roslaunch XML files and the resulting Ruby strings in spawners).