EricVoll / ros-sharp

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

Is Web Socket UWP supported? #18

Closed Gryogor closed 2 years ago

Gryogor commented 2 years ago

After launching ROS sharp on unity 2020 I found about the existance of Web Socket UWP serializer, but after switching to it, if I try to run the project in play mode, it gives the following error for UnitySubscriber (I premade OdomSubsriber):

NullReferenceException: Object reference not set to an instance of an object
RosSharp.RosBridgeClient.UnitySubscriber`1[T].Subscribe () (at Assets/RosSharp/Scripts/RosBridgeClient/RosCommuncation/UnitySubscriber.cs:42)
System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Threading.ThreadHelper.ThreadStart () (at <695d1cc93cca45069c528c15c9fdd749>:0)
UnityEngine.<>c:<RegisterUECatcher>b__0_0(Object, UnhandledExceptionEventArgs)

I also got the similar error in hololens development console after deploying it with Web Socket Sharp, but it was done in Unity 2019: NullReferenceException: Object reference not set to an instance of an object Before deploying, it was fully working in unity

EricVoll commented 2 years ago

Hi @Gryogor It used to work some time back, yes. In the meantime I am primarily using Unity's robotics Hub as explained and reasoned in this short paragraph in the Readme: https://github.com/EricVoll/ros-sharp#maintainer-notes If you are only working in Unity and do not need C# standalone support, then I suggest switching to the robotics hub.

But to answer your question: Generally, yes it should work. https://github.com/EricVoll/ros-sharp/blob/8c7c0f381f6c8b7644e0e182c5fe5adc8a65e47f/ProjectSetup/RosSharpUnity/Assets/RosSharp/Scripts/RosBridgeClient/RosCommuncation/RosConnector.cs#L38 In the example project there are pre-compiler instructions to auto-select the UWP websocket.