Skip to content

Conversation

@stefanscherzinger
Copy link

Goal

By setting the use_custom_simulator parameter, users can specify their
own ros2_control and hardware tags inside their robot description.

Motivation

This allows users to implement their own simulators with custom system_interfaces. I came across this necessity while implementing a MuJoCo-based system_interface. I couldn't find a way to do that with the current choice of simulators inside the xacro macros.

Example usage

Here's a use case with a custom UR5e:

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

        <!-- Parameters are passed to the includes -->
        <xacro:arg name="name" default="ur5e"/>
        <xacro:arg name="ur_type" default="ur5e"/>
        <xacro:arg name="use_custom_simulator" default="true"/>
        <xacro:arg name="prefix" default=""/>

        <!-- Includes -->
        <xacro:include filename="$(find ur_description)/urdf/ur.urdf.xacro"/>
        <xacro:include filename="$(find my_example_project)/urdf/joint_interface.xacro"/>

        <!-- The robot is connected to world by default -->

        <!-- We add our own MuJoCo-based simulator -->
        <ros2_control name="ur5e" type="system">
                <xacro:joint_interface name="shoulder_pan_joint" p="1000" d="100"/>
                <xacro:joint_interface name="shoulder_lift_joint" p="1000" d="100"/>
                <xacro:joint_interface name="elbow_joint" p="1000" d="50"/>
                <xacro:joint_interface name="wrist_1_joint" p="500" d="10"/>
                <xacro:joint_interface name="wrist_2_joint" p="50" d="1"/>
                <xacro:joint_interface name="wrist_3_joint" p="50" d="0.01"/>
                <hardware>
                        <plugin>my_example_project/Simulator</plugin>
                        <param name="mujoco_model">$(arg mujoco_model)</param>
                        <param name="mesh_directory">$(arg mesh_directory)</param>
                </hardware>
        </ros2_control>

</robot>

And here's the joint macro:

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

        <!-- Individual joint. -->
        <xacro:macro name="joint_interface" params="name p d">
                <joint name="${name}">
                        <param name="p">${p}</param>
                        <param name="d">${d}</param>
                        <command_interface name="position"/>
                        <command_interface name="velocity"/>
                        <command_interface name="effort"/>
                        <state_interface name="position"/>
                        <state_interface name="velocity"/>
                        <state_interface name="effort"/>
                </joint>
        </xacro:macro>

</robot>

By setting the `use_custom_simulator` parameter, users can specify their
own `ros2_control` and `hardware` tags inside their robot description.

This allows users to implement their own simulators with custom
`system_interfaces`.
@stefanscherzinger stefanscherzinger force-pushed the support-custom-simulators branch from d11dbb8 to 0c07eba Compare June 20, 2022 14:43
@fmauch fmauch self-requested a review June 21, 2022 09:38
@fmauch
Copy link
Contributor

fmauch commented Jun 21, 2022

I like the idea in general, but implementation-wise I think we can improve this. I haven't yet found a full solution, but Id prefer something that includes the correct files depending on the use case.

Ideally, the implementation-specific parameters for the simulator would live inside their respective repositories.

@destogl
Copy link
Contributor

destogl commented Jul 28, 2022

We could here work with strings for plugins and objects for parameters, similar how origin block is provided.

@fmauch
Copy link
Contributor

fmauch commented Nov 15, 2023

@stefanscherzinger #114 (and the discussion there) might be relevant in this context, as well.

@fmauch
Copy link
Contributor

fmauch commented Nov 17, 2023

Closing this in favor of #114 and #121

@fmauch fmauch closed this Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants