DiddyBorg Scrpit Examples

Hi,

When I run the diddySequence.py example on my diddyborg it runs immediately with all the wires from the keyboard and monitor still plugged in, I tried adding this line "@reboot /home/pi/diddyborg/diddySequence.py" to the bottom of the crontab file but can't seem to save the file when I've added it. Is there anyway I can add a line of code in Python to delay when the program actually starts to run?

Thanks

Alex

piborg's picture

Not sure why you would be having crontab trouble, but adding a delay is easy enough.

Simply add the highlighted lines below into diddySequence.py:

# Import library functions we need
import PicoBorgRev
import time
import math
import sys

# Wait for a bit before starting
time.sleep(60.0)

# Setup the PicoBorg Reverse
PBR = PicoBorgRev.PicoBorgRev()

This will delay the script by a minute.

The number given to time.sleep is how many seconds you wish to wait for.

Hi,

Thanks for the reply. It now works with the delay.
Also I plan to use my Diddyborg as a surveillance robot controlled via wifi around my house, I have got a dongle which I've connected as is working well with my Pi and Diddyborg, but any suggestions as to how I can control the Diddyborg maybe using a Keyboard interface while viewing the robot view from the PiCam on the screen as well? I also want to develop a loop to record and repeat a pre determined manual route (one controlled by myself using the method previously mentioned) autonomously (while still viewing the robot path on screen) as I've seen that the Diddyborg follows a ball autonomously.
Any Code or tutorials to help me with this?

piborg's picture

We do have another example on the forum which uses the keyboard via WiFi to control DiddyBorg:
Keyboard controlling the PicoBorg Reverse

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

Hi,

I'm using a Windows laptop. So far I've always plugged my Diddyborg into a seperate monitor to program it, can I just connect it to my laptop? Also what exactly is the use of Netcat and mplayer for and will i still be able to control the Diddyborg using my laptop keyboard while the video is streaming? Or is there a sort of web interface I can create? And how can i get the diddyborg to repeat a route autonomously?

I also wanted to find out what the power ratings for the Diddyborg is and how much power supply is supplied to each part of the Diddyborg including the motors( are they connected in parallel?). As I have the same eneloop batteries as in the Diddyborg construction NI-Mh capacity 1900mAh 10x 1.2V AA batteries. How much power and current is being drawn from these batteries and what are the pros and cons using these batteries compared to other Ni or lithium batteries.

Thanks

piborg's picture

Netcat is a simple program which sends a stream of data from one machine to another.
Think of it being like a hose pipe but transferring data rather than water.

mplayer is just a video player which is capable of handling a video stream instead of a file.
We are using it to 'play' the output from raspivid, but on the laptop.

The use of netcat and mplayer should not prevent you controlling the DiddyBorg.
We would recommend using SSH to program and control the Raspberry Pi from your laptop.
You can enable SSH from raspi-config on the Raspberry Pi.
To use SSH from a Windows machine we recommend using PuTTY.

The pbrKeyboard.py script sets the voltage output on lines 14 and 15.
Line 14 should be set to the battery voltage, 10x 1.2V = 12V.
Line 15 should be set to the motor voltage, 6V for DiddyBorg.

The motors are in parallel so they each receive the same voltage.
The current draw depends on how hard they are having to work.
For example driving uphill or moving with more weight will use more current.

Subscribe to Comments for "DiddyBorg Scrpit Examples"