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

Cannot subscribe to custom messages between Ros Sharp and Ros Bridge Websocket #11

Closed bryceikeda closed 3 years ago

bryceikeda commented 3 years ago

Here is my bug description: I am trying to use a custom message to communicate with Ros Bridge Websocket but I am getting an error "[id: /topic: 0] subscribe: is not a valid type string". I have tested my custom message with the original Ros Sharp by Martin Bischoff and the custom messages are successfully subscribed to. This leads me to believe it is something with this fork that is the issue. Any idea what it could be?

Perform the following steps reproduce the bug:

  1. Add the Ros Sharp assets to my unity project.
  2. Create an empty game object and add the components RosConnector.cs, LandmarksSubscriber.cs and LandmarksWriter.cs.
  3. Attach the LandmarksWriter to the LandmarksSubscriber.
  4. Add the RosSharpMessages folder to the Unity Assets.
  5. Set the RosConnector.cs Serializer to Newtonsoft_JSON, protocol to Web Socket Sharp and the Ros Bridge Server Url to the websocket IP.
  6. Run Ros Bridge Websocket.
  7. Run the Unity project.

Necessary files: Assets.zip

Observed results: error "[id: /topic: 0] subscribe: is not a valid type string"

Expected results: [INFO] [1611354062.824861]: [Client 0] Subscribed to /topic

Rive4 commented 3 years ago

Hi bryceikeda,

Try to build your solution using UWP Socket instead of Web Socket Sharp. I had the same problem (or a similar one) and was solved changing that.

bryceikeda commented 3 years ago

@Rive4

Just tried that and I am still getting the same error.

EricVoll commented 3 years ago

Hi both 👋 I'll have a look at it later today.

EricVoll commented 3 years ago

@bryceikeda : I noticed:

"is not a valid type string" means that the type string Ros received is invalid. In this UWP Fork all messages must defined their RosMessageName field slightley differently compared to the normal Ros#.

public const string RosMessageName = "perception/Landmark"; should be public override string RosMessageName => "perception/Landmark"; (This was one of the changes I had to make to get everything serializing with the IL2CPP backend. The same is true for Landmarks.cs, Observabtion.cs and Observations.cs

Could you try it with that setup? I think everything else looks fine.

(I did not yet have time to update the RosMsgsGenerator project for this fork. It generates slightley wrong messages...)

bryceikeda commented 3 years ago

@EricVoll

That works! Thanks for looking into this for me.

-Bryce

EricVoll commented 3 years ago

I fixed the generator to generate properties now.

jstiefel commented 3 years ago

Hi @EricVoll

I just run into this problem using the current version of the master branch. I used "Auto Generate Messages -> All Messages in directory". Your fix in the post above worked for me, but this means that the RosMsgsGenerator is producing wrong messages again.

EricVoll commented 3 years ago

Are you using the Unity Menu-Options thing for that? I think I did not adjust the Unity Editor Scripts for that. The console tool in the library folder should work properly.

EricVoll commented 3 years ago

@jstiefel recompiling the MessageGeneration.dll and pulling it into the /Assets/RosSharp/Plugins folder should do the trick, if you want to use the MessageGeneration in the Unity Menu and not use the Console Tool.

jstiefel commented 3 years ago

Ok, this makes sense. I used the Unity Menu of RosBridgeClient, but just changed the message manually. Now switching to the console script.

marcelop3 commented 3 years ago

Hi,

I have experienced the same. But even with the console script I had to manually change the action messages.