eprosima::fastcdr::exception::NotEnoughMemoryException with rclpy.ActionClient

asked 2021-05-14 15:56:53 -0500

David Lu gravatar image

I'm using ROS 2 Foxy on Ubuntu 20.04.

Something wacky is going on with my Durations.

#!/usr/bin/env python3

from control_msgs.action import FollowJointTrajectory

import rclpy
from rclpy.action import ActionClient
from rclpy.duration import Duration
from rclpy.node import Node

from trajectory_msgs.msg import JointTrajectoryPoint

class TrajectoryActionClient(Node):
    def __init__(self):
        self._action_client = ActionClient(self, FollowJointTrajectory,

        goal = FollowJointTrajectory.Goal()
        goal.trajectory.joint_names = ['wrist_extension']
        p0 = JointTrajectoryPoint()
        p0.positions = [0.1]
        p0.velocities = [0.0]
        p0.accelerations = [0.0]

        p1 = JointTrajectoryPoint()
        p1.positions = [0.1]
        p1.velocities = [0.0]
        p1.accelerations = [0.0]
        p1.time_from_start = Duration(seconds=5).to_msg()

        self._send_goal_future = self._action_client.send_goal_async(goal)

    def goal_response_callback(self, future):
        goal_handle = future.result()
        if not goal_handle.accepted:

        self._get_result_future = goal_handle.get_result_async()

    def get_result_callback(self, future):

def main(args=None):
    node = TrajectoryActionClient()

if __name__ == '__main__':

If I run this code as is, I get the following:

terminate called after throwing an instance of 'eprosima::fastcdr::exception::NotEnoughMemoryException'
  what():  Not enough memory in the buffer stream

But if I comment out the line

p1.time_from_start = Duration(seconds=5).to_msg()

It runs fine. Changing it to

p1.time_from_start.sec = 5

also doesn't work.

edit retag flag offensive close merge delete


Hey "good news" the same error happens with rclcpp!

David Lu gravatar image David Lu  ( 2021-05-17 17:11:47 -0500 )edit

I have created an isolated package example here: https://github.com/DLu/my_happy_package

Note: The error only occurs when you run on two machines.

David Lu gravatar image David Lu  ( 2021-05-19 14:15:15 -0500 )edit

Can you try it with cyclone? that would at least tell us if it is a middleware issue or perhaps something in rclpy. Also, do you think you could produce a backtrace for the exception?

William gravatar image William  ( 2021-05-19 16:53:51 -0500 )edit

For switching the rmw implementation, see: https://docs.ros.org/en/foxy/Guides/W...

For getting a C stack trace and/or python traceback from a python script (using gdb): https://wiki.python.org/moin/Debuggin...

William gravatar image William  ( 2021-05-19 16:57:38 -0500 )edit

It seems (according to your package's README), that it works with rolling? It could be a bug in FastDDS that was fixed but not back ported, but it doesn't remind me of anything I know about.

William gravatar image William  ( 2021-05-19 16:59:43 -0500 )edit

In which case... it might be a good time to escalate this to an issue on https://github.com/ros2/rmw_fastrtps/

William gravatar image William  ( 2021-05-19 17:00:38 -0500 )edit

I confirm that it works fine with cyclone, which explains why it works fine in galactic and rolling.

I have put a stack trace here: https://github.com/DLu/my_happy_packa...

David Lu gravatar image David Lu  ( 2021-05-20 08:47:07 -0500 )edit