How to spawn urdf.xacro-file into Gazebo
Hi all,
I've build a robot model with urdf. Additional I've used some macros to reduce my code. The model is working in rviz too. But if I want to spawn my robot into Gazebo, it doesn't work. After removing each macro, I can spawn my model into Gazebo. Is there a way to use my first robot model directly in Gazebo? How can I design my own color in Gazebo. Something like this
<gazebo reference="name_of_link">
<material name="Green">
<color rgba="0.0 0.8 0.0 1.0"/>
</material>
</gazebo>
doesn't work. Many thanks for your help!!!
Now I have a new problem:-( Since the usage of macros still doesn't work, I removed the macros and buil my new robot model bit by bit. But from a certain number of model parts the process of spawning a model is successful but you can't see a model in Gazebo although the robot is listed in the model list. Any ideas?
While spawning I get no errors on the terminal. Here is a part of my code.
<!-- Motorhalterung -->
<link name="motor_holder">
<inertial>
<mass value="1.0" />
<inertia ixx="1" ixy="0" ixz="0"
iyy="1" iyz="0"
izz="1" />
</inertial>
<visual>
<geometry>
<box size="0.03 0.09 0.07"/>
</geometry>
<material name="Dark_Grey">
<color rgba="0.3 0.3 0.3 1"/>
</material>
</visual>
<collision>
<geometry>
<box size="0.03 0.09 0.07"/>
</geometry>
</collision>
</link>
<joint name="chassis_to_motor_holder" type="fixed">
<parent link="base_link"/>
<child link="motor_holder"/>
<origin xyz="0.09 0 ${chassis_height/2 + 0.07/2}"/>
</joint>
<gazebo reference="motor_holder">
<material>ETABot/Dark_Grey</material>
</gazebo>
<!-- Motor -->
<link name="motor">
<inertial>
<mass value="1.0" />
<inertia ixx="1" ixy="0" ixz="0"
iyy="1" iyz="0"
izz="1" />
</inertial>
<visual>
<geometry>
<cylinder length="0.09" radius="0.03"/>
</geometry>
<origin rpy="0 ${pi/2} 0" xyz="0 0 0"/>
<material name="Blue" />
</visual>
<collision>
<geometry>
<cylinder length="0.06" radius="0.03"/>
</geometry>
<origin rpy="0 ${pi/2} 0" xyz="0 0 0"/>
</collision>
</link>
<joint name="motor_holder_to_motor" type="fixed">
<parent link="motor_holder"/>
<child link="motor"/>
<origin xyz="-0.06 0 0"/>
</joint>
<gazebo reference="motor">
<material>ETABot/Blue</material>
</gazebo>
<!-- Motor -->
<link name="motor_controller">
<inertial>
<mass value="1.0" />
<inertia ixx="1" ixy="0" ixz="0"
iyy="1" iyz="0"
izz="1" />
</inertial>
<visual>
<geometry>
<box size="0.05 0.05 0.03"/>
</geometry>
<material name="Blue" />
</visual>
<collision>
<geometry>
<box size="0.05 0.05 0.03"/>
</geometry>
</collision>
</link>
<joint name="chassis_to_motor_controller" type="fixed">
<parent link="base_link"/>
<child link="motor_controller"/>
<origin xyz="-0.11 0 ${chassis_height/2 + 0.03/2}"/>
</joint>
<gazebo reference="motor_controller">
<material>ETABot/Blue</material>
</gazebo>
From the point where the link "motor_controller" will be added, the model will be spawn in Gazebo without any errors but you can't see the robot in the simulator. If I remove the link "motor", the model will be spawn in Gazebo and you can see the robot with ...