Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
A simple ROS2 publisher node that sends messages to a topic.
import rclpy
from rclpy.node import Node
from std_msgs.msg import String
class MinimalPublisher(Node):
def __init__(self):
super().__init__('minimal_publisher')
self.publisher_ = self.create_publisher(String, 'topic', 10)
self.timer = self.create_timer(1.0, self.timer_callback)
def timer_callback(self):
msg = String()
msg.data = 'Hello ROS2'
self.publisher_.publish(msg)
self.get_logger().info('Publishing: %s' % msg.data)
def main(args=None):
rclpy.init(args=args)
node = MinimalPublisher()
rclpy.spin(node)
node.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()ROS (Robot Operating System) and ROS2 are open-source frameworks for robot software development. They provide libraries, tools, and conventions to simplify programming, communication, and control in robotics, supporting modularity, real-time systems, and hardware abstraction.
Origin & Creator
ROS was created by the Stanford AI Lab and Willow Garage around 2007-2009. ROS2 development started by Open Robotics in 2014 to address ROS1 limitations in real-time, security, and cross-platform support.
Industrial Note
ROS2 is increasingly adopted in industrial automation, autonomous vehicles, and robotics middleware due to its support for real-time deterministic systems and secure communication.