Skip to content

Ros2 subscriber

Create a subscriber

  1. init
    1. inherit from Node and name itself
    2. define message in subscription: data type, topic name, listener_callback function, queue size
      1. data type and topic name should be the same as the publisher you want to subscribe
      2. listener_callback function doesn't need any timer, its callback get called as soon as it receives a message
  2. listener_callback
    1. simply print an info message to the console
  3. main
    1. almost same as publisher, replacing the creation and spining of the publisher with the subscriber