can't get response from service callback

asked 2019-10-17 00:17:20 -0500

BattlePants gravatar image

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.

edit retag flag offensive close merge delete

Comments

do you have a spin() somewhere ?

ignacio gravatar image ignacio  ( 2019-10-19 08:29:46 -0500 )edit