0
$\begingroup$

Rosanswers logo

I'm new to ROS and trying to learn from a book "ROS Robotics Projects". I'm using Ubuntu 18.04 LTS and ROS Melodic Morenia. I'm trying to build a robot simulation. And I was following instructions and stucked. I created robot_base.urdf.xacro and robot_essentials.xacro files. Here is the content of files = -robot_base.urdf.xacro

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro" name="robot_base" >

<link name="base_link">
<visual>
<origin
xyz="0 0 0"
rpy="1.5707963267949 0 3.14" />
<geometry>
<mesh filename="package://robot_description/meshes/robot_base.stl"/>
</geometry>
<material
name="">
<color
rgba="0.79216 0.81961 0.93333 1" />
</material>
</visual>
</link>

<xacro:robot_wheel prefix="front_left"/>
<xacro:robot_wheel prefix="front_right"/>
<xacro:robot_wheel prefix="rear_left"/>
<xacro:robot_wheel prefix="rear_right"/>

<xacro:wheel_joint prefix="front_left" origin="0.220 0.250 0"/>
<xacro:wheel_joint prefix="front_right" origin="0.220 -0.250 0"/>
<xacro:wheel_joint prefix="rear_left" origin="-0.220 0.250 0"/>
<xacro:wheel_joint prefix="rear_right" origin="-0.220 -0.250 0"/>

</robot>

and -robot_essentials.xacro =

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro" name="robot_essentials" >
<xacro:macro name="robot_wheel" params="prefix">
<link name="${prefix}_wheel">
<visual>
<origin
xyz="0 0 0"
rpy="1.5707963267949 0 0" />
<geometry>
<mesh filename="package://robot_description/meshes/wheel.stl" />
</geometry>
<material
name="">
<color
rgba="0.79216 0.81961 0.93333 1" />
</material>
</visual>
</link>
</xacro:macro>

<xacro:macro name="wheel_joint" params="prefix origin">
<joint name="${prefix}_wheel_joint" type="continuous">
<axis xyz="0 1 0"/>
<parent link ="base_link"/>
<child link ="${prefix}_wheel"/>
<origin rpy ="0 0 0" xyz= "${origin}"/>
</joint>
</xacro:macro>

</robot>

Than I'm trying to run this command :

roslaunch urdf_tutorial display.launch model:=robot_base.urdf.xacro

I'm getting this error =

unknown macro name: robot_wheel
when processing file: robot_base.urdf.xacro
RLException: Invalid <param> tag: Cannot load command parameter [robot_description]: command [['/opt/ros/melodic/share/xacro/xacro.py', 'robot_base.urdf.xacro']] returned with code [2]. 
Param xml is <param command="$(find xacro)/xacro.py $(arg model)" name="robot_description"/>
The traceback for the exception was written to the log file*

Can you help me to get the issue and solve it.

Thanks.


Originally posted by Morgenstern on ROS Answers with karma: 25 on 2020-06-01

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

Hi,

you need to include in your main URDF a include of the other URDF where you define the wheel:

<xacro:include filename="$(find <your packge>)<path to your urdf inside the package>/robot_essentials" />
<xacro:robot_wheel prefix="front_left"/>
<xacro:robot_wheel prefix="front_right"/>

Originally posted by ahcorde with karma: 421 on 2020-06-01

This answer was ACCEPTED on the original site

Post score: 6


Original comments

Comment by Morgenstern on 2020-06-02:
Thanks. It worked. Thanks for helping me. I hope you have a nice day :) .

Comment by Sudo on 2020-07-16:
I use noetic and the ans worked for me as well Thank You

Comment by concorde42 on 2020-11-26:
Thanks worked for me

Comment by BG_22 on 2020-12-20:
I got the simulation but wheels are not connected to the robot base why??

Comment by YassineA2 on 2021-04-19:
Hi, I'm actually learning from the same book and running the same code. This helped me run the simulation but there was only one wheel in the middle. did you have the same problem, if not can you please help me figure out what's wrong. Thank you

Comment by Morgenstern on 2021-04-26:
Probably you are writin wrong somethin. (Incompletely)

Comment by mr_top on 2022-11-14:
That did it . Thank you

$\endgroup$
1
  • $\begingroup$ for ROS Noetic a launch file template is a below '``` $\endgroup$
    – Joaquim
    Commented Jun 14 at 15:47
0
$\begingroup$

For ROS Noetic a launch file template is a below.

<!-- <?xml version="1.0"?>
<launch>
    <arg default="$(find package_name)/urdf/robot.urdf.xacro" name="model"/>
    <param command="$(find xacro)/xacro $(arg model)" name="robot_description"/>

    <arg name="rviz_config_file" default="$(find package_name)/config/robot_config.rviz"/>

    <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" output="screen"/>
    <node name="joint_state_publisher_gui" pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" output="screen"/>

    <node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rviz_config_file)"/> 
</launch> -->
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.