I’m currently near the end of a rewrite of robot_state_publisher. There are a few goals to this rewrite:
- Simplify the code, as it was too complicated before.
- Bring the code up to modern ROS 2 standards.
- Reinstate some of the features that were missed during the original port.
- Allow the
robot_descriptionto be changed during runtime.
I want to discuss the last point a bit further, and get some thoughts from the community. To start with, I want to make it clear that I am not trying to solve the entire problem of “make a URDF changeable across a robot”. That involves a lot more pieces than just robot_state_publisher. However, adding some level of dynamicity to robot_state_publisher at least solves part of the problem.
With ROS 2, we have a bunch of tools that make solving the problem of a dynamic robot_description possible. We have the ability to get and set parameters (and get notified when they change), we have the ability to publish transient_local (latched) topics, etc. Here are a few different ways I’ve though about to make the robot_description changeable:
-
Make the
robot_descriptiona required parameter during node startup. To access therobot_description, consumers have to do the equivalent ofros2 param get /robot_state_publisher robot_description, and to change it, the equivalent ofros2 param set /robot_state_publisher robot_description <new_description>.- Pros: Most like ROS 1 in concept. Makes
robot_state_publisherthe “owner” of therobot_description. Uses existing ROS 2 parameter infrastructure to the fullest. - Cons: Most unlike existing ROS 2 (meaning we have to make changes to things like rviz2). Makes
robot_state_publisherthe “owner” of therobot_description. Therobot_descriptionis no longer anonymous; consumers have to know the name of therobot_state_publishernode.
- Pros: Most like ROS 1 in concept. Makes
-
Make the
robot_descriptiona required parameter during node startup. Publish the currentrobot_descriptionon a latched topic. To changerobot_description, the equivalent ofros2 param set /robot_state_publisher robot_description <new_description>has to be run.- Pros: Uses the parameter infrastructure for initial configuration and setting. Keeps the topic “anonymous” for getting the
robot_description. Doesn’t require changes to RViz2. - Cons: Setting the
robot_descriptionisn’t anonymous; the name of the node is necessary. Is a bit inconsistent, in that getting and setting therobot_descriptionis done via different mechanisms.
- Pros: Uses the parameter infrastructure for initial configuration and setting. Keeps the topic “anonymous” for getting the
-
Make the
robot_descriptiona required parameter during node startup. Publish the currentrobot_descriptionon a latched topic. Provide a service to allow changes to therobot_description, which would then propagate to the topic.- Pros: Makes getting the
robot_descriptionanonymous, sorobot_state_publisherno longer “owns” therobot_description. Same for the service. RViz2 doesn’t have to change. - Cons: Only uses parameters as an “initialization” mechanism; doesn’t take full advantage of the parameters infrastructure.
- Pros: Makes getting the
-
Make the
robot_descriptionnot provided during node startup.robot_state_publisherwould do nothing until something called a service to set therobot_description, at which point it would start publishing transforms. Changes to therobot_descriptionwould be done via the same service call. There would be a latched topic that publishes the current state ofrobot_descriptionfor downstream consumers.- Pros: Ensures that
robot_state_publisherisn’t the “owner” of therobot_description. Doesn’t require changes to RViz2. - Cons:
robot_state_publisheris no longer standalone; it needs an external “something” to tell it the initialrobot_description.
- Pros: Ensures that
These are the options I’ve thought of; there are some others in this same vein. The ros2-refactor currently implements solution 2, but I’m looking for opinions from the community on any of these options, or an option I haven’t thought of. Thoughts?
Ping @jacob, @sloretz, @IanTheEngineer, @peci1, @karsten as a (non-exhaustive) list of people who have expressed interest in this topic.