Hull Pixelbot Scripting Language lives

One of "Robert's Rules" of programming is that things that sound simple often aren't. And things that sound complicated often aren't. A while back I had an idea for a simple scripting language that could be used to control Hull Pixelbots (or anything else embedded). It sounded simple. It's not.

I've been playing around with the language and I've just about got it going. It's not as simple as I might like, but it does work. The biggest change that I've made from previous versions is to use the "Python" style of code blocks. I did have "endif" keywords to mark the end of conditions but I found these really irritating (I kept missing off the endif and then wondering why the program wouldn't compile). So now you indicate which statements are controlled by a condition (or a loop) by just indenting the statement. Want to see some sample code?

begin
move 100 wait
turn 180 wait
move 100 wiat
end

This program would move the robot forward 100, make it turn 180 degrees and then move back. The wait element means "wait for this move to complete before performing the next statement". If the wait element is omitted the program starts the action and then moves onto the next statement immediately. We can make more interesting behaviours:

begin
forever
    green
    move 100
    if @distance < 100
        red
        turn 90 wait
end

This program makes the robot move forwards. As the robot moves it checks the value returned by the distance sensor . If the program detects an object less than 100 mm away it turns the robot 90 degrees and then continues moving forward. The red and green commands change the colour of the pixel. The indenting above tells you that the red and turn 90 statements are only obeyed if the distance is less than 100. 

The programs are compiled and executed inside the robot. I've written a tiny Python program to send them via the USB port. 

Update: I've made some tiny changes to the way that the wait behaviour works after showing someone the language and realising that it could be better. 

HullOS in the Hull Pixelbot

I've spent a day having some "quality time" with the Hull Pixelbot scripting language. Which is now called HullOS.

The idea is that the computer in the robot (which can be a lowly Arduino Uno) is entirely responsible for converting the plain text of the program into actions. The behaviour will be rather reminiscent of the early 8 bit computers like the BBC Micro and Sinclair Spectrum, which had built in BASIC. They had tiny processors a bit like the one in the Arduino, but they had a lot more RAM than I've got. However, I've just about managed it. A typical program will look a bit like this:

do
    if %dist<10
        yellow
        move -10
    else
        green
    endif
forever

This HullOS program would make a "cowardly robot". The program repeatedly reads the distance sensor. If the robot is less than 10 cm from something it turns the pixel yellow and moves backwards. Otherwise it turns the pixel green. 

There are a few things to sort out, but I'm rather pleased with how it is going. And I've still got around 500 bytes of memory left....

 

Build a Robot in a Day with RB

We did another "Build a robot in a day" course today. It was for a bunch of folks from Reckitt Benckiser. We call it "Build a robot in a day" because that's what you do. But it's not really about robots. It's about learning how embedded devices are created and programmed. 

It was great fun. Everybody managed to build their robot and get it moving around and reacting to its environment. We were using the latest iteration of the Hull Pixelbot chassis, which was lovingly laser-crafted by the wonderful crew at Inno-Plaz. It still needs a few 3D printed parts, but these take around an hour to print, rather than eight. It also looks rather spiffy, as you can see above. 

Everybody proudly took home their robot at the end of the day, I really hope that they keep playing with the robot and making it do new things. 

Hull Pixelbot Scripting Language

About nine months ago I finished off a design for a scripting language for the Hull Pixelbot. The idea was that you could enter programs in clear text and the robot would understand and act on them. You'd not need anything else, and the programs would be compiled and stored inside the robot in an intermediate code. Then "Begin to code with Python" hit me, and everything else stopped as I frantically wrote chapters. 

Well, on Friday I decided to dust off the script design and actually start to build the language. I'm nearly finished. I had a problem when I ran out of memory (I've only got 32K of program space and 2K of memory) but I found that in one part of the program I'd used the sprintf function (which is huge). I've deleted that, freed up a few K of code space and it very nearly works. I've just got to drop in the while loops and I'll have the complete language running. There's nothing quite like designing your own language and then making it work on a tiny device. 

Hull Pixelbot 2.0: The future is clear....

I've spent today working on the 3d printed parts for the latest version of the Hull Pixelbot. I'm now using laser cut perspex for the larger parts, which makes the robot look great and should mean that I can start to make kits of parts available for anybody who wants a Hull Pixelbot of their own....

I was hoping that I could just use all the existing 3d printed parts for the rest of the robot, but it hasn't turned out quite like that. I've changed some sizes, and I've now added a speaker underneath the pixel so that the robots can make some noise. 

I've found some tiny speaker units which an Arduino can drive directly. It's not what you'd call HiFi, but it works.  They fit inside the pixel ring on top of the robot, which means that I've not had to increase the size of the robot to add sound. I've also got a mini-breadboard on the front of the robot to make it easier to add your own circuits. 

The design files for the laser cut parts, along with the customised 3d printed elements, will be going on GitHub soon. 

Writing DXF files from Python

I spent a bit of today creating design files for the latest version of the Hull Pixelbot. This version is going to be laser cut from perspex. This should make it much easier to produce large numbers of robots. Of course I'm not using a CAD package to produce the designs. It's a matter of personal pride that the Hull Pixelbot is entirely a software creation, and the designs are actually built by a Python program. 

The 3D printable version of the designs is created by a program running inside the FreeCad drawing program, but for the laser cut version I'm trying something different. I've discovered the ezdxf library that enables you to create dxf files (the ones that can be used to tell the laser cutter what to cut) directly from Python. 

So, after a bit of fiddling around I've got the start of the designs for the top and bottom of the robot.

Perspex Pixelbots at c4di

This is lovely. I've been pondering how to make Hull Pixelbots quickly (printing one takes around 8 hours or so) and then someone walks into the Hardware Meetup with a perspex pixelbot. 

Then Karl walks in with a laser cut chassis. He'd taken my stl files and converted them into flat components. Then he'd taken the designs to his work and got some prototypes cut out of perspex. The next step is to find out how much it will cost to get a bunch made. 

Reckitt Benckiser at c4di

David Keel of c4di explains what we are about

Spent an afternoon talking about robots and chatbots. In other words, a good afternoon. We had folks from Reckitt Benckiser over to talk about a new partnership with c4di. We were showing off stuff what we had made and I brought along a few Hull Pixelbots. 

Another satisfice Hull Pixelbot customer...

I really love it when I show someone a bit of tech and they go "Oh, so that means we could use this for......." That's a big chunk of what c4di is all about, and there was a lot of it about this afternoon.

Then we went straight into a Hardware meetup. It was great to see everyone come along, Ross brought his beautifully made Hull Pixelbots and we had a good natter about how to control them. 

Great stuff. 

Hull Pixelbot Rumble at c4di today (Thursday)

Finally, a blog post that isn't a thinly disguised plug for one of my books....

Anyhoo, today I'm plugging the Hardware Meetup at c4di tomorrow (Thursday). Ross is going to bring his robots, I'm going to bring some of mine, and we are going to do some robot things that might include rumbling.

You're welcome to come along and marvel. Sign up here. The meetups are in the ground floor of the awesome c4di building. We start at 6:00 pm and go on until 8:00 or until we run out of things to talk about (which usually means a bit later..)

If you've any interest in hardware (computer or otherwise) then it would be great to see you. 

Will Robots Take Over the World?

So, today I did my half an hour on "Will Robots Take Over the World?". I stated of by saying I was fairly sure that then won't, but that they are already here and all around is in the devices that we use from day to day. From that it was a short hop into the joys of software and I finished off with a plug for the Hull Pixelbot and a demonstration from Chrystal Masie, Commander Custard and Aunty Violet, who responded well to commands from the audience. 

Thanks for being a great audience folks. You can find the slides for the talk here

Will Robots Take Over the World

I've just discovered that I'm giving a talk about robots at the university on Monday 26th June. Or at least someone called Rob Miles has been booked to do 30 minutes on whether or not robots will take over the world as part of the Annual UCAS Exhibition which this year is in Hull. 

I probably said yes to it when I was drunk. Or something. 

Anyhoo, if you fancy coming along on Monday at 10:15 in LR13 in the Wilberforce Building on the University campus it would be lovely to see you. I will, of course, be showing off some robots of my own. And I'll be sober. Or something.

I don't teach at the university any more, but I retain a strong affection for the place where I spent my professional life. They even made me a Fellow of the University, which was very nice of them because I think it means I get to give talks like these. 

Pixelbots at CodePen

Thanks to CodePen Hull for the picture of me holding up a phone to prove something worked.

Codepen is a great idea. Get together a bunch of people interested in code and have them tell each other what they are up to. There were six talks over the evening, ranging from a lovely looking Scrum development management tool, a splendid hosting framework, video game development, first steps in programming and the new application development pattern from Facebook.

I should have taken proper notes, but I was too busy thinking about my talk, which was right at the end. I think it went OK, even though at one point I was reduced to holding my phone up with a web page on it shouting "Look. It worked." As if anyone could tell.

I met up with some folks I've not seen for a while and it was lovely to have a catch up. We had pizzas and drinks and it was a great evening. It was great to see it so busy, but there's always room for a few more if you want to come along to the next one.

Anyhoo, I said I'd put the slide deck up and here it is. Including the answer to the competition question (which I'll probably have to change for next time).

I'm really looking forward to the next event. 

Hull Pixelbots at the Radio 1 Academy

Radio 1 invited us to take part in the Radio 1 Academy this week, which was nice of them. There are four days of events encouraging folks to engage with the "creative" arts. I was especially pleased to be asked to go along because I do computer stuff, and I see this as incredibly creative.

I had a very happy day showing people the robots, letting them control then with their phone and then telling them that the "magic ingredient" (i.e. the bit that links everything together) costs two pounds fifty. Which is less than the price of a burger and chips.

With a bit of luck, a few people who had never thought of getting into programming will turn up at one of our c4di hardware meetups and get involved in making stuff. I took a bunch of pictures during the event, you can find them here

Rob wins "Elevator Pitch" at c4di

Won a prize today for speaking in an elevator. Not done that before. Only at c4di

As I walked into the building yesterday I was asked if I'd like to take part in an "elevator pitch" competition. The idea behind an elevator pitch is that perhaps one day you'll find yourself in a lift with someone like Bill Gates or Mark Zuckerberg. So you've got the time it takes to get to the tenth floor to convince them to give you a hunk of money to let you follow your dream. 

I was told I had sixty seconds in the c4di elevator (up to the top and back down) to convince someone I'm worth backing. I wasn't really prepared for it, but I said I'd have a go, and off we went.

I'd got a Hull Pixelbot with me (Crystal Masie as it turned out) and so I decided to wax lyrical about the joys of building tiny connected robots. When I'd finished I asked how much time I had left to speak.

Forty more seconds. 

So I went on a bit more about getting people making and coding, and my dream of building an arena containing 100 Hull Pixelbots wandering around, just to see what they'd do.  Finally the time was up and I went back to my room to do battle with the Microsoft Bot Service. As you do. 

Today I found that I'd won the competition, which is awesome. I got a fantastic trophy and a lunch at Nibble

I love that c4di are doing things like this. You can watch the community of developers building up thanks to the efforts of Dee and Jess.  And getting practice telling people what you are doing and why it's a good idea is vitally important for professionals today. So everybody who took part has got something out of it. 

Great fun.