Ask Your Question
1

Using Two Robots (two robot_description) in ROS

asked 2019-03-09 05:21:14 -0500

Ravi Joshi gravatar image

updated 2019-03-09 08:56:58 -0500

I am using Baxter Robot in ROS. Recently, a new robot is developed. I can visualize this newly build robot inside RViz in a standalone ROS by only sourcing devel/setup.bash but not sourcing baxter.sh.

In order to use this robot with the Baxter robot, I need to use a new parameter for robot_description. I also need to publish the joint states on a topic different than /joint_states. Since the parameters robot_description and /joint_states are occupied by the Baxter robot.

In order to use this robot with Baxter robot, I am doing the following modifications:

<launch>
  <arg name="ns_prefix" default="/subject"/>

  <arg name="model" default="$(find my_subject)/files/subject.urdf"/>
  <arg name="rviz_config" default="$(find my_subject)/files/display.rviz"/>

  <param name="subject_description" command="$(find xacro)/xacro --inorder $(arg model)"/>
  <param name="use_gui" value="true"/>

  <!-- Note that this is disabled since I have a separate joint_state_publisher
  <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher"/>
  -->

  <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher"/>

  <node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rviz_config)" required="true"/>

  <group ns="$(arg ns_prefix)">
    <node name="my_joint_state_publisher" pkg="my_subject" type="my_joint_state_publisher" output="screen">
      <param name="subject_base" value="subject_base" />
    </node>
  </group>
</launch>

Please note that I have a separate joint_state_publisher defined inside my_joint_state_publisher which publishes to /subject/my_joint_state_publisher/joint_states. More precisely, the joint state publisher is defined in the following way:

ros::NodeHandle nh("~");
ros::Publisher jointStatePub = nh.advertise<sensor_msgs::JointState>("joint_states", 1);

Unfortunately, I am still missing something here as RViz is not able to receive the joint states. Please note that Rviz is able to read the URDF as I changed the robot config inside Rviz from robot_description to subject_description.

I want to know the followings:

  1. How to configure ROS and Rviz in this scenario?
  2. How to use TF for both robots? (Please note that I do have the info. of transformation between these two robots)
edit retag flag offensive close merge delete

Comments

Any comments, please?

Ravi Joshi gravatar imageRavi Joshi ( 2019-03-10 08:08:46 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-03-19 05:05:59 -0500

fvd gravatar image

updated 2019-03-19 05:08:23 -0500

I don't have the time to find and link the sources I came across back then, but the last time I considered using multiple robots via their own robot_description, my conclusion was that ROS1 is simply not made for it. MoveIt and probably some other tools do not consider a namespaced robot_description. The same goes for joint_states and other topics. The underlying assumption is always a single robot system and no namespace.

The most common solution for using multiple robots seems to be to add a prefix to each robot (e.g. a_bot_, b_bot_. Most URDF macros have a prefix parameter for this) so that their names are unique*, and then place the robots in the URDF that is published to robot_description. Then you can define a separate planning group for each robot in MoveIt, which is practically identical to having multiple robots. You just have to think of robot_description as the description of your robot system, which contains all the robots you control.

For almost all** use cases with multiple robots, this is the method I would suggest. It is probably not impossible to make multiple robot_description and joint_states topics work, but is it worth the hassle? Consider all of the parts you may need to fix to accommodate this change. Do you plan to use a custom gripper? Its driver needs to publish to a different joint_states topic as well. Does Rviz accept joint_states input from multiple topics? I don't even know. MoveIt does not, at least not in the ways that you would want and expect it to.

* This might not be important for you because your robots are not identical. However, all of the joint and frame names also need to be unique, so prefixes may be a good idea anyway.

** For cases where you don't know the number of robots, or they have to go on-/offline on the fly (swarm management), it sounds like ROS2 will be more suitable.

edit flag offensive delete link more

Comments

I know this will be highly anecdotal, but I wanted to at least respond to this part of your answer:

Does Rviz accept joint_states input from multiple topics? I don't even know.

First: Rviz doesn't really care about JointState, as it typically uses TF, but yes, this is possible and supported. People typically only add a single RobotModel plugin to their RViz instance, but you can load as many as you want/need, each with their own robot_description parameter (just give them a different name).

As long as TF is setup correctly, RViz will display everything just fine.

Consider all of the parts you may need to fix to accommodate this change. Do you plan to use a custom gripper? Its driver needs to publish to a different joint_states topic as well.

Just remap it or push things down into a namespace. I've done this multiple times ...(more)

gvdhoorn gravatar imagegvdhoorn ( 2019-03-19 05:26:01 -0500 )edit

Thanks for the input. True, Rviz would do fine. It is probably MoveIt that would be the most involved to set up and remap everything for. Like I said, not impossible, but it adds yet another layer to troubleshoot, in a pretty uncommon and complicated setup. Would not recommend to beginners. Multiple move groups as described above seemed a lot easier.

fvd gravatar imagefvd ( 2019-03-19 09:15:27 -0500 )edit

I fully agree that for beginners, it's not something to attempt or consider.

But you wrote "I don't think it's supported" (or something along those lines), which would be something else.

gvdhoorn gravatar imagegvdhoorn ( 2019-03-19 10:29:19 -0500 )edit

@fvd and @gvdhoorn: Thanks for the suggestion. I upvoted it. Three points I would like to mention here:

1) Yes. As mentioned in the question itself, I can visualize multiple (two in my case) URDF inside RViz by publishing two robot_description for each robot. However, I am not sure, how to configure TF for two robots. For example, I can see two robots from two URDF inside RViz, but robots are not moving. Because I need to provide joint_states for them. Please note that I already have a joint_state publisher already, but I don't know how to link TF (indirectly RViz) to joint_state.

2) As per the workaround provided by fvd, it suggests making a single robot_description which combines multiple (two in my case) robots URDF. I am wondering how to combine them? Just plain XML contamination? I will give it a try sometime.

<< Point 3 in next comment below >>

Ravi Joshi gravatar imageRavi Joshi ( 2019-03-20 01:53:17 -0500 )edit

3) As I am using the Baxter robot, the roscore is running inside the Baxter robot. The parameter such as robot_description is provided by Baxter robot. Is it possible to change/append another robot_description into already existing robot_description? If yes, any suggestions, how?

Ravi Joshi gravatar imageRavi Joshi ( 2019-03-20 01:53:23 -0500 )edit

I can see how it can be read that way ("ROS1 is not made for it [multiple independent robots under the same roscore]"), but I think it's reasonable. ROS1 was made for a single robot (with a monolithic roscore). Namespacing makes this use case possible, but somewhat arduous. I understand that ROS2 made different architectural choices, also due to reasons related to this.

fvd gravatar imagefvd ( 2019-03-20 02:01:17 -0500 )edit

I don't know how Baxter does it, but the robot_description is likely based on a URDF file in your MoveIt package. You should be able to add the other robot into it, e.g. via an <include> or by using an xacro macro. There should be tutorials.

Otherwise, if both robots are already namespaced and all of your joint/frame names are unique, you could remap the tf and joint_states topics from each robot's namespace to the global one. That might do the trick, but I don't know if that is sufficient.

fvd gravatar imagefvd ( 2019-03-20 02:10:19 -0500 )edit

Great ๐Ÿ‘๐Ÿป I need to try first. Thanks again for the suggestions!

Ravi Joshi gravatar imageRavi Joshi ( 2019-03-20 07:12:43 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-03-09 05:21:14 -0500

Seen: 373 times

Last updated: Mar 19