Remote control

Hi Folks,

I've just started my first project using a PiBorg Reverse and a Raspberry Pi. What I would eventually like to do is sit at my laptop and 'drive' my own robot around the room with a 'first person perspective' supplied by a PiCam or some other camera.

I'd like to ask for your advice. How would you control the Pi/PiBorg over WiFi? I'm sure there are a host of ways - VNC, SSH, etc. My current thinking is running a webserver on the Pi and using AJAX or CGI to fire off python scripts. Not exactly simple but not brain surgery either. Is there a better way ?

TIA

Huw

piborg's picture

Around the house I have found SSH with a GUI can work quite well for providing control.
If you look at our RemoteKeyBorg example, RemoteKeyBorgC specifically, it shows you how you could use pygame to detect keypresses.
If you want to give it typed commands then a Python script using raw_input via SSH is probably best.
VNC does work but it can be sluggish if it is transmitting a lot of changes (such as playing a video).

What we usually do for control is write two scripts which actually read and write to the network using UDP.
This way we do not need a webserver, SSH, or VNC type connection.
The RemoteKeyBorg script is a complete example of detecting key presses, sending messages, and finally controlling a board at the other end.
You could easily change the data to be drive power levels, as well as to command a PicoBorg Reverse instead of the basic PicoBorg.

I have also used raspivid along with netcat to stream from the Raspberry Pi camera to another machine:
raspivid -w 640 -h 480 -fps 60 -t 99999999 -o - | nc 192.168.0.100 5001
where 192.168.0.100 is the IP address of my laptop.

My laptop is running Windows so I use the following to receive the video stream:
nc.exe -L -p 5001 | "C:\mplayer\mplayer.exe" -vo gl -fps 999 -cache 10240 -
I think the equivalent line for Linux is probably:
nc -L -p 5001 | mplayer -vo gl -fps 999 -cache 10240 -

You should be able to find both netcat and mplayer in the repositories under Linux.
You will probably need to download mplayer and netcat if you are using Windows:
NetCat built for Windows: http://www.stuartaxon.com/2008/05/22/netcat-in-windows (use the second link)
mplayer: http://www.mplayerhq.hu/design7/dload.html

Thank you. Very interesting answer :-) I hadn't considered the PyGame route. There are clearly pluses and minuses for all the options. I guess I better try more than one and see which works best. I have more experience with webserver coding so that might be the first place to start.

Once again, thanks for such an interesting response :-)

Subscribe to Comments for "Remote control"