Attach One Robot to Another

asked 2022-02-10 15:55:58 -0600

MadeleineP gravatar image

updated 2022-02-11 14:23:54 -0600

kscottz gravatar image

I would like to attach one robot that is spawned in Gazebo to another. This is the scenario:

I have a Lidar robot. It's more than just a mesh and Gazebo lidar sensor - there are some other parts to it. The whole thing is contained in one urdf.xacro file that starts with a <robot> tag.

I'd like to attach this lidar unit to several different robots, and possibly multiple times to one robot. For example, putting one on the front and also rear bumpers of a car robot. This car would be a separate, stand-alone robot contained in its own URDF file.

The car robot and lidar robots are to be launch with separate launch files, since I might not always want to have the car with the lidar units on it. I might also want to have the lidar unit standing alone or on the top of a static pole or something like this. So the car URDF file should not / cannot contain the lidar files or URDF.

The way I have planned to do it is to pass in the "attachment link" name on the car into the lidar xacro file via an argument. The lidar robot then uses this as its first <link> tag, and the rest of the lidar URDF (joints and links) proceeds from there. The first joint is type="fixed", so the lidar should be fixed to the bumper.

What I have found is that the <origin> tag of the first joint, which connects the rest of the lidar to the attachment link needs to be set using global coordinates, not coordinates relative to what it is attaching to (in this case, the car bumper). This is a red flag.

I can get the simulation to run, and all the robots spawn fine within Gazebo. The TF tree looks correct, with the lidar connected through the car's bumper down to the base footprint of the car. Note that the car's robot_state_publisher is broadcasting the TF for the whole car, and the lidar's is broadcasting from the bumper down through the lidar unit. [I put the lidar's robot_state_publisher in its own namespace so that it doesn't collide with other robot_state_publishers, including other lidar units].

And then when the car is moved, the lidar unit does not stay attached to the bumper. Obviously this is not the intended behavior.

If I view the model in RViz, the car and lidar unit show up as I had intended.

Another avenue that I tried was to pass in a link (I called it lidar_world) to the lidar which served as the root link for the lidar unit. Then I provided a TF transform (tf2_ros / static_transform_publisher) between the bumper's attachment link and the lidar_world link.

The problem here is that the origin tag used in the lidar's first joint is in global coordinates, and again, not relative to the bumper. This makes sense to me, since Gazebo is ... (more)

edit retag flag offensive close merge delete