siemens / ros-sharp

ROS# is a set of open source software libraries and tools in C# for communicating with ROS from .NET applications, in particular Unity3D
Apache License 2.0
987 stars 373 forks source link

Cannnot generate hinge joint #465

Closed hijimasa closed 3 weeks ago

hijimasa commented 3 weeks ago

Here is my bug description: Hinge Joint is not generated when importing below URDF.

<?xml version="1.0" ?>
<!-- =================================================================================== -->
<!-- |    This document was autogenerated by xacro from /home/hijikata/colcon_ws/install/diffbot_description/share/diffbot_description/robots/diffbot.urdf.xacro | -->
<!-- |    EDITING THIS FILE BY HAND IS NOT RECOMMENDED                                 | -->
<!-- =================================================================================== -->
<!-- Basic differential drive mobile base -->
<robot name="diffbot">
  <material name="gray">
    <color rgba="0.5 0.5 0.5 0.2"/>
  </material>
  <material name="ball">
    <color rgba="0.5 0.5 0.5 0.2"/>
  </material>
  <material name="white">
    <color rgba="1.0 1.0 1.0 1.0"/>
  </material>
  <link name="base_link"/>
  <joint name="body_joint" type="fixed">
    <parent link="base_link"/>
    <child link="body_link"/>
    <origin rpy="0 0 0" xyz="-0.07 0 0.07"/>
  </joint>
  <link name="body_link">
    <inertial>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <mass value="1.0"/>
      <inertia ixx="0.001" ixy="0.0" ixz="0.0" iyy="0.001" iyz="0.0" izz="0.001"/>
    </inertial>
    <visual>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <geometry>
        <box size="0.24 0.18 0.06"/>
      </geometry>
      <material name="gray"/>
    </visual>
    <collision>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <geometry>
        <box size="0.24 0.178 0.06"/>
      </geometry>
    </collision>
  </link>
  <joint name="left_wheel_joint" type="continuous">
    <origin rpy="-1.5707963267948966 0 0" xyz="0 0.1 0.05"/>
    <parent link="base_link"/>
    <child link="left_wheel_link"/>
    <axis xyz="0 0 1"/>
  </joint>
  <link name="left_wheel_link">
    <inertial>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <mass value="0.1"/>
      <inertia ixx="0.0001" ixy="0.0" ixz="0.0" iyy="0.0001" iyz="0.0" izz="0.0001"/>
    </inertial>
    <visual>
      <geometry>
        <cylinder length="0.02" radius="0.05"/>
      </geometry>
      <material name="gray"/>
    </visual>
    <collision>
      <geometry>
        <cylinder length="0.02" radius="0.05"/>
      </geometry>
    </collision>
  </link>
  <joint name="right_wheel_joint" type="continuous">
    <origin rpy="-1.5707963267948966 0 0" xyz="0 -0.1 0.05"/>
    <parent link="base_link"/>
    <child link="right_wheel_link"/>
    <axis xyz="0 0 1"/>
  </joint>
  <link name="right_wheel_link">
    <inertial>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <mass value="0.1"/>
      <inertia ixx="0.0001" ixy="0.0" ixz="0.0" iyy="0.0001" iyz="0.0" izz="0.0001"/>
    </inertial>
    <visual>
      <geometry>
        <cylinder length="0.02" radius="0.05"/>
      </geometry>
      <material name="gray"/>
    </visual>
    <collision>
      <geometry>
        <cylinder length="0.02" radius="0.05"/>
      </geometry>
    </collision>
  </link>
  <joint name="ball_joint" type="fixed">
    <parent link="base_link"/>
    <child link="ball_link"/>
    <origin rpy="0 0 0" xyz="-0.14 0 0.04"/>
  </joint>
  <link name="ball_link">
    <visual>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <geometry>
        <sphere radius="0.04"/>
      </geometry>
      <material name="ball"/>
    </visual>
    <collision>
      <origin rpy="0 0 0" xyz="0 0 0"/>
      <geometry>
        <sphere radius="0.04"/>
      </geometry>
    </collision>
  </link>
  <joint name="lidar_joint" type="fixed">
    <parent link="base_link"/>
    <child link="lidar_link"/>
    <origin rpy="0 0 0" xyz="0 0 0.2"/>
  </joint>
  <link name="lidar_link">
    <!-- If visual tag is enable, lidar's ray is blocked. -->
    <!--
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <cylinder radius="0.03" length="0.08" />
      </geometry>
      <material name="white" />
    </visual>
    -->
  </link>
  <joint name="camera_joint" type="fixed">
    <parent link="base_link"/>
    <child link="camera_link"/>
    <origin rpy="0 0 0" xyz="0.05 -0.1 0.1"/>
  </joint>
  <link name="camera_link">
    <!-- If visual tag is enable, camera's view is blocked. -->
    <!--
    <visual>
      <origin xyz="0 0 0" rpy="0 -1.57 0" />
      <geometry>
        <cylinder radius="0.01" length="0.01" />
      </geometry>
      <material name="white" />
    </visual>
    -->
  </link>
  <joint name="depth_camera_joint" type="fixed">
    <parent link="base_link"/>
    <child link="depth_camera_link"/>
    <origin rpy="0 0 0" xyz="0.05 0.1 0.1"/>
  </joint>
  <link name="depth_camera_link">
    <!-- If visual tag is enable, camera's view is blocked. -->
    <!--
    <visual>
      <origin xyz="0 0 0" rpy="0 -1.57 0" />
      <geometry>
        <cylinder radius="0.01" length="0.01" />
      </geometry>
      <material name="white" />
    </visual>
    -->
  </link>
  <ros2_control name="diffbot" type="system">
    <hardware>
      <plugin>topic_based_ros2_control/TopicBasedSystem</plugin>
      <param name="joint_commands_topic">/diffbot/joint_command</param>
      <param name="joint_states_topic">/diffbot/joint_states</param>
      <param name="sum_wrapped_joint_states">true</param>
    </hardware>
    <joint name="left_wheel_joint">
      <command_interface name="velocity">
        <param name="min">-1</param>
        <param name="max">1</param>
      </command_interface>
      <state_interface name="position"/>
      <state_interface name="velocity"/>
      <state_interface name="effort"/>
    </joint>
    <joint name="right_wheel_joint">
      <command_interface name="velocity">
        <param name="min">-1</param>
        <param name="max">1</param>
      </command_interface>
      <state_interface name="position"/>
      <state_interface name="velocity"/>
      <state_interface name="effort"/>
    </joint>
  </ros2_control>
</robot>

Perform the following steps reproduce the bug:

  1. Import URDF
  2. Check base_link and body_link

Observed results: The screenshot is below. Screenshot from 2024-11-04 13-18-23

Expected results: Hinge Joint is generated as in R2D2.

hijimasa commented 3 weeks ago

The reason was that the base_link did not have inertia and the Rigid Body was not generated.