thisismyrobot

Littered with robots and Python code

Site updates

Yay, a new template. This time, with a minimum of IE vs. FF differences! If it's broken in your browser, let me know in the comments.

A little progress


I am slowly knocking up a neat little proto-board for testing out the arduino, more pics to follow as I have time.

Shopping...

I just bought one of these little beauties, the StickDuino , and its tiny size is awesome. There are no tricks of perspective here, it is almost exactly the same size as my old work-horse SanDisk USB Stick, although a tiny bit wider. Aside from the sub-$20USD price-tag, the best bit is the integrated USB chip + connector, something that made the "package-arrived" to "blinking-LED (hello-world) program running" process about 3 minutes (the time it takes to install the drivers and un-rar the IDE).

My intention is to have this attached to the back of my Robosapien V1, with an IR LED for control, or to the CMUCam for a little cat-tracking robot!

A promised follow-up

As I promised a while ago, I have been keeping an eye out for news on the British version of DARPA's Grand Challenge.

Popular Mechanics has nice write-up profiling the top four teams that took part in the challenge.

On a personal note, my apologies for the intermittent arrival of entries lately, this semester's subjects are proving to require a stack more concentration that usual - particularly the Intelligent Systems course taught by Prof Michael Negnevitsky. I promise I will get the updates rolling again soon!

A different kind of post

This is my first non-robot post, inspired by little chunk of PHP that I cooked up. I may be out-of-date with this, but I have a standard prepaid non-3G mobile phone that can browse the internet (Sony-Ericsson w200i). Because it's prepaid, I am slugged rather vigorously when I do venture on to the internet (to sync my calendar/emails etc.)

One thing that I have always wanted to do is keep an eye on a couple of different RSS feeds during the day (local news/weather etc.) - without the overhead of loading a full web page like Google Reader for Mobile.

So, I have created a tiny PHP file that can sit on your hosting of choice - an existing website you have, or your own pc coupled with something like No-IP. The PHP script can aggregate a set of RSS feeds into a single time-ordered list with custom identifiers for each feed. The number of returned lines and the maximum line length can both be adjusted from the URL's GET parameters (more on that later).

In its default set-up, a set of tags and feeds are inserted into the PHP before uploading to your hosting as shown:

$feedslist = array(
array('News','http://feeds.news.com.au/public/rss/2.0/news_breaking_news_32.xml'),
array('SDot','http://rss.slashdot.org/Slashdot/slashdot')
);

When the PHP file is loaded, it will give an output similar to this:

(News) Dollar slips from record highs
(News) Bones proven to be Tsar's kids
(News) Accused 'threw computer at victim'
(SDot) Mars Lander's Robot Arm Shuts Down To Save
(News) Market defies US gloom

As you can see, this is a very minimal representation of the original RSS feed(s) that will probably work fine on any basic html-compatible mobile. There are three different options that can be added to the PHP via GET parameters, the total number of lines, the maximum line length and extra feeds (useful if you find a cool feed whilst you are out and can't access the hosted PHP script).

Modifying lines/length of lines:
http://myhost/feedstripper.php?lines=5&linelength=50
(will give a 5 line output with max 50 chars a line)

Adding Feeds:
http://myhost/feedstripper.php?SDot=http://rss.slashdot.org/Slashdot/slashdot&News=http://feeds.news.com.au/public/rss/2.0/news_breaking_news_32.xml
(would negate the need to declare anything the $feedslist array)

As shown above, in theory, you could list all your feeds in the URL string and not fill out the $feedslist array, this will depend on the maximum URL length of your mobile device.

Obviously, this program is very basic, but that was my intention. I wanted a robust, fast and easy to understand PHP application, as well as the most minimal RSS representation I could create. Feel free to download and play about/improve it, let me know if you like it!

One last point, you can add your twitter feed very easily using the following string:
http://TWITTERUSERNAME:TWITTERPASSWORD@twitter.com/statuses/friends_timeline.rss

How it's all supposed to work...

I've now reached the point in programming the robot where I have to commit to two very important things; a language to write in and a formal structure for development.

The first part is easy; I have fallen for the charms of Python, and whilst I am not a veteran explorer of its abilities, I am progressing very quickly and I have not - yet - hit any brick walls!

The second part is not so easy. I had to come up with a framework for testing out a multitude of ideas that did not just result in a longer and longer .py file. This lead me into the depths of Python's Modules, Classes and Threads. Thankfully, Python - from what I have played with so far - seems to have a very elegant interface for developing and using these elements.

To create an expandable and flexible development platform, I have decided to use an adaptation a few of Rodney Brooks' ideas on Subsumption Architecture. Generalising, the resultant behaviour of a Subsumption Architecture comes from basic interactions between separate and prioritised behavioural layers. Higher priority behaviours can overrule lower priority behaviours, allowing for a "don't hit the wall" behaviour to overrule a "find the ball" behaviour when needed. This approach tends to create very complex emergent behaviours from very basic underpinnings.

Now, here is the problem. For my robot, I wanted to have both the prioritised behaviours and the ability to sequence behaviours. This would allow for the development and refinement of areas of a behaviour independently - in a series of different classes. An example of this might be (The numbers indicate the priorities for the behaviours).

1. Don't hit stuff
2. Centre robot on a coloured target
3. Plan a path towards the target
4. Drive to the target
5. Play a tune of celebration
6. Stop

Looking at this, a problem arises. Obviously "Don't hit stuff" should overrule all the other behaviours at any point, but the rest of the behaviours should only happen once before handing control over to the next behaviour. I could solve this by combining the behaviours 2-6 into one behavioural layer, but there is a decent chance that this will evolve into a obscenely large .py file. What I really wanted was a series of sequential "one-shot" behaviours working in parallel with a collection of "full-time" behaviours for accident avoidance etc.

To solve this problem, I have decided on the following framework:
  • Each behaviour will be implemented as a Python thread. There will also be a motor-driver thread. All threads are loaded and started at program initialisation. All threads will have a given priority.
  • All behaviours will transmit movement commands to a common Queue (the recommended way for Python inter-thread communications) along with that behaviour's priority.
  • Periodically, the motor-driving thread will read the highest priority command from the Queue, acting on it and clearing the Queue.
  • Any "one-shot" threads simply stop adding commands once their goal is achieved, possibly even exiting to save memory/processor overhead.
There is more to it than that, but that is the general idea. I have converted most of my existing code to a series of Classes in Modules, and have successfully got them working as Threads. Currently I am testing out the inter-thread communications via the Queue, and I will post code shortly.

Finally, on a completely different note, I have convinced my University to allow me to do a 4th-year Engineering subject, Intelligent Systems, as a 3rd-year elective in my 3-year Bachelor of Computing. This starts next Monday, and I am absolutely pumped!

Wiring updates


While I am busy polishing up the new thread and class based python code, here is a pic of the Motor controller to H-Bridge wiring (yes, that is a USB to motherboard lead). The Li-Poly battery runs the motors and the 6xAA batteries run the electronics. This may seem counter-intuitive but I wanted to have a rechargeable battery for the motors, and I will be running most of the electronics off the 6xAA batteries. I will upgrade the motor battery pack when the MicroClient is installed, as the weight increase will obviously hurt the runtime between charges.

New Work Area

Here is my new work area! I bought a new desk today to create a more formal area for study/robot/programming/gaming (listed in intended priority...)

On the robot-front, I have been playing around with classes in Python to move the code towards object-orientation. This should make elements of my code both reusable and understandable by people other than myself! I have also been playing with Python's threading module, more on that later.

Glamour Shots

This is the robot's current set-up, including the new rs232 motor controller (not wired in yet).

This is the view from the back, showing the MicroClient's ports and the motor controller. I will post more when I have wired it all in.

Boring posts...

Well, that last post was boringly academic! On a slightly more exciting note, the 8-servo rs2323 controller arrived, and after I finish a small project I am working on concurrently, I will let you know how it performs. Kudos to Ozitronics, it arrived in no time, with extremely decent postage charges.