ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yep, definitely looks like you've created a deadlock.

By default, roscpp runs in a single thread and processes your service callbacks as part of ros::spinOnce() (or ros::spin()). Since service calls are blocking, when each program starts the service call it can't execute callbacks until the service call completes.

Both of your programs are probably sitting at client.call(), waiting for the other program to process its service callback.

There are a couple of ways to solve this:

  • Re-design your program so that it doesn't have a deadlock. (I would start by asking whether you really need blocking service calls; can you use topics instead?)
  • Use an AyncSpinner or some other mechanism to process callbacks in a different thread