Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading non-fixed joint without inertial child throws "MissingComponentException" #217

Open
joaomacp opened this issue Jul 5, 2023 · 0 comments

Comments

@joaomacp
Copy link

joaomacp commented Jul 5, 2023

Describe the bug
When loading a Revolute or Prismatic joint where the child link is missing <inertial> tags, a MissingComponentException exception is thrown.

To Reproduce
Steps to reproduce the behavior:

  1. Load the example URDF below using URDF-Importer
  2. The program crashes and a MissingComponentException is thrown: There is no 'ArticulationBody' attached to the "linkB" game object, but a script is trying to access it.
  3. Uncommenting the <inertial> block loads the URDF correctly.

Console logs / stack traces

UnityEngine.MissingComponentException: There is no 'ArticulationBody' attached to the "linkB" game object, but a script is trying to access it.
You probably need to add a ArticulationBody to the game object "linkB". Or your script needs to check if the component is attached before using it.
  at (wrapper managed-to-native) UnityEngine.ArticulationBody.set_jointType(UnityEngine.ArticulationBody,UnityEngine.ArticulationJointType)
  at Unity.Robotics.UrdfImporter.UrdfJointRevolute.Create (UnityEngine.GameObject linkObject) [0x00012] in Library/PackageCache/com.unity.robotics.urdf-importer@9956ce5368/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevolute.cs:28 
  at Unity.Robotics.UrdfImporter.UrdfJoint.AddCorrectJointType (UnityEngine.GameObject linkObject, Unity.Robotics.UrdfImporter.UrdfJoint+JointTypes jointType) [0x00034] in /Library/PackageCache/com.unity.robotics.urdf-importer@9956ce5368/Runtime/UrdfComponents/UrdfJoints/UrdfJoint.cs:113 
  at Unity.Robotics.UrdfImporter.UrdfJoint.Create (UnityEngine.GameObject linkObject, Unity.Robotics.UrdfImporter.UrdfJoint+JointTypes jointType, Unity.Robotics.UrdfImporter.Joint joint) [0x00000] in /Library/PackageCache/com.unity.robotics.urdf-importer@9956ce5368/Runtime/UrdfComponents/UrdfJoints/UrdfJoint.cs:89 
  at Unity.Robotics.UrdfImporter.UrdfLinkExtensions.ImportLinkData (Unity.Robotics.UrdfImporter.UrdfLink urdfLink, Unity.Robotics.UrdfImporter.Link link, Unity.Robotics.UrdfImporter.Joint joint) [0x0007a] in /Library/PackageCache/com.unity.robotics.urdf-importer@9956ce5368/Runtime/Extensions/UrdfLinkExtensions.cs:62 
  at Unity.Robotics.UrdfImporter.UrdfLinkExtensions.Create (UnityEngine.Transform parent, Unity.Robotics.UrdfImporter.Link link, Unity.Robotics.UrdfImporter.Joint joint) [0x00051] in Library/PackageCache/com.unity.robotics.urdf-importer@9956ce5368/Runtime/Extensions/UrdfLinkExtensions.cs:31 
  at Unity.Robotics.UrdfImporter.UrdfRobotExtensions.ProcessJointStack (Unity.Robotics.UrdfImporter.UrdfRobotExtensions+ImportPipelineData im) [0x00056] in Library/PackageCache/com.unity.robotics.urdf-importer@9956ce5368/Runtime/Extensions/UrdfRobotExtensions.cs:132 
  at Unity.Robotics.UrdfImporter.UrdfRobotExtensions.CreateRuntime (System.String filename, Unity.Robotics.UrdfImporter.ImportSettings settings) [0x00015] in Library/PackageCache/com.unity.robotics.urdf-importer@9956ce5368/Runtime/Extensions/UrdfRobotExtensions.cs:215

Expected behavior
IMO the program shouldn't crash. The joint could be ignored and not added to the structure, and thus not
controllable, since it misses <inertial> info for correct simulation. A warning about this should be logged.

The reason to not crash is that there are URDFs with joints that don't
need to be controlled directly: some parallel grippers contain joints
whose purpose is to be mimicked by other, physical joints. The
controlling joint doesn't need <inertial> info, only the mimic one.

This behaviour is similar to Gazebo, which also ignores links
without inertial info.

Environment:

  • Unity Version: [e.g. Unity 2021.3.24f1]
  • Unity machine OS + version: [e.g. Ubuntu 22.04]
  • Branch or version: [e.g. URDF-Importer v0.5.2]

Example URDF

<robot name = "example">
        <link name = "base_link">
		<inertial>
			<origin xyz = "0 0 0" />
			<mass value = "0.5" />
			<inertia ixx = "0.5" iyy = "0.5" izz = "0.5" ixy = "0" ixz = "0" iyz = "0" />
		</inertial>
		<visual>
			<origin xyz = "0 0 0" />
			<geometry>
				<box size = "0.5 0.5 0.1" />
			</geometry>
			<material name = "gray A">
				<color rgba = "0.1 0.1 0.1 1" />
			</material>
		</visual>
	</link>
	<link name = "linkA">
		<inertial>
			<origin xyz = "0 0 0" />
			<mass value = "0.5" />
			<inertia ixx = "0.5" iyy = "0.5" izz = "0.5" ixy = "0" ixz = "0" iyz = "0" />
		</inertial>
		<visual>
			<origin xyz = "0 0 0" />
			<geometry>
				<box size = "0.5 0.5 0.1" />
			</geometry>
			<material name = "gray A">
				<color rgba = "0.1 0.1 0.1 1" />
			</material>
		</visual>
	</link>
	<link name = "linkB">
		<!-- Uncomment to add inertial info: this fixes the URDF-Importer exception -->
		<!--
		<inertial>
			<origin xyz = "0 0 -0.5" />
			<mass value = "0.5" />
			<inertia ixx = "0.5" iyy = "0.5" izz = "0.5" ixy = "0" ixz = "0" iyz = "0" />
		</inertial>
		-->
		<visual>
			<origin xyz = "0 0 -0.5" />
			<geometry>
				<cylinder radius = "0.05" length = "1"  />
			</geometry>
			<material name = "gray B">
				<color rgba = "0.3 0.3 0.3 1" />
			</material>
		</visual>
	</link>
       <joint name = "base_joint" type = "fixed">
		<parent link = "base_link" />
		<child link = "linkA" />
		<origin xyz = "0 0 -0.05" />
	</joint>
	<joint name = "joint AB" type = "revolute">
		<parent link = "linkA" />
		<child link = "linkB" />
		<origin xyz = "0 0 -0.05" />
		<axis xyz = "0 1 0" />
	</joint>
</robot>
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

No branches or pull requests

1 participant