We're nearly at the point where we can start doing some exciting robotics! There are currently four test programs for the PiBot - python programs which put the current system through its paces, to make sure all the hardware is working as it should.
Firstly here is a listing of the firmware, which has to be running on the Bot Board's Arduino:
Notice that I have embedded these code listings from my Gist account on GitHub, which is where the open source software from the PiBot Team is published. These are my versions of the PiBot Team's software. Hopefully my future versions, on following Blog posts, will be advanced versions of these. As these are embedded, any changes I make to these on GitHub will be reflected in these listings, so I must be careful to generate new Gists.
The four python programs are:
1. drive_in_square.py,
2. monitor_ultrasonic.py,
3. robot_teleop.py and
4. test_pibot_hardware.py.
The code listings that I will give here contain some small adjustments which I made to suit my particular needs.
drive_in_square.py
This test program allows the PiBot to proceed in a straight line for a fixed time, make a right-angled turn, do a straight line, do a right angle, do a straight line and do a right angle - making a square shaped track. The program continues indefinitely, so it has to be interrupted by performing a Ctrl-Z on the Pi's remote terminal on the PC, followed by touching together the two flying leads on the PiBot to do an Arduino reset.
You've seen this program in action in the last post, but here's the version with a shortened square:
Here's the code:
Notice that the speed can be specified in the command line which runs the program. Lines 11 and 12 pick up the argument if you put it in, and otherwise it assigns a default value. For example, if you enter the command:
python drive_in_square.py
the default value of speed at line 9 will be used, while the command
python Drive_in_square.py 255
will enable the command line argument with the value 255 to be picked up, and this value will override line 9.
monitor_ultrasonic.py
This program causes the ultrasonic transceiver to transmit and receive, so that the estimated distance to a solid object can be printed on the remote terminal. The PiBot doesn't move.
Here it is running:
Here's the code:
robot_teleop.py
The teleop program makes the PiBot respond to 1-character keyboard commands - f for forward, b for backward, l for left, r for right turn and s for stop, each followed by an Enter.
Here it is running:
Here's the code:
This program tests all hardware connected to the PiBot. Currently the final kit parts have not been fitted - the panning step motor and the tilting servo for aiming the PiCam, but the code for some of these functions is already there, ready for connection.
Here it is running:
The stepper motor and servo software is included, but this hardware hasn't been attached yet.
Here's the code:
Notice that I am using a couple of mp3 sound bites downloaded from the internet, including one of a cat meeow, hoping to stimulate some interest in our cat, but it doesn't fool her - she just ignores it!
What's next - I hear you say - well, some tidying up of the above, and dreaming up what I could make it do etc.
Some observations so far - the 4 x AA rechargeable batteries work a treat, and for a surprisingly long time. I have 2 sets of 4 x 2400 mA-h AAs, so one set can be charging while I'm running the PiBot with the other set. I haven't timed the workload available, but so far I have only had one episode (the Pi wouldn't boot) where the only remedy seemed to be to replace the batteries, and that worked.
Presumably by the time I start running the PiCam, the system will start to eat up batteries. I'm happy that the Pi I'm using is a Model A because the power consumption is less (1.5W) than that of the Model B (3.5W).
Things I would like to do?
- I assume that I will be able to use the ultrasound distance system to prevent the PiBot from colliding with things - my SD card is getting an awful battering!
- Experimenting with combinations of colours of the neopixels.
- Of course, mounting the camera and transmitting images would be great. (ref HERE).
- I also have a successful XBee pair system working away (ref HERE), so I will try to think how that could be included in the PiBot.
- An IR receiver would be great, to smarten up the remote control. (ref HERE).
- I saw some code for a thermistor, and I would like to incorporate my previously-built thermopile system (ref HERE), which is still working away on my desk, telling me how cold a bag of ice is, or how hot my tea is.
- Another project which is working away on my desk very successfully, is the recently built light follower (ref HERE) - it works a treat and I would like to somehow incorporate that into the PiBot.
- I would like to put a powerful headlamp system on. This could be self-powering like a high-power LED flashlight (or two?) (ref HERE).
- A talking system would be good.
- Get it to make my tea, wash the car.........
But first, I will try to fully understand and maybe explain, the current software.