99576 Views
78289 Views
44897 Views
42231 Views
38578 Views
33219 Views
Robot Arms
TherePi - Music Making with a Raspberry Pi
Motion Controlled Arm
Electric Trombone
PicoTico
ClusteredPi
Introduction to Rust
OctaPi
Raspberry Pi 5 Cluster with Docker Swarm
Building Websites with Jekyll
Docker
Data Manipulation with Pandas and Numpy
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 >