Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Feature] Support Unity Editor #81

Open
ooeygui opened this issue Oct 11, 2021 · 5 comments
Open

[Feature] Support Unity Editor #81

ooeygui opened this issue Oct 11, 2021 · 5 comments
Assignees

Comments

@ooeygui
Copy link
Member

ooeygui commented Oct 11, 2021

This feature is being implemented by Azure Edge Robotics. Payload incoming.

@ooeygui ooeygui self-assigned this Oct 11, 2021
@esteve
Copy link
Member

esteve commented Oct 17, 2021

@ooeygui as part of #82 , one of the goals of ros2-dotnet was to have support for Unity, which was added in order to support Hololens. So I don't know what's missing here, can you please elaborate? Thanks

@ooeygui
Copy link
Member Author

ooeygui commented Oct 17, 2021

Unity Editor has some interesting behaviors that need to be factored into ROS2.net and the unity package. ROS2 itself needs to be enlightened to this fact (which we have a pending change up stream for), but also how load library works in ROS2.net. When packaging a component for Unity, metafile declare where individual binaries will be deployed - but they aren't in the execution path. LoadLibrary doesn't function correctly.

Hololens has a similar problem - LoadLibrary itself is missing in the API set. You need to use LoadPackagedLibrary, which loads it from the UWP package. (A similar fix is made in ROS2 itself).

(On top of this, the Unity native compiler will optimize out Reflection only methods (it doesn't know they are going to be called), so you need to add a link.xml to prevent the optimizer from destroying the ability to bind to ROS messages. This hasn't been addressed in ROS2.net documentation yet)

@esteve
Copy link
Member

esteve commented Oct 18, 2021

Hololens has a similar problem - LoadLibrary itself is missing in the API set. You need to use LoadPackagedLibrary, which loads it from the UWP package. (A similar fix is made in ROS2 itself).

Yes, and that's why rcldotnet_common has this code to use LoadPackagedLibrary instead of LoadLibrary for UWP.

Moreover, https://youtu.be/lQXtoK3w5X8 and https://youtu.be/mGTKNB-Iog0 show using ros2-donet in a Unity app from a Hololens.

Can you elaborate further what's needed? ros2-dotnet always had support for UWP, Unity and the Hololens, it was the very reason it was created. You can find more info about it in http://www.robocity2030.org/2018/06/18/rosin-grant-urjc/ and the talk I gave at ROSCon 2018 about ros2-dotnet and UWP https://vimeo.com/293302046

@ooeygui
Copy link
Member Author

ooeygui commented Oct 18, 2021

In Unity 2020, the Native compiler is now used. When the DllImport is present for an API that doesn't exist, the binary doesn't load - it is an untrappable exception.

@ooeygui
Copy link
Member Author

ooeygui commented Oct 18, 2021

I'll look at it again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants