Playback function

Hi,

Is there some sort of playback function that I can include in my piece of code to automatically repeat my manual operations of the Diddyborg? I'm controlling manually with the keyboard using Putty. And want it to repeat my operations.

Thanks.

piborg's picture

It should be fairly easy to write some code to get a record and playback working.

What you need is to get the code to write the commands entered and the time they happened to a file.

Then you want another piece of code which reads this file, then does the same commands written in the file with delays between them to match the times.

You may wish to read the following bits of the Python tutorial:
File reading / writing ⇒ https://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-...
Delays using sleep ⇒ https://docs.python.org/2/library/time.html#time.sleep
Getting the current time ⇒ https://docs.python.org/2/library/time.html#time.time

Sleep() function actually suspends the processing of the thread in which it is called by the operating system, allowing other threads and processes to execute while it sleeps. With multiple threads and processes, sleep() suspends your thread - it uses next to zero processing power.

Ok but is this possible as I want it to read and write code for me as I control the diddyborg using a keyboard. and instead or in addition to using time I want to use the camera for image processing and record images. So for playback it will need to match the previously recorded images for autonomous movement

piborg's picture

Okay, I think I understand what you are trying to do now.

Image processing is a rather large topic, in particular there are many different ways that images may be 'matched'

I would suggest having a look at the OpenCV tutorials as a starting point:
http://docs.opencv.org/doc/tutorials/tutorials.html
We used OpenCV with the ball following code we made for DiddyBorg.

Subscribe to Comments for "Playback function"