Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 544 Bytes

services.md

File metadata and controls

20 lines (14 loc) · 544 Bytes

rclpy: Services

Synchronous Service Call

By default, services in rclpy are asynchronous. For more info see this How-to Guide.

from my_ros_package.srv import ServiceName
from threading import Thread

cli = my_node.create_client(ServiceName, 'service_name')
cli.wait_for_service()

# Need to spin before making the service call or we will deadlock
spin_thread = Thread(target=rclpy.spin, args=(my_node,))
spin_thread.start()

req = ServiceName.Request()