0
$\begingroup$

Rosanswers logo

Good morning everyone :)

I'm tryng to describe a robot geometry and visualisation with robot_base.urdf.xacro file.

In order to semplify the robot_description, I have made another file in the urdf directory called robot_essentials.xacro.

I would like to visualize this robot in rviz by the following:

$ source devel/setup.bash
$ roscd robot_description/urdf/
$ roslaunch urdf_tutorial display.launch model:=robot_base.urdf.xacro

In the terminal is shown this error:

unknown macro name: xacro:robot_wheel when processing file: robot_base.urdf.xacro RLException: Invalid tag: Cannot load command parameter [robot_description]: command [['/opt/ros/noetic/lib/xacro/xacro', 'robot_base.urdf.xacro']] returned with code [2].

Param xml is The traceback for the exception was written to the log file

It seems that the .urdf.xacro is not able to get the macro written in robot_essentials.xacro file.

The files are structured as follow:

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_left" origin="-0.220
-0.250 0" />
        
        

    </robot>

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>

I have also tried to write in the robot_base.urdf.xacro the include line as follow:

<xacro:include filename="$(find robot_description)/urdf/robot_essentials.xacro" />

rviz is opening but it doesn't show the robot and the terminal shows this error:

[ERROR] [1643066398.619401933]: joint 'rear_left_wheel_joint' is not unique.
[robot_state_publisher-3] process has died [pid 7986, exit code 1, cmd /opt/ros/noetic/lib/robot_state_publisher/robot_state_publisher __name:=robot_state_publisher __log:=/home/fra/.ros/log/24d11a22-7d6c-11ec-9a97-3b5cbcf2596a/robot_state_publisher-3.log].
log file: /home/fra/.ros/log/24d11a22-7d6c-11ec-9a97-3b5cbcf2596a/robot_state_publisher-3*.log
[ERROR] [1643066399.328275824]: joint 'rear_left_wheel_joint' is not unique.

Could someone tell me what I did wrong? Is is an issue of noetic configuration?

I am using noetic, running in a Ubuntu 20.04.3 LTS

Thank you!


Originally posted by Francesco_R on ROS Answers with karma: 36 on 2022-01-24

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Good morning, I have figure it out what was the problem.

The robot_essentials.xacro file is correct. This was useful for cleaning up the robot_base.urdf.xacro.

In the robot_base.urdf.xacro I have to include the robot_essentials.xacro file, by adding this line as I have mentioned in the question:

<xacro:include filename="$(find robot_description)/urdf/robot_essentials.xacro"/>

Then when in the robot_base.urdf.xacro file I have used the macro for the wheel joint, I made a mistake in the last line:

<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_left" origin="-0.220 -0.250 0" />

I should have to replace the last line with the following line:

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

After this modification I can launch the display.launch file in the embedded urdf_tutorial package. The robot is shown in rviz correctly.

Thank you


Originally posted by Francesco_R with karma: 36 on 2022-01-26

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by osilva on 2022-01-26:
Thank you for taking the time to document the answer and help others in the future

$\endgroup$

Your Answer

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