Category: blog

Raspberry Pi – AnswerBox

I’ve been playing with a Raspberry Pi, Logitech USB mic, USB-powered speakers and a USB SDR TV tuner stick, combined with Stephen Hickson’s fantastic voicecommand system. (The Pi is the rainbox-striped box at the back, the flat black thing in the middle is a powered USB hub, into which is plugged the black TV tuner stick, which has an aerial (positioned on the small jar). The Rubix Cube is just there for scale.)

First, speech is sent as raw audio to a Google API which returns text. It would be better to do this on the Pi, but my experiments (with Julius) have shown that Google (with their gargantuan computing grid) is much better in terms of both speed and accuracy. (Since the microphone has an on/off button, audio is only sent to Google when I so choose.)

Second, the text is compared with a list of known commands (see the voicecommand website for more details). If a match is found, the corresponding script is run. (This is how the ‘weather forecast’ and ‘have I got mail’ commands work.) If no match is found, the text is sent off to Wolfram Alpha, which returns a text answer.

Finally, the results from Wolfram Alpha, or the appropriate script, are sent off to another Google API to turn them into an audio file, which is then played out over the speakers. I have tried using espeak, but again, Google’s API currently does a better job.

The whole thing is reasonably fast, given everything that is involved. Occasional internet latency spikes delay responses from the script for 10 seconds or so, but in my experience they are rare.

The live aircraft information is received using the Software Defined Radio (SDR) technique, using a RTL2838 TV tuner USB stick with rtl-sdr and dump1090 software, which provides a nice json interface over http. A python script queries this interface on demand and computes the nearest couple of aircraft to my location, then gathers some supplementary information from the internet before reading the response.

The scripts that make all this work are available on github.

Future plans include: adding commands to play music, add items to a shopping list, read news headlines and much more. My four year old daughter’s most recent request was for the AnswerBox to gain wings and fly around the room on request. There’s probably a python library for that. Hmmm….

MudPi

About 10 years ago, I wrote Alternate Universe MUD, a free text-based online adventure game, with a space-theme and an emphasis on exploration and discovery.

Note: for younger/less geeky readers, a MUD is a Multi User Dungeon, i.e. a game that you could play (with other people, no less!), which often revolved around dungeons, monsters and combat. Massively Multiplayer Online Role-Playing Games (MMORPGs) like World of Warcraft can trace their history back to these kinds of games.

The game features spaceships, several worlds, an astronomical observatory, mudmail and mud-wide-web terminals, a stock market, various robots and even an auditorium where Shakespeare’s plays are performed by bots every few hours.

Over 2000 players discovered Alternate Universe over the first few years (not bad for something that started out just as an experiment). Most players just played, but others contributed code, some helped build the world from the inside and one even ran an in-game monthly newspaper. I ended up meeting some of them in real life too, as a result of all this.

The game server itself was written from scratch in Java and has had many homes, but thanks to Oracle’s release of Java 8 for ARM in December, it now runs on a Raspberry Pi (and it runs happily too, using less than a third of the 512MB of memory – AU was mostly written on a 400MHz HP laptop with half the CPU speed that the Pi has now, so I’m not that surprised).


(the black thing poking out by the yellow S-Video socket is an external temperature sensor – I hope to wire this up to the MUD, so that the external temperature drives some behaviour or description inside the game)

Play!
To play Alternate Universe, go to the command-line and type
telnet alternateuniverse.dyndns.org 1063
If you are playing from another Pi, you may first need to install the ‘telnet’ program:
sudo apt-get install telnet

I hope you have fun playing. Drop me a MUD-mail if you enjoy the game!

Golf Bravo Uniform Indigo Kilo

Yesterday I finally used the Flight Experience voucher that my wife bought me for my birthday. However as it turned out there were a few hurdles to cross first.. after nearly two weeks of sunshine and perfect blue skies, the forecast for Tuesday was for heavy rain. I couldn’t believe my luck. Thankfully the Met office showed the rain coming in the afternoon & my flight was booked for 11am so we might just be ok. I got all technical and checked the METAR (aviation forecast) for Luton which looked something like this:

EGGW 030720Z 29008KT 9999 FEW031 07/05 Q1003

Thankfully there was also a translation:

wind 290 degrees 08 knots, visibility 10km or more, a few clouds at 3100ft, temperature 8'c, dewpoint 5'c and air pressure 1003mb.

.. which basically meant that we were still on for flying. Phew! – first hurdle.

Just after setting off for the airfield (Panshangar, a few miles from Hertford), with plenty of time to spare, we got a call to say our 18 month old daughter had been sick at nursery, please could we come and pick her up? Aaargh. Second hurdle. So we had to drive back – she was sans breakfast but looking a lot brighter. We figured perhaps it was just a one off – nursery couldn’t keep her in case it was contagious, but maybe she’d be able to sit and watch a few planes?

We set off for Panshangar again… .. and then she threw up all over her car seat. Noooo! Clearly this wasn’t going to be the day that we’d planned – I had to drop my wife and daughter off at home but made it Panshangar on the dot of 11. (Third hurdle crossed – finally made it, phew!)

Thankfully the atmosphere at Panshangar was very relaxed & I had ten minutes to sit with a coffee before being introduced to Sergio, my instructor for the flight. Before this point, my expectation was that a real pilot would fly the plane, I would get to look out the window and enjoy the view, take a few photos and perhaps get a chance to have a go at the controls for a bit. Ho ho ho. As Sergio led me out to the aircraft, his words were “you’re the pilot today so you’ll be doing the whole flight, including the takeoff and all of the landing if you like”. Wow, gulp. Hopefully all those hours spent messing around with flight simulators on my computer would help. I knew what most of the instruments did, but this would be the real thing – and I’d been told that flight simulators are only about 10% of the real experience, so I was nervous.

Unfortunately my wife wasn’t there to be able to take any photos, but I did manage to get a few. This is G-BUIK (Golf Bravo Uniform Indigo Kilo) – a Piper Warrior II, just a couple of years younger than me:

(Sergio is doing the necessary pre-flight engine checks, so I got a chance to look under the covers. There was surprisingly little in there!)

After a walk around the aircraft talking about physics and wobbling various wobbly bits, it was time to hop in.

Right then, what does all this do again? Headsets on, turn the key to start the engine and then we’re off taxiing across the airfield, and I’m learning to drive a plane across the bumpy grass by steering with the pedals (or pushing with my toes to brake) and desperately trying not to embarrass myself!

After following another plane to the end of the runway, we waited & checked the engines one last time (it’s worth being sure, right?). Then I taxiied onto the runway, and with the throttle full open bounced along the grass pointed it at the sky and all of a sudden we’re up in the air. Wow. (You know that feeling of heavy-headedness and disorientation you get when your plane first leaves the runway? Yep.) But it was so smooth – the aircraft was wobbling around a bit, but not as much as I was expecting. The feeling was fantastic! We turned a few times and climbed up to 2000ft, where the view was just incredible – you could see the airports at Stansted and Luton, and even make out Canary Wharf in the distance.

(Sorry, no photos from this bit – I was having too much fun)

I had a go at navigating, practising turns using the rudder pedals as well as the yoke, controlling ascent and descent with the throttle, and even a stall (which I thought would mean we’d fall out of the sky rather dramatically, but it turns out that with this type of plane it just beeps at you and the tail flutters around a bit until you sort it out). The half hour seemed to last a long time as we flew around the skies of north Hertfordshire (obviously there were limits on where we could fly due to the nearby airports), but eventually, just a few drops of rain started to streak along the windshield, it was time to head back to Panshangar – but not before we’d passed over my house, where Sergio took the controls for a bit while I got the camera out:

.. and checked up on the progress with our garden. (see the patio and snaking stone path?)

Then came the hardest part – landing. It was fairly easy to steer the aircraft so that it was lined up with the runway, but Sergio had to help with the throttle a bit so that we didn’t come in too fast. Then we were over the trees and with the throttle closed, pulling hard back on the yoke to land – gently! – on the runway.

(approach to Panshangar – this pic from Google Earth – I was a bit busy at the time)

In fact as landings go, I might be biased, but I reckon it was smoother than some of the commercial flights I’ve been on. :-) Then I taxiied off the runway, back round to the parking area and we stopped pretty much bang on the marks. As the engine stopped and the generators whined down, I thanked Sergio for what had been a brilliant flight and tremendous fun. I might just have to do this again sometime.

(My hair was already like this before the flight, just for the record.)

Over and out.

Theme change

Changed the theme of my blog again as I decided it was looking a bit too techy. Not that most of the stuff I post is at all tech-related. No.

New Applications for CodeAlchemists

The last few months have been especially busy with the arrival of my beautiful daughter, but I have still managed to find some time to write a couple of new applications for CodeAlchemists.

BabyPatterns is a simple program that displays stimulating high-contrast patterns of the type which occasionally entertain young babies.

Contact Sheets generates a ‘Contact Sheet’ for each folder, showing all the photos in that folder. It’s vaguely intelligent about it, regenerating sheets for folders if they’ve changed, skipping folders that haven’t, that sort of thing. Useful when you’ve built up a large archive of photos, as I have. :-)

Next on the development list is a new version of JDarkRoom.

Blog migration & a new ‘retro’ theme

I’ve finally upgraded the version of WordPress which runs this blog. In doing so, sadly I managed to trash all the comments that people had contributed. One of the reasons for the upgrade was that I’d had to disable comments due to the sheer deluge of comment-spam (1000+ messages a day). Comments are now enabled again.

I’ve chosen this retro theme because I like it and it’s clear and easy to read – but it still needs a few tweaks.

Comment Spam

It seems that I’ve finally got rid of all the comment spam that was clogging up this blog and its moderation queue. My apologies if your comment was delayed and has only now made it to the blog.

Thank you again for all the comments about JDarkRoom. I read every one and good suggestions make it into the JDarkRoom TODO list.

Dansette