105800 Views
82496 Views
47243 Views
47066 Views
45458 Views
38527 Views
Pi-Apps
Intermediate MicroPython
Arduino Alvik
Raspberry Pi Time machine
Now Ad-Free
Guiding Light
Intermediate level MicroPython
Introduction to FreeCAD for Beginners
Building a Robot Arm with Raspberry Pi and PCA9685
Building User Authentication for Static Sites with FastAPI
Mastering Pydantic for Robust Data Validation
Mastering Markdown for Documentation with Jekyll
KevsRobots Learning Platform
55% Percent Complete
By Kevin McAleer, 1 Minute
Lets create another program, that will publishes messages.
This time we’ll make it in a class:
import rclpy from rclpy.node import Node class talker(Node): def __init__(self): super().__init__("node_test") self.counter_ = 0 self.get_logger().info("Hello World") self.create_timer(0.5, self.timer_callback) def timer_callback(self): self.counter_ += 1 self.get_logger().info("Hello" + str(self.counter_)) def main(args=None): rclpy.init(args=args) node = talker() rclpy.spin(node) rclpy.shutdown() if __name__ == "__main__": main()
< Previous Next >