xacro properties

asked 2018-09-17 06:11:49 -0500

aPonza gravatar image

I'm trying to use the mesh from the realsense camera in my .urdf.xacro file and getting name 'd435_cam_height' is not defined or similar.

This is a MWE to show the issue:

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

    <!-- sensors -->
    <xacro:include filename="$(find realsense2_camera)/urdf/_d435.urdf.xacro"/>
    <xacro:sensor_d435 parent="base_link">
        <origin xyz="0 ${(0.355-d435_cam_height)/2} 0.0445" rpy="0 0 ${pi/2}"/>

    <link name="base_link">
                <box size="0.483 0.355 0.089"/>
            <origin xyz="0 0 0"/>
                <box size="0.483 0.355 0.089"/>
            <origin xyz="0 0 0"/>
            <mass value="7"/>
            <inertia ixx="0.0781351666667" ixy="0" ixz="0" iyy="0.140705833333" iyz="0" izz="0.140705833333"/>

They define the property I'm trying to use with the following snippet:

<?xml version="1.0"?>
<robot name="sensor_d435" xmlns:xacro="http://ros.org/wiki/xacro">
    <xacro:macro name="sensor_d435" params="parent *origin">


        <xacro:property name="d435_cam_height" value="0.025"/>


        <!-- camera body, with origin at bottom screw mount -->
        <joint name="camera_joint" type="fixed">
            <xacro:insert_block name="origin" />
            <parent link="${parent}"/>
            <child link="camera_link" />



Is it not possible to use properties defined inside a macro in another xacro file? I tried with namespaces, I tried to search for similar questions and I did the tutorial and looked for similar robots with no luck. Of course using 0.025 directly solves the issue, it's beside the point of using properties then.

edit retag flag offensive close merge delete


With the "new xacro" (ie: Jade and up), that property is most likely local to the sensor_d435 macro, so not exposed to parent scopes.

What did you "try with namespaces"?

gvdhoorn gravatar image gvdhoorn  ( 2018-09-17 07:15:57 -0500 )edit

sensor_d435.d435_cam_height and xacro:sensor_d435.d435_cam_height both to no avail, of course. So the only solution is to go ask nicely if Intel can put the properties outside the macro? It wouldn't change anything to them, right?

aPonza gravatar image aPonza  ( 2018-09-17 07:19:10 -0500 )edit