Skip to content

Feature request: index support into bundled params #49

@freyzor

Description

@freyzor

Trying to write modular xacto definitions I find myself really wanting to be able to index bundled xyz or rpi params passed along into macros. This would greatly simplify making components.

To give an example here is a bioloid F2 bracket part used to compose composit links.

    <macro name="geometry_F2">
        <geometry>
            <mesh filename="package://${PACKAGE}/meshes/F2.stl" scale="${M_SCALE_3}"/>
        </geometry>
    </macro>
    <macro name="visual_F2" params="xyz rpy">
        <visual>
            <origin xyz="${xyz}" rpy="${rpy}" />
            <geometry_F2 />
            <color_grey60 />
        </visual>
    </macro>
    <macro name="collision_F2" params="xyz rpy">
        <collision_box xyz="${xyz}" rpy="${rpy}" size="0.025 0.0485 0.0375" />
    </macro>
    <macro name="part_F2" params="xyz rpy">
        <collision_F2 xyz="${xyz}" rpy="${rpy}" />
        <visual_F2 xyz="${xyz}" rpy="${rpy}" />
    </macro>

I then use it in to create a link like so

    <macro name="coxa_bone" params="parent name">
        <link name="${name}_link">
            <inertia_default />
            <part_ax12 xyz="0 0 0" rpy="0 0 ${MPI}" />
            <part_F3 xyz="0 0 -0.0415" rpy="0 ${MPI} 0 "/>
            <part_F2 xyz="0 0 -${L_COXA}" rpy="0 0 ${MPI2} "/>
        </link> 
        <joint_revolute name="${name}" parent="${parent}" xyz="0 0 0" rpy="0 0 0" 
            vel="100" llimit="${MIN_RAD_COXA}" ulimit="${MAX_RAD_COXA}" axis="0 1 0" />   
    </macro>

If I want to provide an offset to the xyz in the collision_F2 macro as it does not align to the stl mesh I'm unable to extract the x y z components again to add an offset. You can get around this by passing in the values separately but that does brake the encapsulation and makes the whole thing pretty verbose again.

what I'd like to be able to do would be something like the following.

    <macro name="collision_F2" params="xyz rpy">
        <collision_box xyz="${xyz[0]+0.03 xyz[1]-0.4 xyz[3]}" rpy="${rpy}" size="0.025 0.0485 0.0375" />
    </macro>

This way I can keep the implementation detail neatly contained.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions