Skip to content

Instantly share code, notes, and snippets.

@xaedes
Created December 10, 2019 13:07
Show Gist options
  • Save xaedes/629d048b9501b63dfe8a7c2f4c20e8fb to your computer and use it in GitHub Desktop.
Save xaedes/629d048b9501b63dfe8a7c2f4c20e8fb to your computer and use it in GitHub Desktop.
Publish ROS message with seq number as specified in message in Python / Rospy
def pub(publisher, msg):
# undocumented rospy behaviour:
# publisher.publish will pre-inc publisher.impl.seq
# and use this instead of msg.header.seq
# (see https://github.com/ros/ros_comm/blob/309753f4777755f1dc9482f26fbeeeceb48f352d/clients/rospy/src/rospy/topics.py#L1065)
publisher.impl.seq = msg.header.seq - 1
publisher.publish(msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment