eProsima/Integration-Service

crash when sending custom array from websocket to ros2

tal-grossman opened this issue · 5 comments

Issue Description:

I am able to send any msg type including custom srtuct with array (sequence accroding to yaml) from ros2 to websocket but integration service crashes when sending from websocket to ros2.

How To reproduce:

  1. setup ros2 and websocket environment according to https://integration-service.docs.eprosima.com/en/latest/examples/different_protocols/pubsub/ros2-websocket.html
  2. build custom msg and create mix file using colcon build --cmake-args -DMIX_ROS2_PACKAGES="client_interface_msgs"
  3. create custom struct accorting to yaml_config guide and self exploration and try and error. see yaml configuration below.
  4. run integration-service RoboxClientInterface.yaml
  5. use node-red as websocket client and publish to (localhost) ros2 same custom msg.

Expected Result:

receiving custom struct as ros2 msg from websocket client.

Actual Result:

integration service crashers with this terminal msg:
[Integration Service][INFO] [is::sh::WebSocket::Server] Sent publication on topic 'robox_to_client': [[ {"msg":{"request":"test","theta":"","values":[{"key":"test_key","value":"test_value"},{"key":"test_kekey2","value":"test_value2"}],"x":"","y":""},"op":"publish","topic":"robox_to_client"} ]] [Integration Service][INFO] [is::sh::WebSocket::Server] Handle TCP message from connection '1': [[ {"op":"publish","topic":"robox_to_client","msg":{"request":"test","theta":"","values":[{"key":"test_key","value":"test_value"},{"key":"test_kekey2","value":"test_value2"}],"x":"","y":""}} ]] terminate called after throwing an instance of 'eprosima::is::json_xtypes::UnsupportedType' what(): Aborted (core dumped)

Yaml file (RoboxClientInterface.yaml): yaml_file

ros2 custom msg package (cient_interface_msgs): client_interface_msgs_package

Additional Information

  • when sending same msg from ros2 termial to websocket client (node-red in my case), its working. example:
    ros2 topic pub /robox_to_client client_interface_msgs/msg/RoboxClientInterface '{request: "test", values: [{key: "test_key", value: "test_value"}, {key: "test_kekey2", value: "test_value2"}]}'
    and from node-red side got:
    {"msg":{"request":"test","theta":"","values":[{"key":"test_key","value":"test_value"},{"key":"test_kekey2","value":"test_value2"}],"x":"","y":""},"op":"publish","topic":"robox_to_client"}
  • Versions:
    Integration service: 812b14e
    ROS-SH: 8f6e0e1ed1a20e2ee6f20c56e29bd8d325f7048b
    Websocket-SH: 436c8ddf52768f49b5f8a74a3453a437c962bbb0
    libwebsocketpp-dev: 0.8.1-7
    Im using on my local enviorment

BTW,
Same issue is open under WebSocket-SH, so feel free to close one of them

This definitely could be related to our json-xtypes library not properly handling this particular type definition, thanks for the feedback. I am going to try to replicate your scenario and will come back as soon as I have something

hey any new with this?
I also eperience degredation in other types.
Now I can't send from Websocket to Ros2 other types like geometry/Pose, for the same reason.

Good morning @tal-grossman I just had time to test your use case and I am happy to say that everything works fine.

Just a couple of remarks regarding on how I modified/tested your example:

  • First of all, the YAML file that you sent me can be hugely simplified. Notice that, using the types-from attribute, no IDL is
    required to be specified in the types section; this also means that no type remapping is needed for the websocket system. Thus, the final configuration file would look like this:

    systems:
      ros2: { type: ros2 }
      websocket: { type: websocket_server, types-from: ros2, port: 12345, security: none }
    
    routes:
      websocket_to_ros2: { from: websocket, to: ros2 }
      ros2_to_websocket: { from: ros2, to: websocket }
    
    
    topics:
      client_to_robox: { type: "client_interface_msgs/RoboxClientInterface", route: websocket_to_ros2 }
      robox_to_client: { type: "client_interface_msgs/RoboxClientInterface", route: ros2_to_websocket }
  • I tested this example using the WebSocket echo webpage as a WebSocket client. It should be the same from Node-RED:

    • First, you should connect to the Server. You should receive an advertise for the topic robox_to_client, and a subscribe for the topic client_to_robox:

      RECEIVED: {"op":"subscribe","topic":"client_to_robox","type":"client_interface_msgs__RoboxClientInterface"}
      
      RECEIVED: {"op":"advertise","topic":"robox_to_client","type":"client_interface_msgs__RoboxClientInterface"}
    • Then, it is needed to perform an advertise operation to the topic you want to publish to from WebSocket, that is, client_to_robox:

      {"op": "advertise", "topic": "client_to_robox", "type": "client_interface_msgs/RoboxClientInterface"}
    • Finally, publish a message instance to the client_to_robox topic, using the provided format specified in the documentation:

      {"op": "publish", "topic": "client_to_robox", "msg": {"request": "thisisarequest", "x": "hey", "y": "bye", "theta": "theta", "values": [{"key": "1", "value": "one"}, {"key": "2", "value": "two"}]}}
    • You should receive the message in ROS 2:

      ros2 topic echo /client_to_robox
      request: thisisarequest
      x: hey
      y: bye
      theta: theta
      values:
      - key: '1'
        value: one
      - key: '2'
        value: two

Please try and close the issue if everything works as expected, otherwise reply to this thread.

Also, notice that we are preparing a minor release which will properly handle the json_xtypes conversion library exceptions, so that the whole Integration Service instance does not get aborted due to one of them being thrown.

Hello @jamoralp!
Firstly, thank you very much on your efforts and dedication! (b.t.w This integration service repo is great!)

I have been testing according to your instructions and you are right, it works fine!
I guess my poor usage of this tool, specifically my Yaml configuration file was the issue's root cause. configuring Idls and remmaping instead of just using types-from: ros2 is bad.

I did however noticed that sending advertise from web-socket to ros2

{"op": "advertise", "topic": "client_to_robox", "type": "client_interface_msgs/RoboxClientInterface"}

as you elaborated in detail is unnecessary. I skipped it and just used

 {"op": "publish", "topic": "client_to_robox", "msg": {"request": "thisisarequest", "x": "hey", "y": "bye", "theta": "theta", "values": [{"key": "1", "value": "one"}, {"key": "2", "value": "two"}]}}

and got the msg to ros2 the server.

Feel free to close this isuse if you will. I'm following closley on this repo and looking forward for the next version :)

That's great to hear! We're happy that the project fits your needs. It's been a lot of work but we believe it has been worth it 🙂

About the advertise thing, yes you are right. That only applies for the server.

Also, regarding the bunch of exceptions in websocket and the JSON to xTypes library that currently cause the Integration Service to be aborted, we have prepared a couple of pull requests to treat properly these exceptions: #149 and eProsima/WebSocket-SH#26. Hope this information is useful for you. Cheers!