0
$\begingroup$

Rosanswers logo

Hello all,

I'm trying to do something that I think is very basic but running into all kinds of trouble. System is Ubuntu 16.04 with ROS Kinetic. I want to define my robot (a drone) with the following file: sample_drone.urdf.xacro

<?xml version="1.0"?>

<robot name="test_drone" xmlns:xacro="http://ros.org/wiki/xacro">
    <!-- Load up the base pieces -->
    <xacro:include filename="xacro_modules/base_link.xacro"/>
    <xacro:include filename="xacro_modules/fiveinch_chasis.xacro"/>
    <!-- Right now just testing having a camera -->
    <xacro:include filename="xacro_modules/orbbec_astra.xacro"/>
    <xacro:orbbec_astra parent="five_inch_chasis" x="0.15" y="0.0" side="1.0"/>
</robot>

And for reference, the astra file looks like: orbbec_astra.xacro:

<?xml version="1.0"?>
<xacro:macro name="orbbec_astra" params="parent x y side">
    <!-- Actual link -->
    <link name="orbbec_astra">
        <visual>
            <geometry>
                <!-- TODO: replace with the actual mesh here -->
                <box size="0.083  0.058  0.020"/>
            </geometry>
            <origin xyz="0 0 0" rpy="0 0 0"/>
        </visual>
        <collision>
            <geometry>
                <box size="0.083  0.058  0.020"/>
            </geometry>
            <origin xyz="0 0 0" rpy="0 0 0"/>
        </collision>
        <inertial>
            <mass value="0.038"/>
            <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0" />
        </inertial>
    </link>
    <!-- Connecting Joint -->
    <joint name="${parent}_to_astra" type="fixed">
        <parent link="${parent}"/>
        <child link="orbbec_astra"/>
        <origin xyz="${x} ${y} ${ (0.01 + (drone_thickness/2.0) )*side}" rpy="${ (side-1)*(pi/2.0) } 0 0"/>
    </joint>
</xacro:macro>

I've tried several different tweaks to this, but everything seems to run into some kind of error. Is there any way I can include the orbbec_astra.xacro without having it automatically expand (and thus fail because it has no parameters) and then call the macro with the required parameters?

Edit: For more clarification, I am running

rosrun xacro xacro.py sample_drone.urdf.xacro > sample_drone.urdf

With the code I've shown above, I get the following errors:

xacro: Traditional processing is deprecated. Switch to --inorder processing!
To check for compatibility of your document, use option --check-order.
For more infos, see http://wiki.ros.org/xacro#Processing_Order
name 'parent' is not defined
when evaluating expression 'parent'
when processing file: sample_drone.urdf.xacro

Which makes sense, because it seems to try expanding the astra macro completely.

Now if I remove the line

<xacro:orbbec_astra parent="five_inch_chasis" x="0.15" y="0.0" side="1.0"/>

from the top-level file and instead try to pass parameters to the include such as like:

<xacro:include filename="xacro_modules/orbbec_astra.xacro" parent="five_inch_chasis"/>

I get errors that parent is not a known parameter (makes sense, that's not what xacro knows about).

Edit: [Answer]: Including the robot tag in the astra macro has resolved the issue.


Originally posted by Chuples on ROS Answers with karma: 3 on 2018-07-23

Post score: 0


Original comments

Comment by gvdhoorn on 2018-07-23:\

but everything seems to run into some kind of error

would you agree it would probably be a lot easier for us to help you if we could actually see those errors?

Comment by Chuples on 2018-07-23:
I've edited the original message to be more clear.

Comment by gvdhoorn on 2018-07-23:
I've re-opened the question: we don't normally close questions here on ROS Answers if they've actually been answered. Ticking the checkmark to the left of the correct answer indicates much more clearly that a question has been answered.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

As to your problem: I believe your orbbec_astra.xacro is missing some elements. I would expect something like:

<robot xmlns:xacro="http://wiki.ros.org/xacro">
</robot>

to be the root element of the file.


Originally posted by gvdhoorn with karma: 86574 on 2018-07-23

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Chuples on 2018-07-23:
That robot tag seems to have resolved it. It seems there is weird behavior when not including the tag and it automatically expands things in that case. Seems a little odd, but I'll take it.

Cheers

$\endgroup$

Your Answer

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