How to spawn 2 ur16e arms in gazebo and rviz?

asked 2022-01-13 06:41:21 -0600

aarsh_t gravatar image

updated 2022-01-18 11:04:47 -0600

Hello everyone,

I have 2 UR16e arms in simulation. I have created moveit config and ikfast plugin pkgs for myself. The issue is when I spawn 2 UR16e arms it appears correctly in gazebo but I am not sure why it does not appear in rviz at the same place as gazebo when I add model in rviz.

To give you brief about the project detail,

I am using Ubuntu 1804 and ROS melodic. I have two different urdf files for 2 robots as we have several deferences between arms. I have created moveit config and ikfast plugin package for one arm. I am following this question as well.

Main Issue, I am able to see 2 robot models from different namespaces in rviz but both are shown at the same zero rviz position instead of their respective spawning coordinates.

One more thing in which I need input is, do we really I will need 2 different moveit and ikfast configuration for similar robot spawning 2 times?


tf_frames after spawning 2 robots in the gazebo:

tf_frames after spawning 2 robots in the gazebo


tf_frames after adding the prefix as robot name

image description


2 robot model in rviz

image description

2 MotionPlanning (moveit) loaded in rviz. You can not see the 2 robots but it is there both are at same place.

image description

Thank you.

edit retag flag offensive close merge delete


do you have something that publishes the global position (e.g. the map -> baselink) transformation for each arm? else RViz won't know where the robots are actually supposed to be.

shonigmann gravatar image shonigmann  ( 2022-01-13 12:59:17 -0600 )edit

yes I do have world frame but problem is I can only see the frames of one robot (the last robot spawned). When I spawn robot1, I can see the tf_frames of that robot but when I spawn robot1 and robot2 I can only see the frames of robot2. I will edit the question with image of tf frames for your reference. I have world link in both the urdf files. that can be an issue?

aarsh_t gravatar image aarsh_t  ( 2022-01-14 00:03:20 -0600 )edit

It sounds like your frame names are identical between robot1 and robot2 - that would cause the tf frames to clash between the two publishers, resulting in you only seeing one of the two robots in the tf graph. The UR arms xacro files should have an option to specify a prefix that should help remove the name clashing.

shonigmann gravatar image shonigmann  ( 2022-01-14 11:18:30 -0600 )edit

Hello Shounigmann, Sorry for little delay. After adding prefix to tf frames I am getting 2 world frames each associated with the robot. Have a look in the question that I have edited. I am not getting robot rendered correctly in rviz as well, it is just white parts gathered at one place.

Unfortunately I am not directly using the UR package from ros_industrial but I am just using their robot description but that as well I have tweaked a lot from what is available now over there for ur16e.

aarsh_t gravatar image aarsh_t  ( 2022-01-16 10:32:47 -0600 )edit

I would suggest adding a static transformer in your launch files for each robot like so:

<node pkg="tf2_ros" type="static_transform_publisher" name="robot_world_broadcaster" args="0 0 0 0 0 0 world $(arg robot1)/base_link"/>

<node pkg="tf2_ros" type="static_transform_publisher" name="robot2_world_broadcaster" args="0 0 0 0 0 0 world $(arg robot2)/base_link" />

otherwise the tf_tree's are not connected, so they both start at the same point. For this I would also suggest setting the position args for one of the static_transform_publisher as different, so they wouldn't overlap. For more info check out the tf2 static_transform_publisher page.

sniegs gravatar image sniegs  ( 2022-01-18 03:23:44 -0600 )edit

This is indeed a good idea. Let me try that out. Being not so experience I forgot that static transform also exist in tf. Thanks.

aarsh_t gravatar image aarsh_t  ( 2022-01-18 06:55:55 -0600 )edit

However after adding the static_transform_publisher it does reflected the robot into correct position in rviz... But only while adding the Robotmodel in rviz, while adding the MotionPlanning for the moveit, both robots are shown at same places. Refer the edit I have made in question.

aarsh_t gravatar image aarsh_t  ( 2022-01-18 11:01:38 -0600 )edit

I'm not sure if I've ever successfully been able to run two Motion Planning tabs in Rviz simultaneously (there are a ton of parameters that aren't inherently namespaced that might be clashing). As a sanity check, consider removing one of the motion planners, and changing the target within the remaining motion planner to see if the arms are correctly selected (the orange version which indicates the target pose)

shonigmann gravatar image shonigmann  ( 2022-01-18 11:14:47 -0600 )edit