Properly check the state of ROS before calling the prolog service