Pause execution of program from callback function
In my main, I have defined a callback function with the following code:
// initialize a Subscribing for reading the current pose
CallbackHandler cb_handler(slam, &node_list, &node_tstamps);
ros::Subscriber sub = nh.subscribe("/pose2D", 1000, &CallbackHandler::checkOdometricConstraint, &cb_handler);
After that I call ros::spin()
to wait for callbacks
ros::spin();
Is it possible to pause the system execution from within the callback function?
I tried using cpp approaches like system("pause")
or std::cin.get()
but that didn't work.
can you tell us why you want to do that (just trying to avoid an xy-problem)?
I incrementally add elements to an std::vector when the callback function is called, and each time this happens I need some time to investigate the added element. I could use ros::Duration(x).sleep() for this purpose but it would be handier if I could pause execution as long as I needed..
With "I need some time to investigate" are you really talking about you, the person, or the rest of your program?
I am talking about me watching the program output. My goal is to see what is the output of the program, for debugging reasons.