ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

For Python 3:

def serialize_msg(msg):
    buff = BytesIO()
    msg.serialize(buff)
    return buff.getvalue()

Traced it using ROS1 Melodic's implementation here:

https://github.com/ros/ros_comm/blob/fad51345f1937a8fca036b264a4c6fb034970a5f/clients/rospy/src/rospy/topics.py#L906