Unity-Technologies / URDF-Importer

URDF importer
Apache License 2.0
231 stars 71 forks source link

namespace 'UrdfImporter' does not exist in 'Unity.Robotics' #228

Open FabianEP11 opened 1 month ago

FabianEP11 commented 1 month ago

I have a Unity project with the URDF-Importer plugin (v0.5.2), and I need to get the name of the joints from code like this:

string joint_name = articulationBody.gameObject.GetComponent<UrdfJointRevolute>().jointName; which uses using Unity.Robotics.UrdfImporter.

When I run the app in the Editor everything works fine, but when I build the app, it fails because it cannot fine the namespace:

The type or namespace name 'UrdfImporter' does not exist in the namespace 'Unity.Robotics' (are you missing an assembly reference?)

I also tried adding the entire namespace to the GetComponent type like: string joint_name = articulationBody.gameObject.GetComponent<Unity.Robotics.UrdfImporter.UrdfJointRevolute>().jointName; but it is the same

Is the using Unity.Robotics.UrdfImporter just available on the Editor? or how can I fix that?

CarlTornberg commented 2 days ago

The URDF importer needs to compile for whichever build target you have set (In my case, I use Android).

First, move the URDF importer package from the CachedPackage folder to the asset package folder:

  1. Find the package by: Project -> Packages -> URDF Importer
  2. Right-click and press Show in explorer, ctrl+x the URDF folder,
  3. Paste in the Asset/Packages by: Project -> Assets
  4. Right-click and press Show in explorer.
  5. Paste in the Packages folder

When the package is moved, let it recompile and find the package in the editor. Project -> Packages -> URDF Importer -> Runtime -> Unity.Robotics.URDFImporter -> (In the inspector) Click with platform you are compiling to -> Apply.

Image

FabianEP11 commented 1 day ago

Hey, Yeah, previously I was able to build the app for a HoloLens device by manually adding "WSA" to the "includePlatforms" in the "Library\PackageCache\com.unity.robotics.urdf-importer@90f353e435\Runtime\Unity.Robotics.URDFImporter.asmdef" file. I guess that the inspector checkbox changes the same file.

Thanks!

CarlTornberg commented 1 day ago

Further more, Im not sure if this is for all build platforms, but is for Android. An exception named 'Packages/com.unity.robotics.urdf-importer/Runtime/UnityMeshImporter/Plugins/AssimpNet/Native/win/x86/assimp.dll' (Key: assimp.dll;None) since plugin with the same name and architecture was already added ('Packages/com.unity.robotics.urdf-importer/Runtime/UnityMeshImporter/Plugins/AssimpNet/Native/win/x86_64/assimp.dll (Architecture: None)') fails the build. Here is the solution to that issue Note that you do not have to remove the files, and can just check "Android" as an excluded build platform for the assimp Image