Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You have a typo in your code. The second service call should be;

whereas you have;

which you have already shutdown.

A couple of more suggestions / information (as I have OCD)

You don't need to explicitly call shutdown as per documentation. When the service client goes out of scope, it will be automatically shutdown.

Also, declaring everything on the top makes the code more readable, like this

    ros::ServiceClient pauseGazebo = n_.serviceClient<std_srvs::Empty>("/gazebo/pause_physics");
    ros::ServiceClient unpauseGazebo = n_.serviceClient<std_srvs::Empty>("/gazebo/unpause_physics");
    std_srvs::Empty pauseSrv;
    std_srvs::Empty unpauseSrv;
    char key;;

    std::cout<<"enter q to continue"<<std::endl;

    if('q' == key)
    {          ;
        std::cout<<"q is pushed"<<std::endl;