From e9859c4becda48194e153356afc0a802516b1488 Mon Sep 17 00:00:00 2001 From: peifeng-unity <56408141+peifeng-unity@users.noreply.github.com> Date: Thu, 15 Jul 2021 17:20:54 -0700 Subject: [PATCH] Merge v0.5.0 (#131) --- .yamato/yamato-config.yml | 2 +- README.md | 6 +- .../Assets/Settings/ForwardRenderer.asset | 12 +- TestUrdfImporter/Assets/Test URDF export.meta | 8 + .../Assets/fetch_description.meta | 8 + .../Assets/fetch_description/robots.meta | 8 + .../franka_panda_description-master.meta | 8 + TestUrdfImporter/Assets/turtlebot3.meta | 8 + .../turtlebot3/turtlebot3_description.meta | 8 + TestUrdfImporter/Assets/ur3_with_gripper.meta | 8 + .../ur3_with_gripper/ur_description.meta | 8 + .../ur_description/meshes.meta | 8 + TestUrdfImporter/Assets/urdf.meta | 8 + TestUrdfImporter/Packages/manifest.json | 14 +- TestUrdfImporter/Packages/packages-lock.json | 43 +- .../ProjectSettings/ProjectVersion.txt | 4 +- .../ProjectSettings/URPProjectSettings.asset | 2 +- Third Party Notices.md | 45 +- com.unity.robotics.urdf-importer/CHANGELOG.md | 33 +- .../HingeJointLimitsManagerEditor.cs | 2 +- .../CustomEditors/UrdfCollisionEditor.cs | 2 +- .../CustomEditors/UrdfCollisionsEditor.cs | 2 +- .../Editor/CustomEditors/UrdfFkrobotEditor.cs | 4 +- .../CustomEditors/UrdfInertialEditor.cs | 2 +- .../Editor/CustomEditors/UrdfJointEditor.cs | 2 +- .../Editor/CustomEditors/UrdfLinkEditor.cs | 2 +- .../Editor/CustomEditors/UrdfPluginsEditor.cs | 2 +- .../Editor/CustomEditors/UrdfRobotEditor.cs | 12 +- .../Editor/CustomEditors/UrdfVisualEditor.cs | 2 +- .../Editor/CustomEditors/UrdfVisualsEditor.cs | 2 +- .../Editor/MenuItems/AddDhParameterWindow.cs | 4 +- .../{CompareURDF.cs => CompareUrdf.cs} | 4 +- ...ompareURDF.cs.meta => CompareUrdf.cs.meta} | 0 .../Editor/MenuItems/FileImportMenu.cs | 5 +- .../MenuItems/UrdfExportEditorWindow.cs | 2 +- .../MenuItems/UrdfImporterContextMenuItem.cs | 2 +- .../Editor/MenuItems/UrdfImporterMenuItem.cs | 2 +- .../MenuItems/UrdfRobotCreatorMenuItem.cs | 2 +- .../Unity.Robotics.URDFImporter.Editor.asmdef | 4 +- .../AssetHandlers/LocateAssetHandler.cs | 27 +- .../AssetHandlers/UrdfAssetPathHandler.cs | 16 +- .../AssetHandlers/UrdfExportPathHandler.cs | 2 +- .../AssetHandlers/UrdfMeshExportHandler.cs | 25 +- .../Runtime/Controller/Controller.cs | 2 +- .../Runtime/Controller/FKRobot.cs | 38 +- .../Runtime/Controller/IKRobot.cs | 9 +- .../Runtime/Controller/JointControl.cs | 12 +- .../Runtime/Extensions/BuiltInExtensions.cs | 2 +- .../Extensions/UrdfCollisionExtensions.cs | 2 +- .../Extensions/UrdfCollisionsExtensions.cs | 2 +- .../Runtime/Extensions/UrdfGeometry.cs | 2 +- .../Extensions/UrdfGeometryCollision.cs | 26 +- .../Runtime/Extensions/UrdfGeometryVisual.cs | 6 +- .../Runtime/Extensions/UrdfLinkExtensions.cs | 2 +- .../Runtime/Extensions/UrdfMaterial.cs | 20 +- .../Runtime/Extensions/UrdfRobotExtensions.cs | 64 ++- .../Extensions/UrdfVisualExtensions.cs | 2 +- .../Extensions/UrdfVisualsExtensions.cs | 2 +- .../HingeJointLimitsManager.cs | 4 +- .../PrismaticJointLimitsManager.cs | 4 +- .../Runtime/Math/Matrix3x3.cs | 2 +- .../ColladaAssetPostProcessor.cs | 4 +- .../MeshProcessing/StlAssetPostProcessor.cs | 73 ++-- .../Runtime/MeshProcessing/StlExporter.cs | 2 +- .../Runtime/MeshProcessing/StlImporter.cs | 2 +- .../Runtime/MeshProcessing/StlReader.cs | 2 +- .../Runtime/MeshProcessing/StlWriter.cs | 2 +- .../Runtime/RosSharpDefinitions/Joint.cs | 2 +- .../Runtime/RosSharpDefinitions/Link.cs | 2 +- .../Runtime/RosSharpDefinitions/Origin.cs | 2 +- .../Runtime/RosSharpDefinitions/Plugin.cs | 2 +- .../Runtime/RosSharpDefinitions/Robot.cs | 2 +- .../XAttributeExtensions.cs | 2 +- .../{RuntimeURDF.cs => RuntimeUrdf.cs} | 20 +- ...untimeURDF.cs.meta => RuntimeUrdf.cs.meta} | 0 ...orter.cs => RuntimeUrdfImporterExample.cs} | 26 +- ...eta => RuntimeUrdfImporterExample.cs.meta} | 0 .../Unity.Robotics.URDFImporter.asmdef | 4 +- .../Native/win/x86_64/assimp.dll.meta | 11 + .../Runtime/UrdfComponents/CollisionIgnore.cs | 2 +- .../Runtime/UrdfComponents/ImportSettings.cs | 4 +- .../Runtime/UrdfComponents/UrdfCollision.cs | 2 +- .../Runtime/UrdfComponents/UrdfCollisions.cs | 2 +- .../Runtime/UrdfComponents/UrdfComparator.cs | 2 +- .../Runtime/UrdfComponents/UrdfInertial.cs | 2 +- .../UrdfComponents/UrdfJoints/UrdfJoint.cs | 2 +- .../UrdfJoints/UrdfJointContinuous.cs | 2 +- .../UrdfJoints/UrdfJointFixed.cs | 2 +- .../UrdfJoints/UrdfJointFloating.cs | 2 +- .../UrdfJoints/UrdfJointPlanar.cs | 2 +- .../UrdfJoints/UrdfJointPrismatic.cs | 2 +- .../UrdfJoints/UrdfJointRevolute.cs | 2 +- .../Runtime/UrdfComponents/UrdfLink.cs | 2 +- .../Runtime/UrdfComponents/UrdfOrigin.cs | 2 +- .../Runtime/UrdfComponents/UrdfPlugin.cs | 2 +- .../Runtime/UrdfComponents/UrdfPlugins.cs | 2 +- .../Runtime/UrdfComponents/UrdfRobot.cs | 16 +- .../Runtime/UrdfComponents/UrdfVisual.cs | 2 +- .../Runtime/UrdfComponents/UrdfVisuals.cs | 2 +- ....Robotics.URDFImporter.Editor.Tests.asmdef | 5 +- .../UrdfAssetPathHandlerTests.cs | 28 +- .../Extensions/BuiltInExtensionsTests.cs | 2 +- .../UrdfCollisionExtensionsTests.cs | 22 +- .../UrdfCollisionsExtensionsTests.cs | 10 +- .../Extensions/UrdfGeometryCollisionTests.cs | 37 +- .../Runtime/Extensions/UrdfGeometryTests.cs | 22 +- .../Tests/Runtime/Math/Matrix3x3Tests.cs | 166 ++++---- .../Tests/Runtime/MeshProcessing.meta | 8 + .../StlAssetPostProcessorTests.cs | 51 +++ .../StlAssetPostProcessorTests.cs.meta | 11 + .../Runtime/RuntimeImport/RuntimeURDFTests.cs | 156 ------- .../Runtime/RuntimeImport/RuntimeUrdfTests.cs | 179 ++++++++ ...Tests.cs.meta => RuntimeUrdfTests.cs.meta} | 0 ...Robotics.UrdfImporter.Runtime.Tests.asmdef | 2 +- .../UrdfJoints/UrdfJointContinuousTests.cs | 257 ++++++------ .../UrdfJoints/UrdfJointPlanarTests.cs | 326 +++++++-------- .../UrdfJoints/UrdfJointPrismaticTests.cs | 326 +++++++-------- .../UrdfJoints/UrdfJointRevoluteTests.cs | 328 +++++++-------- .../UrdfJoints/UrdfJointTests.cs | 386 +++++++++--------- .../Tests/Runtime/VHACD/VHACDTests.cs | 2 +- com.unity.robotics.urdf-importer/package.json | 2 +- 121 files changed, 1760 insertions(+), 1351 deletions(-) create mode 100644 TestUrdfImporter/Assets/Test URDF export.meta create mode 100644 TestUrdfImporter/Assets/fetch_description.meta create mode 100644 TestUrdfImporter/Assets/fetch_description/robots.meta create mode 100644 TestUrdfImporter/Assets/franka_panda_description-master.meta create mode 100644 TestUrdfImporter/Assets/turtlebot3.meta create mode 100644 TestUrdfImporter/Assets/turtlebot3/turtlebot3_description.meta create mode 100644 TestUrdfImporter/Assets/ur3_with_gripper.meta create mode 100644 TestUrdfImporter/Assets/ur3_with_gripper/ur_description.meta create mode 100644 TestUrdfImporter/Assets/ur3_with_gripper/ur_description/meshes.meta create mode 100644 TestUrdfImporter/Assets/urdf.meta rename com.unity.robotics.urdf-importer/Editor/MenuItems/{CompareURDF.cs => CompareUrdf.cs} (98%) rename com.unity.robotics.urdf-importer/Editor/MenuItems/{CompareURDF.cs.meta => CompareUrdf.cs.meta} (100%) rename com.unity.robotics.urdf-importer/Runtime/RuntimeImport/{RuntimeURDF.cs => RuntimeUrdf.cs} (89%) rename com.unity.robotics.urdf-importer/Runtime/RuntimeImport/{RuntimeURDF.cs.meta => RuntimeUrdf.cs.meta} (100%) rename com.unity.robotics.urdf-importer/Runtime/RuntimeImport/{RuntimeURDFImporter.cs => RuntimeUrdfImporterExample.cs} (79%) rename com.unity.robotics.urdf-importer/Runtime/RuntimeImport/{RuntimeURDFImporter.cs.meta => RuntimeUrdfImporterExample.cs.meta} (100%) create mode 100644 com.unity.robotics.urdf-importer/Tests/Runtime/MeshProcessing.meta create mode 100644 com.unity.robotics.urdf-importer/Tests/Runtime/MeshProcessing/StlAssetPostProcessorTests.cs create mode 100644 com.unity.robotics.urdf-importer/Tests/Runtime/MeshProcessing/StlAssetPostProcessorTests.cs.meta delete mode 100644 com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeURDFTests.cs create mode 100644 com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeUrdfTests.cs rename com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/{RuntimeURDFTests.cs.meta => RuntimeUrdfTests.cs.meta} (100%) diff --git a/.yamato/yamato-config.yml b/.yamato/yamato-config.yml index ad2a89c7..cbb6fcb7 100644 --- a/.yamato/yamato-config.yml +++ b/.yamato/yamato-config.yml @@ -8,7 +8,7 @@ variables: commands: - git submodule update --init --recursive - python3 -m pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade - - unity-downloader-cli -u 2020.2.0b9 -c editor -c StandaloneSupport-IL2CPP -c Linux --wait --published + - unity-downloader-cli -u 2020.3.11f1 -c editor -c StandaloneSupport-IL2CPP -c Linux --wait --published - git clone git@github.cds.internal.unity3d.com:unity/utr.git utr - utr/utr --testproject=./TestUrdfImporter --editor-location=.Editor --reruncount=0 --artifacts_path=test-results --suite=playmode --suite=editor --platform=Editor --enable-code-coverage --coverage-results-path=../test-results --coverage-options="assemblyFilters:+Unity.Robotics.URDFImporter,+Unity.Robotics.URDFImporter.Editor;generateHtmlReport;generateBadgeReport;generateAdditionalMetrics" # check test coverage diff --git a/README.md b/README.md index 3c973fdc..795228ac 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # URDF Importer -[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) +[![Version](https://img.shields.io/github/v/tag/Unity-Technologies/URDF-Importer)](https://github.com/Unity-Technologies/URDF-Importer/releases) +[![License](https://img.shields.io/badge/license-Apache--2.0-green.svg)](LICENSE.md) +![Unity](https://img.shields.io/badge/unity-2020.2+-brightgreen) URDF Importer allows you to import a robot defined in [URDF](http://wiki.ros.org/urdf/XML) format in a Unity scene. URDF defines the geometry, visual meshes, kinematic and dynamic attributes of a Robot. Importer parses a URDF file and imports it into Unity using PhyX 4.0 articulation bodies. @@ -14,7 +16,7 @@ URDF Importer allows you to import a robot defined in [URDF](http://wiki.ros.org -3. Enter the git URL for the URDF Importer with the latest version tag (currently v0.4.0) `https://github.com/Unity-Technologies/URDF-Importer.git?path=/com.unity.robotics.urdf-importer#v0.4.0` in the text box and press `Enter`. +3. Enter the git URL for the URDF Importer with the latest version tag (currently v0.5.0) `https://github.com/Unity-Technologies/URDF-Importer.git?path=/com.unity.robotics.urdf-importer#v0.5.0` in the text box and press `Enter`. 4. Click `Import URDF`. diff --git a/TestUrdfImporter/Assets/Settings/ForwardRenderer.asset b/TestUrdfImporter/Assets/Settings/ForwardRenderer.asset index 4514a2b8..b9a801ce 100644 --- a/TestUrdfImporter/Assets/Settings/ForwardRenderer.asset +++ b/TestUrdfImporter/Assets/Settings/ForwardRenderer.asset @@ -13,14 +13,19 @@ MonoBehaviour: m_Name: ForwardRenderer m_EditorClassIdentifier: m_RendererFeatures: [] + m_RendererFeatureMap: postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2} + xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2} shaders: blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3} copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3} - screenSpaceShadowPS: {fileID: 4800000, guid: 0f854b35a0cf61a429bd5dcfea30eddd, - type: 3} + screenSpaceShadowPS: {fileID: 4800000, guid: 0f854b35a0cf61a429bd5dcfea30eddd, type: 3} samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3} + tileDepthInfoPS: {fileID: 0} + tileDeferredPS: {fileID: 0} + stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3} fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3} + materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3} m_OpaqueLayerMask: serializedVersion: 2 m_Bits: 4294967295 @@ -34,3 +39,6 @@ MonoBehaviour: passOperation: 0 failOperation: 0 zFailOperation: 0 + m_ShadowTransparentReceive: 1 + m_RenderingMode: 0 + m_AccurateGbufferNormals: 0 diff --git a/TestUrdfImporter/Assets/Test URDF export.meta b/TestUrdfImporter/Assets/Test URDF export.meta new file mode 100644 index 00000000..4caf8445 --- /dev/null +++ b/TestUrdfImporter/Assets/Test URDF export.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a51b350ae06a149eb9ae6de042800922 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestUrdfImporter/Assets/fetch_description.meta b/TestUrdfImporter/Assets/fetch_description.meta new file mode 100644 index 00000000..f4e7802c --- /dev/null +++ b/TestUrdfImporter/Assets/fetch_description.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ad7aef710df90482aad37204e6ec99c8 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestUrdfImporter/Assets/fetch_description/robots.meta b/TestUrdfImporter/Assets/fetch_description/robots.meta new file mode 100644 index 00000000..051a3cc4 --- /dev/null +++ b/TestUrdfImporter/Assets/fetch_description/robots.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0a8089b559f304f789bc56276704d0d0 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestUrdfImporter/Assets/franka_panda_description-master.meta b/TestUrdfImporter/Assets/franka_panda_description-master.meta new file mode 100644 index 00000000..7d637b9c --- /dev/null +++ b/TestUrdfImporter/Assets/franka_panda_description-master.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b9cc269490bde4ac38f6ab7595edee29 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestUrdfImporter/Assets/turtlebot3.meta b/TestUrdfImporter/Assets/turtlebot3.meta new file mode 100644 index 00000000..bd415ad4 --- /dev/null +++ b/TestUrdfImporter/Assets/turtlebot3.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: feed3a2414df041568e19c941b769a20 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestUrdfImporter/Assets/turtlebot3/turtlebot3_description.meta b/TestUrdfImporter/Assets/turtlebot3/turtlebot3_description.meta new file mode 100644 index 00000000..b0fe64a8 --- /dev/null +++ b/TestUrdfImporter/Assets/turtlebot3/turtlebot3_description.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a6212a5f530ae49c0ba44ebff2a0a9f7 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestUrdfImporter/Assets/ur3_with_gripper.meta b/TestUrdfImporter/Assets/ur3_with_gripper.meta new file mode 100644 index 00000000..f717caae --- /dev/null +++ b/TestUrdfImporter/Assets/ur3_with_gripper.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bdd20656863574499a2f5243015e2a9b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestUrdfImporter/Assets/ur3_with_gripper/ur_description.meta b/TestUrdfImporter/Assets/ur3_with_gripper/ur_description.meta new file mode 100644 index 00000000..9c5d88c9 --- /dev/null +++ b/TestUrdfImporter/Assets/ur3_with_gripper/ur_description.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 074f158bd1506474f8e2883808b74d50 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestUrdfImporter/Assets/ur3_with_gripper/ur_description/meshes.meta b/TestUrdfImporter/Assets/ur3_with_gripper/ur_description/meshes.meta new file mode 100644 index 00000000..c0b16083 --- /dev/null +++ b/TestUrdfImporter/Assets/ur3_with_gripper/ur_description/meshes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 430a18699e46549d8b16905ad991de8a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestUrdfImporter/Assets/urdf.meta b/TestUrdfImporter/Assets/urdf.meta new file mode 100644 index 00000000..f26ce948 --- /dev/null +++ b/TestUrdfImporter/Assets/urdf.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 28ebdaa059f274e3591ee47d45db65f4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/TestUrdfImporter/Packages/manifest.json b/TestUrdfImporter/Packages/manifest.json index 992f3529..753d7a50 100644 --- a/TestUrdfImporter/Packages/manifest.json +++ b/TestUrdfImporter/Packages/manifest.json @@ -1,15 +1,15 @@ { "dependencies": { - "com.unity.collab-proxy": "1.3.9", + "com.unity.collab-proxy": "1.5.7", "com.unity.ide.rider": "2.0.7", - "com.unity.ide.visualstudio": "2.0.3", - "com.unity.ide.vscode": "1.2.2", - "com.unity.render-pipelines.universal": "10.0.0-preview.26", + "com.unity.ide.visualstudio": "2.0.8", + "com.unity.ide.vscode": "1.2.3", + "com.unity.render-pipelines.universal": "10.5.0", "com.unity.robotics.urdf-importer": "file:../../com.unity.robotics.urdf-importer", - "com.unity.test-framework": "1.1.20", + "com.unity.test-framework": "1.1.24", "com.unity.testtools.codecoverage": "1.0.0", - "com.unity.textmeshpro": "3.0.1", - "com.unity.timeline": "1.4.3", + "com.unity.textmeshpro": "3.0.6", + "com.unity.timeline": "1.4.8", "com.unity.ugui": "1.0.0", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", diff --git a/TestUrdfImporter/Packages/packages-lock.json b/TestUrdfImporter/Packages/packages-lock.json index 5cf2e780..21a60d1a 100644 --- a/TestUrdfImporter/Packages/packages-lock.json +++ b/TestUrdfImporter/Packages/packages-lock.json @@ -1,10 +1,12 @@ { "dependencies": { "com.unity.collab-proxy": { - "version": "1.3.9", + "version": "1.5.7", "depth": 0, "source": "registry", - "dependencies": {}, + "dependencies": { + "com.unity.nuget.newtonsoft-json": "2.0.0" + }, "url": "https://packages.unity.com" }, "com.unity.editorcoroutines": { @@ -31,14 +33,16 @@ "url": "https://packages.unity.com" }, "com.unity.ide.visualstudio": { - "version": "2.0.3", + "version": "2.0.8", "depth": 0, "source": "registry", - "dependencies": {}, + "dependencies": { + "com.unity.test-framework": "1.1.9" + }, "url": "https://packages.unity.com" }, "com.unity.ide.vscode": { - "version": "1.2.2", + "version": "1.2.3", "depth": 0, "source": "registry", "dependencies": {}, @@ -51,8 +55,15 @@ "dependencies": {}, "url": "https://packages.unity.com" }, + "com.unity.nuget.newtonsoft-json": { + "version": "2.0.0", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, "com.unity.render-pipelines.core": { - "version": "10.0.0-preview.30", + "version": "10.5.0", "depth": 1, "source": "registry", "dependencies": { @@ -61,13 +72,13 @@ "url": "https://packages.unity.com" }, "com.unity.render-pipelines.universal": { - "version": "10.0.0-preview.26", + "version": "10.5.0", "depth": 0, "source": "registry", "dependencies": { "com.unity.mathematics": "1.1.0", - "com.unity.render-pipelines.core": "10.0.0-preview.30", - "com.unity.shadergraph": "10.0.0-preview.27" + "com.unity.render-pipelines.core": "10.5.0", + "com.unity.shadergraph": "10.5.0" }, "url": "https://packages.unity.com" }, @@ -80,7 +91,7 @@ } }, "com.unity.searcher": { - "version": "4.3.1", + "version": "4.3.2", "depth": 2, "source": "registry", "dependencies": {}, @@ -94,17 +105,17 @@ "url": "https://packages.unity.com" }, "com.unity.shadergraph": { - "version": "10.0.0-preview.27", + "version": "10.5.0", "depth": 1, "source": "registry", "dependencies": { - "com.unity.render-pipelines.core": "10.0.0-preview.30", - "com.unity.searcher": "4.3.1" + "com.unity.render-pipelines.core": "10.5.0", + "com.unity.searcher": "4.3.2" }, "url": "https://packages.unity.com" }, "com.unity.test-framework": { - "version": "1.1.20", + "version": "1.1.24", "depth": 0, "source": "registry", "dependencies": { @@ -125,7 +136,7 @@ "url": "https://packages.unity.com" }, "com.unity.textmeshpro": { - "version": "3.0.1", + "version": "3.0.6", "depth": 0, "source": "registry", "dependencies": { @@ -134,7 +145,7 @@ "url": "https://packages.unity.com" }, "com.unity.timeline": { - "version": "1.4.3", + "version": "1.4.8", "depth": 0, "source": "registry", "dependencies": { diff --git a/TestUrdfImporter/ProjectSettings/ProjectVersion.txt b/TestUrdfImporter/ProjectSettings/ProjectVersion.txt index ccec5356..e610e282 100644 --- a/TestUrdfImporter/ProjectSettings/ProjectVersion.txt +++ b/TestUrdfImporter/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2020.2.0b9 -m_EditorVersionWithRevision: 2020.2.0b9 (ef2968fa77ae) +m_EditorVersion: 2020.3.11f1 +m_EditorVersionWithRevision: 2020.3.11f1 (99c7afb366b3) diff --git a/TestUrdfImporter/ProjectSettings/URPProjectSettings.asset b/TestUrdfImporter/ProjectSettings/URPProjectSettings.asset index 91791f36..3077404f 100644 --- a/TestUrdfImporter/ProjectSettings/URPProjectSettings.asset +++ b/TestUrdfImporter/ProjectSettings/URPProjectSettings.asset @@ -12,4 +12,4 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 247994e1f5a72c2419c26a37e9334c01, type: 3} m_Name: m_EditorClassIdentifier: - m_LastMaterialVersion: 2 + m_LastMaterialVersion: 4 diff --git a/Third Party Notices.md b/Third Party Notices.md index 85cf8cdc..6ae1803d 100644 --- a/Third Party Notices.md +++ b/Third Party Notices.md @@ -1,16 +1,39 @@ -Component name: siemens/ros-sharp
-Copyright 2017-2020 Siemens AG
-Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+Component name: ROS# (siemens/ros-sharp) - http://www.apache.org/licenses/LICENSE-2.0
+License Type: Apache 2.0 -Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -
+Copyright 2017-2020 Siemens AG -Component name: jasonmeisel/v-hacd-unity
-Copyright 2017-2020 Jason Meisel
-Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
+``` +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at - http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0 -Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. \ No newline at end of file +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. +``` + +--- + +Component name: VHACD Unity (jasonmeisel/v-hacd-unity) + +License Type: Apache 2.0 + +Copyright 2017-2020 Jason Meisel + +``` +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. +``` \ No newline at end of file diff --git a/com.unity.robotics.urdf-importer/CHANGELOG.md b/com.unity.robotics.urdf-importer/CHANGELOG.md index 6933ec6d..be341237 100644 --- a/com.unity.robotics.urdf-importer/CHANGELOG.md +++ b/com.unity.robotics.urdf-importer/CHANGELOG.md @@ -20,6 +20,37 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ### Fixed +## [0.5.0-preview] - 2021-07-15 + +### Upgrade Notes +Update third party notices + +Upgrade namespace from RosSharp.Urdf to Unity.Robotics.UrdfImporter + +### Known Issues + +### Added +Adding badges to main README + +### Changed +STL files will not be automatically processed to create .prefab files when copied into the Assets directory or when assets are reimported. Instead the processing happens during the URDF import and required .prefab files will be created if they don't exist already or if the "Overwrite Existing Prefabs" option is checked in the URDF Import settings dialog. + +Renamed "URDF" to "Urdf" in class names, function names and source filenames. + +Renamed RuntimeURDFImporter to RuntimeUrdfImporterExample for clarification + +### Deprecated + +### Removed + +### Fixed +Bug where-in URDF Importer would throw an error when installed via Package Manager because it can't save prefabs to its own directories + +Compile error "Plugin 'assimp.dll' is used from several locations" when creating a Universal Windows Platform build (#122) + +Fix no material issue in Export robot to URDF (#127) + +Fix the inconsistent casing of meta files (#128) ## [0.4.0-preview] - 2021-05-27 @@ -46,4 +77,4 @@ Add unit tests and test coverage reporting ### Fixed Correct collider rotation so that the collider meshes matches visual meshes for both Y-axis and Z-axis -Replace "../" with the expected "package://" and throw more warnings if things still don't match up \ No newline at end of file +Replace "../" with the expected "package://" and throw more warnings if things still don't match up diff --git a/com.unity.robotics.urdf-importer/Editor/CustomEditors/HingeJointLimitsManagerEditor.cs b/com.unity.robotics.urdf-importer/Editor/CustomEditors/HingeJointLimitsManagerEditor.cs index a534f268..885d2ec5 100644 --- a/com.unity.robotics.urdf-importer/Editor/CustomEditors/HingeJointLimitsManagerEditor.cs +++ b/com.unity.robotics.urdf-importer/Editor/CustomEditors/HingeJointLimitsManagerEditor.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEditor; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { [CustomEditor(typeof(HingeJointLimitsManager))] diff --git a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfCollisionEditor.cs b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfCollisionEditor.cs index 1e679146..320c6491 100644 --- a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfCollisionEditor.cs +++ b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfCollisionEditor.cs @@ -15,7 +15,7 @@ limitations under the License. using UnityEditor; using UnityEngine; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { [CustomEditor(typeof(UrdfCollision))] class UrdfCollisionEditor : UnityEditor.Editor diff --git a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfCollisionsEditor.cs b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfCollisionsEditor.cs index 66ca0291..7603ad50 100644 --- a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfCollisionsEditor.cs +++ b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfCollisionsEditor.cs @@ -15,7 +15,7 @@ limitations under the License. using UnityEditor; using UnityEngine; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { [CustomEditor(typeof(UrdfCollisions))] class UrdfCollisionsEditor : UnityEditor.Editor diff --git a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfFkrobotEditor.cs b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfFkrobotEditor.cs index 3e99e9b5..b531c2c9 100644 --- a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfFkrobotEditor.cs +++ b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfFkrobotEditor.cs @@ -1,8 +1,8 @@ using UnityEditor; using UnityEngine; -using RosSharp.Control; +using Unity.Robotics.UrdfImporter.Control; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { [CustomEditor(typeof(FKRobot), true)] public class UrdfFkrobotEditor : UnityEditor.Editor diff --git a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfInertialEditor.cs b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfInertialEditor.cs index 528253a1..b739ee41 100644 --- a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfInertialEditor.cs +++ b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfInertialEditor.cs @@ -15,7 +15,7 @@ limitations under the License. using UnityEditor; using UnityEngine; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { [CustomEditor(typeof(UrdfInertial))] public class UrdfInertialEditor : UnityEditor.Editor diff --git a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfJointEditor.cs b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfJointEditor.cs index 6ab64c23..3ad4b4eb 100644 --- a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfJointEditor.cs +++ b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfJointEditor.cs @@ -15,7 +15,7 @@ limitations under the License. using UnityEditor; using UnityEngine; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { [CustomEditor(typeof(UrdfJoint), true)] public class UrdfJointEditor : UnityEditor.Editor diff --git a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfLinkEditor.cs b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfLinkEditor.cs index bc34eda1..0ef2a0a6 100644 --- a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfLinkEditor.cs +++ b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfLinkEditor.cs @@ -15,7 +15,7 @@ limitations under the License. using UnityEditor; using UnityEngine; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { [CustomEditor(typeof(UrdfLink))] public class UrdfLinkEditor : UnityEditor.Editor diff --git a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfPluginsEditor.cs b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfPluginsEditor.cs index b4f0cedb..7a5cf905 100644 --- a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfPluginsEditor.cs +++ b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfPluginsEditor.cs @@ -15,7 +15,7 @@ limitations under the License. using UnityEditor; using UnityEngine; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { [CustomEditor(typeof(UrdfPlugins))] class UrdfPluginsEditor : UnityEditor.Editor diff --git a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfRobotEditor.cs b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfRobotEditor.cs index 852e3ad0..87168d19 100644 --- a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfRobotEditor.cs +++ b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfRobotEditor.cs @@ -16,7 +16,7 @@ limitations under the License. using UnityEditor; using UnityEngine; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { [CustomEditor(typeof(UrdfRobot))] public class UrdfRobotEditor : UnityEditor.Editor @@ -65,19 +65,19 @@ public override void OnInspectorGUI() serializedObject.ApplyModifiedProperties(); UrdfRobotExtensions.CorrectAxis(urdfRobot.gameObject); - if (urdfRobot.GetComponent() == null || urdfRobot.GetComponent() == null) + if (urdfRobot.GetComponent() == null || urdfRobot.GetComponent() == null) { GUILayout.Label("Components", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); - if (GUILayout.Button(urdfRobot.GetComponent() == null? "Add Controller": "Remove Controller")) + if (GUILayout.Button(urdfRobot.GetComponent() == null? "Add Controller": "Remove Controller")) { urdfRobot.AddController(); } - if (urdfRobot.GetComponent() == null) + if (urdfRobot.GetComponent() == null) { if (GUILayout.Button("Add Forward Kinematics")) { - urdfRobot.gameObject.AddComponent(); + urdfRobot.gameObject.AddComponent(); } } GUILayout.EndHorizontal(); @@ -104,7 +104,7 @@ public override void OnInspectorGUI() GUILayout.Space(5); if (GUILayout.Button("Compare URDF Files")) { - CompareURDF window = (CompareURDF)EditorWindow.GetWindow(typeof(CompareURDF)); + CompareUrdf window = (CompareUrdf)EditorWindow.GetWindow(typeof(CompareUrdf)); window.minSize = new Vector2(500, 200); window.GetEditorPrefs(); window.Show(); diff --git a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfVisualEditor.cs b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfVisualEditor.cs index 543c11aa..63246a98 100644 --- a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfVisualEditor.cs +++ b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfVisualEditor.cs @@ -15,7 +15,7 @@ limitations under the License. using UnityEditor; using UnityEngine; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { [CustomEditor(typeof(UrdfVisual))] class UrdfVisualEditor : UnityEditor.Editor diff --git a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfVisualsEditor.cs b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfVisualsEditor.cs index 4888bf75..9888944d 100644 --- a/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfVisualsEditor.cs +++ b/com.unity.robotics.urdf-importer/Editor/CustomEditors/UrdfVisualsEditor.cs @@ -15,7 +15,7 @@ limitations under the License. using UnityEditor; using UnityEngine; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { [CustomEditor(typeof(UrdfVisuals))] class UrdfVisualsEditor : UnityEditor.Editor diff --git a/com.unity.robotics.urdf-importer/Editor/MenuItems/AddDhParameterWindow.cs b/com.unity.robotics.urdf-importer/Editor/MenuItems/AddDhParameterWindow.cs index 53c32239..3ef0ca45 100644 --- a/com.unity.robotics.urdf-importer/Editor/MenuItems/AddDhParameterWindow.cs +++ b/com.unity.robotics.urdf-importer/Editor/MenuItems/AddDhParameterWindow.cs @@ -2,9 +2,9 @@ using System.Collections.Generic; using UnityEditor; using UnityEngine; -using RosSharp.Control; +using Unity.Robotics.UrdfImporter.Control; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { public class AddDhParameterWindow : EditorWindow { diff --git a/com.unity.robotics.urdf-importer/Editor/MenuItems/CompareURDF.cs b/com.unity.robotics.urdf-importer/Editor/MenuItems/CompareUrdf.cs similarity index 98% rename from com.unity.robotics.urdf-importer/Editor/MenuItems/CompareURDF.cs rename to com.unity.robotics.urdf-importer/Editor/MenuItems/CompareUrdf.cs index 148d1b05..0842ed6c 100644 --- a/com.unity.robotics.urdf-importer/Editor/MenuItems/CompareURDF.cs +++ b/com.unity.robotics.urdf-importer/Editor/MenuItems/CompareUrdf.cs @@ -2,9 +2,9 @@ using UnityEditor; using UnityEngine; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { - public class CompareURDF : EditorWindow + public class CompareUrdf : EditorWindow { public UrdfComparator comparator; public string originalFile = ""; diff --git a/com.unity.robotics.urdf-importer/Editor/MenuItems/CompareURDF.cs.meta b/com.unity.robotics.urdf-importer/Editor/MenuItems/CompareUrdf.cs.meta similarity index 100% rename from com.unity.robotics.urdf-importer/Editor/MenuItems/CompareURDF.cs.meta rename to com.unity.robotics.urdf-importer/Editor/MenuItems/CompareUrdf.cs.meta diff --git a/com.unity.robotics.urdf-importer/Editor/MenuItems/FileImportMenu.cs b/com.unity.robotics.urdf-importer/Editor/MenuItems/FileImportMenu.cs index 477224e4..b0763dfb 100644 --- a/com.unity.robotics.urdf-importer/Editor/MenuItems/FileImportMenu.cs +++ b/com.unity.robotics.urdf-importer/Editor/MenuItems/FileImportMenu.cs @@ -5,7 +5,7 @@ using UnityEditor; using UnityEngine; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { public class FileImportMenu : EditorWindow { @@ -53,6 +53,9 @@ private void OnGUI() "Mesh Decomposer", settings.convexMethod); EditorGUILayout.EndHorizontal(); + GUILayout.Space(10); + settings.OverwriteExistingPrefabs = GUILayout.Toggle(settings.OverwriteExistingPrefabs, "Overwrite Existing Prefabs"); + //Import Robot button GUILayout.Space(10); if (GUILayout.Button("Import URDF")) diff --git a/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfExportEditorWindow.cs b/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfExportEditorWindow.cs index c50b627f..cdce39ad 100644 --- a/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfExportEditorWindow.cs +++ b/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfExportEditorWindow.cs @@ -16,7 +16,7 @@ limitations under the License. using UnityEditor; using UnityEngine; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { public class UrdfExportEditorWindow : EditorWindow { diff --git a/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfImporterContextMenuItem.cs b/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfImporterContextMenuItem.cs index de4fcf4b..c237f8f0 100644 --- a/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfImporterContextMenuItem.cs +++ b/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfImporterContextMenuItem.cs @@ -16,7 +16,7 @@ limitations under the License. using UnityEditor; using UnityEngine; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { public static class UrdfImporterContextMenuItem { diff --git a/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfImporterMenuItem.cs b/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfImporterMenuItem.cs index c48ddbec..c292b8d8 100644 --- a/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfImporterMenuItem.cs +++ b/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfImporterMenuItem.cs @@ -16,7 +16,7 @@ limitations under the License. using UnityEditor; using UnityEngine; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { public class UrdfImporterMenuItem { diff --git a/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfRobotCreatorMenuItem.cs b/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfRobotCreatorMenuItem.cs index 50c5c55d..61ff577b 100644 --- a/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfRobotCreatorMenuItem.cs +++ b/com.unity.robotics.urdf-importer/Editor/MenuItems/UrdfRobotCreatorMenuItem.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEditor; -namespace RosSharp.Urdf.Editor +namespace Unity.Robotics.UrdfImporter.Editor { public static class UrdfRobotCreatorMenuItem { diff --git a/com.unity.robotics.urdf-importer/Editor/Unity.Robotics.URDFImporter.Editor.asmdef b/com.unity.robotics.urdf-importer/Editor/Unity.Robotics.URDFImporter.Editor.asmdef index bbf2c129..6154167e 100644 --- a/com.unity.robotics.urdf-importer/Editor/Unity.Robotics.URDFImporter.Editor.asmdef +++ b/com.unity.robotics.urdf-importer/Editor/Unity.Robotics.URDFImporter.Editor.asmdef @@ -1,6 +1,6 @@ { - "name": "Unity.Robotics.URDFImporter.Editor", - "rootNamespace": "RosSharp.Urdf.Editor", + "name": "Unity.Robotics.UrdfImporter.Editor", + "rootNamespace": "Unity.Robotics.UrdfImporter.Urdf.Editor", "references": [ "GUID:b1ef917f7a8a86a4eb639ec2352edbf8", "GUID:6a697808d7c80a549b57420070d6c4f3", diff --git a/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/LocateAssetHandler.cs b/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/LocateAssetHandler.cs index c0f69b84..209d32bd 100644 --- a/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/LocateAssetHandler.cs +++ b/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/LocateAssetHandler.cs @@ -16,22 +16,33 @@ limitations under the License. using System; using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public static class LocateAssetHandler { public static T FindUrdfAsset(string urdfFileName) where T : UnityEngine.Object { string fileAssetPath = UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath(urdfFileName); - T assetObject = RuntimeURDF.AssetDatabase_LoadAssetAtPath(fileAssetPath); - if (assetObject != null) + // check if it is an asset tha requires post processing (AIRO-908) + var originalUrdfPath = UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath(urdfFileName, false); + if (originalUrdfPath.ToLower().EndsWith(".stl")) + {// it is an asset that requires post processing + if (UrdfRobotExtensions.importsettings.OverwriteExistingPrefabs || !RuntimeUrdf.AssetExists(fileAssetPath, true)) + {// post process again to (re)create prefabs + StlAssetPostProcessor.PostprocessStlFile(originalUrdfPath); + } + } + + T assetObject = RuntimeUrdf.AssetDatabase_LoadAssetAtPath(fileAssetPath); + + if (assetObject) return assetObject; //If asset was not found, let user choose whether to search for //or ignore the missing asset. string invalidPath = fileAssetPath ?? urdfFileName; - int option = RuntimeURDF.EditorUtility_DisplayDialogComplex("Urdf Importer: Asset Not Found", + int option = RuntimeUrdf.EditorUtility_DisplayDialogComplex("Urdf Importer: Asset Not Found", "Current root folder: " + UrdfAssetPathHandler.GetPackageRoot() + "\n\nExpected asset path: " + invalidPath, "Locate Asset", @@ -49,7 +60,7 @@ public static T FindUrdfAsset(string urdfFileName) where T : UnityEngine.Obje break; } - assetObject = (T) RuntimeURDF.AssetDatabase_LoadAssetAtPath(fileAssetPath, typeof(T)); + assetObject = (T) RuntimeUrdf.AssetDatabase_LoadAssetAtPath(fileAssetPath, typeof(T)); if (assetObject != null) return assetObject; @@ -59,7 +70,7 @@ public static T FindUrdfAsset(string urdfFileName) where T : UnityEngine.Obje private static string LocateRootAssetFolder(string urdfFileName) where T : UnityEngine.Object { - string newAssetPath = RuntimeURDF.EditorUtility_OpenFolderPanel( + string newAssetPath = RuntimeUrdf.EditorUtility_OpenFolderPanel( "Locate package root folder", Path.Combine(Path.GetDirectoryName(Application.dataPath), "Assets"), ""); @@ -79,7 +90,7 @@ private static string LocateAssetFile(string invalidPath) { string fileExtension = Path.GetExtension(invalidPath)?.Replace(".", ""); - string newPath = RuntimeURDF.EditorUtility_OpenFilePanel( + string newPath = RuntimeUrdf.EditorUtility_OpenFilePanel( "Couldn't find asset at " + invalidPath + ". Select correct file.", UrdfAssetPathHandler.GetPackageRoot(), fileExtension); @@ -89,7 +100,7 @@ private static string LocateAssetFile(string invalidPath) private static void ChooseFailureOption(string urdfFilePath) { - if (!RuntimeURDF.EditorUtility_DisplayDialog( + if (!RuntimeUrdf.EditorUtility_DisplayDialog( "Urdf Importer: Missing Asset", "Missing asset " + Path.GetFileName(urdfFilePath) + " was ignored or could not be found.\n\nContinue URDF Import?", diff --git a/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/UrdfAssetPathHandler.cs b/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/UrdfAssetPathHandler.cs index 30fc5292..64058948 100644 --- a/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/UrdfAssetPathHandler.cs +++ b/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/UrdfAssetPathHandler.cs @@ -15,7 +15,7 @@ limitations under the License. using System.IO; using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public static class UrdfAssetPathHandler { @@ -30,9 +30,9 @@ public static void SetPackageRoot(string newPath, bool correctingIncorrectPackag packageRoot = GetRelativeAssetPath(newPath); - if (!RuntimeURDF.AssetDatabase_IsValidFolder(Path.Combine(packageRoot, MaterialFolderName))) + if (!RuntimeUrdf.AssetDatabase_IsValidFolder(Path.Combine(packageRoot, MaterialFolderName))) { - RuntimeURDF.AssetDatabase_CreateFolder(packageRoot, MaterialFolderName); + RuntimeUrdf.AssetDatabase_CreateFolder(packageRoot, MaterialFolderName); } if (correctingIncorrectPackageRoot) @@ -54,7 +54,7 @@ public static string GetRelativeAssetPath(string absolutePath) if (!absolutePathUnityFormat.StartsWith(Application.dataPath.SetSeparatorChar())) { #if UNITY_EDITOR - if (!RuntimeURDF.IsRuntimeMode()) + if (!RuntimeUrdf.IsRuntimeMode()) { return null; } @@ -118,7 +118,7 @@ public static string GetRelativeAssetPathFromUrdfPath(string urdfPath, bool conv public static bool IsValidAssetPath(string path) { #if UNITY_EDITOR - if (!RuntimeURDF.IsRuntimeMode()) + if (!RuntimeUrdf.IsRuntimeMode()) { return GetRelativeAssetPath(path) != null; } @@ -131,15 +131,15 @@ public static bool IsValidAssetPath(string path) private static void MoveMaterialsToNewLocation(string oldPackageRoot) { - if (RuntimeURDF.AssetDatabase_IsValidFolder(Path.Combine(oldPackageRoot, MaterialFolderName))) + if (RuntimeUrdf.AssetDatabase_IsValidFolder(Path.Combine(oldPackageRoot, MaterialFolderName))) { - RuntimeURDF.AssetDatabase_MoveAsset( + RuntimeUrdf.AssetDatabase_MoveAsset( Path.Combine(oldPackageRoot, MaterialFolderName), Path.Combine(UrdfAssetPathHandler.GetPackageRoot(), MaterialFolderName)); } else { - RuntimeURDF.AssetDatabase_CreateFolder(UrdfAssetPathHandler.GetPackageRoot(), MaterialFolderName); + RuntimeUrdf.AssetDatabase_CreateFolder(UrdfAssetPathHandler.GetPackageRoot(), MaterialFolderName); } } diff --git a/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/UrdfExportPathHandler.cs b/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/UrdfExportPathHandler.cs index 9331b1a5..f721a01c 100644 --- a/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/UrdfExportPathHandler.cs +++ b/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/UrdfExportPathHandler.cs @@ -14,7 +14,7 @@ limitations under the License. using System.IO; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public static class UrdfExportPathHandler { diff --git a/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/UrdfMeshExportHandler.cs b/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/UrdfMeshExportHandler.cs index fe0cb00b..f311de0c 100644 --- a/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/UrdfMeshExportHandler.cs +++ b/com.unity.robotics.urdf-importer/Runtime/AssetHandlers/UrdfMeshExportHandler.cs @@ -10,12 +10,12 @@ You may obtain a copy of the License at WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ +*/ using System.IO; using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public static class UrdfMeshExportHandler { @@ -33,9 +33,9 @@ public static string CopyOrCreateMesh(GameObject geometryObject, bool isCollisio string[] foldersToSearch = {Path.GetDirectoryName(prefabPath)}; string prefabName = Path.GetFileNameWithoutExtension(prefabPath); - foreach (string guid2 in RuntimeURDF.AssetDatabase_FindAssets(prefabName, foldersToSearch)) + foreach (string guid2 in RuntimeUrdf.AssetDatabase_FindAssets(prefabName, foldersToSearch)) { - string possiblePath = RuntimeURDF.AssetDatabase_GUIDToAssetPath(guid2); + string possiblePath = RuntimeUrdf.AssetDatabase_GUIDToAssetPath(guid2); if (possiblePath.ToLower().Contains(".stl")) { prefabPath = possiblePath; @@ -45,7 +45,7 @@ public static string CopyOrCreateMesh(GameObject geometryObject, bool isCollisio } } } - + if (foundExistingColladaOrStl) return CopyMeshToExportDestination(prefabPath); @@ -69,19 +69,20 @@ private static string CopyMeshToExportDestination(string prefabPath) private static void CopyDaeTextureToExportDestination(string prefabPath, string newFolderLocation) { //Get material from Collada prefab - Material material = RuntimeURDF.AssetDatabase_LoadAssetAtPath(prefabPath); - if (material.mainTexture == null) return; - + Material material = RuntimeUrdf.AssetDatabase_LoadAssetAtPath(prefabPath); + if (material == null || material.mainTexture == null) + return; + //Get relative subfolder where texture is, compared to the DAE file. string commonFolder = Path.GetDirectoryName(prefabPath).SetSeparatorChar(); - string texturePath = RuntimeURDF.AssetDatabase_GetAssetPath(material.mainTexture).SetSeparatorChar(); + string texturePath = RuntimeUrdf.AssetDatabase_GetAssetPath(material.mainTexture).SetSeparatorChar(); string relativeLocation = ""; if (texturePath.Contains(commonFolder)) relativeLocation = texturePath.Substring(commonFolder.Length + 1); string newTexturePath = Path.Combine(newFolderLocation, relativeLocation); Directory.CreateDirectory(Path.GetDirectoryName(newTexturePath)); - + CopyFileToNewLocation(UrdfAssetPathHandler.GetFullAssetPath(texturePath), newTexturePath); } @@ -107,7 +108,7 @@ private static string CreateNewStlFile(GameObject geometryObject, bool isCollisi private static string GetPrefabPath(GameObject gameObject) { - return RuntimeURDF.AssetDatabase_GetAssetPath(RuntimeURDF.PrefabUtility_GetCorrespondingObjectFromSource(gameObject)); + return RuntimeUrdf.AssetDatabase_GetAssetPath(RuntimeUrdf.PrefabUtility_GetCorrespondingObjectFromSource(gameObject)); } } -} \ No newline at end of file +} diff --git a/com.unity.robotics.urdf-importer/Runtime/Controller/Controller.cs b/com.unity.robotics.urdf-importer/Runtime/Controller/Controller.cs index 63a6937d..5475d5a8 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Controller/Controller.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Controller/Controller.cs @@ -2,7 +2,7 @@ using Unity.Robotics; using UnityEngine; -namespace RosSharp.Control +namespace Unity.Robotics.UrdfImporter.Control { public enum RotationDirection { None = 0, Positive = 1, Negative = -1 }; public enum ControlType { PositionControl }; diff --git a/com.unity.robotics.urdf-importer/Runtime/Controller/FKRobot.cs b/com.unity.robotics.urdf-importer/Runtime/Controller/FKRobot.cs index c62ca22d..312a80a9 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Controller/FKRobot.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Controller/FKRobot.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System; -namespace RosSharp.Control{ +namespace Unity.Robotics.UrdfImporter.Control{ public class FKRobot : MonoBehaviour { private GameObject robot; @@ -14,15 +14,26 @@ public class FKRobot : MonoBehaviour public Quaternion endEffectorRotation; public Matrix4x4 endEffectorPosition; + + public const string k_TagName = "robot"; // TODO : Automatically adding DH parameters 2. Detecting number of active joints void Start() { - robot = GameObject.FindWithTag("robot"); - if(dh == null) + if (dh == null) + { dh = new List(); + } jointChain = new List(); + + robot = FindRobotObject(); + + if (!robot) + { + return; + } + foreach (ArticulationBody joint in robot.GetComponentsInChildren()) { if (joint.jointType != ArticulationJointType.FixedJoint) @@ -30,9 +41,28 @@ void Start() } } + public static GameObject FindRobotObject() + { + try + { + GameObject robot = GameObject.FindWithTag(k_TagName); + if (robot == null) + { + Debug.LogWarning($"No GameObject with tag '{k_TagName}' was found."); + } + return robot; + } + catch (Exception) + { + Debug.LogError($"Unable to find tag '{k_TagName}'. " + + $"Add A tag '{k_TagName}' in the Project Settings in Unity Editor."); + } + return null; + } + void FixedUpdate() { - if(dh.Count == jointChain.Count) + if (dh.Count == jointChain.Count) FK(); } diff --git a/com.unity.robotics.urdf-importer/Runtime/Controller/IKRobot.cs b/com.unity.robotics.urdf-importer/Runtime/Controller/IKRobot.cs index 250ef3b9..ed6839a2 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Controller/IKRobot.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Controller/IKRobot.cs @@ -3,7 +3,7 @@ using UnityEngine; // TODO: Check matrix access type across the board; -namespace RosSharp.Control +namespace Unity.Robotics.UrdfImporter.Control { public class IKRobot : MonoBehaviour { @@ -15,7 +15,12 @@ public class IKRobot : MonoBehaviour public float mDelta = .001f; void Start() { - robot = GameObject.FindWithTag("robot"); + robot = FKRobot.FindRobotObject(); + if (!robot) + { + return; + } + Fk = robot.GetComponent(); jacobian = new float[6, Fk.jointChain.Count]; } diff --git a/com.unity.robotics.urdf-importer/Runtime/Controller/JointControl.cs b/com.unity.robotics.urdf-importer/Runtime/Controller/JointControl.cs index 27ea102e..477defe9 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Controller/JointControl.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Controller/JointControl.cs @@ -1,14 +1,14 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -using RosSharp; +using Unity.Robotics.UrdfImporter; public class JointControl : MonoBehaviour { - RosSharp.Control.Controller controller; + Unity.Robotics.UrdfImporter.Control.Controller controller; - public RosSharp.Control.RotationDirection direction; - public RosSharp.Control.ControlType controltype; + public Unity.Robotics.UrdfImporter.Control.RotationDirection direction; + public Unity.Robotics.UrdfImporter.Control.ControlType controltype; public float speed ; public float torque ; public float acceleration; @@ -18,7 +18,7 @@ public class JointControl : MonoBehaviour void Start() { direction = 0; - controller = (RosSharp.Control.Controller)this.GetComponentInParent(typeof(RosSharp.Control.Controller)); + controller = (Unity.Robotics.UrdfImporter.Control.Controller)this.GetComponentInParent(typeof(Unity.Robotics.UrdfImporter.Control.Controller)); joint = this.GetComponent(); controller.UpdateControlType(this); speed = controller.speed; @@ -35,7 +35,7 @@ void FixedUpdate(){ if (joint.jointType != ArticulationJointType.FixedJoint) { - if (controltype == RosSharp.Control.ControlType.PositionControl) + if (controltype == Unity.Robotics.UrdfImporter.Control.ControlType.PositionControl) { ArticulationDrive currentDrive = joint.xDrive; float newTargetDelta = (int)direction * Time.fixedDeltaTime * speed; diff --git a/com.unity.robotics.urdf-importer/Runtime/Extensions/BuiltInExtensions.cs b/com.unity.robotics.urdf-importer/Runtime/Extensions/BuiltInExtensions.cs index afd266e9..1cce2155 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Extensions/BuiltInExtensions.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Extensions/BuiltInExtensions.cs @@ -17,7 +17,7 @@ limitations under the License. using UnityEngine; using Object = UnityEngine.Object; -namespace RosSharp +namespace Unity.Robotics.UrdfImporter { internal static class BuiltInExtensions { diff --git a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfCollisionExtensions.cs b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfCollisionExtensions.cs index 26f63219..7ee701e8 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfCollisionExtensions.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfCollisionExtensions.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public static class UrdfCollisionExtensions { diff --git a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfCollisionsExtensions.cs b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfCollisionsExtensions.cs index 42e399e8..43f5f8a3 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfCollisionsExtensions.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfCollisionsExtensions.cs @@ -16,7 +16,7 @@ limitations under the License. using System.Linq; using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public static class UrdfCollisionsExtensions { diff --git a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfGeometry.cs b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfGeometry.cs index 9af3300c..5f2b47a6 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfGeometry.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfGeometry.cs @@ -15,7 +15,7 @@ limitations under the License. using System; using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class UrdfGeometry { diff --git a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfGeometryCollision.cs b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfGeometryCollision.cs index 0d612315..6f18e541 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfGeometryCollision.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfGeometryCollision.cs @@ -17,7 +17,7 @@ limitations under the License. using MeshProcess; using System.IO; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class UrdfGeometryCollision : UrdfGeometry { @@ -63,7 +63,7 @@ public static void Create(Transform parent, GeometryTypes geometryType, Link.Geo private static GameObject CreateMeshCollider(Link.Geometry.Mesh mesh) { - if (!RuntimeURDF.IsRuntimeMode()) + if (!RuntimeUrdf.IsRuntimeMode()) { GameObject prefabObject = LocateAssetHandler.FindUrdfAsset(mesh.filename); if (prefabObject == null) @@ -72,7 +72,7 @@ private static GameObject CreateMeshCollider(Link.Geometry.Mesh mesh) return null; } - GameObject meshObject = (GameObject)RuntimeURDF.PrefabUtility_InstantiatePrefab(prefabObject); + GameObject meshObject = (GameObject)RuntimeUrdf.PrefabUtility_InstantiatePrefab(prefabObject); ConvertMeshToColliders(meshObject, location:mesh.filename); return meshObject; @@ -118,14 +118,14 @@ private static void ConvertCylinderToCollider(MeshFilter filter) GameObject go = filter.gameObject; var collider = filter.sharedMesh; // Only create an asset if not runtime import - if (!RuntimeURDF.IsRuntimeMode()) + if (!RuntimeUrdf.IsRuntimeMode()) { var packageRoot = UrdfAssetPathHandler.GetPackageRoot(); - var filePath = RuntimeURDF.AssetDatabase_GUIDToAssetPath(RuntimeURDF.AssetDatabase_CreateFolder($"{packageRoot}", "meshes")); + var filePath = RuntimeUrdf.AssetDatabase_GUIDToAssetPath(RuntimeUrdf.AssetDatabase_CreateFolder($"{packageRoot}", "meshes")); var name =$"{filePath}/Cylinder.asset"; Debug.Log($"Creating new cylinder file: {name}"); - RuntimeURDF.AssetDatabase_CreateAsset(collider, name, uniquePath:true); - RuntimeURDF.AssetDatabase_SaveAssets(); + RuntimeUrdf.AssetDatabase_CreateAsset(collider, name, uniquePath:true); + RuntimeUrdf.AssetDatabase_SaveAssets(); } MeshCollider current = go.AddComponent(); current.sharedMesh = collider; @@ -142,12 +142,12 @@ public static void CreateMatchingMeshCollision(Transform parent, Transform visua } GameObject objectToCopy = visualToCopy.GetChild(0).gameObject; - GameObject prefabObject = (GameObject)RuntimeURDF.PrefabUtility_GetCorrespondingObjectFromSource(objectToCopy); + GameObject prefabObject = (GameObject)RuntimeUrdf.PrefabUtility_GetCorrespondingObjectFromSource(objectToCopy); GameObject collisionObject; if (prefabObject != null) { - collisionObject = (GameObject)RuntimeURDF.PrefabUtility_InstantiatePrefab(prefabObject); + collisionObject = (GameObject)RuntimeUrdf.PrefabUtility_InstantiatePrefab(prefabObject); } else { @@ -182,7 +182,7 @@ private static void ConvertMeshToColliders(GameObject gameObject, string locatio string templateFileName = ""; string filePath = ""; int meshIndex = 0; - if (!RuntimeURDF.IsRuntimeMode() && location != null) + if (!RuntimeUrdf.IsRuntimeMode() && location != null) { string meshFilePath = UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath(location, false); templateFileName = Path.GetFileNameWithoutExtension(meshFilePath); @@ -196,13 +196,13 @@ private static void ConvertMeshToColliders(GameObject gameObject, string locatio List colliderMeshes = decomposer.GenerateConvexMeshes(meshFilter.sharedMesh); foreach (Mesh collider in colliderMeshes) { - if (!RuntimeURDF.IsRuntimeMode()) + if (!RuntimeUrdf.IsRuntimeMode()) { meshIndex++; string name = $"{filePath}/{templateFileName}_{meshIndex}.asset"; Debug.Log($"Creating new mesh file: {name}"); - RuntimeURDF.AssetDatabase_CreateAsset(collider, name); - RuntimeURDF.AssetDatabase_SaveAssets(); + RuntimeUrdf.AssetDatabase_CreateAsset(collider, name); + RuntimeUrdf.AssetDatabase_SaveAssets(); } MeshCollider current = child.AddComponent(); current.sharedMesh = collider; diff --git a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfGeometryVisual.cs b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfGeometryVisual.cs index 6aaf9a68..8e7bb93a 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfGeometryVisual.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfGeometryVisual.cs @@ -16,7 +16,7 @@ limitations under the License. using UnityEngine; using UnityMeshImporter; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class UrdfGeometryVisual : UrdfGeometry { @@ -60,10 +60,10 @@ public static void Create(Transform parent, GeometryTypes geometryType, Link.Geo private static GameObject CreateMeshVisual(Link.Geometry.Mesh mesh) { #if UNITY_EDITOR - if (!RuntimeURDF.IsRuntimeMode()) + if (!RuntimeUrdf.IsRuntimeMode()) { GameObject meshObject = LocateAssetHandler.FindUrdfAsset(mesh.filename); - return meshObject == null ? null : (GameObject)RuntimeURDF.PrefabUtility_InstantiatePrefab(meshObject); + return meshObject == null ? null : (GameObject)RuntimeUrdf.PrefabUtility_InstantiatePrefab(meshObject); } #endif return CreateMeshVisualRuntime(mesh); diff --git a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfLinkExtensions.cs b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfLinkExtensions.cs index 7f4bc490..a6059af5 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfLinkExtensions.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfLinkExtensions.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public static class UrdfLinkExtensions { diff --git a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfMaterial.cs b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfMaterial.cs index 82b139ad..f2035c27 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfMaterial.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfMaterial.cs @@ -19,7 +19,7 @@ limitations under the License. using UnityEngine; using UnityEngine.Rendering; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public static class UrdfMaterial { @@ -37,7 +37,7 @@ private static Material CreateMaterial(this Link.Visual.Material urdfMaterial) urdfMaterial.name = GenerateMaterialName(urdfMaterial); } - var material = RuntimeURDF.AssetDatabase_LoadAssetAtPath(UrdfAssetPathHandler.GetMaterialAssetPath(urdfMaterial.name)); + var material = RuntimeUrdf.AssetDatabase_LoadAssetAtPath(UrdfAssetPathHandler.GetMaterialAssetPath(urdfMaterial.name)); if (material != null) { //material already exists return material; @@ -53,7 +53,7 @@ private static Material CreateMaterial(this Link.Visual.Material urdfMaterial) material.mainTexture = LoadTexture(urdfMaterial.texture.filename); } - RuntimeURDF.AssetDatabase_CreateAsset(material, UrdfAssetPathHandler.GetMaterialAssetPath(urdfMaterial.name)); + RuntimeUrdf.AssetDatabase_CreateAsset(material, UrdfAssetPathHandler.GetMaterialAssetPath(urdfMaterial.name)); return material; } @@ -62,9 +62,9 @@ private static void CreateDefaultMaterial() { Material material = defaultMaterial; #if UNITY_EDITOR - if (!RuntimeURDF.IsRuntimeMode()) + if (!RuntimeUrdf.IsRuntimeMode()) { - material = RuntimeURDF.AssetDatabase_LoadAssetAtPath(UrdfAssetPathHandler.GetMaterialAssetPath(DefaultMaterialName)); + material = RuntimeUrdf.AssetDatabase_LoadAssetAtPath(UrdfAssetPathHandler.GetMaterialAssetPath(DefaultMaterialName)); } #endif if (material != null) @@ -78,10 +78,10 @@ private static void CreateDefaultMaterial() // just keep it in memory while the app is running. defaultMaterial = material; #if UNITY_EDITOR - if (!RuntimeURDF.IsRuntimeMode()) + if (!RuntimeUrdf.IsRuntimeMode()) { // create the material to be reused - RuntimeURDF.AssetDatabase_CreateAsset(material, UrdfAssetPathHandler.GetMaterialAssetPath(DefaultMaterialName)); + RuntimeUrdf.AssetDatabase_CreateAsset(material, UrdfAssetPathHandler.GetMaterialAssetPath(DefaultMaterialName)); } #endif } @@ -143,9 +143,9 @@ public static void SetUrdfMaterial(GameObject gameObject, Link.Visual.Material u { Material material = defaultMaterial; #if UNITY_EDITOR - if (!RuntimeURDF.IsRuntimeMode()) + if (!RuntimeUrdf.IsRuntimeMode()) { - material = RuntimeURDF.AssetDatabase_LoadAssetAtPath(UrdfAssetPathHandler.GetMaterialAssetPath(DefaultMaterialName)); + material = RuntimeUrdf.AssetDatabase_LoadAssetAtPath(UrdfAssetPathHandler.GetMaterialAssetPath(DefaultMaterialName)); } #endif SetMaterial(gameObject, material); @@ -207,7 +207,7 @@ private static double[] ExportRgbaData(Material material) private static Link.Visual.Material.Texture ExportTextureData(Texture texture) { - string oldTexturePath = UrdfAssetPathHandler.GetFullAssetPath(RuntimeURDF.AssetDatabase_GetAssetPath(texture)); + string oldTexturePath = UrdfAssetPathHandler.GetFullAssetPath(RuntimeUrdf.AssetDatabase_GetAssetPath(texture)); string newTexturePath = UrdfExportPathHandler.GetNewResourcePath(Path.GetFileName(oldTexturePath)); if (oldTexturePath != newTexturePath) { diff --git a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfRobotExtensions.cs b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfRobotExtensions.cs index 0cba6221..afe22508 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfRobotExtensions.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfRobotExtensions.cs @@ -16,16 +16,16 @@ limitations under the License. using System; using System.IO; using System.Linq; +using Unity.Robotics.UrdfImporter.Control; #if UNITY_EDITOR using UnityEditor; #endif using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public static class UrdfRobotExtensions { - static string tagName = "robot"; static string collisionObjectName = "Collisions"; public static ImportSettings importsettings; @@ -34,9 +34,9 @@ public static void Create() CreateTag(); GameObject robotGameObject = new GameObject("Robot"); - robotGameObject.tag = tagName; + SetTag(robotGameObject); robotGameObject.AddComponent(); - robotGameObject.AddComponent(); + robotGameObject.AddComponent(); UrdfPlugins.Create(robotGameObject.transform); @@ -68,12 +68,12 @@ private static ImportPipelineData ImportPipelineInit(string filename, ImportSett ImportPipelineData im = new ImportPipelineData(); im.settings = settings; im.loadStatus = loadStatus; - im.wasRuntimeMode = RuntimeURDF.IsRuntimeMode(); + im.wasRuntimeMode = RuntimeUrdf.IsRuntimeMode(); im.forceRuntimeMode = forceRuntimeMode; if (forceRuntimeMode) { - RuntimeURDF.SetRuntimeMode(true); + RuntimeUrdf.SetRuntimeMode(true); } im.robot = new Robot(filename); @@ -83,7 +83,7 @@ private static ImportPipelineData ImportPipelineInit(string filename, ImportSett Debug.LogError("URDF file and ressources must be placed in Assets Folder:\n" + Application.dataPath); if (forceRuntimeMode) { // set runtime mode back to what it was - RuntimeURDF.SetRuntimeMode(im.wasRuntimeMode); + RuntimeUrdf.SetRuntimeMode(im.wasRuntimeMode); } return null; } @@ -97,15 +97,16 @@ private static void ImportPipelineCreateObject(ImportPipelineData im) importsettings = im.settings; im.settings.totalLinks = im.robot.links.Count; + CreateTag(); - im.robotGameObject.tag = tagName; + SetTag(im.robotGameObject); im.robotGameObject.AddComponent(); - im.robotGameObject.AddComponent(); - if (RuntimeURDF.IsRuntimeMode()) + im.robotGameObject.AddComponent(); + if (RuntimeUrdf.IsRuntimeMode()) {// In runtime mode, we have to disable controller while robot is being constructed. - im.robotGameObject.GetComponent().enabled = false; + im.robotGameObject.GetComponent().enabled = false; } im.robotGameObject.GetComponent().SetAxis(im.settings.choosenAxis); @@ -153,7 +154,7 @@ private static void ImportPipelinePostCreate(ImportPipelineData im) if (im.forceRuntimeMode) { // set runtime mode back to what it was - RuntimeURDF.SetRuntimeMode(im.wasRuntimeMode); + RuntimeUrdf.SetRuntimeMode(im.wasRuntimeMode); } } @@ -348,6 +349,13 @@ private static Robot ExportRobotData(this UrdfRobot urdfRobot) public static void CreateTag() { #if UNITY_EDITOR + if (RuntimeUrdf.IsRuntimeMode()) + { + // This is to make the behavior consistent with Runtime mode + // as tags cannot be created in a Standalone build. + return; + } + // Open tag manager SerializedObject tagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]); SerializedProperty tagsProp = tagManager.FindProperty("tags"); @@ -358,7 +366,7 @@ public static void CreateTag() for (int i = 0; i < tagsProp.arraySize; i++) { SerializedProperty t = tagsProp.GetArrayElementAtIndex(i); - if (t.stringValue.Equals(tagName)) + if (t.stringValue.Equals(FKRobot.k_TagName)) { found = true; break; @@ -370,11 +378,37 @@ public static void CreateTag() { tagsProp.InsertArrayElementAtIndex(0); SerializedProperty n = tagsProp.GetArrayElementAtIndex(0); - n.stringValue = tagName; + n.stringValue = FKRobot.k_TagName; } - tagManager.ApplyModifiedProperties(); + tagManager.ApplyModifiedProperties(); #endif } + + static void SetTag(GameObject go) + { + try + { + GameObject.FindWithTag(FKRobot.k_TagName); + } + catch (Exception) + { + Debug.LogError($"Unable to find tag '{FKRobot.k_TagName}'." + + $"Add a tag '{FKRobot.k_TagName}' in the Project Settings in Unity Editor."); + return; + } + + if (!go) + return; + + try + { + go.tag = FKRobot.k_TagName; + } + catch (Exception) + { + Debug.LogError($"Unable to set the GameObject '{go.name}' tag to '{FKRobot.k_TagName}'."); + } + } } } diff --git a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfVisualExtensions.cs b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfVisualExtensions.cs index ffa26b98..682e6306 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfVisualExtensions.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfVisualExtensions.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public static class UrdfVisualExtensions { diff --git a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfVisualsExtensions.cs b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfVisualsExtensions.cs index 368b95c3..4de5d5d9 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfVisualsExtensions.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Extensions/UrdfVisualsExtensions.cs @@ -16,7 +16,7 @@ limitations under the License. using System.Linq; using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public static class UrdfVisualsExtensions { diff --git a/com.unity.robotics.urdf-importer/Runtime/JointLimitsManagers/HingeJointLimitsManager.cs b/com.unity.robotics.urdf-importer/Runtime/JointLimitsManagers/HingeJointLimitsManager.cs index 48398f47..7017f1ca 100644 --- a/com.unity.robotics.urdf-importer/Runtime/JointLimitsManagers/HingeJointLimitsManager.cs +++ b/com.unity.robotics.urdf-importer/Runtime/JointLimitsManagers/HingeJointLimitsManager.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp +namespace Unity.Robotics.UrdfImporter { [RequireComponent(typeof(HingeJoint))] [ExecuteInEditMode] @@ -155,7 +155,7 @@ private static JointLimits UpdateLimits(JointLimits jointLimits, float min, floa return jointLimits; } - public void InitializeLimits(Urdf.Joint.Limit limit, HingeJoint joint) + public void InitializeLimits(Joint.Limit limit, HingeJoint joint) { LargeAngleLimitMin = (float)limit.lower * Mathf.Rad2Deg; LargeAngleLimitMax = (float)limit.upper * Mathf.Rad2Deg; diff --git a/com.unity.robotics.urdf-importer/Runtime/JointLimitsManagers/PrismaticJointLimitsManager.cs b/com.unity.robotics.urdf-importer/Runtime/JointLimitsManagers/PrismaticJointLimitsManager.cs index faa5c5ee..69a49329 100644 --- a/com.unity.robotics.urdf-importer/Runtime/JointLimitsManagers/PrismaticJointLimitsManager.cs +++ b/com.unity.robotics.urdf-importer/Runtime/JointLimitsManagers/PrismaticJointLimitsManager.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp +namespace Unity.Robotics.UrdfImporter { public class PrismaticJointLimitsManager : MonoBehaviour { @@ -69,7 +69,7 @@ private static SoftJointLimit UpdateLimit(SoftJointLimit softJointLimit, float l return softJointLimit; } - public void InitializeLimits(Urdf.Joint.Limit limit) + public void InitializeLimits(Joint.Limit limit) { PositionLimitMax = (float)limit.upper; PositionLimitMin = (float)limit.lower; diff --git a/com.unity.robotics.urdf-importer/Runtime/Math/Matrix3x3.cs b/com.unity.robotics.urdf-importer/Runtime/Math/Matrix3x3.cs index 4644c67e..85da70e7 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Math/Matrix3x3.cs +++ b/com.unity.robotics.urdf-importer/Runtime/Math/Matrix3x3.cs @@ -15,7 +15,7 @@ limitations under the License. using System.Collections.Generic; using UnityEngine; -namespace RosSharp +namespace Unity.Robotics.UrdfImporter { public class Matrix3x3 { diff --git a/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/ColladaAssetPostProcessor.cs b/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/ColladaAssetPostProcessor.cs index f0bf7743..d19b6258 100644 --- a/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/ColladaAssetPostProcessor.cs +++ b/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/ColladaAssetPostProcessor.cs @@ -17,7 +17,7 @@ limitations under the License. using UnityEngine; using System.IO; -namespace RosSharp +namespace Unity.Robotics.UrdfImporter { #if UNITY_EDITOR using UnityEditor; @@ -32,7 +32,7 @@ public class ColladaAssetPostProcessor public void OnPreprocessModel() { #if UNITY_EDITOR - if (!RuntimeURDF.IsRuntimeMode()) + if (!RuntimeUrdf.IsRuntimeMode()) { ModelImporter modelImporter = (ModelImporter)assetImporter; isCollada = Path.GetExtension(modelImporter.assetPath).ToLowerInvariant() == ".dae"; diff --git a/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlAssetPostProcessor.cs b/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlAssetPostProcessor.cs index b38affeb..a8211193 100644 --- a/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlAssetPostProcessor.cs +++ b/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlAssetPostProcessor.cs @@ -16,61 +16,70 @@ limitations under the License. using System.Linq; using System.IO; -namespace RosSharp +namespace Unity.Robotics.UrdfImporter { - using Unity.Robotics; -#if UNITY_EDITOR - using UnityEditor; - public class StlAssetPostProcessor : AssetPostprocessor -#else + /// + /// Utility functions for processing STL mesh files. + /// Note that no post processing is done on STL files anymore when they are added to the project + /// As such StlAssetPostProcessor no longer drives from AssetPostProcessor and the OnPostprocessAllAssets() + /// function is removed. + /// public class StlAssetPostProcessor -#endif { - private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromPath) + private static Material s_DefaultDiffuse = null; + + public static void PostprocessStlFile(string stlFile) { -#if UNITY_EDITOR - if (!RuntimeURDF.IsRuntimeMode()) + var stlFileLowercase = stlFile.ToLower(); + if (stlFileLowercase.StartsWith("assets")) { - foreach (string stlFile in importedAssets.Where(x => x.ToLowerInvariant().EndsWith(".stl"))) - { - createStlPrefab(stlFile); - } + Debug.Log($"Detected an stl file at {stlFile} - creating a mesh prefab."); + CreateStlPrefab(stlFile); + } + else if (stlFileLowercase.StartsWith("packages")) + { + Debug.Log($"Found an stl file at {stlFile} - " + + "skipping post-processing because it's a Package asset"); + } + else + { + Debug.LogWarning($"Found an stl file at {stlFile} - " + + "skipping post-processing because we don't know how to handle an asset in this location."); } -#endif } - private static void createStlPrefab(string stlFile) + private static void CreateStlPrefab(string stlFile) { GameObject gameObject = CreateStlParent(stlFile); - if (gameObject == null) + if (!gameObject) { + Debug.LogWarning($"Could not create a mesh prefab for {stlFile}"); return; } - RuntimeURDF.PrefabUtility_SaveAsPrefabAsset(gameObject, getPrefabAssetPath(stlFile)); + RuntimeUrdf.PrefabUtility_SaveAsPrefabAsset(gameObject, GetPrefabAssetPath(stlFile)); Object.DestroyImmediate(gameObject); } - private static Material defaultDiffuse = null; private static Material GetDefaultDiffuseMaterial() { #if UNITY_EDITOR // also save the material in the Assets - if (!RuntimeURDF.IsRuntimeMode() && MaterialExtensions.GetRenderPipelineType() == MaterialExtensions.RenderPipelineType.Standard) + if (!RuntimeUrdf.IsRuntimeMode() && MaterialExtensions.GetRenderPipelineType() == MaterialExtensions.RenderPipelineType.Standard) { - defaultDiffuse = RuntimeURDF.AssetDatabase_GetBuiltinExtraResource("Default-Diffuse.mat"); + s_DefaultDiffuse = RuntimeUrdf.AssetDatabase_GetBuiltinExtraResource("Default-Diffuse.mat"); } #endif - if (defaultDiffuse == null) + if (s_DefaultDiffuse) { // Could't use the "Default-Diffuse.mat", either because of HDRP or runtime. so let's create one. - defaultDiffuse = MaterialExtensions.CreateBasicMaterial(); + s_DefaultDiffuse = MaterialExtensions.CreateBasicMaterial(); } - return defaultDiffuse; + return s_DefaultDiffuse; } private static GameObject CreateStlParent(string stlFile) { - Mesh[] meshes = Urdf.StlImporter.ImportMesh(stlFile); + Mesh[] meshes = StlImporter.ImportMesh(stlFile); if (meshes == null) return null; @@ -79,8 +88,8 @@ private static GameObject CreateStlParent(string stlFile) for (int i = 0; i < meshes.Length; i++) { - string meshAssetPath = getMeshAssetPath(stlFile, i); - RuntimeURDF.AssetDatabase_CreateAsset(meshes[i], meshAssetPath); + string meshAssetPath = GetMeshAssetPath(stlFile, i); + RuntimeUrdf.AssetDatabase_CreateAsset(meshes[i], meshAssetPath); GameObject gameObject = CreateStlGameObject(meshAssetPath, material); gameObject.transform.SetParent(parent.transform, false); } @@ -90,24 +99,24 @@ private static GameObject CreateStlParent(string stlFile) private static GameObject CreateStlGameObject(string meshAssetPath, Material material) { GameObject gameObject = new GameObject(Path.GetFileNameWithoutExtension(meshAssetPath)); - gameObject.AddComponent().sharedMesh = RuntimeURDF.AssetDatabase_LoadAssetAtPath(meshAssetPath); + gameObject.AddComponent().sharedMesh = RuntimeUrdf.AssetDatabase_LoadAssetAtPath(meshAssetPath); gameObject.AddComponent().sharedMaterial = material; return gameObject; } - private static string getMeshAssetPath(string stlFile, int i) + public static string GetMeshAssetPath(string stlFile, int i) { return stlFile.Substring(0, stlFile.Length - 4) + "_" + i.ToString() + ".asset"; } - private static string getPrefabAssetPath(string stlFile) + public static string GetPrefabAssetPath(string stlFile) { return stlFile.Substring(0, stlFile.Length - 4) + ".prefab"; } public static GameObject CreateStlGameObjectRuntime(string stlFile) { - Mesh[] meshes = Urdf.StlImporter.ImportMesh(stlFile); + Mesh[] meshes = StlImporter.ImportMesh(stlFile); if (meshes == null) { return null; @@ -119,7 +128,7 @@ public static GameObject CreateStlGameObjectRuntime(string stlFile) for (int i = 0; i < meshes.Length; i++) { - GameObject gameObject = new GameObject(Path.GetFileNameWithoutExtension(getMeshAssetPath(stlFile, i))); + GameObject gameObject = new GameObject(Path.GetFileNameWithoutExtension(GetMeshAssetPath(stlFile, i))); gameObject.AddComponent().sharedMesh = meshes[i]; gameObject.AddComponent().sharedMaterial = material; gameObject.transform.SetParent(parent.transform, false); diff --git a/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlExporter.cs b/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlExporter.cs index def25629..1fcba2fd 100644 --- a/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlExporter.cs +++ b/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlExporter.cs @@ -15,7 +15,7 @@ limitations under the License. using UnityEngine; using System.Collections.Generic; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class StlExporter { diff --git a/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlImporter.cs b/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlImporter.cs index b1e3e9a9..01a073fc 100644 --- a/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlImporter.cs +++ b/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlImporter.cs @@ -16,7 +16,7 @@ limitations under the License. using System.Collections.Generic; using System.IO; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public static class StlImporter { diff --git a/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlReader.cs b/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlReader.cs index abcd5c89..1f41107a 100644 --- a/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlReader.cs +++ b/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlReader.cs @@ -17,7 +17,7 @@ limitations under the License. using System.Text; using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public static class StlReader { diff --git a/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlWriter.cs b/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlWriter.cs index 4e15971d..ec67a900 100644 --- a/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlWriter.cs +++ b/com.unity.robotics.urdf-importer/Runtime/MeshProcessing/StlWriter.cs @@ -18,7 +18,7 @@ limitations under the License. using System.Text; using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class StlWriter { diff --git a/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Joint.cs b/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Joint.cs index e7de7bf8..0044d57b 100644 --- a/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Joint.cs +++ b/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Joint.cs @@ -15,7 +15,7 @@ limitations under the License. using System.Xml; using System.Xml.Linq; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class Joint { diff --git a/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Link.cs b/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Link.cs index cc6c39d3..4b0a8f5b 100644 --- a/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Link.cs +++ b/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Link.cs @@ -17,7 +17,7 @@ limitations under the License. using System.Xml; using System.Xml.Linq; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class Link { diff --git a/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Origin.cs b/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Origin.cs index 44df7f3d..54288f88 100644 --- a/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Origin.cs +++ b/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Origin.cs @@ -15,7 +15,7 @@ limitations under the License. using System.Xml; using System.Xml.Linq; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class Origin { diff --git a/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Plugin.cs b/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Plugin.cs index 2a8ba7f1..979107db 100644 --- a/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Plugin.cs +++ b/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Plugin.cs @@ -15,7 +15,7 @@ limitations under the License. using System.Xml; using System.Xml.Linq; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class Plugin { diff --git a/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Robot.cs b/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Robot.cs index c8388f1d..368e0778 100644 --- a/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Robot.cs +++ b/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/Robot.cs @@ -21,7 +21,7 @@ limitations under the License. using System; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class Robot { diff --git a/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/XAttributeExtensions.cs b/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/XAttributeExtensions.cs index b86a101e..a21b74cb 100644 --- a/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/XAttributeExtensions.cs +++ b/com.unity.robotics.urdf-importer/Runtime/RosSharpDefinitions/XAttributeExtensions.cs @@ -18,7 +18,7 @@ limitations under the License. using System.Xml.Linq; using System.Globalization; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public static class XAttributeExtensions { diff --git a/com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeURDF.cs b/com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeUrdf.cs similarity index 89% rename from com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeURDF.cs rename to com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeUrdf.cs index affc2b9c..8a5bd0b4 100644 --- a/com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeURDF.cs +++ b/com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeUrdf.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using UnityEngine; #if UNITY_EDITOR using UnityEditor; @@ -9,7 +10,7 @@ /// This is to reduce the usage of #if UNITY_EDITOR in the code and have a consistent way of skipping editor only code. /// Also to allow having the option of running the runtime mode code in editor. /// -public static class RuntimeURDF +public static class RuntimeUrdf { #if UNITY_EDITOR public static bool runtimeModeEnabled = false; @@ -233,4 +234,21 @@ public static void AssetDatabase_SaveAssets() } #endif } + + public static bool AssetExists(string assetPath, bool ignoreCase = false) + { +#if UNITY_EDITOR + string[] foldersToSearch = {Path.GetDirectoryName(assetPath)}; + var assetName = Path.GetFileNameWithoutExtension(assetPath); + foreach (var guid2 in AssetDatabase_FindAssets(assetName, foldersToSearch)) + { + var possiblePath = RuntimeUrdf.AssetDatabase_GUIDToAssetPath(guid2); + if (string.Equals(possiblePath, assetPath, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal)) + { + return true; + } + } +#endif + return false; + } } diff --git a/com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeURDF.cs.meta b/com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeUrdf.cs.meta similarity index 100% rename from com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeURDF.cs.meta rename to com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeUrdf.cs.meta diff --git a/com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeURDFImporter.cs b/com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeUrdfImporterExample.cs similarity index 79% rename from com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeURDFImporter.cs rename to com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeUrdfImporterExample.cs index da7b0dad..513d4794 100644 --- a/com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeURDFImporter.cs +++ b/com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeUrdfImporterExample.cs @@ -1,24 +1,34 @@ -using System; using System.Collections; using System.Collections.Generic; -using RosSharp; -using RosSharp.Control; -using RosSharp.Urdf; +using Unity.Robotics.UrdfImporter; +using Unity.Robotics.UrdfImporter.Control; using UnityEngine; /// /// Example component for using the runtime urdf import funcionality. /// To use, attach to a gameobject and use the GUI to load a URDF. +/// +/// Notes: +/// +/// - This component is for demonstration and testing only +/// and is not intended to be used as is in a final product. +/// +/// - The runtime import feature is currently only functional in builds created using +/// Mono scripting backend and will not fully work in standalone builds created with +/// IL2CPP due to the dependency to Assimpnet plugin for loading collada meshes. +/// However URDF files that only use STL format for both visual and collision meshes +/// can still be imported in runtime in standalone IL2CPP builds. /// -public class RuntimeURDFImporter : MonoBehaviour +public class RuntimeUrdfImporterExample : MonoBehaviour { public string urdfFilepath; public bool setImmovableLink = true; - public bool useVHACD = false; + public bool useVHACD = false; // this is not yet fully functional in runtime. public bool showProgress = false; // this is not stable in runtime. public bool clearOnLoad = true; public string immovableLinkName = "base_link"; + // The values below are tested to work with the niryo_one URDF: private float controllerStiffness = 10000; private float controllerDamping = 100; private float controllerForceLimit = 1000; @@ -27,7 +37,7 @@ public class RuntimeURDFImporter : MonoBehaviour private GameObject currentRobot = null; private bool isLoading = false; - private IEnumerator LoadURDF() + private IEnumerator LoadUrdf() { isLoading = true; if (string.IsNullOrEmpty(urdfFilepath)) @@ -107,7 +117,7 @@ void OnGUI() showProgress = GUI.Toggle(new Rect(10, 125, 200, 25), showProgress, "Show Progress (experimental)"); if (!isLoading && GUI.Button(new Rect(530, 50, 150, 25), "Load UDRF File")) { - StartCoroutine(LoadURDF()); + StartCoroutine(LoadUrdf()); } } } \ No newline at end of file diff --git a/com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeURDFImporter.cs.meta b/com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeUrdfImporterExample.cs.meta similarity index 100% rename from com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeURDFImporter.cs.meta rename to com.unity.robotics.urdf-importer/Runtime/RuntimeImport/RuntimeUrdfImporterExample.cs.meta diff --git a/com.unity.robotics.urdf-importer/Runtime/Unity.Robotics.URDFImporter.asmdef b/com.unity.robotics.urdf-importer/Runtime/Unity.Robotics.URDFImporter.asmdef index c5ae2a9a..8ef6ea1d 100644 --- a/com.unity.robotics.urdf-importer/Runtime/Unity.Robotics.URDFImporter.asmdef +++ b/com.unity.robotics.urdf-importer/Runtime/Unity.Robotics.URDFImporter.asmdef @@ -1,6 +1,6 @@ { - "name": "Unity.Robotics.URDFImporter", - "rootNamespace": "RosSharp.Urdf", + "name": "Unity.Robotics.UrdfImporter", + "rootNamespace": "Unity.Robotics.UrdfImporter.Urdf", "references": [ "GUID:6a697808d7c80a549b57420070d6c4f3" ], diff --git a/com.unity.robotics.urdf-importer/Runtime/UnityMeshImporter/Plugins/AssimpNet/Native/win/x86_64/assimp.dll.meta b/com.unity.robotics.urdf-importer/Runtime/UnityMeshImporter/Plugins/AssimpNet/Native/win/x86_64/assimp.dll.meta index aa561c4e..3cd8c864 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UnityMeshImporter/Plugins/AssimpNet/Native/win/x86_64/assimp.dll.meta +++ b/com.unity.robotics.urdf-importer/Runtime/UnityMeshImporter/Plugins/AssimpNet/Native/win/x86_64/assimp.dll.meta @@ -23,6 +23,7 @@ PluginImporter: Exclude OSXUniversal: 0 Exclude Win: 1 Exclude Win64: 0 + Exclude WindowsStoreApps: 0 - first: Any: second: @@ -84,6 +85,16 @@ PluginImporter: enabled: 1 settings: CPU: AnyCPU + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: X64 + DontProcess: false + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend userData: assetBundleName: assetBundleVariant: diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/CollisionIgnore.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/CollisionIgnore.cs index 7721809d..ba5030a2 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/CollisionIgnore.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/CollisionIgnore.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { [System.Serializable] public class CollisionIgnore { diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/ImportSettings.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/ImportSettings.cs index af1043be..d117d873 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/ImportSettings.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/ImportSettings.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using UnityEngine; -namespace RosSharp +namespace Unity.Robotics.UrdfImporter { public class ImportSettings { @@ -21,6 +21,8 @@ public enum convexDecomposer public axisType choosenAxis = axisType.yAxis; public convexDecomposer convexMethod = convexDecomposer.vHACD; + public bool OverwriteExistingPrefabs { get; set; } = false; + public int linksLoaded = 0; public int totalLinks = 0; diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfCollision.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfCollision.cs index 48776ec1..697e394f 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfCollision.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfCollision.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { [SelectionBase] public class UrdfCollision : MonoBehaviour diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfCollisions.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfCollisions.cs index e4f3b3cf..be4d425b 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfCollisions.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfCollisions.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class UrdfCollisions : MonoBehaviour { diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfComparator.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfComparator.cs index ffcedb7c..3453e798 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfComparator.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfComparator.cs @@ -2,7 +2,7 @@ using System.IO; using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class UrdfComparator { diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfInertial.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfInertial.cs index a482f297..09b363f4 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfInertial.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfInertial.cs @@ -15,7 +15,7 @@ limitations under the License. using System; using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { #if UNITY_2020_1_OR_NEWER [RequireComponent(typeof(ArticulationBody))] diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJoint.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJoint.cs index 247895ee..ba8ff679 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJoint.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJoint.cs @@ -15,7 +15,7 @@ limitations under the License. using System; using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { #if UNITY_2020_1_OR_NEWER [RequireComponent(typeof(ArticulationBody))] diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuous.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuous.cs index 55218546..6a8d3f99 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuous.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuous.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class UrdfJointContinuous : UrdfJoint { diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointFixed.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointFixed.cs index ecd74ed9..0c6ada6a 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointFixed.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointFixed.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class UrdfJointFixed : UrdfJoint { diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointFloating.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointFloating.cs index fc86be4e..a9281ba5 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointFloating.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointFloating.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class UrdfJointFloating : UrdfJoint { diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanar.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanar.cs index e2029934..73299826 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanar.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanar.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class UrdfJointPlanar : UrdfJoint { diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismatic.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismatic.cs index 5a8187d4..8e0ec91c 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismatic.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismatic.cs @@ -15,7 +15,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class UrdfJointPrismatic : UrdfJoint { diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevolute.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevolute.cs index 3b73a2e3..a79aad48 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevolute.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevolute.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class UrdfJointRevolute : UrdfJoint { diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfLink.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfLink.cs index 6dacf71c..8ab61c95 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfLink.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfLink.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class UrdfLink : MonoBehaviour { diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfOrigin.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfOrigin.cs index 0f82a7c6..80f09c04 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfOrigin.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfOrigin.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public static class UrdfOrigin { diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfPlugin.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfPlugin.cs index a9de7bbd..bdac9db9 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfPlugin.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfPlugin.cs @@ -15,7 +15,7 @@ limitations under the License. using System.Xml; using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class UrdfPlugin : MonoBehaviour { diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfPlugins.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfPlugins.cs index 9e7f0e8e..96011976 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfPlugins.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfPlugins.cs @@ -16,7 +16,7 @@ limitations under the License. using System.Linq; using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class UrdfPlugins : MonoBehaviour { diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfRobot.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfRobot.cs index 6f0e74ac..d00ed14a 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfRobot.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfRobot.cs @@ -16,7 +16,7 @@ limitations under the License. using System; using System.Collections.Generic; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public enum GeometryTypes { Box, Cylinder, Sphere, Mesh } @@ -86,14 +86,14 @@ public void SetOrientation() public void AddController() { - if (!addController && this.gameObject.GetComponent< RosSharp.Control.Controller>() == null) + if (!addController && this.gameObject.GetComponent< Unity.Robotics.UrdfImporter.Control.Controller>() == null) { - this.gameObject.AddComponent(); + this.gameObject.AddComponent(); } else { - DestroyImmediate(this.gameObject.GetComponent()); - DestroyImmediate(this.gameObject.GetComponent()); + DestroyImmediate(this.gameObject.GetComponent()); + DestroyImmediate(this.gameObject.GetComponent()); JointControl[] scriptList = GetComponentsInChildren(); foreach (JointControl script in scriptList) DestroyImmediate(script); @@ -103,13 +103,13 @@ public void AddController() public void AddFkRobot() { - if (!addFkRobot && this.gameObject.GetComponent() == null) + if (!addFkRobot && this.gameObject.GetComponent() == null) { - this.gameObject.AddComponent(); + this.gameObject.AddComponent(); } else { - DestroyImmediate(this.gameObject.GetComponent()); + DestroyImmediate(this.gameObject.GetComponent()); } addFkRobot = !addFkRobot; } diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfVisual.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfVisual.cs index d4fc0765..fb385b62 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfVisual.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfVisual.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { [SelectionBase] public class UrdfVisual : MonoBehaviour diff --git a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfVisuals.cs b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfVisuals.cs index fdfb2c60..8e73811e 100644 --- a/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfVisuals.cs +++ b/com.unity.robotics.urdf-importer/Runtime/UrdfComponents/UrdfVisuals.cs @@ -14,7 +14,7 @@ limitations under the License. using UnityEngine; -namespace RosSharp.Urdf +namespace Unity.Robotics.UrdfImporter { public class UrdfVisuals : MonoBehaviour { diff --git a/com.unity.robotics.urdf-importer/Tests/Editor/Unity.Robotics.URDFImporter.Editor.Tests.asmdef b/com.unity.robotics.urdf-importer/Tests/Editor/Unity.Robotics.URDFImporter.Editor.Tests.asmdef index 02925c30..b9c9cf49 100644 --- a/com.unity.robotics.urdf-importer/Tests/Editor/Unity.Robotics.URDFImporter.Editor.Tests.asmdef +++ b/com.unity.robotics.urdf-importer/Tests/Editor/Unity.Robotics.URDFImporter.Editor.Tests.asmdef @@ -1,10 +1,11 @@ { - "name": "Unity.Robotics.URDFImporter.Editor.Tests", + "name": "Unity.Robotics.UrdfImporter.Editor.Tests", "rootNamespace": "Unity.Robotics.EditorTests.URDFImporter", "references": [ "UnityEngine.TestRunner", "UnityEditor.TestRunner", - "Unity.Robotics.URDFImporter.Editor" + "Unity.Robotics.UrdfImporter.Editor", + "Unity.Robotics.UrdfImporter" ], "includePlatforms": [ "Editor" diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/AssetHandlers/UrdfAssetPathHandlerTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/AssetHandlers/UrdfAssetPathHandlerTests.cs index 256ad75c..2e29eaca 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/AssetHandlers/UrdfAssetPathHandlerTests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/AssetHandlers/UrdfAssetPathHandlerTests.cs @@ -5,10 +5,10 @@ using UnityEngine; using UnityEditor; using UnityEngine.TestTools; -using RosSharp.Urdf; +using Unity.Robotics.UrdfImporter; using Object = UnityEngine.Object; -namespace RosSharp.Tests +namespace Unity.Robotics.UrdfImporter.Tests { public class UrdfAssetPathHandlerTests { @@ -21,7 +21,7 @@ public void SetUp() assetRoot = "Assets/Tests/Runtime/UrdfAssetPathHandler"; packageRoot = "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfAssetPathHandler"; - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; Directory.CreateDirectory(assetRoot); Directory.CreateDirectory(packageRoot); } @@ -30,7 +30,7 @@ public void SetUp() public void GetSetPackageRoot_RuntimeModeEnabled_Success() { // Force runtime mode to set testing package root - RuntimeURDF.runtimeModeEnabled = true; + RuntimeUrdf.runtimeModeEnabled = true; UrdfAssetPathHandler.SetPackageRoot(assetRoot); // Set oldPackagePath UrdfAssetPathHandler.SetPackageRoot(assetRoot, true); // Run correctPackageRoot Assert.AreEqual(assetRoot, UrdfAssetPathHandler.GetPackageRoot()); @@ -39,7 +39,7 @@ public void GetSetPackageRoot_RuntimeModeEnabled_Success() [Test] public void GetRelativeAssetPath_Nonruntime_NullValues() { - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; // Everything returns null during non-runtime Assert.IsNull(UrdfAssetPathHandler.GetRelativeAssetPath("Invalid/Asset/Path")); Assert.IsNull(UrdfAssetPathHandler.GetRelativeAssetPath($"{assetRoot}/TestAsset.txt")); @@ -49,7 +49,7 @@ public void GetRelativeAssetPath_Nonruntime_NullValues() [Test] public void GetRelativeAssetPath_Runtime_Success() { - RuntimeURDF.runtimeModeEnabled = true; + RuntimeUrdf.runtimeModeEnabled = true; // Starting with Application.dataPath Assert.AreEqual("Assets/Valid/Path", UrdfAssetPathHandler.GetRelativeAssetPath($"{Application.dataPath}/Valid/Path")); // Not starting with dataPath @@ -69,9 +69,9 @@ public void GetRelativeAssetPathFromUrdfPath_CubeUrdf_Success() { string urdfRoot = "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube"; // Force runtime mode to set testing package root - RuntimeURDF.runtimeModeEnabled = true; + RuntimeUrdf.runtimeModeEnabled = true; UrdfAssetPathHandler.SetPackageRoot(urdfRoot); - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; Assert.AreEqual($"{urdfRoot}/meshes/cube.prefab", UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath("package://meshes/cube.stl")); Assert.AreEqual($"{urdfRoot}/meshes/cube.prefab", UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath("../meshes/cube.stl")); @@ -80,7 +80,7 @@ public void GetRelativeAssetPathFromUrdfPath_CubeUrdf_Success() [Test] public void IsValidAssetPath_Nonruntime_Success() { - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; AssetDatabase.CreateAsset(new TextAsset("TestAsset"), $"{assetRoot}/TestAsset.txt"); // Everything returns null during non-runtime @@ -88,7 +88,7 @@ public void IsValidAssetPath_Nonruntime_Success() Assert.IsFalse(UrdfAssetPathHandler.IsValidAssetPath($"{assetRoot}/TestAsset.txt")); Assert.IsFalse(UrdfAssetPathHandler.IsValidAssetPath($"Packages/com.unity.robotics.urdf-importer/Tests/Runtime/AssetHandlers/UrdfAssetPathHandlerTests.cs")); - RuntimeURDF.runtimeModeEnabled = true; + RuntimeUrdf.runtimeModeEnabled = true; // Everything returns true during runtime Assert.IsTrue(UrdfAssetPathHandler.IsValidAssetPath("Invalid/Asset/Path")); Assert.IsTrue(UrdfAssetPathHandler.IsValidAssetPath($"{assetRoot}/TestAsset.txt")); @@ -99,16 +99,16 @@ public void IsValidAssetPath_Nonruntime_Success() public void GetMaterialAssetPath_AssetAndPackage_Success() { // Force runtime mode to set testing package root - RuntimeURDF.runtimeModeEnabled = true; + RuntimeUrdf.runtimeModeEnabled = true; UrdfAssetPathHandler.SetPackageRoot(assetRoot); - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; Assert.AreEqual($"{assetRoot}/Materials/TestMaterial.mat", UrdfAssetPathHandler.GetMaterialAssetPath("TestMaterial")); // Force runtime mode to set testing package root - RuntimeURDF.runtimeModeEnabled = true; + RuntimeUrdf.runtimeModeEnabled = true; UrdfAssetPathHandler.SetPackageRoot(packageRoot); - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; Assert.AreEqual($"{packageRoot}/Materials/TestMaterial.mat", UrdfAssetPathHandler.GetMaterialAssetPath("TestMaterial")); } diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/BuiltInExtensionsTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/BuiltInExtensionsTests.cs index 4820f8f1..ece2a7ef 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/BuiltInExtensionsTests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/BuiltInExtensionsTests.cs @@ -6,7 +6,7 @@ using UnityEngine.TestTools; using Object = UnityEngine.Object; -namespace RosSharp.Tests +namespace Unity.Robotics.UrdfImporter.Tests { public class BuiltInExtensionsTests { diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfCollisionExtensionsTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfCollisionExtensionsTests.cs index 7c5e7d4e..8c09864f 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfCollisionExtensionsTests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfCollisionExtensionsTests.cs @@ -5,20 +5,20 @@ using UnityEngine; using UnityEditor; using UnityEngine.TestTools; -using RosSharp.Urdf; +using Unity.Robotics.UrdfImporter; using Object = UnityEngine.Object; -using Collision = RosSharp.Urdf.Link.Collision; -using Geometry = RosSharp.Urdf.Link.Geometry; -using Box = RosSharp.Urdf.Link.Geometry.Box; +using Collision = Unity.Robotics.UrdfImporter.Link.Collision; +using Geometry = Unity.Robotics.UrdfImporter.Link.Geometry; +using Box = Unity.Robotics.UrdfImporter.Link.Geometry.Box; -namespace RosSharp.Urdf.Tests +namespace Unity.Robotics.UrdfImporter.Tests { public class UrdfCollisionExtensionsTests { [Test] public void Create_GeometryBox_DefaultGeometry() { - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; var parent = new GameObject("Parent").transform; var collision = UrdfCollisionExtensions.Create(parent, GeometryTypes.Box); @@ -32,7 +32,7 @@ public void Create_GeometryBox_DefaultGeometry() [Test] public void Create_GeometryBoxWithVisual_NondefaultScale() { - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; var parent = new GameObject("Parent").transform; var copy = new GameObject("Copy").transform; copy.transform.localScale = Vector3.one * 2f; @@ -49,7 +49,7 @@ public void Create_GeometryBoxWithVisual_NondefaultScale() [Test] public void Create_GeometryMesh_DefaultGeometry() { - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; var parent = new GameObject("Parent").transform; var collision = UrdfCollisionExtensions.Create(parent, GeometryTypes.Mesh); @@ -63,7 +63,7 @@ public void Create_GeometryMesh_DefaultGeometry() [Test] public void Create_GeometryMeshWithVisual_NondefaultScale() { - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; var parent = new GameObject("Parent").transform; var copy = new GameObject("Copy").transform; copy.transform.localScale = Vector3.one * 2f; @@ -80,7 +80,7 @@ public void Create_GeometryMeshWithVisual_NondefaultScale() [Test] public void Create_LinkCollision_DefaultGeometry() { - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; var parent = new GameObject("Parent").transform; var geometry = new Geometry(box:new Box(new double[] {1, 1, 1})); @@ -96,7 +96,7 @@ public void Create_LinkCollision_DefaultGeometry() [Test] public void ExportCollisionData_DefaultGeometry_Succeeds() { - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; var parent = new GameObject("Parent").transform; var collisionComponent = UrdfCollisionExtensions.Create(parent, GeometryTypes.Box); diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfCollisionsExtensionsTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfCollisionsExtensionsTests.cs index 3ed37126..05afdcc2 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfCollisionsExtensionsTests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfCollisionsExtensionsTests.cs @@ -5,13 +5,13 @@ using UnityEngine; using UnityEditor; using UnityEngine.TestTools; -using RosSharp.Urdf; +using Unity.Robotics.UrdfImporter; using Object = UnityEngine.Object; -using Collision = RosSharp.Urdf.Link.Collision; -using Geometry = RosSharp.Urdf.Link.Geometry; -using Box = RosSharp.Urdf.Link.Geometry.Box; +using Collision = Unity.Robotics.UrdfImporter.Link.Collision; +using Geometry = Unity.Robotics.UrdfImporter.Link.Geometry; +using Box = Unity.Robotics.UrdfImporter.Link.Geometry.Box; -namespace RosSharp.Urdf.Tests +namespace Unity.Robotics.UrdfImporter.Tests { public class UrdfCollisionsExtensionsTests { diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfGeometryCollisionTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfGeometryCollisionTests.cs index 32a16fe3..64aa91b8 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfGeometryCollisionTests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfGeometryCollisionTests.cs @@ -5,14 +5,14 @@ using UnityEngine; using UnityEditor; using UnityEngine.TestTools; -using RosSharp.Urdf; +using Unity.Robotics.UrdfImporter; using Object = UnityEngine.Object; -using Collision = RosSharp.Urdf.Link.Collision; -using Geometry = RosSharp.Urdf.Link.Geometry; -using Box = RosSharp.Urdf.Link.Geometry.Box; -using Mesh = RosSharp.Urdf.Link.Geometry.Mesh; +using Collision = Unity.Robotics.UrdfImporter.Link.Collision; +using Geometry = Unity.Robotics.UrdfImporter.Link.Geometry; +using Box = Unity.Robotics.UrdfImporter.Link.Geometry.Box; +using Mesh = Unity.Robotics.UrdfImporter.Link.Geometry.Mesh; -namespace RosSharp.Urdf.Tests +namespace Unity.Robotics.UrdfImporter.Tests { public class UrdfGeometryCollisionTests { @@ -22,9 +22,12 @@ public class UrdfGeometryCollisionTests [SetUp] public void SetUp() { - RuntimeURDF.AssetDatabase_CreateFolder("Assets", "Tests"); - RuntimeURDF.AssetDatabase_CreateFolder("Assets/Tests", "Runtime"); - RuntimeURDF.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "GeometryTests"); + // a robot tag needs to be added in project settings before runtime import can work + RuntimeUrdf.SetRuntimeMode(false); + UrdfRobotExtensions.CreateTag(); + RuntimeUrdf.AssetDatabase_CreateFolder("Assets", "Tests"); + RuntimeUrdf.AssetDatabase_CreateFolder("Assets/Tests", "Runtime"); + RuntimeUrdf.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "GeometryTests"); } [Test] @@ -46,9 +49,9 @@ public void Create_Box_UnityPrimitive() public void Create_CylinderMesh_AssetCreated() { // Force runtime mode to set testing package root - RuntimeURDF.runtimeModeEnabled = true; + RuntimeUrdf.runtimeModeEnabled = true; UrdfAssetPathHandler.SetPackageRoot("Assets/Tests/Runtime/GeometryTests"); - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; var parent = new GameObject("Parent").transform; UrdfGeometryCollision.Create(parent, GeometryTypes.Cylinder); @@ -62,7 +65,7 @@ public void Create_CylinderMesh_AssetCreated() Assert.IsTrue(Vector3.Distance(Vector3.zero, createdCylinder.GetComponent().sharedMesh.bounds.center) < centerDelta); Assert.IsTrue(Vector3.Distance(new Vector3(0.5f, 1f, 0.5f), createdCylinder.GetComponent().sharedMesh.bounds.extents) < scaleDelta); // Verify Cylinder created in Assets - Assert.IsNotNull(RuntimeURDF.AssetDatabase_FindAssets("Cylinder t:mesh", new string[] {"Assets/Tests/Runtime/GeometryTests"})); + Assert.IsNotNull(RuntimeUrdf.AssetDatabase_FindAssets("Cylinder t:mesh", new string[] {"Assets/Tests/Runtime/GeometryTests"})); AssetDatabase.DeleteAsset("Assets/Tests/Runtime/GeometryTests/Cylinder.asset"); Object.DestroyImmediate(parent.gameObject); @@ -102,9 +105,9 @@ public void Create_Mesh_UnityPrimitive() public void Create_FromStlUnity_CubeMesh() { // Force runtime mode to set testing package root - RuntimeURDF.runtimeModeEnabled = true; + RuntimeUrdf.runtimeModeEnabled = true; UrdfAssetPathHandler.SetPackageRoot("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube/"); - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; UrdfRobotExtensions.importsettings = ImportSettings.DefaultSettings(); UrdfRobotExtensions.importsettings.convexMethod = ImportSettings.convexDecomposer.unity; @@ -132,9 +135,9 @@ public void Create_FromStlUnity_CubeMesh() public void Create_FromStlVhacdNotRuntime_CubeMesh() { // Force runtime mode to set testing package root - RuntimeURDF.runtimeModeEnabled = true; + RuntimeUrdf.runtimeModeEnabled = true; UrdfAssetPathHandler.SetPackageRoot("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube/"); - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; UrdfRobotExtensions.importsettings = ImportSettings.DefaultSettings(); var parent = new GameObject("Parent").transform; @@ -161,7 +164,7 @@ public void Create_FromStlVhacdNotRuntime_CubeMesh() public void Create_FromStlVhacdRuntime_CubeMesh() { // Force runtime mode to set testing package root - RuntimeURDF.runtimeModeEnabled = true; + RuntimeUrdf.runtimeModeEnabled = true; UrdfAssetPathHandler.SetPackageRoot("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube/"); UrdfRobotExtensions.importsettings = ImportSettings.DefaultSettings(); diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfGeometryTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfGeometryTests.cs index a3ca1824..151b5705 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfGeometryTests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/Extensions/UrdfGeometryTests.cs @@ -5,19 +5,19 @@ using UnityEngine; using UnityEditor; using UnityEngine.TestTools; -using RosSharp.Urdf; +using Unity.Robotics.UrdfImporter; using Object = UnityEngine.Object; -using Collision = RosSharp.Urdf.Link.Collision; -using Geometry = RosSharp.Urdf.Link.Geometry; -using Box = RosSharp.Urdf.Link.Geometry.Box; -using Cylinder = RosSharp.Urdf.Link.Geometry.Cylinder; -using Sphere = RosSharp.Urdf.Link.Geometry.Sphere; -using Mesh = RosSharp.Urdf.Link.Geometry.Mesh; +using Collision = Unity.Robotics.UrdfImporter.Link.Collision; +using Geometry = Unity.Robotics.UrdfImporter.Link.Geometry; +using Box = Unity.Robotics.UrdfImporter.Link.Geometry.Box; +using Cylinder = Unity.Robotics.UrdfImporter.Link.Geometry.Cylinder; +using Sphere = Unity.Robotics.UrdfImporter.Link.Geometry.Sphere; +using Mesh = Unity.Robotics.UrdfImporter.Link.Geometry.Mesh; /// Sample STL from Obijuan.cube, Public domain, via Wikimedia Commons /// https://commons.wikimedia.org/wiki/File:3D_model_of_a_Cube.stl -namespace RosSharp.Urdf.Tests +namespace Unity.Robotics.UrdfImporter.Tests { public class UrdfGeometryTests { @@ -52,7 +52,7 @@ public void ExportGeometryData_Box_DefaultGeometry() public void ExportGeometryData_Cylinder_DefaultGeometry() { // Force runtime mode to avoid creating asset file - RuntimeURDF.runtimeModeEnabled = true; + RuntimeUrdf.runtimeModeEnabled = true; var parent = new GameObject("Parent").transform; UrdfGeometryCollision.Create(parent, GeometryTypes.Cylinder); @@ -90,9 +90,9 @@ public void ExportGeometryData_Sphere_DefaultGeometry() public void ExportGeometryData_MeshUnityDecomposer_DefaultGeometry() { // Force runtime mode to set testing package root - RuntimeURDF.runtimeModeEnabled = true; + RuntimeUrdf.runtimeModeEnabled = true; UrdfAssetPathHandler.SetPackageRoot("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube/"); - RuntimeURDF.runtimeModeEnabled = false; + RuntimeUrdf.runtimeModeEnabled = false; UrdfRobotExtensions.importsettings = ImportSettings.DefaultSettings(); UrdfRobotExtensions.importsettings.convexMethod = ImportSettings.convexDecomposer.unity; diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/Math/Matrix3x3Tests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/Math/Matrix3x3Tests.cs index a4faea32..bdd5f7f6 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/Math/Matrix3x3Tests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/Math/Matrix3x3Tests.cs @@ -3,95 +3,99 @@ using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; -using RosSharp; +using Unity.Robotics.UrdfImporter; -public class Matrix3x3Tests -{ - const float delta = 1e-5f; - [Test] - public void Matrix3x3_Instantiations_All() +namespace Unity.Robotics.UrdfImporter.Tests +{ + public class Matrix3x3Tests { - var zeroMatrix = new Matrix3x3(0f); + const float delta = 1e-5f; - Assert.AreEqual(zeroMatrix.elements, new Matrix3x3(new float[] {0, 0, 0}).elements); - Assert.AreEqual(zeroMatrix.elements, new Matrix3x3(new float[] {0, 0, 0, 0, 0, 0}).elements); - Assert.AreEqual(zeroMatrix.elements, new Matrix3x3(new float[] {0, 0, 0, 0, 0, 0, 0, 0, 0}).elements); - Assert.AreEqual(zeroMatrix.elements, new Matrix3x3(new float[][] { new float[]{0, 0, 0}, new float[]{0, 0, 0}, new float[]{0, 0, 0 }}).elements); - Assert.AreEqual(zeroMatrix.elements, new Matrix3x3(new Vector3[] {Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero}).elements); - } + [Test] + public void Matrix3x3_Instantiations_All() + { + var zeroMatrix = new Matrix3x3(0f); - [Test] - public void Member_Indexing() - { - var m = new Matrix3x3(); - Assert.IsNotNull(m[0]); - Assert.IsNotNull(m[0] = new float[] {0, 0, 0}); - } + Assert.AreEqual(zeroMatrix.elements, new Matrix3x3(new float[] { 0, 0, 0 }).elements); + Assert.AreEqual(zeroMatrix.elements, new Matrix3x3(new float[] { 0, 0, 0, 0, 0, 0 }).elements); + Assert.AreEqual(zeroMatrix.elements, new Matrix3x3(new float[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 }).elements); + Assert.AreEqual(zeroMatrix.elements, new Matrix3x3(new float[][] { new float[] { 0, 0, 0 }, new float[] { 0, 0, 0 }, new float[] { 0, 0, 0 } }).elements); + Assert.AreEqual(zeroMatrix.elements, new Matrix3x3(new Vector3[] { Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero }).elements); + } - [Test] - public void OperatorOverrides_Arithmetic() - { - var zeroMatrix = new Matrix3x3(0f); - var oneMatrix = new Matrix3x3(1f); - var negOneMatrix = new Matrix3x3(-1f); - - // + - Assert.AreEqual(zeroMatrix.elements, (oneMatrix + negOneMatrix).elements); - Assert.AreEqual(zeroMatrix.elements, (negOneMatrix + 1f).elements); - - // - - Assert.AreEqual(zeroMatrix.elements, (oneMatrix - oneMatrix).elements); - Assert.AreEqual(zeroMatrix.elements, (oneMatrix - 1f).elements); - - // * - Assert.AreEqual(zeroMatrix.elements, (oneMatrix * zeroMatrix).elements); - Assert.AreEqual(zeroMatrix.elements, (oneMatrix * 0f).elements); - Assert.AreEqual(Vector3.one * 6f, (oneMatrix * new Vector3(1, 2, 3))); - } + [Test] + public void Member_Indexing() + { + var m = new Matrix3x3(); + Assert.IsNotNull(m[0]); + Assert.IsNotNull(m[0] = new float[] { 0, 0, 0 }); + } - [Test] - public void MatrixOperations() - { - var identity = new Matrix3x3(new float[] {1f, 1f, 1f}); - var identityEigen = new Vector3[] {new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1)}; - var nonDiag = new Matrix3x3(new float[] {0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f}); - var nonDiagT = new Matrix3x3(new float[] {0f, 3f, 6f, 1f, 4f, 7f, 2f, 5f, 8f}); - var eigenTest = new Matrix3x3(1f); - var eigenValues = new Vector3(3f, 0f, 0f); - var eigenVectors = new Vector3[] {Vector3.one * 0.57735f, new Vector3(-0.408248f, -0.408248f, 0.816497f), new Vector3(0.7071f, -0.7071f, 0)}; - - // Determinant - Assert.AreEqual(1f, identity.Determinant()); - - // Trace - Assert.AreEqual(3f, identity.Trace()); - - // IsDiagonal - Assert.IsTrue(identity.IsDiagonal()); - Assert.IsFalse(nonDiag.IsDiagonal()); - - // Transpose - Assert.AreEqual(identity.elements, identity.Transpose().elements); - Assert.AreEqual(nonDiagT.elements, nonDiag.Transpose().elements); - - // DiagonalizeRealSymmetric - // Identity - Vector3 values; - Vector3[] vectors; - identity.DiagonalizeRealSymmetric(out values, out vectors); - Assert.AreEqual(Vector3.one, values); - Assert.AreEqual(identityEigen, vectors); - - // Non-identity - Vector3 nonDiagValues; - Vector3[] nonDiagVectors; - eigenTest.DiagonalizeRealSymmetric(out nonDiagValues, out nonDiagVectors); - Assert.IsTrue(Vector3.Distance(eigenValues, nonDiagValues) < delta); - Assert.AreEqual(eigenVectors.Length, nonDiagVectors.Length); - for (int i = 0; i < eigenVectors.Length; i++) + [Test] + public void OperatorOverrides_Arithmetic() { - Assert.IsTrue(Vector3.Distance(eigenVectors[i], nonDiagVectors[i]) < delta); + var zeroMatrix = new Matrix3x3(0f); + var oneMatrix = new Matrix3x3(1f); + var negOneMatrix = new Matrix3x3(-1f); + + // + + Assert.AreEqual(zeroMatrix.elements, (oneMatrix + negOneMatrix).elements); + Assert.AreEqual(zeroMatrix.elements, (negOneMatrix + 1f).elements); + + // - + Assert.AreEqual(zeroMatrix.elements, (oneMatrix - oneMatrix).elements); + Assert.AreEqual(zeroMatrix.elements, (oneMatrix - 1f).elements); + + // * + Assert.AreEqual(zeroMatrix.elements, (oneMatrix * zeroMatrix).elements); + Assert.AreEqual(zeroMatrix.elements, (oneMatrix * 0f).elements); + Assert.AreEqual(Vector3.one * 6f, (oneMatrix * new Vector3(1, 2, 3))); + } + + [Test] + public void MatrixOperations() + { + var identity = new Matrix3x3(new float[] { 1f, 1f, 1f }); + var identityEigen = new Vector3[] { new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1) }; + var nonDiag = new Matrix3x3(new float[] { 0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f }); + var nonDiagT = new Matrix3x3(new float[] { 0f, 3f, 6f, 1f, 4f, 7f, 2f, 5f, 8f }); + var eigenTest = new Matrix3x3(1f); + var eigenValues = new Vector3(3f, 0f, 0f); + var eigenVectors = new Vector3[] { Vector3.one * 0.57735f, new Vector3(-0.408248f, -0.408248f, 0.816497f), new Vector3(0.7071f, -0.7071f, 0) }; + + // Determinant + Assert.AreEqual(1f, identity.Determinant()); + + // Trace + Assert.AreEqual(3f, identity.Trace()); + + // IsDiagonal + Assert.IsTrue(identity.IsDiagonal()); + Assert.IsFalse(nonDiag.IsDiagonal()); + + // Transpose + Assert.AreEqual(identity.elements, identity.Transpose().elements); + Assert.AreEqual(nonDiagT.elements, nonDiag.Transpose().elements); + + // DiagonalizeRealSymmetric + // Identity + Vector3 values; + Vector3[] vectors; + identity.DiagonalizeRealSymmetric(out values, out vectors); + Assert.AreEqual(Vector3.one, values); + Assert.AreEqual(identityEigen, vectors); + + // Non-identity + Vector3 nonDiagValues; + Vector3[] nonDiagVectors; + eigenTest.DiagonalizeRealSymmetric(out nonDiagValues, out nonDiagVectors); + Assert.IsTrue(Vector3.Distance(eigenValues, nonDiagValues) < delta); + Assert.AreEqual(eigenVectors.Length, nonDiagVectors.Length); + for (int i = 0; i < eigenVectors.Length; i++) + { + Assert.IsTrue(Vector3.Distance(eigenVectors[i], nonDiagVectors[i]) < delta); + } } } } diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/MeshProcessing.meta b/com.unity.robotics.urdf-importer/Tests/Runtime/MeshProcessing.meta new file mode 100644 index 00000000..afc83f4a --- /dev/null +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/MeshProcessing.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 44e0aa47ef2dc4cbeb4d7fb17999a225 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/MeshProcessing/StlAssetPostProcessorTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/MeshProcessing/StlAssetPostProcessorTests.cs new file mode 100644 index 00000000..cc87ad5e --- /dev/null +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/MeshProcessing/StlAssetPostProcessorTests.cs @@ -0,0 +1,51 @@ +using System.IO; +using System.Collections.Generic; +using NUnit.Framework; +using UnityEditor; +using UnityEngine; + +namespace Unity.Robotics.UrdfImporter.Tests +{ + public class StlAssetPostProcessorTests + { + const string k_AssetRoot = "Assets/Tests/Runtime/StlAssetPostProcessorTests"; + const string k_StlCubeSourcePath = "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/Assets/URDF/cube/meshes/cube.stl"; + string m_StlCubeCopyPath; + + [SetUp] + public void SetUp() + { + m_StlCubeCopyPath = k_AssetRoot + "/cube.stl"; + RuntimeUrdf.SetRuntimeMode(false); + Directory.CreateDirectory(k_AssetRoot); + } + + [Test] + public void StlPostprocess_NewStl_DontCreatePrefab() + { + // make a new copy of the stl file + Assert.IsTrue(AssetDatabase.CopyAsset(k_StlCubeSourcePath, m_StlCubeCopyPath)); + Assert.IsTrue(RuntimeUrdf.AssetExists(m_StlCubeCopyPath)); + + // make sure the .asset file is not automatically created + var meshAssetPath = StlAssetPostProcessor.GetMeshAssetPath(m_StlCubeCopyPath, 0); + Assert.IsFalse(RuntimeUrdf.AssetExists(meshAssetPath)); + + // make sure the .prefab file is not automatically created + var prefabPath = StlAssetPostProcessor.GetPrefabAssetPath(m_StlCubeCopyPath); + Assert.IsFalse(RuntimeUrdf.AssetExists(prefabPath)); + + // make sure the .asset and .prefab file are created when requested + StlAssetPostProcessor.PostprocessStlFile(m_StlCubeCopyPath); + Assert.IsTrue(RuntimeUrdf.AssetExists(meshAssetPath)); + Assert.IsTrue(RuntimeUrdf.AssetExists(prefabPath)); + } + + [TearDown] + public void TearDown() + { + List outFailedPaths = new List(); + AssetDatabase.DeleteAssets(new string[] {"Assets/Tests"}, outFailedPaths); + } + } +} \ No newline at end of file diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/MeshProcessing/StlAssetPostProcessorTests.cs.meta b/com.unity.robotics.urdf-importer/Tests/Runtime/MeshProcessing/StlAssetPostProcessorTests.cs.meta new file mode 100644 index 00000000..c407c2b7 --- /dev/null +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/MeshProcessing/StlAssetPostProcessorTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0d226d856c98644969b886d1368d95d3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeURDFTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeURDFTests.cs deleted file mode 100644 index c2a246bd..00000000 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeURDFTests.cs +++ /dev/null @@ -1,156 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using NUnit.Framework; -using UnityEngine; -using UnityEditor; -using UnityEngine.TestTools; -using RosSharp.Urdf; - -public class RuntimeURDFTests -{ - string createAssetPath = "Assets/Tests/Runtime"; - string createFolderPath = "Assets/Tests/Runtime/RuntimeURDF"; - UnityEngine.Object testObject; - - [SetUp] - public void SetUp() - { - RuntimeURDF.runtimeModeEnabled = false; - AssetDatabase.CreateFolder("Assets", "Tests"); - AssetDatabase.CreateFolder("Assets/Tests", "Runtime"); - - testObject = PrefabUtility.SaveAsPrefabAsset(new GameObject("TestAsset"), $"{createAssetPath}/TestAsset.prefab"); - } - - [Test] - public void IsRuntimeMode_True() - { - RuntimeURDF.runtimeModeEnabled = true; - Assert.IsTrue(RuntimeURDF.IsRuntimeMode()); - } - - [Test] - public void SetRuntimeMode_False() - { - RuntimeURDF.SetRuntimeMode(false); - Assert.IsFalse(RuntimeURDF.IsRuntimeMode()); - } - - [Test] - public void AssetDatabase_LoadAssetAtPath_Script() - { - RuntimeURDF.SetRuntimeMode(false); - string path = "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeURDFTests.cs"; - Assert.IsNotNull(RuntimeURDF.AssetDatabase_LoadAssetAtPath(path)); - } - - [Test] - public void AssetDatabase_LoadAssetAtPath_Object() - { - RuntimeURDF.SetRuntimeMode(false); - string path = "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeURDFTests.cs"; - Assert.IsNotNull(RuntimeURDF.AssetDatabase_LoadAssetAtPath(path, typeof(UnityEngine.Object))); - } - - [Test] - public void AssetDatabase_IsValidFolder_EditorMode() - { - RuntimeURDF.runtimeModeEnabled = false; - Assert.IsTrue(RuntimeURDF.AssetDatabase_IsValidFolder("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport")); - Assert.IsFalse(RuntimeURDF.AssetDatabase_IsValidFolder("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/Does/Not/Exist")); - } - - [Test] - public void AssetDatabase_CreateFolder_AssetAsRoot() - { - RuntimeURDF.runtimeModeEnabled = false; - string createdGUID = RuntimeURDF.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "RuntimeURDF"); - string compareGUID = AssetDatabase.GUIDFromAssetPath(createFolderPath).ToString(); - - // Verify valid folder - Assert.IsTrue(AssetDatabase.IsValidFolder(createFolderPath)); - // Verify matching GUID - Assert.AreEqual(createdGUID, compareGUID); - - // Try creating the same folder again - createdGUID = RuntimeURDF.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "RuntimeURDF"); - Assert.AreEqual(createdGUID, compareGUID); - } - - [Test] - public void AssetDatabase_MoveAsset_AssetAsRoot() - { - RuntimeURDF.runtimeModeEnabled = false; - Assert.IsTrue(RuntimeURDF.AssetDatabase_MoveAsset($"{createAssetPath}/TestAsset.prefab", "Assets/Tests/TestAsset.prefab").Length == 0); - - // Move back for other tests - AssetDatabase.MoveAsset("Assets/Tests/TestAsset.prefab", $"{createAssetPath}/TestAsset.prefab"); - } - - [Test] - public void AssetDatabase_FindAssets_AssetAsRoot() - { - RuntimeURDF.runtimeModeEnabled = false; - Assert.IsTrue(RuntimeURDF.AssetDatabase_FindAssets("TestAsset", new string[] {"Assets/Tests"}).Length > 0); - } - - [Test] - public void AssetDatabase_GUIDToAssetPath_AssetAsRoot() - { - RuntimeURDF.runtimeModeEnabled = false; - string createdGUID = RuntimeURDF.AssetDatabase_CreateFolder(createAssetPath, "RuntimeURDF"); - Assert.AreEqual(createFolderPath, RuntimeURDF.AssetDatabase_GUIDToAssetPath(AssetDatabase.AssetPathToGUID(createFolderPath))); - } - - [Test] - public void AssetDatabase_GetAssetPath_AssetAsRoot() - { - RuntimeURDF.runtimeModeEnabled = false; - Assert.AreEqual($"{createAssetPath}/TestAsset.prefab", RuntimeURDF.AssetDatabase_GetAssetPath(testObject)); - } - - [Test] - public void PrefabUtility_GetCorrespondingObjectFromSource_AssetAsRoot() - { - RuntimeURDF.runtimeModeEnabled = false; - var instantiated = PrefabUtility.InstantiatePrefab(testObject); - Assert.AreEqual(testObject, RuntimeURDF.PrefabUtility_GetCorrespondingObjectFromSource(instantiated)); - } - - [Test] - public void PrefabUtility_SaveAsPrefabAsset_AssetAsRoot() - { - RuntimeURDF.runtimeModeEnabled = false; - Assert.IsNotNull(RuntimeURDF.PrefabUtility_SaveAsPrefabAsset(new GameObject("TestAsset2"), $"{createAssetPath}/TestAsset2.prefab")); - } - - [Test] - public void AssetDatabase_GetBuiltinExtraResource_Sprite() - { - RuntimeURDF.runtimeModeEnabled = false; - Assert.IsNotNull(RuntimeURDF.AssetDatabase_GetBuiltinExtraResource("UI/Skin/Background.psd")); - } - - [Test] - public void AssetDatabase_CreateAsset_GameObject() - { - RuntimeURDF.runtimeModeEnabled = false; - RuntimeURDF.AssetDatabase_CreateAsset(new TextAsset("TextAsset content"), $"{createAssetPath}/TestAsset3", true); - Assert.IsNotNull(AssetDatabase.FindAssets("TestAsset3", new string[] {createAssetPath})); - } - - [Test] - public void PrefabUtility_InstantiatePrefab_GameObject() - { - RuntimeURDF.runtimeModeEnabled = false; - Assert.IsNotNull(RuntimeURDF.PrefabUtility_InstantiatePrefab(testObject)); - } - - [TearDown] - public void TearDown() - { - List outFailedPaths = new List(); - AssetDatabase.DeleteAssets(new string[] {"Assets/Tests"}, outFailedPaths); - } -} diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeUrdfTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeUrdfTests.cs new file mode 100644 index 00000000..dfc3724e --- /dev/null +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeUrdfTests.cs @@ -0,0 +1,179 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using NUnit.Framework; +using UnityEngine; +using UnityEditor; +using UnityEngine.TestTools; +using Unity.Robotics.UrdfImporter; + +namespace Unity.Robotics.UrdfImporter.Tests +{ + public class RuntimeUrdfTests + { + string createAssetPath = "Assets/Tests/Runtime"; + string createFolderPath = "Assets/Tests/Runtime/RuntimeUrdf"; + UnityEngine.Object testObject; + + [SetUp] + public void SetUp() + { + RuntimeUrdf.runtimeModeEnabled = false; + AssetDatabase.CreateFolder("Assets", "Tests"); + AssetDatabase.CreateFolder("Assets/Tests", "Runtime"); + + testObject = PrefabUtility.SaveAsPrefabAsset(new GameObject("TestAsset"), $"{createAssetPath}/TestAsset.prefab"); + } + + [Test] + public void IsRuntimeMode_True() + { + RuntimeUrdf.runtimeModeEnabled = true; + Assert.IsTrue(RuntimeUrdf.IsRuntimeMode()); + } + + [Test] + public void SetRuntimeMode_False() + { + RuntimeUrdf.SetRuntimeMode(false); + Assert.IsFalse(RuntimeUrdf.IsRuntimeMode()); + } + + [Test] + public void AssetDatabase_LoadAssetAtPath_Script() + { + RuntimeUrdf.SetRuntimeMode(false); + string path = "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeUrdfTests.cs"; + Assert.IsNotNull(RuntimeUrdf.AssetDatabase_LoadAssetAtPath(path)); + } + + [Test] + public void AssetDatabase_LoadAssetAtPath_Object() + { + RuntimeUrdf.SetRuntimeMode(false); + string path = "Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeUrdfTests.cs"; + Assert.IsNotNull(RuntimeUrdf.AssetDatabase_LoadAssetAtPath(path, typeof(UnityEngine.Object))); + } + + [Test] + public void AssetDatabase_IsValidFolder_EditorMode() + { + RuntimeUrdf.runtimeModeEnabled = false; + Assert.IsTrue(RuntimeUrdf.AssetDatabase_IsValidFolder("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport")); + Assert.IsFalse(RuntimeUrdf.AssetDatabase_IsValidFolder("Packages/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/Does/Not/Exist")); + } + + [Test] + public void AssetDatabase_CreateFolder_AssetAsRoot() + { + RuntimeUrdf.runtimeModeEnabled = false; + string createdGUID = RuntimeUrdf.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "RuntimeUrdf"); + string compareGUID = AssetDatabase.GUIDFromAssetPath(createFolderPath).ToString(); + + // Verify valid folder + Assert.IsTrue(AssetDatabase.IsValidFolder(createFolderPath)); + + // Verify matching GUID + Assert.AreEqual(createdGUID, compareGUID); + + // Try creating the same folder again + createdGUID = RuntimeUrdf.AssetDatabase_CreateFolder("Assets/Tests/Runtime", "RuntimeUrdf"); + Assert.AreEqual(createdGUID, compareGUID); + } + + [Test] + public void AssetDatabase_MoveAsset_AssetAsRoot() + { + RuntimeUrdf.runtimeModeEnabled = false; + Assert.IsTrue(RuntimeUrdf.AssetDatabase_MoveAsset($"{createAssetPath}/TestAsset.prefab", "Assets/Tests/TestAsset.prefab").Length == 0); + + // Move back for other tests + AssetDatabase.MoveAsset("Assets/Tests/TestAsset.prefab", $"{createAssetPath}/TestAsset.prefab"); + } + + [Test] + public void AssetDatabase_FindAssets_AssetAsRoot() + { + RuntimeUrdf.runtimeModeEnabled = false; + Assert.IsTrue(RuntimeUrdf.AssetDatabase_FindAssets("TestAsset", new string[] { "Assets/Tests" }).Length > 0); + } + + [Test] + public void AssetDatabase_GUIDToAssetPath_AssetAsRoot() + { + RuntimeUrdf.runtimeModeEnabled = false; + string createdGUID = RuntimeUrdf.AssetDatabase_CreateFolder(createAssetPath, "RuntimeUrdf"); + Assert.AreEqual(createFolderPath, RuntimeUrdf.AssetDatabase_GUIDToAssetPath(AssetDatabase.AssetPathToGUID(createFolderPath))); + } + + [Test] + public void AssetDatabase_GetAssetPath_AssetAsRoot() + { + RuntimeUrdf.runtimeModeEnabled = false; + Assert.AreEqual($"{createAssetPath}/TestAsset.prefab", RuntimeUrdf.AssetDatabase_GetAssetPath(testObject)); + } + + [Test] + public void PrefabUtility_GetCorrespondingObjectFromSource_AssetAsRoot() + { + RuntimeUrdf.runtimeModeEnabled = false; + var instantiated = PrefabUtility.InstantiatePrefab(testObject); + Assert.AreEqual(testObject, RuntimeUrdf.PrefabUtility_GetCorrespondingObjectFromSource(instantiated)); + } + + [Test] + public void PrefabUtility_SaveAsPrefabAsset_AssetAsRoot() + { + RuntimeUrdf.runtimeModeEnabled = false; + Assert.IsNotNull(RuntimeUrdf.PrefabUtility_SaveAsPrefabAsset(new GameObject("TestAsset2"), $"{createAssetPath}/TestAsset2.prefab")); + } + + [Test] + public void AssetDatabase_GetBuiltinExtraResource_Sprite() + { + RuntimeUrdf.runtimeModeEnabled = false; + Assert.IsNotNull(RuntimeUrdf.AssetDatabase_GetBuiltinExtraResource("UI/Skin/Background.psd")); + } + + [Test] + public void AssetDatabase_CreateAsset_GameObject() + { + RuntimeUrdf.runtimeModeEnabled = false; + RuntimeUrdf.AssetDatabase_CreateAsset(new TextAsset("TextAsset content"), $"{createAssetPath}/TestAsset3", true); + Assert.IsNotNull(AssetDatabase.FindAssets("TestAsset3", new string[] { createAssetPath })); + } + + [Test] + public void PrefabUtility_InstantiatePrefab_GameObject() + { + RuntimeUrdf.runtimeModeEnabled = false; + Assert.IsNotNull(RuntimeUrdf.PrefabUtility_InstantiatePrefab(testObject)); + } + + [Test] + public void AssetExists_True() + { + RuntimeUrdf.SetRuntimeMode(false); + Assert.IsTrue(RuntimeUrdf.AssetExists($"{createAssetPath}/TestAsset.prefab")); + Assert.IsTrue(RuntimeUrdf.AssetExists($"{createAssetPath}/tEstAsset.Prefab", true)); + } + + [Test] + public void AssetExists_False() + { + RuntimeUrdf.SetRuntimeMode(false); + Assert.IsFalse(RuntimeUrdf.AssetExists($"{createAssetPath}/tEstAsset.Prefab")); // case + Assert.IsFalse(RuntimeUrdf.AssetExists($"{createAssetPath}/TestAsset.prefabs", true)); + Assert.IsFalse(RuntimeUrdf.AssetExists($"{createAssetPath}/TestAsset.prefa", true)); + Assert.IsFalse(RuntimeUrdf.AssetExists($"{createAssetPath}/estAsset.prefab", true)); + Assert.IsFalse(RuntimeUrdf.AssetExists($"{createAssetPath}/sub/TestAsset.prefab", true)); + } + + [TearDown] + public void TearDown() + { + List outFailedPaths = new List(); + AssetDatabase.DeleteAssets(new string[] { "Assets/Tests" }, outFailedPaths); + } + } +} diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeURDFTests.cs.meta b/com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeUrdfTests.cs.meta similarity index 100% rename from com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeURDFTests.cs.meta rename to com.unity.robotics.urdf-importer/Tests/Runtime/RuntimeImport/RuntimeUrdfTests.cs.meta diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/Unity.Robotics.UrdfImporter.Runtime.Tests.asmdef b/com.unity.robotics.urdf-importer/Tests/Runtime/Unity.Robotics.UrdfImporter.Runtime.Tests.asmdef index ba16fd8e..c7d4ab64 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/Unity.Robotics.UrdfImporter.Runtime.Tests.asmdef +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/Unity.Robotics.UrdfImporter.Runtime.Tests.asmdef @@ -3,7 +3,7 @@ "rootNamespace": "", "references": [ "UnityEngine.TestRunner", - "Unity.Robotics.URDFImporter", + "Unity.Robotics.UrdfImporter", "vhacd" ], "includePlatforms": [], diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuousTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuousTests.cs index 426f8f8a..8d47ea61 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuousTests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointContinuousTests.cs @@ -1,137 +1,140 @@ using NUnit.Framework; -using RosSharp.Urdf; +using Unity.Robotics.UrdfImporter; using UnityEngine; -using Joint = RosSharp.Urdf.Joint; +using Joint = Unity.Robotics.UrdfImporter.Joint; -public class TestUrdfJointContinuous : UrdfJointContinuous +namespace Unity.Robotics.UrdfImporter.Tests { - public void TestImportJointData(Joint joint) + public class TestUrdfJointContinuous : UrdfJointContinuous { - unityJoint = gameObject.GetComponent(); - ImportJointData(joint); + public void TestImportJointData(Joint joint) + { + unityJoint = gameObject.GetComponent(); + ImportJointData(joint); + } + + public Joint TestExportSpecificJointData(Joint joint) + { + unityJoint = gameObject.GetComponent(); + return ExportSpecificJointData(joint); + } + + public void SetAxisOfMotion(Vector3 axisofMotion) => this.axisofMotion = axisofMotion; + public void Dynamics(Joint.Dynamics dynamics) => SetDynamics(dynamics); } - public Joint TestExportSpecificJointData(Joint joint) + public class UrdfJointContinuousTests { - unityJoint = gameObject.GetComponent(); - return ExportSpecificJointData(joint); - } - - public void SetAxisOfMotion(Vector3 axisofMotion) => this.axisofMotion = axisofMotion; - public void Dynamics(Joint.Dynamics dynamics) => SetDynamics(dynamics); -} - -public class UrdfJointContinuousTests -{ - [Test] - public void Create_UrdfJointContinuous_Succeeds() - { - GameObject linkObject = new GameObject("link"); - UrdfJoint joint = UrdfJointContinuous.Create(linkObject); - UrdfJoint urdfJoint = linkObject.GetComponent(); - ArticulationBody articulationBody = linkObject.GetComponent(); - - Assert.IsTrue(joint is UrdfJointContinuous); - Assert.AreEqual(joint, urdfJoint); - Assert.AreEqual(ArticulationJointType.RevoluteJoint, articulationBody.jointType); - - Object.DestroyImmediate(linkObject); - } - - [Test] - public void GetPositionVelocityEffort_Succeeds() - { - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; - - UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); - UrdfJoint joint = UrdfJointContinuous.Create(linkObject); - ArticulationBody articulationBody = linkObject.GetComponent(); - articulationBody.jointPosition = new ArticulationReducedSpace(1, 2, 3); - articulationBody.jointVelocity = new ArticulationReducedSpace(4, 5, 6); - articulationBody.jointForce = new ArticulationReducedSpace(7, 8, 9); - - Assert.AreEqual(1, joint.GetPosition()); - Assert.AreEqual(4, joint.GetVelocity()); - Assert.AreEqual(7, joint.GetEffort()); - - Object.DestroyImmediate(baseObject); - } - - [Test] - public void UpdateJointState_Succeeds() - { - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; - - UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); - UrdfJoint joint = UrdfJointContinuous.Create(linkObject); - ArticulationBody articulationBody = linkObject.GetComponent(); - - Assert.AreEqual(0, articulationBody.xDrive.target); - joint.UpdateJointState(1); - Assert.AreEqual(1, articulationBody.xDrive.target); - - Object.DestroyImmediate(baseObject); - } - - [Test] - public void ImportJointData_Succeeds() - { - var joint = new Joint( - name: "custom_joint", type: "continuous", parent: "base", child: "link", - axis: new Joint.Axis(new double[] { 1, 2, 3 }), - limit: new Joint.Limit(4, 5, 6, 7), - dynamics: new Joint.Dynamics(8, 9)); - - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; - - UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); - TestUrdfJointContinuous urdfJoint = linkObject.AddComponent(); - ArticulationBody articulationBody = linkObject.GetComponent(); - urdfJoint.TestImportJointData(joint); - - Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockX); - Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockY); - Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockZ); - Assert.AreEqual(ArticulationDofLock.FreeMotion, articulationBody.twistLock); - - Quaternion expectedAnchorRotation = new Quaternion(); - expectedAnchorRotation.SetFromToRotation(new Vector3(1, 0, 0), -new Vector3(-2, 3, 1)); - Assert.AreEqual(expectedAnchorRotation, articulationBody.anchorRotation); - - Assert.AreEqual(6, articulationBody.xDrive.forceLimit); - Assert.AreEqual(7, articulationBody.maxAngularVelocity); - Assert.AreEqual(8, articulationBody.linearDamping); - Assert.AreEqual(8, articulationBody.angularDamping); - Assert.AreEqual(9, articulationBody.jointFriction); - - Object.DestroyImmediate(baseObject); - } - - [Test] - public void ExportSpecificJointData_Succeeds() - { - GameObject linkObject = new GameObject("link"); - TestUrdfJointContinuous urdfJoint = linkObject.AddComponent(); - ArticulationBody articulationBody = linkObject.GetComponent(); - urdfJoint.SetAxisOfMotion(new Vector3(1.2345678f, 2.3456789f, 3.4567891f)); - urdfJoint.Dynamics(new Joint.Dynamics(4, 5)); - - var joint = new Joint( - name: "custom_joint", type: "continuous", parent: "base", child: "link"); - urdfJoint.TestExportSpecificJointData(joint); - - UnityEngine.Assertions.Assert.AreApproximatelyEqual(1.234568f, (float)joint.axis.xyz[0]); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(2.345679f, (float)joint.axis.xyz[1]); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(3.456789f, (float)joint.axis.xyz[2]); - Assert.AreEqual(4, joint.dynamics.damping); - Assert.AreEqual(5, joint.dynamics.friction); - - Object.DestroyImmediate(linkObject); + [Test] + public void Create_UrdfJointContinuous_Succeeds() + { + GameObject linkObject = new GameObject("link"); + UrdfJoint joint = UrdfJointContinuous.Create(linkObject); + UrdfJoint urdfJoint = linkObject.GetComponent(); + ArticulationBody articulationBody = linkObject.GetComponent(); + + Assert.IsTrue(joint is UrdfJointContinuous); + Assert.AreEqual(joint, urdfJoint); + Assert.AreEqual(ArticulationJointType.RevoluteJoint, articulationBody.jointType); + + Object.DestroyImmediate(linkObject); + } + + [Test] + public void GetPositionVelocityEffort_Succeeds() + { + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; + + UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); + UrdfJoint joint = UrdfJointContinuous.Create(linkObject); + ArticulationBody articulationBody = linkObject.GetComponent(); + articulationBody.jointPosition = new ArticulationReducedSpace(1, 2, 3); + articulationBody.jointVelocity = new ArticulationReducedSpace(4, 5, 6); + articulationBody.jointForce = new ArticulationReducedSpace(7, 8, 9); + + Assert.AreEqual(1, joint.GetPosition()); + Assert.AreEqual(4, joint.GetVelocity()); + Assert.AreEqual(7, joint.GetEffort()); + + Object.DestroyImmediate(baseObject); + } + + [Test] + public void UpdateJointState_Succeeds() + { + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; + + UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); + UrdfJoint joint = UrdfJointContinuous.Create(linkObject); + ArticulationBody articulationBody = linkObject.GetComponent(); + + Assert.AreEqual(0, articulationBody.xDrive.target); + joint.UpdateJointState(1); + Assert.AreEqual(1, articulationBody.xDrive.target); + + Object.DestroyImmediate(baseObject); + } + + [Test] + public void ImportJointData_Succeeds() + { + var joint = new Joint( + name: "custom_joint", type: "continuous", parent: "base", child: "link", + axis: new Joint.Axis(new double[] { 1, 2, 3 }), + limit: new Joint.Limit(4, 5, 6, 7), + dynamics: new Joint.Dynamics(8, 9)); + + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; + + UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); + TestUrdfJointContinuous urdfJoint = linkObject.AddComponent(); + ArticulationBody articulationBody = linkObject.GetComponent(); + urdfJoint.TestImportJointData(joint); + + Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockX); + Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockY); + Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockZ); + Assert.AreEqual(ArticulationDofLock.FreeMotion, articulationBody.twistLock); + + Quaternion expectedAnchorRotation = new Quaternion(); + expectedAnchorRotation.SetFromToRotation(new Vector3(1, 0, 0), -new Vector3(-2, 3, 1)); + Assert.AreEqual(expectedAnchorRotation, articulationBody.anchorRotation); + + Assert.AreEqual(6, articulationBody.xDrive.forceLimit); + Assert.AreEqual(7, articulationBody.maxAngularVelocity); + Assert.AreEqual(8, articulationBody.linearDamping); + Assert.AreEqual(8, articulationBody.angularDamping); + Assert.AreEqual(9, articulationBody.jointFriction); + + Object.DestroyImmediate(baseObject); + } + + [Test] + public void ExportSpecificJointData_Succeeds() + { + GameObject linkObject = new GameObject("link"); + TestUrdfJointContinuous urdfJoint = linkObject.AddComponent(); + ArticulationBody articulationBody = linkObject.GetComponent(); + urdfJoint.SetAxisOfMotion(new Vector3(1.2345678f, 2.3456789f, 3.4567891f)); + urdfJoint.Dynamics(new Joint.Dynamics(4, 5)); + + var joint = new Joint( + name: "custom_joint", type: "continuous", parent: "base", child: "link"); + urdfJoint.TestExportSpecificJointData(joint); + + UnityEngine.Assertions.Assert.AreApproximatelyEqual(1.234568f, (float)joint.axis.xyz[0]); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(2.345679f, (float)joint.axis.xyz[1]); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(3.456789f, (float)joint.axis.xyz[2]); + Assert.AreEqual(4, joint.dynamics.damping); + Assert.AreEqual(5, joint.dynamics.friction); + + Object.DestroyImmediate(linkObject); + } } } diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanarTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanarTests.cs index e090f17a..2f4cfad5 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanarTests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPlanarTests.cs @@ -1,198 +1,202 @@ using System.Collections.Generic; using NUnit.Framework; -using RosSharp.Urdf; +using Unity.Robotics.UrdfImporter; using UnityEngine; -using Joint = RosSharp.Urdf.Joint; +using Joint = Unity.Robotics.UrdfImporter.Joint; -public class TestUrdfJointPlanar : UrdfJointPlanar +namespace Unity.Robotics.UrdfImporter.Tests { - public void TestImportJointData(Joint joint) - { - unityJoint = gameObject.GetComponent(); - ImportJointData(joint); - } - public Joint TestExportSpecificJointData(Joint joint) + public class TestUrdfJointPlanar : UrdfJointPlanar { - unityJoint = gameObject.GetComponent(); - return ExportSpecificJointData(joint); - } + public void TestImportJointData(Joint joint) + { + unityJoint = gameObject.GetComponent(); + ImportJointData(joint); + } - public Joint.Limit TestExportLimitData => ExportLimitData(); - public bool TestIsJointAxisDefined => IsJointAxisDefined(); + public Joint TestExportSpecificJointData(Joint joint) + { + unityJoint = gameObject.GetComponent(); + return ExportSpecificJointData(joint); + } - public void SetAxisOfMotion(Vector3 axisofMotion) => this.axisofMotion = axisofMotion; - public void Dynamics(Joint.Dynamics dynamics) => SetDynamics(dynamics); -} + public Joint.Limit TestExportLimitData => ExportLimitData(); + public bool TestIsJointAxisDefined => IsJointAxisDefined(); -public class UrdfJointPlanarTests -{ - [Test] - public void Create_UrdfJointPlanar_Succeeds() + public void SetAxisOfMotion(Vector3 axisofMotion) => this.axisofMotion = axisofMotion; + public void Dynamics(Joint.Dynamics dynamics) => SetDynamics(dynamics); + } + + public class UrdfJointPlanarTests { - GameObject linkObject = new GameObject("link"); - UrdfJoint joint = UrdfJointPlanar.Create(linkObject); - UrdfJoint urdfJoint = linkObject.GetComponent(); - ArticulationBody articulationBody = linkObject.GetComponent(); + [Test] + public void Create_UrdfJointPlanar_Succeeds() + { + GameObject linkObject = new GameObject("link"); + UrdfJoint joint = UrdfJointPlanar.Create(linkObject); + UrdfJoint urdfJoint = linkObject.GetComponent(); + ArticulationBody articulationBody = linkObject.GetComponent(); - Assert.IsTrue(joint is UrdfJointPlanar); - Assert.AreEqual(joint, urdfJoint); - Assert.AreEqual(ArticulationJointType.PrismaticJoint, articulationBody.jointType); + Assert.IsTrue(joint is UrdfJointPlanar); + Assert.AreEqual(joint, urdfJoint); + Assert.AreEqual(ArticulationJointType.PrismaticJoint, articulationBody.jointType); - Object.DestroyImmediate(linkObject); - } + Object.DestroyImmediate(linkObject); + } - [Test] - public void GetPosition_Succeeds() - { - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; - linkObject.transform.localPosition = new Vector3(1, 2, 3); + [Test] + public void GetPosition_Succeeds() + { + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; + linkObject.transform.localPosition = new Vector3(1, 2, 3); - UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); - UrdfJoint joint = UrdfJointPlanar.Create(linkObject); + UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); + UrdfJoint joint = UrdfJointPlanar.Create(linkObject); - Assert.AreEqual(linkObject.transform.localPosition.magnitude, joint.GetPosition()); + Assert.AreEqual(linkObject.transform.localPosition.magnitude, joint.GetPosition()); - Object.DestroyImmediate(baseObject); - } + Object.DestroyImmediate(baseObject); + } - [Test, TestCaseSource("AxisType")] - public void ImportJointData_DefaultAxis_Succeeds(Joint.Axis axis, Quaternion expectedAnchorRotation) - { - var joint = new Joint( - name: "custom_joint", type: "continuous", parent: "base", child: "link", - axis: axis); + [Test, TestCaseSource("AxisType")] + public void ImportJointData_DefaultAxis_Succeeds(Joint.Axis axis, Quaternion expectedAnchorRotation) + { + var joint = new Joint( + name: "custom_joint", type: "continuous", parent: "base", child: "link", + axis: axis); - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; - UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); - TestUrdfJointPlanar urdfJoint = linkObject.AddComponent(); - ArticulationBody articulationBody = linkObject.GetComponent(); - urdfJoint.TestImportJointData(joint); + UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); + TestUrdfJointPlanar urdfJoint = linkObject.AddComponent(); + ArticulationBody articulationBody = linkObject.GetComponent(); + urdfJoint.TestImportJointData(joint); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(expectedAnchorRotation.w, articulationBody.anchorRotation.w); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(expectedAnchorRotation.x, articulationBody.anchorRotation.x); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(expectedAnchorRotation.y, articulationBody.anchorRotation.y); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(expectedAnchorRotation.z, articulationBody.anchorRotation.z); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(expectedAnchorRotation.w, articulationBody.anchorRotation.w); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(expectedAnchorRotation.x, articulationBody.anchorRotation.x); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(expectedAnchorRotation.y, articulationBody.anchorRotation.y); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(expectedAnchorRotation.z, articulationBody.anchorRotation.z); - Object.DestroyImmediate(baseObject); - } + Object.DestroyImmediate(baseObject); + } - private static IEnumerable AxisType - { - get + private static IEnumerable AxisType { - yield return new TestCaseData(null, Quaternion.Euler(new Vector3(0, -90, 0))); - yield return new TestCaseData(new Joint.Axis(new double[] { 1, 0, 0 }), Quaternion.Euler(new Vector3(0, -90, 0))); - yield return new TestCaseData(new Joint.Axis(new double[] { 0, 1, 0 }), Quaternion.Euler(new Vector3(0, 0, 0))); - yield return new TestCaseData(new Joint.Axis(new double[] { 0, 0, 1 }), Quaternion.Euler(new Vector3(0, 0, 90))); + get + { + yield return new TestCaseData(null, Quaternion.Euler(new Vector3(0, -90, 0))); + yield return new TestCaseData(new Joint.Axis(new double[] { 1, 0, 0 }), Quaternion.Euler(new Vector3(0, -90, 0))); + yield return new TestCaseData(new Joint.Axis(new double[] { 0, 1, 0 }), Quaternion.Euler(new Vector3(0, 0, 0))); + yield return new TestCaseData(new Joint.Axis(new double[] { 0, 0, 1 }), Quaternion.Euler(new Vector3(0, 0, 90))); + } } - } - - [Test] - public void ImportJointData_SpecificLimit_Succeeds() - { - var joint = new Joint( - name: "custom_joint", type: "planar", parent: "base", child: "link", - limit: new Joint.Limit(4, 5, 6, 7), - dynamics: new Joint.Dynamics(8, 9)); - - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; - - UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); - TestUrdfJointPlanar urdfJoint = linkObject.AddComponent(); - ArticulationBody articulationBody = linkObject.GetComponent(); - urdfJoint.TestImportJointData(joint); - - Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockX); - Assert.AreEqual(ArticulationDofLock.LimitedMotion, articulationBody.linearLockY); - Assert.AreEqual(ArticulationDofLock.LimitedMotion, articulationBody.linearLockZ); - - Assert.AreEqual(4, articulationBody.xDrive.lowerLimit); - Assert.AreEqual(4, articulationBody.yDrive.lowerLimit); - Assert.AreEqual(4, articulationBody.zDrive.lowerLimit); - Assert.AreEqual(5, articulationBody.xDrive.upperLimit); - Assert.AreEqual(5, articulationBody.yDrive.upperLimit); - Assert.AreEqual(5, articulationBody.zDrive.upperLimit); - Assert.AreEqual(6, articulationBody.xDrive.forceLimit); - Assert.AreEqual(6, articulationBody.yDrive.forceLimit); - Assert.AreEqual(6, articulationBody.zDrive.forceLimit); - Assert.AreEqual(7, articulationBody.maxLinearVelocity); - - Object.DestroyImmediate(baseObject); - } - [Test] - public void ExportSpecificJointData_Succeeds() - { - GameObject linkObject = new GameObject("link"); - TestUrdfJointPlanar urdfJoint = linkObject.AddComponent(); - urdfJoint.SetAxisOfMotion(new Vector3(1.2345678f, 2.3456789f, 3.4567891f)); - urdfJoint.Dynamics(new Joint.Dynamics(4, 5)); - - var joint = new Joint( - name: "custom_joint", type: "planar", parent: "base", child: "link"); - urdfJoint.TestExportSpecificJointData(joint); - - UnityEngine.Assertions.Assert.AreApproximatelyEqual(1.234568f, (float)joint.axis.xyz[0]); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(2.345679f, (float)joint.axis.xyz[1]); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(3.456789f, (float)joint.axis.xyz[2]); - Assert.AreEqual(4, joint.dynamics.damping); - Assert.AreEqual(5, joint.dynamics.friction); - - Object.DestroyImmediate(linkObject); - } - - [Test] - public void ExportLimitData_Succeeds() - { - GameObject linkObject = new GameObject("link"); - TestUrdfJointPlanar joint = linkObject.AddComponent(); - ArticulationBody articulationBody = linkObject.GetComponent(); - articulationBody.yDrive = new ArticulationDrive() + [Test] + public void ImportJointData_SpecificLimit_Succeeds() { - lowerLimit = 1, - upperLimit = 2, - }; - Joint.Limit limit = joint.TestExportLimitData; + var joint = new Joint( + name: "custom_joint", type: "planar", parent: "base", child: "link", + limit: new Joint.Limit(4, 5, 6, 7), + dynamics: new Joint.Dynamics(8, 9)); + + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; + + UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); + TestUrdfJointPlanar urdfJoint = linkObject.AddComponent(); + ArticulationBody articulationBody = linkObject.GetComponent(); + urdfJoint.TestImportJointData(joint); + + Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockX); + Assert.AreEqual(ArticulationDofLock.LimitedMotion, articulationBody.linearLockY); + Assert.AreEqual(ArticulationDofLock.LimitedMotion, articulationBody.linearLockZ); + + Assert.AreEqual(4, articulationBody.xDrive.lowerLimit); + Assert.AreEqual(4, articulationBody.yDrive.lowerLimit); + Assert.AreEqual(4, articulationBody.zDrive.lowerLimit); + Assert.AreEqual(5, articulationBody.xDrive.upperLimit); + Assert.AreEqual(5, articulationBody.yDrive.upperLimit); + Assert.AreEqual(5, articulationBody.zDrive.upperLimit); + Assert.AreEqual(6, articulationBody.xDrive.forceLimit); + Assert.AreEqual(6, articulationBody.yDrive.forceLimit); + Assert.AreEqual(6, articulationBody.zDrive.forceLimit); + Assert.AreEqual(7, articulationBody.maxLinearVelocity); + + Object.DestroyImmediate(baseObject); + } - Assert.AreEqual(1, limit.lower); - Assert.AreEqual(2, limit.upper); - Assert.AreEqual(joint.EffortLimit, limit.effort); - Assert.AreEqual(joint.VelocityLimit, limit.velocity); + [Test] + public void ExportSpecificJointData_Succeeds() + { + GameObject linkObject = new GameObject("link"); + TestUrdfJointPlanar urdfJoint = linkObject.AddComponent(); + urdfJoint.SetAxisOfMotion(new Vector3(1.2345678f, 2.3456789f, 3.4567891f)); + urdfJoint.Dynamics(new Joint.Dynamics(4, 5)); + + var joint = new Joint( + name: "custom_joint", type: "planar", parent: "base", child: "link"); + urdfJoint.TestExportSpecificJointData(joint); + + UnityEngine.Assertions.Assert.AreApproximatelyEqual(1.234568f, (float)joint.axis.xyz[0]); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(2.345679f, (float)joint.axis.xyz[1]); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(3.456789f, (float)joint.axis.xyz[2]); + Assert.AreEqual(4, joint.dynamics.damping); + Assert.AreEqual(5, joint.dynamics.friction); + + Object.DestroyImmediate(linkObject); + } - Object.DestroyImmediate(linkObject); - } + [Test] + public void ExportLimitData_Succeeds() + { + GameObject linkObject = new GameObject("link"); + TestUrdfJointPlanar joint = linkObject.AddComponent(); + ArticulationBody articulationBody = linkObject.GetComponent(); + articulationBody.yDrive = new ArticulationDrive() + { + lowerLimit = 1, + upperLimit = 2, + }; + Joint.Limit limit = joint.TestExportLimitData; + + Assert.AreEqual(1, limit.lower); + Assert.AreEqual(2, limit.upper); + Assert.AreEqual(joint.EffortLimit, limit.effort); + Assert.AreEqual(joint.VelocityLimit, limit.velocity); + + Object.DestroyImmediate(linkObject); + } - [Test] - public void Create_AreLimitCorrect_Succeeds() - { - var joint = new Joint( - name: "custom_joint", type: "planar", parent: "base", child: "link", - limit: new Joint.Limit(4, 5, 6, 7), - dynamics: new Joint.Dynamics(8, 9)); - GameObject linkObject = new GameObject("link"); - UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Planar, joint); + [Test] + public void Create_AreLimitCorrect_Succeeds() + { + var joint = new Joint( + name: "custom_joint", type: "planar", parent: "base", child: "link", + limit: new Joint.Limit(4, 5, 6, 7), + dynamics: new Joint.Dynamics(8, 9)); + GameObject linkObject = new GameObject("link"); + UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Planar, joint); - Assert.IsTrue(urdfJoint.AreLimitsCorrect()); + Assert.IsTrue(urdfJoint.AreLimitsCorrect()); - Object.DestroyImmediate(linkObject); - } + Object.DestroyImmediate(linkObject); + } - [Test] - public void IsJointAxisDefined_IsFalse() - { - GameObject linkObject = new GameObject("link"); - TestUrdfJointPlanar joint = linkObject.AddComponent(); + [Test] + public void IsJointAxisDefined_IsFalse() + { + GameObject linkObject = new GameObject("link"); + TestUrdfJointPlanar joint = linkObject.AddComponent(); - Assert.IsFalse(joint.TestIsJointAxisDefined); + Assert.IsFalse(joint.TestIsJointAxisDefined); - Object.DestroyImmediate(linkObject); + Object.DestroyImmediate(linkObject); + } } } diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismaticTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismaticTests.cs index 44442506..3c3de789 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismaticTests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointPrismaticTests.cs @@ -1,172 +1,176 @@ using NUnit.Framework; -using RosSharp.Urdf; +using Unity.Robotics.UrdfImporter; using UnityEngine; -using Joint = RosSharp.Urdf.Joint; +using Joint = Unity.Robotics.UrdfImporter.Joint; -public class TestUrdfJointPrismatic : UrdfJointPrismatic -{ - public void TestImportJointData(Joint joint) - { - unityJoint = gameObject.GetComponent(); - ImportJointData(joint); - } - - public Joint TestExportSpecificJointData(Joint joint) - { - unityJoint = gameObject.GetComponent(); - return ExportSpecificJointData(joint); - } - - public void SetAxisOfMotion(Vector3 axisofMotion) => this.axisofMotion = axisofMotion; - public void Dynamics(Joint.Dynamics dynamics) => SetDynamics(dynamics); -} -public class UrdfJointPrismaticTests +namespace Unity.Robotics.UrdfImporter.Tests { - [Test] - public void Create_UrdfJointPrismatic_Succeeds() - { - GameObject linkObject = new GameObject("link"); - UrdfJoint joint = UrdfJointPrismatic.Create(linkObject); - UrdfJoint urdfJoint = linkObject.GetComponent(); - ArticulationBody articulationBody = linkObject.GetComponent(); - - Assert.IsTrue(joint is UrdfJointPrismatic); - Assert.AreEqual(joint, urdfJoint); - Assert.AreEqual(ArticulationJointType.PrismaticJoint, articulationBody.jointType); - - Object.DestroyImmediate(linkObject); - } - - [Test] - public void GetPositionVelocityEffort_Succeeds() - { - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; - - UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); - UrdfJoint joint = UrdfJointPrismatic.Create(linkObject); - ArticulationBody articulationBody = linkObject.GetComponent(); - articulationBody.jointPosition = new ArticulationReducedSpace(1, 2, 3); - articulationBody.jointVelocity = new ArticulationReducedSpace(4, 5, 6); - articulationBody.jointForce = new ArticulationReducedSpace(7, 8, 9); - - Assert.AreEqual(1, joint.GetPosition()); - Assert.AreEqual(4, joint.GetVelocity()); - Assert.AreEqual(7, joint.GetEffort()); - - Object.DestroyImmediate(baseObject); - } - - [Test] - public void UpdateJointState_Succeeds() + public class TestUrdfJointPrismatic : UrdfJointPrismatic { - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; - - UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); - UrdfJoint joint = UrdfJointPrismatic.Create(linkObject); - ArticulationBody articulationBody = linkObject.GetComponent(); - - Assert.AreEqual(0, articulationBody.xDrive.target); - joint.UpdateJointState(1); - Assert.AreEqual(1, articulationBody.xDrive.target); - - Object.DestroyImmediate(baseObject); - } - - [Test] - public void ImportJointData_SpecificAixs_Succeeds() - { - var joint = new Joint( - name: "custom_joint", type: "prismatic", parent: "base", child: "link", - axis: new Joint.Axis(new double[] { 1, 2, 3 }), - limit: new Joint.Limit(4, 5, 6, 7), - dynamics: new Joint.Dynamics(8, 9)); - - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; - - UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); - TestUrdfJointPrismatic urdfJoint = linkObject.AddComponent(); - ArticulationBody articulationBody = linkObject.GetComponent(); - urdfJoint.TestImportJointData(joint); - - Assert.AreEqual(ArticulationDofLock.LimitedMotion, articulationBody.linearLockX); - Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockY); - Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockZ); - - Quaternion expectedAnchorRotation = new Quaternion(); - expectedAnchorRotation.SetFromToRotation(new Vector3(1, 0, 0), new Vector3(-2, 3, 1)); - Assert.AreEqual(expectedAnchorRotation, articulationBody.anchorRotation); - - Assert.AreEqual(4, articulationBody.xDrive.lowerLimit); - Assert.AreEqual(5, articulationBody.xDrive.upperLimit); - Assert.AreEqual(6, articulationBody.xDrive.forceLimit); - Assert.AreEqual(7, articulationBody.maxLinearVelocity); - Assert.AreEqual(8, articulationBody.linearDamping); - Assert.AreEqual(8, articulationBody.angularDamping); - Assert.AreEqual(9, articulationBody.jointFriction); - - Object.DestroyImmediate(baseObject); - } - - [Test] - public void ExportSpecificJointData_Succeeds() - { - GameObject linkObject = new GameObject("link"); - TestUrdfJointPrismatic urdfJoint = linkObject.AddComponent(); - ArticulationBody articulationBody = linkObject.GetComponent(); - urdfJoint.SetAxisOfMotion(new Vector3(1.2345678f, 2.3456789f, 3.4567891f)); - urdfJoint.Dynamics(new Joint.Dynamics(4, 5)); - - var joint = new Joint( - name: "custom_joint", type: "continuous", parent: "base", child: "link"); - urdfJoint.TestExportSpecificJointData(joint); - - UnityEngine.Assertions.Assert.AreApproximatelyEqual(1.234568f, (float)joint.axis.xyz[0]); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(2.345679f, (float)joint.axis.xyz[1]); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(3.456789f, (float)joint.axis.xyz[2]); - Assert.AreEqual(4, joint.dynamics.damping); - Assert.AreEqual(5, joint.dynamics.friction); - Assert.AreEqual(articulationBody.xDrive.lowerLimit, joint.limit.lower); - Assert.AreEqual(articulationBody.xDrive.upperLimit, joint.limit.upper); - Assert.AreEqual(articulationBody.xDrive.forceLimit, joint.limit.effort); - Assert.AreEqual(articulationBody.maxLinearVelocity, joint.limit.velocity); - - Object.DestroyImmediate(linkObject); - } - - [Test] - public void AreLimitsCorrect_Succeeds() - { - var joint = new Joint( - name: "custom_joint", type: "planar", parent: "base", child: "link", - limit: new Joint.Limit(4, 5, 6, 7), - dynamics: new Joint.Dynamics(8, 9)); - GameObject linkObject = new GameObject("link"); - UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Prismatic, joint); - - Assert.IsTrue(urdfJoint.AreLimitsCorrect()); - - Object.DestroyImmediate(linkObject); + public void TestImportJointData(Joint joint) + { + unityJoint = gameObject.GetComponent(); + ImportJointData(joint); + } + + public Joint TestExportSpecificJointData(Joint joint) + { + unityJoint = gameObject.GetComponent(); + return ExportSpecificJointData(joint); + } + + public void SetAxisOfMotion(Vector3 axisofMotion) => this.axisofMotion = axisofMotion; + public void Dynamics(Joint.Dynamics dynamics) => SetDynamics(dynamics); } - [Test] - public void AreLimitsCorrect_Fails() + public class UrdfJointPrismaticTests { - var joint = new Joint( - name: "custom_joint", type: "planar", parent: "base", child: "link", - limit: new Joint.Limit(5, 4, 6, 7), - dynamics: new Joint.Dynamics(8, 9)); - GameObject linkObject = new GameObject("link"); - UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Prismatic, joint); - - Assert.IsFalse(urdfJoint.AreLimitsCorrect()); - - Object.DestroyImmediate(linkObject); + [Test] + public void Create_UrdfJointPrismatic_Succeeds() + { + GameObject linkObject = new GameObject("link"); + UrdfJoint joint = UrdfJointPrismatic.Create(linkObject); + UrdfJoint urdfJoint = linkObject.GetComponent(); + ArticulationBody articulationBody = linkObject.GetComponent(); + + Assert.IsTrue(joint is UrdfJointPrismatic); + Assert.AreEqual(joint, urdfJoint); + Assert.AreEqual(ArticulationJointType.PrismaticJoint, articulationBody.jointType); + + Object.DestroyImmediate(linkObject); + } + + [Test] + public void GetPositionVelocityEffort_Succeeds() + { + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; + + UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); + UrdfJoint joint = UrdfJointPrismatic.Create(linkObject); + ArticulationBody articulationBody = linkObject.GetComponent(); + articulationBody.jointPosition = new ArticulationReducedSpace(1, 2, 3); + articulationBody.jointVelocity = new ArticulationReducedSpace(4, 5, 6); + articulationBody.jointForce = new ArticulationReducedSpace(7, 8, 9); + + Assert.AreEqual(1, joint.GetPosition()); + Assert.AreEqual(4, joint.GetVelocity()); + Assert.AreEqual(7, joint.GetEffort()); + + Object.DestroyImmediate(baseObject); + } + + [Test] + public void UpdateJointState_Succeeds() + { + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; + + UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); + UrdfJoint joint = UrdfJointPrismatic.Create(linkObject); + ArticulationBody articulationBody = linkObject.GetComponent(); + + Assert.AreEqual(0, articulationBody.xDrive.target); + joint.UpdateJointState(1); + Assert.AreEqual(1, articulationBody.xDrive.target); + + Object.DestroyImmediate(baseObject); + } + + [Test] + public void ImportJointData_SpecificAixs_Succeeds() + { + var joint = new Joint( + name: "custom_joint", type: "prismatic", parent: "base", child: "link", + axis: new Joint.Axis(new double[] { 1, 2, 3 }), + limit: new Joint.Limit(4, 5, 6, 7), + dynamics: new Joint.Dynamics(8, 9)); + + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; + + UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); + TestUrdfJointPrismatic urdfJoint = linkObject.AddComponent(); + ArticulationBody articulationBody = linkObject.GetComponent(); + urdfJoint.TestImportJointData(joint); + + Assert.AreEqual(ArticulationDofLock.LimitedMotion, articulationBody.linearLockX); + Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockY); + Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockZ); + + Quaternion expectedAnchorRotation = new Quaternion(); + expectedAnchorRotation.SetFromToRotation(new Vector3(1, 0, 0), new Vector3(-2, 3, 1)); + Assert.AreEqual(expectedAnchorRotation, articulationBody.anchorRotation); + + Assert.AreEqual(4, articulationBody.xDrive.lowerLimit); + Assert.AreEqual(5, articulationBody.xDrive.upperLimit); + Assert.AreEqual(6, articulationBody.xDrive.forceLimit); + Assert.AreEqual(7, articulationBody.maxLinearVelocity); + Assert.AreEqual(8, articulationBody.linearDamping); + Assert.AreEqual(8, articulationBody.angularDamping); + Assert.AreEqual(9, articulationBody.jointFriction); + + Object.DestroyImmediate(baseObject); + } + + [Test] + public void ExportSpecificJointData_Succeeds() + { + GameObject linkObject = new GameObject("link"); + TestUrdfJointPrismatic urdfJoint = linkObject.AddComponent(); + ArticulationBody articulationBody = linkObject.GetComponent(); + urdfJoint.SetAxisOfMotion(new Vector3(1.2345678f, 2.3456789f, 3.4567891f)); + urdfJoint.Dynamics(new Joint.Dynamics(4, 5)); + + var joint = new Joint( + name: "custom_joint", type: "continuous", parent: "base", child: "link"); + urdfJoint.TestExportSpecificJointData(joint); + + UnityEngine.Assertions.Assert.AreApproximatelyEqual(1.234568f, (float)joint.axis.xyz[0]); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(2.345679f, (float)joint.axis.xyz[1]); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(3.456789f, (float)joint.axis.xyz[2]); + Assert.AreEqual(4, joint.dynamics.damping); + Assert.AreEqual(5, joint.dynamics.friction); + Assert.AreEqual(articulationBody.xDrive.lowerLimit, joint.limit.lower); + Assert.AreEqual(articulationBody.xDrive.upperLimit, joint.limit.upper); + Assert.AreEqual(articulationBody.xDrive.forceLimit, joint.limit.effort); + Assert.AreEqual(articulationBody.maxLinearVelocity, joint.limit.velocity); + + Object.DestroyImmediate(linkObject); + } + + [Test] + public void AreLimitsCorrect_Succeeds() + { + var joint = new Joint( + name: "custom_joint", type: "planar", parent: "base", child: "link", + limit: new Joint.Limit(4, 5, 6, 7), + dynamics: new Joint.Dynamics(8, 9)); + GameObject linkObject = new GameObject("link"); + UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Prismatic, joint); + + Assert.IsTrue(urdfJoint.AreLimitsCorrect()); + + Object.DestroyImmediate(linkObject); + } + + [Test] + public void AreLimitsCorrect_Fails() + { + var joint = new Joint( + name: "custom_joint", type: "planar", parent: "base", child: "link", + limit: new Joint.Limit(5, 4, 6, 7), + dynamics: new Joint.Dynamics(8, 9)); + GameObject linkObject = new GameObject("link"); + UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Prismatic, joint); + + Assert.IsFalse(urdfJoint.AreLimitsCorrect()); + + Object.DestroyImmediate(linkObject); + } } } diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevoluteTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevoluteTests.cs index 5e2e2de6..a6dd2cd3 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevoluteTests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointRevoluteTests.cs @@ -3,174 +3,178 @@ using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; -using RosSharp.Urdf; -using Joint = RosSharp.Urdf.Joint; +using Unity.Robotics.UrdfImporter; +using Joint = Unity.Robotics.UrdfImporter.Joint; -public class TestUrdfJointRevolute : UrdfJointRevolute +namespace Unity.Robotics.UrdfImporter.Tests { - public void TestImportJointData(Joint joint) - { - unityJoint = gameObject.GetComponent(); - ImportJointData(joint); - } - - public Joint TestExportSpecificJointData(Joint joint) - { - unityJoint = gameObject.GetComponent(); - return ExportSpecificJointData(joint); - } - - public void SetAxisOfMotion(Vector3 axisofMotion) => this.axisofMotion = axisofMotion; - public void Dynamics(Joint.Dynamics dynamics) => SetDynamics(dynamics); -} - -public class UrdfJointRevoluteTests -{ - [Test] - public void Create_UrdfJointRevolute_Succeeds() - { - GameObject linkObject = new GameObject("link"); - UrdfJoint joint = UrdfJointRevolute.Create(linkObject); - UrdfJoint urdfJoint = linkObject.GetComponent(); - ArticulationBody articulationBody = linkObject.GetComponent(); - - Assert.IsTrue(joint is UrdfJointRevolute); - Assert.AreEqual(joint, urdfJoint); - Assert.AreEqual(ArticulationJointType.RevoluteJoint, articulationBody.jointType); - - Object.DestroyImmediate(linkObject); - } - - [Test] - public void GetPositionVelocityEffort_Succeeds() - { - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; - - UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); - UrdfJoint joint = UrdfJointPrismatic.Create(linkObject); - ArticulationBody articulationBody = linkObject.GetComponent(); - articulationBody.jointPosition = new ArticulationReducedSpace(1, 2, 3); - articulationBody.jointVelocity = new ArticulationReducedSpace(4, 5, 6); - articulationBody.jointForce = new ArticulationReducedSpace(7, 8, 9); - - Assert.AreEqual(1, joint.GetPosition()); - Assert.AreEqual(4, joint.GetVelocity()); - Assert.AreEqual(7, joint.GetEffort()); - - Object.DestroyImmediate(baseObject); - } - [Test] - public void UpdateJointState_Succeeds() + public class TestUrdfJointRevolute : UrdfJointRevolute { - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; - - UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); - UrdfJoint joint = UrdfJointRevolute.Create(linkObject); - ArticulationBody articulationBody = linkObject.GetComponent(); - - Assert.AreEqual(0, articulationBody.xDrive.target); - joint.UpdateJointState(1); - Assert.AreEqual(1 * Mathf.Rad2Deg, articulationBody.xDrive.target); - - Object.DestroyImmediate(baseObject); - } - - [Test] - public void ImportJointData_SpecificAixs_Succeeds() - { - var joint = new Joint( - name: "custom_joint", type: "prismatic", parent: "base", child: "link", - axis: new Joint.Axis(new double[] { 1, 2, 3 }), - limit: new Joint.Limit(4, 5, 6, 7), - dynamics: new Joint.Dynamics(8, 9)); - - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; - - UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); - TestUrdfJointRevolute urdfJoint = linkObject.AddComponent(); - ArticulationBody articulationBody = linkObject.GetComponent(); - urdfJoint.TestImportJointData(joint); - - Assert.AreEqual(ArticulationDofLock.LimitedMotion, articulationBody.linearLockX); - Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockY); - Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockZ); - Assert.AreEqual(ArticulationDofLock.LimitedMotion, articulationBody.twistLock); - - Quaternion expectedAnchorRotation = new Quaternion(); - expectedAnchorRotation.SetFromToRotation(new Vector3(1, 0, 0), -new Vector3(-2, 3, 1)); - Assert.AreEqual(expectedAnchorRotation, articulationBody.anchorRotation); - - Assert.AreEqual(4 * Mathf.Rad2Deg, articulationBody.xDrive.lowerLimit); - Assert.AreEqual(5 * Mathf.Rad2Deg, articulationBody.xDrive.upperLimit); - Assert.AreEqual(6, articulationBody.xDrive.forceLimit); - Assert.AreEqual(7, articulationBody.maxAngularVelocity); - Assert.AreEqual(8, articulationBody.linearDamping); - Assert.AreEqual(8, articulationBody.angularDamping); - Assert.AreEqual(9, articulationBody.jointFriction); - - Object.DestroyImmediate(baseObject); - } - - [Test] - public void ExportSpecificJointData_Succeeds() - { - GameObject linkObject = new GameObject("link"); - TestUrdfJointRevolute urdfJoint = linkObject.AddComponent(); - ArticulationBody articulationBody = linkObject.GetComponent(); - urdfJoint.SetAxisOfMotion(new Vector3(1.2345678f, 2.3456789f, 3.4567891f)); - urdfJoint.Dynamics(new Joint.Dynamics(4, 5)); - - var joint = new Joint( - name: "custom_joint", type: "continuous", parent: "base", child: "link"); - urdfJoint.TestExportSpecificJointData(joint); - - UnityEngine.Assertions.Assert.AreApproximatelyEqual(1.234568f, (float)joint.axis.xyz[0]); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(2.345679f, (float)joint.axis.xyz[1]); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(3.456789f, (float)joint.axis.xyz[2]); - Assert.AreEqual(4, joint.dynamics.damping); - Assert.AreEqual(5, joint.dynamics.friction); - Assert.AreEqual(articulationBody.xDrive.lowerLimit * Mathf.Deg2Rad, joint.limit.lower); - Assert.AreEqual(articulationBody.xDrive.upperLimit * Mathf.Deg2Rad, joint.limit.upper); - Assert.AreEqual(articulationBody.xDrive.forceLimit, joint.limit.effort); - Assert.AreEqual(articulationBody.maxAngularVelocity, joint.limit.velocity); - - Object.DestroyImmediate(linkObject); - } - - [Test] - public void AreLimitsCorrect_Succeeds() - { - var joint = new Joint( - name: "custom_joint", type: "planar", parent: "base", child: "link", - limit: new Joint.Limit(4, 5, 6, 7), - dynamics: new Joint.Dynamics(8, 9)); - GameObject linkObject = new GameObject("link"); - UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Revolute, joint); - - Assert.IsTrue(urdfJoint.AreLimitsCorrect()); - - Object.DestroyImmediate(linkObject); + public void TestImportJointData(Joint joint) + { + unityJoint = gameObject.GetComponent(); + ImportJointData(joint); + } + + public Joint TestExportSpecificJointData(Joint joint) + { + unityJoint = gameObject.GetComponent(); + return ExportSpecificJointData(joint); + } + + public void SetAxisOfMotion(Vector3 axisofMotion) => this.axisofMotion = axisofMotion; + public void Dynamics(Joint.Dynamics dynamics) => SetDynamics(dynamics); } - [Test] - public void AreLimitsCorrect_Fails() + public class UrdfJointRevoluteTests { - var joint = new Joint( - name: "custom_joint", type: "planar", parent: "base", child: "link", - limit: new Joint.Limit(5, 4, 6, 7), - dynamics: new Joint.Dynamics(8, 9)); - GameObject linkObject = new GameObject("link"); - UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Revolute, joint); - - Assert.IsFalse(urdfJoint.AreLimitsCorrect()); - - Object.DestroyImmediate(linkObject); + [Test] + public void Create_UrdfJointRevolute_Succeeds() + { + GameObject linkObject = new GameObject("link"); + UrdfJoint joint = UrdfJointRevolute.Create(linkObject); + UrdfJoint urdfJoint = linkObject.GetComponent(); + ArticulationBody articulationBody = linkObject.GetComponent(); + + Assert.IsTrue(joint is UrdfJointRevolute); + Assert.AreEqual(joint, urdfJoint); + Assert.AreEqual(ArticulationJointType.RevoluteJoint, articulationBody.jointType); + + Object.DestroyImmediate(linkObject); + } + + [Test] + public void GetPositionVelocityEffort_Succeeds() + { + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; + + UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); + UrdfJoint joint = UrdfJointPrismatic.Create(linkObject); + ArticulationBody articulationBody = linkObject.GetComponent(); + articulationBody.jointPosition = new ArticulationReducedSpace(1, 2, 3); + articulationBody.jointVelocity = new ArticulationReducedSpace(4, 5, 6); + articulationBody.jointForce = new ArticulationReducedSpace(7, 8, 9); + + Assert.AreEqual(1, joint.GetPosition()); + Assert.AreEqual(4, joint.GetVelocity()); + Assert.AreEqual(7, joint.GetEffort()); + + Object.DestroyImmediate(baseObject); + } + + [Test] + public void UpdateJointState_Succeeds() + { + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; + + UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); + UrdfJoint joint = UrdfJointRevolute.Create(linkObject); + ArticulationBody articulationBody = linkObject.GetComponent(); + + Assert.AreEqual(0, articulationBody.xDrive.target); + joint.UpdateJointState(1); + Assert.AreEqual(1 * Mathf.Rad2Deg, articulationBody.xDrive.target); + + Object.DestroyImmediate(baseObject); + } + + [Test] + public void ImportJointData_SpecificAixs_Succeeds() + { + var joint = new Joint( + name: "custom_joint", type: "prismatic", parent: "base", child: "link", + axis: new Joint.Axis(new double[] { 1, 2, 3 }), + limit: new Joint.Limit(4, 5, 6, 7), + dynamics: new Joint.Dynamics(8, 9)); + + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; + + UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); + TestUrdfJointRevolute urdfJoint = linkObject.AddComponent(); + ArticulationBody articulationBody = linkObject.GetComponent(); + urdfJoint.TestImportJointData(joint); + + Assert.AreEqual(ArticulationDofLock.LimitedMotion, articulationBody.linearLockX); + Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockY); + Assert.AreEqual(ArticulationDofLock.LockedMotion, articulationBody.linearLockZ); + Assert.AreEqual(ArticulationDofLock.LimitedMotion, articulationBody.twistLock); + + Quaternion expectedAnchorRotation = new Quaternion(); + expectedAnchorRotation.SetFromToRotation(new Vector3(1, 0, 0), -new Vector3(-2, 3, 1)); + Assert.AreEqual(expectedAnchorRotation, articulationBody.anchorRotation); + + Assert.AreEqual(4 * Mathf.Rad2Deg, articulationBody.xDrive.lowerLimit); + Assert.AreEqual(5 * Mathf.Rad2Deg, articulationBody.xDrive.upperLimit); + Assert.AreEqual(6, articulationBody.xDrive.forceLimit); + Assert.AreEqual(7, articulationBody.maxAngularVelocity); + Assert.AreEqual(8, articulationBody.linearDamping); + Assert.AreEqual(8, articulationBody.angularDamping); + Assert.AreEqual(9, articulationBody.jointFriction); + + Object.DestroyImmediate(baseObject); + } + + [Test] + public void ExportSpecificJointData_Succeeds() + { + GameObject linkObject = new GameObject("link"); + TestUrdfJointRevolute urdfJoint = linkObject.AddComponent(); + ArticulationBody articulationBody = linkObject.GetComponent(); + urdfJoint.SetAxisOfMotion(new Vector3(1.2345678f, 2.3456789f, 3.4567891f)); + urdfJoint.Dynamics(new Joint.Dynamics(4, 5)); + + var joint = new Joint( + name: "custom_joint", type: "continuous", parent: "base", child: "link"); + urdfJoint.TestExportSpecificJointData(joint); + + UnityEngine.Assertions.Assert.AreApproximatelyEqual(1.234568f, (float)joint.axis.xyz[0]); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(2.345679f, (float)joint.axis.xyz[1]); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(3.456789f, (float)joint.axis.xyz[2]); + Assert.AreEqual(4, joint.dynamics.damping); + Assert.AreEqual(5, joint.dynamics.friction); + Assert.AreEqual(articulationBody.xDrive.lowerLimit * Mathf.Deg2Rad, joint.limit.lower); + Assert.AreEqual(articulationBody.xDrive.upperLimit * Mathf.Deg2Rad, joint.limit.upper); + Assert.AreEqual(articulationBody.xDrive.forceLimit, joint.limit.effort); + Assert.AreEqual(articulationBody.maxAngularVelocity, joint.limit.velocity); + + Object.DestroyImmediate(linkObject); + } + + [Test] + public void AreLimitsCorrect_Succeeds() + { + var joint = new Joint( + name: "custom_joint", type: "planar", parent: "base", child: "link", + limit: new Joint.Limit(4, 5, 6, 7), + dynamics: new Joint.Dynamics(8, 9)); + GameObject linkObject = new GameObject("link"); + UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Revolute, joint); + + Assert.IsTrue(urdfJoint.AreLimitsCorrect()); + + Object.DestroyImmediate(linkObject); + } + + [Test] + public void AreLimitsCorrect_Fails() + { + var joint = new Joint( + name: "custom_joint", type: "planar", parent: "base", child: "link", + limit: new Joint.Limit(5, 4, 6, 7), + dynamics: new Joint.Dynamics(8, 9)); + GameObject linkObject = new GameObject("link"); + UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Revolute, joint); + + Assert.IsFalse(urdfJoint.AreLimitsCorrect()); + + Object.DestroyImmediate(linkObject); + } } } diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointTests.cs index d3954d92..b005552a 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointTests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/UrdfComponents/UrdfJoints/UrdfJointTests.cs @@ -1,240 +1,244 @@ using System.Collections.Generic; using NUnit.Framework; using UnityEngine; -using RosSharp.Urdf; -using Joint = RosSharp.Urdf.Joint; +using Unity.Robotics.UrdfImporter; +using Joint = Unity.Robotics.UrdfImporter.Joint; -public class TestUrdfJoint : UrdfJoint +namespace Unity.Robotics.UrdfImporter.Tests { - public override JointTypes JointType => throw new System.NotImplementedException(); - public static Vector3 Axis(Joint.Axis axis) => GetAxis(axis); - public static Vector3 DefaultAxis() => GetDefaultAxis(); - public static Joint.Axis AxisData(Vector3 axis) => GetAxisData(axis); - public void Dynamics(Joint.Dynamics dynamics) => SetDynamics(dynamics); -} + public class TestUrdfJoint : UrdfJoint + { + public override JointTypes JointType => throw new System.NotImplementedException(); -public class UrdfJointTests -{ + public static Vector3 Axis(Joint.Axis axis) => GetAxis(axis); + public static Vector3 DefaultAxis() => GetDefaultAxis(); + public static Joint.Axis AxisData(Vector3 axis) => GetAxisData(axis); + public void Dynamics(Joint.Dynamics dynamics) => SetDynamics(dynamics); + } -#if UNITY_2020_1_OR_NEWER - [Test, TestCaseSource("JointTypes")] - public void Create_UrdfJoint_Succeeds(UrdfJoint.JointTypes urdfJointType, ArticulationJointType articulationJointType) + public class UrdfJointTests { - GameObject linkObject = new GameObject("link"); - UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, urdfJointType); - ArticulationBody articulationBody = linkObject.GetComponent(); - Assert.IsNotNull(urdfJoint); - Assert.IsNotNull(articulationBody); - Assert.AreEqual(urdfJointType, urdfJoint.JointType); - Assert.AreEqual(articulationJointType, articulationBody.jointType); +#if UNITY_2020_1_OR_NEWER + [Test, TestCaseSource("JointTypes")] + public void Create_UrdfJoint_Succeeds(UrdfJoint.JointTypes urdfJointType, ArticulationJointType articulationJointType) + { + GameObject linkObject = new GameObject("link"); + UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, urdfJointType); + ArticulationBody articulationBody = linkObject.GetComponent(); - Object.DestroyImmediate(linkObject); - } + Assert.IsNotNull(urdfJoint); + Assert.IsNotNull(articulationBody); + Assert.AreEqual(urdfJointType, urdfJoint.JointType); + Assert.AreEqual(articulationJointType, articulationBody.jointType); - private static IEnumerable JointTypes - { - get + Object.DestroyImmediate(linkObject); + } + + private static IEnumerable JointTypes { - yield return new TestCaseData(UrdfJoint.JointTypes.Fixed, ArticulationJointType.FixedJoint); - yield return new TestCaseData(UrdfJoint.JointTypes.Continuous, ArticulationJointType.RevoluteJoint); - yield return new TestCaseData(UrdfJoint.JointTypes.Floating, ArticulationJointType.FixedJoint); - yield return new TestCaseData(UrdfJoint.JointTypes.Planar, ArticulationJointType.PrismaticJoint); - yield return new TestCaseData(UrdfJoint.JointTypes.Prismatic, ArticulationJointType.PrismaticJoint); - yield return new TestCaseData(UrdfJoint.JointTypes.Revolute, ArticulationJointType.RevoluteJoint); + get + { + yield return new TestCaseData(UrdfJoint.JointTypes.Fixed, ArticulationJointType.FixedJoint); + yield return new TestCaseData(UrdfJoint.JointTypes.Continuous, ArticulationJointType.RevoluteJoint); + yield return new TestCaseData(UrdfJoint.JointTypes.Floating, ArticulationJointType.FixedJoint); + yield return new TestCaseData(UrdfJoint.JointTypes.Planar, ArticulationJointType.PrismaticJoint); + yield return new TestCaseData(UrdfJoint.JointTypes.Prismatic, ArticulationJointType.PrismaticJoint); + yield return new TestCaseData(UrdfJoint.JointTypes.Revolute, ArticulationJointType.RevoluteJoint); + } } - } - [Test] - public void Create_WithOtherTypeOfJointData_FixedArticulationBody() - { - Joint joint = new Joint( - name: "reference", type: "prismatic", parent: null, child: null); - GameObject linkObject = new GameObject("link"); - UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Fixed, joint); - ArticulationBody articulationBody = linkObject.GetComponent(); - - Assert.IsNotNull(urdfJoint); - Assert.IsNotNull(articulationBody); - Assert.AreEqual(UrdfJoint.JointTypes.Fixed, urdfJoint.JointType); - Assert.AreEqual(ArticulationJointType.FixedJoint, articulationBody.jointType); - } + [Test] + public void Create_WithOtherTypeOfJointData_FixedArticulationBody() + { + Joint joint = new Joint( + name: "reference", type: "prismatic", parent: null, child: null); + GameObject linkObject = new GameObject("link"); + UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Fixed, joint); + ArticulationBody articulationBody = linkObject.GetComponent(); + + Assert.IsNotNull(urdfJoint); + Assert.IsNotNull(articulationBody); + Assert.AreEqual(UrdfJoint.JointTypes.Fixed, urdfJoint.JointType); + Assert.AreEqual(ArticulationJointType.FixedJoint, articulationBody.jointType); + } - [Test] - public void Create_WithJointData_Succeeds() - { - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; + [Test] + public void Create_WithJointData_Succeeds() + { + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; - var joint = new Joint("custom_name", "revolute", "base", "link"); - UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Prismatic, joint); + var joint = new Joint("custom_name", "revolute", "base", "link"); + UrdfJoint urdfJoint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Prismatic, joint); - Assert.AreEqual("custom_name", urdfJoint.jointName); + Assert.AreEqual("custom_name", urdfJoint.jointName); - Object.DestroyImmediate(baseObject); - Object.DestroyImmediate(linkObject); - } + Object.DestroyImmediate(baseObject); + Object.DestroyImmediate(linkObject); + } - [Test] - public void ChangeJointType_FromFixedToRevolute_Succeeds() - { - GameObject baseLink = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseLink.transform; + [Test] + public void ChangeJointType_FromFixedToRevolute_Succeeds() + { + GameObject baseLink = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseLink.transform; - UrdfJoint.Create(baseLink, UrdfJoint.JointTypes.Fixed); - UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Fixed); - ArticulationBody articulationBody = linkObject.GetComponent(); + UrdfJoint.Create(baseLink, UrdfJoint.JointTypes.Fixed); + UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Fixed); + ArticulationBody articulationBody = linkObject.GetComponent(); - Assert.AreEqual(ArticulationJointType.FixedJoint, articulationBody.jointType); - Assert.AreEqual(0, articulationBody.dofCount); + Assert.AreEqual(ArticulationJointType.FixedJoint, articulationBody.jointType); + Assert.AreEqual(0, articulationBody.dofCount); - UrdfJoint.ChangeJointType(linkObject, UrdfJoint.JointTypes.Revolute); - articulationBody = linkObject.GetComponent(); + UrdfJoint.ChangeJointType(linkObject, UrdfJoint.JointTypes.Revolute); + articulationBody = linkObject.GetComponent(); - Assert.AreEqual(ArticulationJointType.RevoluteJoint, articulationBody.jointType); - Assert.AreEqual(1, articulationBody.dofCount); + Assert.AreEqual(ArticulationJointType.RevoluteJoint, articulationBody.jointType); + Assert.AreEqual(1, articulationBody.dofCount); - Object.DestroyImmediate(linkObject); - } + Object.DestroyImmediate(linkObject); + } #endif - [Test] - public void GetJointType_AllJointTypes_Succeeds() - { - Assert.AreEqual(UrdfJoint.JointTypes.Fixed, UrdfJoint.GetJointType("fixed")); - Assert.AreEqual(UrdfJoint.JointTypes.Continuous, UrdfJoint.GetJointType("continuous")); - Assert.AreEqual(UrdfJoint.JointTypes.Revolute, UrdfJoint.GetJointType("revolute")); - Assert.AreEqual(UrdfJoint.JointTypes.Floating, UrdfJoint.GetJointType("floating")); - Assert.AreEqual(UrdfJoint.JointTypes.Prismatic, UrdfJoint.GetJointType("prismatic")); - Assert.AreEqual(UrdfJoint.JointTypes.Planar, UrdfJoint.GetJointType("planar")); - Assert.AreEqual(UrdfJoint.JointTypes.Fixed, UrdfJoint.GetJointType("unknown")); - } + [Test] + public void GetJointType_AllJointTypes_Succeeds() + { + Assert.AreEqual(UrdfJoint.JointTypes.Fixed, UrdfJoint.GetJointType("fixed")); + Assert.AreEqual(UrdfJoint.JointTypes.Continuous, UrdfJoint.GetJointType("continuous")); + Assert.AreEqual(UrdfJoint.JointTypes.Revolute, UrdfJoint.GetJointType("revolute")); + Assert.AreEqual(UrdfJoint.JointTypes.Floating, UrdfJoint.GetJointType("floating")); + Assert.AreEqual(UrdfJoint.JointTypes.Prismatic, UrdfJoint.GetJointType("prismatic")); + Assert.AreEqual(UrdfJoint.JointTypes.Planar, UrdfJoint.GetJointType("planar")); + Assert.AreEqual(UrdfJoint.JointTypes.Fixed, UrdfJoint.GetJointType("unknown")); + } - [Test] - public void GetAxis_JointAxis_Succeeds() - { - var axis = new Joint.Axis(new double[] { 1, 2, 3 }); - Assert.AreEqual(new Vector3(-2, 3, 1), TestUrdfJoint.Axis(axis)); - } + [Test] + public void GetAxis_JointAxis_Succeeds() + { + var axis = new Joint.Axis(new double[] { 1, 2, 3 }); + Assert.AreEqual(new Vector3(-2, 3, 1), TestUrdfJoint.Axis(axis)); + } - [Test] - public void GetDefaultAxis_JointAxis_Succeeds() - { - Assert.AreEqual(new Vector3(-1, 0, 0), TestUrdfJoint.DefaultAxis()); - } + [Test] + public void GetDefaultAxis_JointAxis_Succeeds() + { + Assert.AreEqual(new Vector3(-1, 0, 0), TestUrdfJoint.DefaultAxis()); + } - [Test] - public void SetDynamics_ArbitraryDynamics_Succeeds() - { - var dynamics = new Joint.Dynamics(1, 2); - GameObject linkObject = new GameObject("link"); - var joint = linkObject.AddComponent(); - joint.Dynamics(dynamics); + [Test] + public void SetDynamics_ArbitraryDynamics_Succeeds() + { + var dynamics = new Joint.Dynamics(1, 2); + GameObject linkObject = new GameObject("link"); + var joint = linkObject.AddComponent(); + joint.Dynamics(dynamics); - var articulationBody = linkObject.GetComponent(); - Assert.AreEqual(1, articulationBody.linearDamping); - Assert.AreEqual(1, articulationBody.angularDamping); - Assert.AreEqual(2, articulationBody.jointFriction); + var articulationBody = linkObject.GetComponent(); + Assert.AreEqual(1, articulationBody.linearDamping); + Assert.AreEqual(1, articulationBody.angularDamping); + Assert.AreEqual(2, articulationBody.jointFriction); - Object.DestroyImmediate(linkObject); - } + Object.DestroyImmediate(linkObject); + } - [Test] - public void SetDynamics_DefaultDynamics_Succeeds() - { - GameObject linkObject = new GameObject("link"); - var joint = linkObject.AddComponent(); - joint.Dynamics(null); + [Test] + public void SetDynamics_DefaultDynamics_Succeeds() + { + GameObject linkObject = new GameObject("link"); + var joint = linkObject.AddComponent(); + joint.Dynamics(null); - var articulationBody = linkObject.GetComponent(); - Assert.AreEqual(0, articulationBody.linearDamping); - Assert.AreEqual(0, articulationBody.angularDamping); - Assert.AreEqual(0, articulationBody.jointFriction); + var articulationBody = linkObject.GetComponent(); + Assert.AreEqual(0, articulationBody.linearDamping); + Assert.AreEqual(0, articulationBody.angularDamping); + Assert.AreEqual(0, articulationBody.jointFriction); - Object.DestroyImmediate(linkObject); - } + Object.DestroyImmediate(linkObject); + } - [Test] - public void ExportJointData_ArbitraryJointData_Succeeds() - { - Vector3 position = new Vector3(1, 2, 3); - Quaternion rotation = Quaternion.Euler(4, 5, 6); - - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; - linkObject.transform.position = position; - linkObject.transform.rotation = rotation; - - UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); - UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Revolute); - var joint = linkObject.GetComponent().ExportJointData(); - - Assert.IsNull(joint.name); - Assert.AreEqual("revolute", joint.type); - Assert.AreEqual(baseObject.name, joint.parent); - Assert.AreEqual(linkObject.name, joint.child); - Assert.AreEqual(new double[] { position[2], -position[0], position[1] }, joint.origin.Xyz); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(-rotation.eulerAngles[2] * Mathf.Deg2Rad, (float)joint.origin.Rpy[0]); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(rotation.eulerAngles[0] * Mathf.Deg2Rad, (float)joint.origin.Rpy[1]); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(-rotation.eulerAngles[1] * Mathf.Deg2Rad, (float)joint.origin.Rpy[2]); - - Object.DestroyImmediate(baseObject); - Object.DestroyImmediate(linkObject); - } + [Test] + public void ExportJointData_ArbitraryJointData_Succeeds() + { + Vector3 position = new Vector3(1, 2, 3); + Quaternion rotation = Quaternion.Euler(4, 5, 6); + + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; + linkObject.transform.position = position; + linkObject.transform.rotation = rotation; + + UrdfJoint.Create(baseObject, UrdfJoint.JointTypes.Fixed); + UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Revolute); + var joint = linkObject.GetComponent().ExportJointData(); + + Assert.IsNull(joint.name); + Assert.AreEqual("revolute", joint.type); + Assert.AreEqual(baseObject.name, joint.parent); + Assert.AreEqual(linkObject.name, joint.child); + Assert.AreEqual(new double[] { position[2], -position[0], position[1] }, joint.origin.Xyz); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(-rotation.eulerAngles[2] * Mathf.Deg2Rad, (float)joint.origin.Rpy[0]); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(rotation.eulerAngles[0] * Mathf.Deg2Rad, (float)joint.origin.Rpy[1]); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(-rotation.eulerAngles[1] * Mathf.Deg2Rad, (float)joint.origin.Rpy[2]); + + Object.DestroyImmediate(baseObject); + Object.DestroyImmediate(linkObject); + } - [Test] - public void ExportDefaultJointData_DefaultJoint_Succeeds() - { - Vector3 position = new Vector3(1, 2, 3); - Quaternion rotation = Quaternion.Euler(4, 5, 6); + [Test] + public void ExportDefaultJointData_DefaultJoint_Succeeds() + { + Vector3 position = new Vector3(1, 2, 3); + Quaternion rotation = Quaternion.Euler(4, 5, 6); - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; - linkObject.transform.position = position; - linkObject.transform.rotation = rotation; + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; + linkObject.transform.position = position; + linkObject.transform.rotation = rotation; - Joint joint = UrdfJoint.ExportDefaultJoint(linkObject.transform); + Joint joint = UrdfJoint.ExportDefaultJoint(linkObject.transform); - Assert.AreEqual("base_link_joint", joint.name); - Assert.AreEqual("fixed", joint.type); - Assert.AreEqual(baseObject.name, joint.parent); - Assert.AreEqual(linkObject.name, joint.child); + Assert.AreEqual("base_link_joint", joint.name); + Assert.AreEqual("fixed", joint.type); + Assert.AreEqual(baseObject.name, joint.parent); + Assert.AreEqual(linkObject.name, joint.child); - Assert.AreEqual(new double[] { position[2], -position[0], position[1] }, joint.origin.Xyz); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(-rotation.eulerAngles[2] * Mathf.Deg2Rad, (float)joint.origin.Rpy[0]); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(rotation.eulerAngles[0] * Mathf.Deg2Rad, (float)joint.origin.Rpy[1]); - UnityEngine.Assertions.Assert.AreApproximatelyEqual(-rotation.eulerAngles[1] * Mathf.Deg2Rad, (float)joint.origin.Rpy[2]); + Assert.AreEqual(new double[] { position[2], -position[0], position[1] }, joint.origin.Xyz); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(-rotation.eulerAngles[2] * Mathf.Deg2Rad, (float)joint.origin.Rpy[0]); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(rotation.eulerAngles[0] * Mathf.Deg2Rad, (float)joint.origin.Rpy[1]); + UnityEngine.Assertions.Assert.AreApproximatelyEqual(-rotation.eulerAngles[1] * Mathf.Deg2Rad, (float)joint.origin.Rpy[2]); - Object.DestroyImmediate(baseObject); - Object.DestroyImmediate(linkObject); - } + Object.DestroyImmediate(baseObject); + Object.DestroyImmediate(linkObject); + } - [Test] - public void GenerateUniqueJointName_UniqueName_Succeeds() - { - GameObject baseObject = new GameObject("base"); - GameObject linkObject = new GameObject("link"); - linkObject.transform.parent = baseObject.transform; + [Test] + public void GenerateUniqueJointName_UniqueName_Succeeds() + { + GameObject baseObject = new GameObject("base"); + GameObject linkObject = new GameObject("link"); + linkObject.transform.parent = baseObject.transform; - var joint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Revolute); + var joint = UrdfJoint.Create(linkObject, UrdfJoint.JointTypes.Revolute); - Assert.IsNull(joint.jointName); - joint.GenerateUniqueJointName(); - Assert.NotNull(joint.jointName); + Assert.IsNull(joint.jointName); + joint.GenerateUniqueJointName(); + Assert.NotNull(joint.jointName); - Object.DestroyImmediate(baseObject); - Object.DestroyImmediate(linkObject); - } + Object.DestroyImmediate(baseObject); + Object.DestroyImmediate(linkObject); + } - [Test] - public void GetAxisData_ArbitraryData_Succeeds() - { - Assert.AreEqual(new double[] { 1.234568, 2.345679, 3.456789 }, - TestUrdfJoint.AxisData(new Vector3(1.2345678f, 2.3456789f, 3.4567891f)).xyz); + [Test] + public void GetAxisData_ArbitraryData_Succeeds() + { + Assert.AreEqual(new double[] { 1.234568, 2.345679, 3.456789 }, + TestUrdfJoint.AxisData(new Vector3(1.2345678f, 2.3456789f, 3.4567891f)).xyz); + } } } diff --git a/com.unity.robotics.urdf-importer/Tests/Runtime/VHACD/VHACDTests.cs b/com.unity.robotics.urdf-importer/Tests/Runtime/VHACD/VHACDTests.cs index 1c86bb8f..f027b90d 100644 --- a/com.unity.robotics.urdf-importer/Tests/Runtime/VHACD/VHACDTests.cs +++ b/com.unity.robotics.urdf-importer/Tests/Runtime/VHACD/VHACDTests.cs @@ -3,7 +3,7 @@ using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; -using RosSharp.Urdf; +using Unity.Robotics.UrdfImporter; using MeshProcess; public class VHACDTests diff --git a/com.unity.robotics.urdf-importer/package.json b/com.unity.robotics.urdf-importer/package.json index f260116d..4752a801 100644 --- a/com.unity.robotics.urdf-importer/package.json +++ b/com.unity.robotics.urdf-importer/package.json @@ -1,6 +1,6 @@ { "name": "com.unity.robotics.urdf-importer", - "version": "0.4.0-preview", + "version": "0.5.0-preview", "displayName": "URDF Importer", "description": "Facilitates importing configurations from the Universal Robot Description Format", "unity": "2020.2",