ros c++ pause unpause gazebo
Hi, I want to control the gazebo simulation by c++. My core code is below:
ros::ServiceClient pauseGazebo = n_.serviceClient<std_srvs::Empty>("/gazebo/pause_physics");
std_srvs::Empty pauseSrv;
pauseGazebo.call(pauseSrv);
std::cout<<"enter q to continue"<<std::endl;
char key;
std::cin>>key;
if('q' == key)
{
pauseGazebo.shutdown();
ros::ServiceClient unpauseGazebo = n_.serviceClient<std_srvs::Empty>("/gazebo/unpause_physics");
std_srvs::Empty unpauseSrv;
pauseGazebo.call(unpauseSrv);
std::cout<<"q is pushed"<<std::endl;
}
The puase work well, after I enter q, the "q is pushed" output, but the gazebo is still in the state of pasue. Can you provide some tip?