Ask Your Question
0

Load two urdf models in one launch file

asked 2018-08-28 12:06:39 -0500

-LD- gravatar image

updated 2018-08-29 07:54:16 -0500

Hello,

i'm trying to load two models in one lunch file. I have one file for a robot arm and one for the base, that is intended to carry the robot arm around. Each separated works but as i try to load them together only the last model is loaded. Basically that's not surprising for me since i load both with the "robot_description" parameter and therefor overwrite the first loaded model. But how is it done the correct way? As i name the descriptions different, rviz complains about not having a properly set "robot_description" parameter. Keeping one "robot_description" and naming the other different leads to a white model with TF complaining about not having a transform tor every of the links. So, how to load both models from one launch file?

Thanks to everyone.

UPDATE:

I tried what gvdhorn suggested. I created a file "jaco_mp470.xacro", that only contains the following lines:

<robot xmlns::xacro="http://www.ros.org/wiki/xacro">

    <xacro:include filename="$(find mp470_description)/urdf/mp470.xacro"/>
    <xacro:include filename="$(find kinova_description)/urdf/j2s7s300.xacro"/>

    <xacro:mp470 prefix="mp470" />
    <xacro:j2s7s300 base_parent="root" /> <!-- taken from another xacro_macro file -->

    <joint name="jaco_to_base" type="fixed">
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <parrent link="mount"/>
        <chiled link="root"/>
    </joint>
</robot>

And than tried to load it with:

<param name="robot_description" command="$(find xacro)/xacro.py '$(find total_model)/urdf/jaco_mp470.xacro'" />
<node name="joint_state_publisher" pkg="....... />
<node name="robot_state_publisher" pkg="....... />

But rviz tells me that the robot_description parameter is not loaded. So what do i miss?




Snippet of old launch file:

<!-- platform, designed by myself-->
<param name="mp470_description" command="cat $(find mp470_description)/urdf/mp470.xacro" />

<!-- just the model of the arm, no controlers and no MoveIt -->
<param name="robot_description" command="$(find xacro)/xacro.py '$(find kinova_description)/urdf/j2s7s300_standalone.xacro'"/>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
  <param name="/use_gui" value="false"/>
  <rosparam param="/source_list">[/move_group/fake_controller_joint_states]</rosparam>
  <param name="zeros/j2s7s300_joint_2" value="3.1415"/>     
  <param name="zeros/j2s7s300_joint_4" value="3.1415"/> 
  <param name="zeros/j2s7s300_joint_6" value="3.1415"/> 
</node>

<!-- rviz told me to use this line just once -->
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="true" output="screen" />
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
1

answered 2018-08-28 14:44:02 -0500

gvdhoorn gravatar image

updated 2018-08-29 06:50:03 -0500

So, how to load both models from one launch file?

you don't.

The (implicit) assumption is that there is only a single robot_description that contains the urdf for your entire application. You can definitely have multiple parameters containing snippets of urdf, but almost every node that consumes urdf will assume that the parameter is called robot_description.

Pushing things in namespaces is supported, so that could allow you to have multiple robot_description parameters, but then you run into the issues you already mentioned.

So in your specific case: create a composite xacro that 'marries' an instance of the Kinova model with your mp470. Use a fixed joint for that fi. If you make sure to model that in a way that reflects reality, you can then even use that to do planning for both base and manipulator at the same time.

Then load that composite xacro -- which is now also a top-level xacro -- into the robot_description parameter and everything should start working.


Edit:

I tried what gvdhorn suggested. I created a file "jaco_mp470.xacro", that only contains the following two lines:

<xacro:include filename="$(find mp470_description)/urdf/mp470.xacro"/>
<xacro:include filename="$(find kinova_description)/urdf/j2s7s300_standalone.xacro"/>

And than tried to load it with:

<param name="robot_description" command="$(find xacro)/xacro.py '$(find total_model)/urdf/jaco_mp470.xacro'" />
<node joint_state_publisher" pkg="....... />
<node name="robot_state_publisher" pkg="....... />

But rviz tells me that the robot_description parameter is not loaded. So what do i miss?

Just including the two xacros is not enough.

That is similar to #include <..> in C/C++ and then not using any of the functions defined in those headers. xacro doesn't magically know that you want to insert two instances of those models in your xacro, where those should be placed in the scene or how they should be connected to each other.

There are quite a few examples 'out there' that show you how to create a composite xacro properly, but I'm going to link you to this one: Example: adding an end-effector to a robot.

Notice how there are three aspects to this:

  1. includeing the definition
  2. calling the macro (or 'instantiating the model')
  3. connecting everything together using one or more joints

Skip any of those three and xacro will abort with an error or return an empty document, causing any node expecting something in robot_description to not be able to find anything.

(note: the example I linked you to actually creates a xacro macro that instantiates and connects everything. If your world is simple enough, or you'll never need more than one of it, you can ignore that. You would need another top-level xacro to call that macro or else you'll run into the same problem again with an empty document (ie: definition but no instantiation or use))

edit flag offensive delete link more

Comments

Btw:

<rosparam param="/source_list">[/move_group/fake_controller_joint_states]</rosparam>

this is a really strange line to have there.

The fake controller manager is not a suitable source of JointState messages. It's not a simulator.

gvdhoorn gravatar imagegvdhoorn ( 2018-08-28 14:45:14 -0500 )edit

jea, you are right. That line seems not to be needed. I just ripped apart and reassembled the xacro-file from the jaco arm till the arm finally was displayed in rviz. So that's why the line ended up there.

-LD- gravatar image-LD- ( 2018-08-29 06:26:30 -0500 )edit

About the xacro file: it seems like i'm still doing something wrong. I updated my question. May i ask you to have a look at it? Maybe you find what i'm still missing.

-LD- gravatar image-LD- ( 2018-08-29 06:29:11 -0500 )edit

Oh yea, totally forgot: thanks for your answer.

-LD- gravatar image-LD- ( 2018-08-29 06:43:45 -0500 )edit

Since working with ROS i came across many questions without a real answer (especially for beginners). So i would like to post my final file to fix the models. But i don't have it working yet. Will tick as answered once i have it.

-LD- gravatar image-LD- ( 2018-08-29 07:17:41 -0500 )edit

Problem for now is indeed that i don't have a xacro macro. My urdf.xacro just starts with <robot name="..." xmlns:xacro="..."> and ends with </robot>. So how do i create an instance of each model in this case??

-LD- gravatar image-LD- ( 2018-08-29 07:24:53 -0500 )edit

as I wrote in my answer: you don't need to create a macro. Just instantiate the two models and add the joint as you've already done.

gvdhoorn gravatar imagegvdhoorn ( 2018-08-29 07:32:57 -0500 )edit

Now i get it. the <xacro:[robot_name]="" prefix="[???]"/> is how the instance is initialized. Thought that's part of the macro. Sorry, i'm totally new to this. And it seems like it still doesn't work.

-LD- gravatar image-LD- ( 2018-08-29 07:51:19 -0500 )edit
0

answered 2018-12-26 06:05:02 -0500

liamtht gravatar image

HI, i am working on load two different model in r viz as you ( one is robot arm, the other is mobile robot). However, this two robot does not connect together. The manipulator is in static position and the mobile robot will move around. Would you have any advice how could i edit to use in one robot_description parameter ?

edit flag offensive delete link more
0

answered 2018-08-29 09:03:18 -0500

-LD- gravatar image

Ok, once again the complete things i have done:

in the launch file:

<!-- don't forget the [$(find xacro)/xacro.py] or Permission denied error will come up -->
<param name="robot_description" command="$(find xacro)/xacro.py '$(find [folder_name])/urdf/jaco_mp470.xacro'"/>

<!-- optionally if needed -->
<node name="jiont_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
    <param name="zeros/j2s7s300_joint2" value="3.141"/>
    <param name ............ />
</node>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"/>

in the xacro that joints together the urdf's:

<robot name="base_arm" xmlns::xacro="http://www.ros.org/wiki/xacro">

    <xacro:include filename="$(find mp470_description)/urdf/mp470.xacro"/>
    <xacro:include filename="$(find kinova_description)/urdf/j2s7s300.xacro"/>

    <!-- very basic xacro written by myself. no macros and stuff, just links and joints -->
    <xacro:mp470 prefix="mp470" />

    <!-- taken from another xacro file. this model is created calling a macro (?)-->
    <xacro:j2s7s300 base_parent="mount_link" /> 

    <!-- not needed for me since the desired link is already named correctly -->
    <!-- but should work like this -->
    <joint name="jaco_to_base" type="fixed">
        <origin xyz="0 0 0" rpy="0 0 0"/>
        <parrent link="mount"/>
        <chiled link="root"/>
    </joint>
</robot>

Very very thanks to gvdhoorn, who took the time to respond to all my comments. The above is his solution just typed down my me for any beginner as a complete solution (in hope that i have no typos again).

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-08-28 12:06:39 -0500

Seen: 823 times

Last updated: Aug 29 '18