ros2 / rmw_fastrtps

Implementation of the ROS Middleware (rmw) Interface using eProsima's Fast RTPS.
Apache License 2.0
157 stars 117 forks source link

failed to deserialize ROS message: Fast CDR exception deserializing message of type std_srvs::srv::dds_::Empty_Response_. #729

Closed theksg closed 2 months ago

theksg commented 1 year ago

Hi,

I am creating a ROS Service in Unity Simulator of type std_srvs/Empty.

I am able to call the service, service is doing the intended work.

But when I return the empty response, I get the following error:

The following exception was never retrieved: failed to deserialize ROS message: Fast CDR exception deserializing message of type stdsrvs::srv::dds::EmptyResponse., at /home/user/ros2_humble/src/ros2/rmw_fastrtps/rmw_fastrtps_cpp/src/type_support_common.cpp:118

can anyone help me with what could be going wrong?

clalancette commented 1 year ago

Usually this happens when you have two nodes on the same service and with the same type, but the actual "type" has been changed. Then the deserialization will attempt to deserialize the wrong thing. Ensure that there are no other nodes in your network that are on the same service name and try again.

sloretz commented 1 year ago

@theksg would you be willing to provide a minimal reproducible example?

JingyuQian commented 2 months ago

I met the same problem when trying this demo at https://github.com/foxglove/mcap/blob/main/python/examples/ros2/py_mcap_demo/py_mcap_demo/reader.py. I'm reading a recorded .mcap file. Not sure what this error means since I'm new in ros2. @clalancette would you be able to clarify a bit more? thank you.

To be specific, this demo code runs well on string messages but crashed on bytes messages.

fujitatomoya commented 2 months ago

@JingyuQian

https://github.com/foxglove/mcap/blob/main/python/examples/ros2/py_mcap_demo/py_mcap_demo/reader.py.

this is maintained by https://github.com/foxglove but ros2 organization. i suggest you to create the issue to https://github.com/foxglove/mcap instead.

clalancette commented 2 months ago

Given that there was no response to the original, I'm going to close this one out. As @fujitatomoya says, if you are having trouble with mcap please open an issue on that repository.

mjforan commented 1 month ago

I have this problem with one custom message type, while other similar custom messages are fine. Creating a subscription causes CPU to hit 100%. Occasionally a message will make it through successfully, but mostly I get "A message was lost!!!" warnings. This happens with both ros2 topic echo and C++ subscribers. I am playing data from an MCAP bag, but Cyclone DDS does not exhibit this issue.

MiguelCompany commented 1 month ago

@mjforan If the bag was captured with service data coming from Cyclone DDS, you should be aware that the RMWs for Cyclone DDS and Fast DDS do not interoperate for services

mjforan commented 1 month ago

@MiguelCompany My bag is in the FastRTPS format- it is actually a ROS1 bag which has been converted. This error comes from a regular topic (not service).

mjforan commented 1 month ago

Apparently my team's custom message type changed between ROS 1 and 2. That likely caused the deserialization problem. It would be nice to get an exception instead of locking up the CPU.

JingyuQian commented 1 month ago

@mjforan Yes. After extensive debugging, I can confirm it is the mismatch between recorded mcap and messages.

For my case, I can use https://mcap.dev/docs/python/mcap-ros2-apidoc/mcap_ros2.reader#:~:text=mcap_ros2.reader.read_ros2_messages to read each mcap message. I found that each message contains the schema being used and can be compared with schemas I'm deserializing with.

Pattybhjd commented 3 weeks ago

change the DDS to Cyclone for humble