EricVoll/ros-sharp

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

bryceikeda opened this issue ยท 11 comments

  • [ x] I am at the right place and my issue is directly related to ROS#. General technical questions I would post e.g. at ROS Answers or Stack Overflow. For library-specific questions I would look for help in the corresponding library forums.
  • I have thoroughly read the Contributing Guideline and writing this issue is the right thing to do in my case.

I found a bug!

  • [x ] I am using the latest ROS# version available here on the master branch.

  • I am adding all required information, code and data files, screenshots and log files so that you can reproduce the problem.

  • My OS is: Ubuntu 18.04

  • My Unity Version is: 2019.4.15f1

  • My ROS Distribution is: Melodic

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

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.

@Rive4

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

Hi both ๐Ÿ‘‹
I'll have a look at it later today.

@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...)

@EricVoll

That works! Thanks for looking into this for me.

-Bryce

I fixed the generator to generate properties now.

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.

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.

@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.

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

Hi,

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