Unity-Technologies / Unity-Robotics-Hub

Central repository for tools, tutorials, resources, and documentation for robotics simulation in Unity.
Apache License 2.0
2.04k stars 420 forks source link

Trigger service call crashes ros_tcp_endpoint Node #390

Open wyattrees opened 1 year ago

wyattrees commented 1 year ago

Describe the bug Calling a ROS2 service of type std_srvs/srv/Trigger will crash the default_server_endpoint Node

To Reproduce Steps to reproduce the behavior:

  1. Start a ROS2 Node that has a service of type std_srvs/srv/Trigger alongside the default_server_endpoint Node.
  2. Register & call said service from a Unity script.

Console logs / stack traces

servo_1  | [default_server_endpoint-4] Exception in thread Thread-4:
servo_1  | [default_server_endpoint-4] Traceback (most recent call last):
servo_1  | [default_server_endpoint-4]   File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
servo_1  | [default_server_endpoint-4]     self.run()
servo_1  | [default_server_endpoint-4]   File "/usr/lib/python3.8/threading.py", line 870, in run
servo_1  | [default_server_endpoint-4]     self._target(*self._args, **self._kwargs)
servo_1  | [default_server_endpoint-4]   File "/home/dev_ws/install/ros_tcp_endpoint/lib/python3.8/site-packages/ros_tcp_endpoint/client.py", line 163, in service_call_thread
servo_1  | [default_server_endpoint-4]     response = ros_communicator.send(data)
servo_1  | [default_server_endpoint-4]   File "/home/dev_ws/install/ros_tcp_endpoint/lib/python3.8/site-packages/ros_tcp_endpoint/service.py", line 55, in send
servo_1  | [default_server_endpoint-4]     message = deserialize_message(data, message_type)
servo_1  | [default_server_endpoint-4]   File "/opt/ros/galactic/lib/python3.8/site-packages/rclpy/serialization.py", line 42, in deserialize_message
servo_1  | [default_server_endpoint-4]     return _rclpy.rclpy_deserialize(serialized_message, message_type)
servo_1  | [default_server_endpoint-4] rclpy._rclpy_pybind11.RMWError: failed to deserialize ROS message: rmw_serialize: invalid data size, at /tmp/binarydeb/ros-galactic-rmw-cyclonedds-cpp-0.22.6/src/rmw_node.cpp:1536

Expected behavior The service call executes successfully.

Screenshots N/A

Environment (please complete the following information, where applicable):

Additional context Services of other types work as expected. The ROS2 Node I am using in this example is a MoveIt Servo Node. The service I am trying to call is /servo_node/start_servo.

panagelak commented 3 months ago

@wyattrees i solved it by doing a workaround..

at service.py file i imported std_srvs at the top and then i did an if as follows at the send function

    message = None
    if (isinstance(message_type, std_srvs.srv._trigger.Metaclass_Trigger_Request)):
        message = std_srvs.srv.Trigger.Request()
    else:
        message = deserialize_message(data, message_type)