ROS Toolbox Fast CDR exception deserializing message of type rmw_dds_common...

조회 수: 60 (최근 30일)
Penelope
Penelope 2025년 6월 27일
답변: George Wu 2025년 7월 3일
Problem: When a python publisher is set up and a MatLab subscriber is on the same domain, creating the subscriber or running ros2 topic list in the Matlab terminal will return this error;
[rcutils|error_handling.c:108] rcutils_set_error_state()
This error state is being overwritten:
''Bad alloc' exception deserializing message of type rmw_dds_common::msg::dds_::ParticipantEntitiesInfo_., at ./src/type_support_common.cpp:123'
with this new error message:
'Fast CDR exception deserializing message of type rmw_dds_common::msg::dds_::ParticipantEntitiesInfo_., at ./src/type_support_common.cpp:118'
rcutils_reset_error() should be called after error handling to avoid this.
This then repeats about 5 times, which then leads to substantial lag, followed by either Matlab crashing (100% RAM and CPU usage) or the system running smoothly without crashing, seemingly unaware of the issue. This also repeats when the subscriber is closed.
The code I have is very simple.
Python:
# simple_pub_float64multiarray.py
# Publishes an example float64multiarray on the "tester" topic
import rclpy
import math
from rclpy.node import Node
from std_msgs.msg import Float64MultiArray
class MinimalPublisher(Node):
def __init__(self):
super().__init__('minimal_publisher')
self.publisher_ = self.create_publisher(Float64MultiArray, 'tester', 10)
timer_period = 0.2 # seconds
self.timer = self.create_timer(timer_period, self.timer_callback)
self.i = 1.0
def timer_callback(self):
msg = Float64MultiArray()
msg.data = [42.0, 10.0, 9.0]
self.publisher_.publish(msg)
self.get_logger().info('%s' % msg)
self.i += 1
def main(args=None):
rclpy.init(args=args)
minimal_publisher = MinimalPublisher()
rclpy.spin(minimal_publisher)
minimal_publisher.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()
Matlab:
matlabSubNodeName = "matlab_receiver";
matlabSubNode = ros2node(matlabSubNodeName);
subscriber = ros2subscriber(matlabSubNode, "/tester", @testSub, "Reliability", "besteffort");
function testSub(msg)
disp(msg.data)
end
Additional Information: I am on Matlab 2025a, using Python 3.10, and have tried both cyclone_dds and fastrtps_dds. Both my Ubuntu and Matlab are using ROS2 Humble. When running these very simple scripts, the chances of crashing are low; however, I am having to connect a large amount of subscribers due to how my code is structured, which increases the chance of a crash occuring.
I have also received the following errors when using cyclone_dds instead of fastrtps_dds;
Error; This error state is being overwritten:
'invalid data size, at ./src/serdata.cpp:384'
with this new error message:
'string data is not null-terminated, at ./src/serdata.cpp:384'
I have also gotten this error in the terminal I am using to run Matlab;
[WARN] [1751049296.108842927] [rmw_cyclonedds_cpp]: Failed to parse type hash for topic 'ros_discovery_info' with type 'rmw_dds_common::msg::dds_::ParticipantEntitiesInfo_' from USER_DATA '(null)'.
Some assistance would be greatly appreciated.

답변 (1개)

George Wu
George Wu 2025년 7월 3일
Hi,
This also happened to me when I migrated from R2024a to R2025a. In my matlab log, there was a warning saying ROS_LOCALHOST_ONLY is deprecated but still honored if it is enabled. Use ROS_AUTOMATIC_DISCOVERY_RANGE and ROS_STATIC_PEERS instead.
I've then checked the environment setting by `getenv('ROS_LOCALHOST_ONLY')`, where ROS_LOCALHOST_ONLY was set to 0, where no values should be set, as the exception handler in ROS2 apparently causes lag.
I've fixed it by adding a line `setenv('ROS_LOCALHOST_ONLY', '');`
Regards,
George

카테고리

Help CenterFile Exchange에서 ROS 2 Network Connection and Exploration에 대해 자세히 알아보기

제품


릴리스

R2025a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by