Load two urdf models in one launch file

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"/>
</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-->
<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)) 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. ( 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. ( 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. ( 2018-08-29 06:29:11 -0500 )edit Oh yea, totally forgot: thanks for your answer. ( 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. ( 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?? ( 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. ( 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. ( 2018-08-29 07:51:19 -0500 )edit 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 ? more 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 (?)-->

<!-- 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"/>
</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).

more