can't get response from service callback
hi
I'm trying to use ros2 service feature, but there is an problem
below is simplified version of my code
service_server.py
rclpy.init()
node = rclpy.create_node('test')
service = node.create_service(serviceType, 'service_name', service_callback)
def service_callback(self, request, response):
response.success = True
return response
service_client.py
rclpy.init()
node = rclpy.create_node('test')
client = node.create_client(serviceType, 'service_name')
request = serviceType.Request()
if client.wait_for_service():
response = client.call(request)
Server is fine. When I call service with ros2 command line interface, it worked. Problem is the client. Client is stuck in 'response = client.call(request)', like response is never been arrived.
do you have a
spin()
somewhere ?