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

You should not try to prevent the service from being called by slowing or inhibiting spinning. Trying to prevent the system from turning over with limiting how much the executor turns over with spin_once is just going to starve your system of callbacks including things like your subscriptions.

If you invoke the service call in every callback it's going to be executed for every incoming message, that's what you're programming it to do. It you only want it to happen on change(aka only called when it's needed) you should be keeping track of the state of the system and then only invoking the service when the conditions are right. This is your logic and it's your responsibility as the developer to know when it's needed. The system doesn't know when "it's needed".