robosuite导入自定义机器人

目录


目的:

实现其他标准/非标准机器人的构建

案例一:

成果展示

添加机器人JAKA ZU 7 这个模型

具体步骤:

URDF文件准备

github 或机器人官网,下载 urdf 模型以及对应的 mesh

xml文件生成

官方提供的 urdf 模型如下:

urdf 复制代码
<?xml version="1.0" encoding="utf-8" ?>
<!-- This URDF was automatically created by SolidWorks to URDF Exporter! Originally created by Stephen Brawner (brawner@gmail.com) 
     Commit Version: 1.5.1-0-g916b5db  Build Version: 1.5.7152.31018
     For more information, please see http://wiki.ros.org/sw_urdf_exporter -->
<robot name="jaka_zu7">
    <!-- LINK -->
    <link name="world" />

    <link name="Link_0">     
        <inertial>
            <origin xyz="0.00096371 8.8222E-08 0.019555" rpy="0 0 0" />
            <mass value="4.0392" />
            <inertia ixx="0.0048763" ixy="-1.8056E-07" ixz="2.5196E-05" iyy="0.0068003" iyz="-1.7678E-09" izz="0.010618" />
        </inertial>

        <visual>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="/home/idm/Downloads/jaka_robot_v2.2/src/jaka_description/meshes/jaka_zu7_meshes/Link_0.STL" />
            </geometry>
            <material name="">
                <color rgba="0.84706 0.84706 0.84706 1" />
            </material>
        </visual>
        <collision>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <mesh filename="/home/idm/Downloads/jaka_robot_v2.2/src/jaka_description/meshes/jaka_zu7_meshes/Link_0.STL" />
            </geometry>
        </collision>
    </link>
        <gazebo>
        <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
            <robotNamespace>/</robotNamespace>
            <!-- <robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>
            <legacyModeNS>true</legacyModeNS> -->
        </plugin>
    </gazebo>
</robot>

修改最下面,将 gazebo 改成:

    <mujoco>
        <compiler 
        meshdir="/home/idm/Downloads/jaka_robot_v2.2/src/jaka_description/meshes/jaka_zu7_meshes/" 
        balanceinertia="true" 
        discardvisual="false" />
    </mujoco>

注意修改下 meshdir 的路径。

然后执行 ./compile urdf robot.xml,实现 urdfxml 的转变,后续操作之需要在 xml 的基础上修改即可;

xml修改

原始生成的文件如下:

<mujoco model="jaka_zu7">
    <compiler angle="radian" meshdir="/home/idm/Downloads/jaka_robot_v2.2/src/jaka_description/meshes/jaka_zu7_meshes/" />
    <size njmax="500" nconmax="100" />
    <asset>
        <mesh name="Link_0" file="Link_0.STL" />
        <mesh name="Link_1" file="Link_1.STL" />
        <mesh name="Link_2" file="Link_2.STL" />
        <mesh name="Link_3" file="Link_3.STL" />
        <mesh name="Link_4" file="Link_4.STL" />
        <mesh name="Link_5" file="Link_5.STL" />
        <mesh name="Link_6" file="Link_6.STL" />
    </asset>
    <worldbody>
        <geom type="mesh" contype="0" conaffinity="0" group="1" rgba="0.84706 0.84706 0.84706 1" mesh="Link_0" />
        <geom type="mesh" rgba="0.84706 0.84706 0.84706 1" mesh="Link_0" />
        <body name="Link_1" pos="0 0 0.12015">
            <inertial pos="-2.5186e-07 0.0033226 -0.001509" quat="1 0.00056994 2.2456e-05 6.30952e-05" mass="15.135" diaginertia="0.044302 0.043091 0.030523" />
            <joint name="joint_1" pos="0 0 0" axis="0 0 1" limited="true" range="-6.28 6.28" />
            <geom type="mesh" contype="0" conaffinity="0" group="1" rgba="0.84706 0.84706 0.84706 1" mesh="Link_1" />
            <geom type="mesh" rgba="0.84706 0.84706 0.84706 1" mesh="Link_1" />
            <body name="Link_2" pos="0 0 0" quat="0.707105 0.707108 0 0">
                <inertial pos="0.18 8.8001e-09 -0.14308" quat="0.5 0.5 0.5 0.5" mass="42.872" diaginertia="1.1119 1.0844 0.1014" />
                <joint name="joint_2" pos="0 0 0" axis="0 0 1" limited="true" range="-1.48 4.62" />
                <geom type="mesh" contype="0" conaffinity="0" group="1" rgba="0.84706 0.84706 0.84706 1" mesh="Link_2" />
                <geom type="mesh" rgba="0.84706 0.84706 0.84706 1" mesh="Link_2" />
                <body name="Link_3" pos="0.36 0 0">
                    <inertial pos="0.15515 5.4643e-08 -0.012576" quat="0.517406 0.481957 0.481946 0.517433" mass="16.562" diaginertia="0.28365 0.279787 0.0196608" />
                    <joint name="joint_3" pos="0 0 0" axis="0 0 1" limited="true" range="-3.05 3.05" />
                    <geom type="mesh" contype="0" conaffinity="0" group="1" rgba="0.84706 0.84706 0.84706 1" mesh="Link_3" />
                    <geom type="mesh" rgba="0.84706 0.84706 0.84706 1" mesh="Link_3" />
                    <body name="Link_4" pos="0.30353 0 -0.11501">
                        <inertial pos="-2.1345e-06 -0.0058004 0.0026717" quat="0.699182 0.714944 2.86648e-05 -8.42093e-06" mass="5.5525" diaginertia="0.0092564 0.00897016 0.00522324" />
                        <joint name="joint_4" pos="0 0 0" axis="0 0 1" limited="true" range="-1.48 4.62" />
                        <geom type="mesh" contype="0" conaffinity="0" group="1" rgba="0.84706 0.84706 0.84706 1" mesh="Link_4" />
                        <geom type="mesh" rgba="0.84706 0.84706 0.84706 1" mesh="Link_4" />
                        <body name="Link_5" pos="0 -0.1135 0" quat="0.707105 0.707108 0 0">
                            <inertial pos="-2.0304e-06 -0.0028889 -0.0023424" quat="0.709446 0.70476 -1.15346e-05 9.23912e-07" mass="6.3339" diaginertia="0.012993 0.0127003 0.0058451" />
                            <joint name="joint_5" pos="0 0 0" axis="0 0 1" limited="true" range="-6.28 6.28" />
                            <geom type="mesh" contype="0" conaffinity="0" group="1" rgba="0.84706 0.84706 0.84706 1" mesh="Link_5" />
                            <geom type="mesh" rgba="0.84706 0.84706 0.84706 1" mesh="Link_5" />
                            <body name="Link_6" pos="0 0.107 0" quat="0.707105 -0.707108 0 0">
                                <inertial pos="2.7652e-05 -1.3485e-05 -0.021245" quat="-0.0453216 0.705107 0.0468242 0.7061" mass="1.4169" diaginertia="0.0011337 0.00072384 0.000718438" />
                                <joint name="joint_6" pos="0 0 0" axis="0 0 1" limited="true" range="-6.28 6.28" />
                                <geom type="mesh" contype="0" conaffinity="0" group="1" rgba="0.84706 0.84706 0.84706 1" mesh="Link_6" />
                                <geom type="mesh" rgba="0.84706 0.84706 0.84706 1" mesh="Link_6" />
                            </body>
                        </body>
                    </body>
                </body>
            </body>
        </body>
    </worldbody>
</mujoco>
  1. 首先把 compiler, size 这两行去掉,没用了,然后把 asset 中的 file 修改下路径即可;

  2. 增加代码

    <actuator> <motor ctrllimited="true" ctrlrange="-150.0 150.0" joint="joint_1" name="torq_j1"/> <motor ctrllimited="true" ctrlrange="-150.0 150.0" joint="joint_2" name="torq_j2"/> <motor ctrllimited="true" ctrlrange="-150.0 150.0" joint="joint_3" name="torq_j3"/> <motor ctrllimited="true" ctrlrange="-28.0 28.0" joint="joint_4" name="torq_j4"/> <motor ctrllimited="true" ctrlrange="-28.0 28.0" joint="joint_5" name="torq_j5"/> <motor ctrllimited="true" ctrlrange="-28.0 28.0" joint="joint_6" name="torq_j6"/> </actuator>
  3. link_6 后面加上 right_hand

    <body name="Link_6" pos="0 0.107 0" quat="0.707105 -0.707108 0 0"> <inertial pos="2.7652e-05 -1.3485e-05 -0.021245" quat="-0.0453216 0.705107 0.0468242 0.7061" mass="1.4169" diaginertia="0.0011337 0.00072384 0.000718438" /> <joint name="joint_6" pos="0 0 0" axis="0 0 1" limited="true" range="-6.28 6.28" /> <geom type="mesh" contype="0" conaffinity="0" group="1" rgba="0.84706 0.84706 0.84706 1" mesh="Link_6" /> <geom type="mesh" rgba="0.84706 0.84706 0.84706 1" mesh="Link_6" /> <body name="right_hand" pos="0 0.098 0" quat="0.707 -0.707 0 0" > <camera mode="fixed" name="eye_in_hand" pos="0.05 0 0" quat="0 0.707108 0.707108 0" fovy="75"/> </body> </body>

截止到此,该机器人配置文件可用了。

机器人构建

从原有机器人中,随便找个机器人的 py 文件,复制一份,然后该个名字,并在 init 中注册以下就可以了

相关推荐
Py小趴4 分钟前
Python自学之Colormaps指南
开发语言·python·数据可视化
华清远见成都中心8 分钟前
物联网学习路线来啦!
物联网·学习
晒足以百八十9 分钟前
基于Python 和 pyecharts 制作招聘数据可视化分析大屏
开发语言·python·信息可视化
hgy896916 分钟前
Ekman理论回归
学习
Watermelo61723 分钟前
通过MongoDB Atlas 实现语义搜索与 RAG——迈向AI的搜索机制
人工智能·深度学习·神经网络·mongodb·机器学习·自然语言处理·数据挖掘
敲代码不忘补水29 分钟前
生成式GPT商品推荐:精准满足用户需求
开发语言·python·gpt·产品运营·产品经理
坚硬果壳_34 分钟前
《硬件架构的艺术》笔记(一):亚稳态
笔记·学习
孤客网络科技工作室34 分钟前
Python Plotly 库使用教程
python·信息可视化·plotly
悟解了34 分钟前
《数据可视化技术》上机报告
python·信息可视化·数据分析
AI算法-图哥35 分钟前
pytorch量化训练
人工智能·pytorch·深度学习·文生图·模型压缩·量化