How to dynamically modify robot URDF?
We currently have many robots of the same model that all have the same basic components but differ according to certain attachments and/or features. For example, a chassis and arm would be standard to all the robots but different claw types or end effector attachments could be changed by the user.
What we would like to have happen is that as the user changes certain attachments or smaller components on the actual, physical robot that the robot URDF would be updated accordingly during runtime. We have a GUI setup for the robot that allows the user to select different attachments but it does not do anything right now. The idea is that the user's selection in the user interface would then publish a ROS message and somehow the robot would dynamically reconfigure its joints and links accordingly. The updated URDF is then used to update the robot avatar in the GUI and for path planning calculations.
We have divided the various components and attachments that the robot can take into separate .xacro files (ex/ claw.xacro, long_claw.xacro, short_claw.xacro, etc..). What we originally were thinking is that we would just create a ROS node to do this. Currently, our startup script runs:
rosrun xacro xacro -o robot1.urdf robot1.xacro
with the robot1.xacro specifying all of the hardware (other .xacro files) to include and that are standard specifically to robot1. But right now this is only done at startup and cannot be changed at runtime.
Should we just create a ROS node that calls a bash script that calls the above command when it receives a message from the user to update the URDF? Is changing the robot URDF during runtime something is normally done?
We are running ROS Melodic on Ubuntu 18.04.