Keep running the function without restarting it?
I have this problem that i cannot make run my while(true) without it get restarted..
I think the problem occurs since
in my main loop
int main
{
ros::init(argc,argv, "loop");
loop();
ros::spin();
}
In side loop()
void loop()
{
cout << "Are you ready" << endl;
while(ready == false
{
//DO SOMETHING
ros::spinOnce() //needed since i read from a subscriber in this while loop
}
cout << "i am out" << endl;
while(true)
{
//do something again
ros::spinOnce();
}
}
Right now it keep printing "are you ready", the idea was it should print it once.. I don't understand how it comes outside the loop.. it seems impossible to do..