Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
A ROS2 service that responds to requests with a greeting message.
import rclpy
from rclpy.node import Node
from example_interfaces.srv import AddTwoInts
class MinimalService(Node):
def __init__(self):
super().__init__('minimal_service')
self.srv = self.create_service(AddTwoInts, 'add_two_ints', self.add_two_ints_callback)
def add_two_ints_callback(self, request, response):
response.sum = request.a + request.b
self.get_logger().info('Incoming request: a=%d, b=%d' % (request.a, request.b))
return response
def main(args=None):
rclpy.init(args=args)
node = MinimalService()
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.