ROS/Connection Header

The ROS connection header contains important metadata about a connection being established, including typing information and routing information. How it is exchanged depends on the ROS transport being used.

See also:

Encoding Format

4-byte length + [4-byte field length + field=value ]*

All length fields are little-endian integers. Field names and values are strings.

Example encoding of a published message

Raw hex output from rostopic pub /chatter std_msgs/String "hello" (new lines and indenting added for readability):

b0 00 00 00
   20 00 00 00
      6d 65 73 73 61 67 65 5f 64 65 66 69 6e 69 74 69 6f 6e 3d 73 74 72 69 6e 67
      20 64 61 74 61 0a 0a
   25 00 00 00
      63 61 6c 6c 65 72 69 64 3d 2f 72 6f 73 74 6f 70 69 63 5f 34 37 36 37 5f 31
      33 31 36 39 31 32 37 34 31 35 35 37
   0a 00 00 00
      6c 61 74 63 68 69 6e 67 3d 31
   27 00 00 00
      6d 64 35 73 75 6d 3d 39 39 32 63 65 38 61 31 36 38 37 63 65 63 38 63 38 62
      64 38 38 33 65 63 37 33 63 61 34 31 64 31
   0e 00 00 00
      74 6f 70 69 63 3d 2f 63 68 61 74 74 65 72
   14 00 00 00
      74 79 70 65 3d 73 74 64 5f 6d 73 67 73 2f 53 74 72 69 6e 67
09 00 00 00
   05 00 00 00
      68 65 6c 6c 6f

The output can be translated as:

  • The message header length is 176 bytes (b0 00 00 00, length field encoding is little-endian).
  • The message_definition field length is 32 bytes (20 00 00 00):

6d 65 73 73 61 67 65 5f 64 65 66 69 6e 69 74 69 6f 6e 3d 73 74 72 69 6e 67-
 m  e  s  s  a  g  e  _  d  e  f  i  n  i  t  i  o  n  =  s  t  r  i  n  g-
20 64 61 74 61 0a 0a
    d  a  t  a \n \n
  • The callerid field length is 37 bytes (25 00 00 00):

63 61 6c 6c 65 72 69 64 3d 2f 72 6f 73 74 6f 70 69 63 5f 34 37 36 37 5f 31 33-
 c  a  l  l  e  r  i  d  =  /  r  o  s  t  o  p  i  c  _  4  7  6  7  _  1  3-
31 36 39 31 32 37 34 31 35 35 37
 1  6  9  1  2  7  4  1  5  5  7
  • The latching field length is 10 bytes (0a 00 00 00):

6c 61 74 63 68 69 6e 67 3d 31
 l  a  t  c  h  i  n  g  =  1
  • The md5sum field length is 39 bytes (27 00 00 00):

6d 64 35 73 75 6d 3d 39 39 32 63 65 38 61 31 36 38 37 63 65 63 38 63 38 62 64-
 m  d  5  s  u  m  =  9  9  2  c  e  8  a  1  6  8  7  c  e  c  8  c  8  b  d- 
38 38 33 65 63 37 33 63 61 34 31 64 31
 8  8  3  e  c  7  3  c  a  4  1  d  1
  • The topic field length is 14 bytes (0e 00 00 00):

74 6f 70 69 63 3d 2f 63 68 61 74 74 65 72
 t  o  p  i  c  =  /  c  h  a  t  t  e  r
  • The message type length is 20 bytes (14 00 00 00):

74 79 70 65 3d 73 74 64 5f 6d 73 67 73 2f 53 74 72 69 6e 67
 t  y  p  e  =  s  t  d  _  m  s  g  s  /  S  t  r  i  n  g
  • The message body length is 9 bytes (09 00 00 00).
  • The first field of the std_msgs/String message (data) is 5 bytes (05 00 00 00):

68 65 6c 6c 6f
 h  e  l  l  o

Fields

See TCPROS information on the specific fields used when creating TCPROS connections.

  • callerid: name of node sending data
  • topic: name of the topic the subscriber is connecting to
  • service: name of service the client is calling
  • md5sum: md5sum of the message type
  • type: message type
  • message_definition: full text of message definition (output of gendeps --cat)
  • error: human-readable error message if the connection is not successful
  • persistent: sent from a service client to a service. If '1', keep connection open for multiple requests.
  • tcp_nodelay: sent from subscriber to publisher. If '1', publisher will set TCP_NODELAY on socket if possible
  • latching: publisher is in latching mode (i.e. sends the last value published to new subscribers)

Wiki: ROS/Connection Header (last edited 2011-09-25 21:56:49 by baalexander)