Ros2 publisher
Createa a publisher
- Init
- inherit from parent
- define messages of publisher node(data type, topic name, queue size)
- queue size: It's the number of message that will help subscriber to hold if subscribe received message slowly, rather than control the sending speed
- set a timer, used to control sending speed
- set a counter self.i used in callback
- set timer_callback
- it creates a message with the counter value appended, and publishes it to the console with get_logger().info
- set main function
- rclpy.init(args=args)
- define node in a variable
- called rclpy.spin(node) to repeattedly called timer_callback until type ctrl+c the loop then close
- (optional) publisher.destroy_node()
- rclpy.shotdown()
- Add dependency in setup.py, setup.cfg and package.xml