Practice the ROS2 Services - Basic Service Server coding problem in ROS2 Services. Browser-based execution with automated grading — no local ROS install required. 71% of engineers pass this challenge.
Topics are fire-and-forget — the publisher doesn't know if anyone received the message. Services are different: they're synchronous request/response calls, like a function call between nodes.
[client node] ──request──▶ /add_two_ints ──response──▶ [client node]
▲
[server node handles it]
Key API (server side):
self.srv = self.create_service(ServiceType, '/service_name', self.callback)
def callback(self, request, response):
response.sum = request.a + request.b
return response # must return the response object
When to use services vs topics:
Services provide a synchronous Request/Response communication pattern. Create a service server that adds two integers.
add_two_ints_serveradd_two_intsexample_interfaces/AddTwoIntsrequest.a and request.b into response.sumInput:
a=2, b=3Output:
sum=5None instead of response.It is a hands-on ROS2 Services challenge on SimuCode where you implement and run ROS2 code in the browser with runtime-verified tests.
Open this page, sign in, and solve the problem in the built-in IDE. Your solution is graded against real ROS2 execution checks.
This Hard problem focuses on services, server, request-response skills used in robotics interviews and production systems.