Robotics StackExchange | Archived questions

waitKey and ROS

How can i use Waitkey in ROS..

I have while loop which waits for a user input, and then goes to the next state.. Within i get video image using Image_transport.

So my idea is to have

cout << "Am i done?" << endl;
While(input != 'y')
{
      Retreive new frames for the function to work with.... 
}

But the problem is that it keeps outputting "Am i done", which i suspect is because the Ros::spin(), but what doesn't make sense, it how it breaks out of the while loop. How do make it only do the thing within the while loop until a key is pressed.

Asked by 215 on 2015-03-19 11:43:46 UTC

Comments

where is the getting input part ?

Asked by bvbdort on 2015-03-19 14:47:06 UTC

user input

Asked by 215 on 2015-03-19 15:02:49 UTC

where is cin ?

Asked by bvbdort on 2015-03-19 17:30:07 UTC

Well.. the way i was thinking of doing was using getch() to detect the input, and if it correspond to a letter ex. 'y' it will jump out.. while(input != 'y' ) { .... input = getch(); }

Asked by 215 on 2015-03-19 17:47:17 UTC

may be some small datatype error from reading input. please put your real code about input.

Asked by bvbdort on 2015-03-20 06:10:31 UTC

The reason why i want to use OpenCV wait key.. is because the function within runs imshow("webcam",frame), which require wait key...

Asked by 215 on 2015-03-26 10:16:05 UTC

Answers