Hull Pixelbots on the rampage..
/I’m getting all the Hull Pixelbots ready for some Robot Rugby action at the moment. I’m updating the firmware, reworking the server and making a new Pico powered version. Great fun.
Rob Miles on the web. Also available in Real Life (tm)
I’m getting all the Hull Pixelbots ready for some Robot Rugby action at the moment. I’m updating the firmware, reworking the server and making a new Pico powered version. Great fun.
You’d think it would be easy to move a C program from the Arduino platform to the Raspberry Pi PICO. After all, we have the wonderful libraries from Earle F. Philhower, III and the fabulous PlatformIO framework you can use to manage your project (don’t forget to perform this stuff before you try to build anything). And anyway, C is the same everywhere. Right?
Wrong.
When I write the Arduino stuff a while back I made one or two questionable design decisions. One of them was to use the char data type to hold 8 bit values. This was kind of OK back in the day (and by this I mean the 1980’s) but it turned out to be a stupid thing to do. Because some C compilers think that char holds a signed value (-128 to 127) and some think it holds unsigned (0 to 255). Of course the Arduino C compiler goes one way and the PICO C compiler goes the other way. Neither are wrong - the C language standard doesn’t specify this - and you could argue that anyone daft enough to perform maths with variables that are supposed to just hold character codes deserves all the trouble they get. But we are where we are, which in my case was looking at a program that has been working for years and has suddenly gone nuts.
I actually fixed it quite quickly once I figured out the stupid thing I’d done. The Pico debug probe proved very useful for this. I was able to set breakpoints in the timer interrupt handlers and then watch as various counters were updated. When I saw the code subtract 1 from 0 and get the answer 255 I knew exactly what had happened…..
A few years ago I made some little robots called “Hull Pixelbots”. They have this name because they are from Hull and they have a pixel on the top. We had quite a lot of fun building them and playing with them, but then I went on to other things.
Well, I’m going back to them. I’m going to make a version with a PICO rather than the ESP devices I’ve used before, create a web based code editor and bring the robot into the “Connected Little Boxes” fold.
Should be fun.
Tonight we did some robot tracking at the hardware meetup. This is all part of the “Robot Rugby” thing we are working on. Brian and I set up our cameras and got to work. Brian is reading QR codes from the top of the robot, I’m trying to find out if I can get position and orientation from two lit pixels on top of the robot.
We set up the supports (with copious duct tape) and started playing. Tests seem to indicate that I should be able to detect only the pixels on the robot by turning down the gain on the camera so that only very bright lights show up. Lots of work to do here, but we are making progress.
As part of our Hull Pixelbot Rugby effort we need some supports for the camera that we will use to track the robot player positions. Searching for “camera supports” doesn’t work. But after a bit of bouncing around Amazon I came across the above. It’s supposed to be used by photographers to support backdrop cloths, but it provides exactly what we want, a portable means of hanging a small camera over a playfield. The price is very nice too. And I might even use it for photography.
I’m trying to create the game of robot rugby. As you do. I’ve no idea how the game mechanic will work. My plan is to rope in some folks at the Hardware Meetup to try and work out the rules.
Anyhoo, one of the things that we are working on is some way of tracking the robots around the playfield so that each robot player can know where it is. Brian has been working on some code to track things by means of QR codes and so I said I’d make some “rugby hats” for the robots with QR codes printed on them. So I needed to get and print some QR codes.
It turns out that making QR codes from a Python program is really, really easy. I found this library which works a treat.
import qrcode
for i in range(1,25):
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=5,
border=4,
)
text="Robot"+str(i)
qr.add_data(text)
qr.make()
img = qr.make_image(fill_color="black", back_color="white")
filename = text+".png"
img.save(filename)
This will make 24 labels that will just fill an A4 page in a word document. I printed them out onto label paper and stuck them on some pixel shades that I’d printed.
We’ve taken “Build a robot in a day” on the road and today we spent a lovely day today down at GSK in Weybridge. Things went so well that at one point we thought we might have to rename the course “Build a robot before lunch”. Everyone got their robot moving around and interacting with them.
If you were on the course (or are just interested) you can find all sample programs here.
If you want to work further with the Arduino I’d recommend that you search Amazon or ebay for “Arduino Kit” and buy something that costs around 25 pounds or so.
Update:
I’m back home now and I’ve put a few pictures of the event on Flickr here.
One of the downsides of thinking “I’ll use my phone for all my pictures” seems to be that don’t take any photographs at all when I should. This is how it was today at the Hull Pixelbot talk I gave at the university. However, the talk went well with a very appreciative audience.
I hope I didn’t come over as too obsessive compulsive when, during the session I started to fret about the use of the wrong kind of double quote in some of my sample code. Stupid “Smart Quotes” had stuck its fingers into my text and broken it. I hate it when I see it in other folk’s stuff, and I usually try to make sure that my quote characters are the right stuff.
For those of you who’ve no idea what I’m on about, its the “ in the top line should be vertical double quotes like the rest of the sample. It’s important to me, but perhaps I should get out more…..
For connoisseurs of quotation marks you can find the slide deck here.
I’m doing a talk about Hull Pixelbot and HullOS at Hull University (seems appropriate) this week. The talk is at 2:00 pm on Wednesday 7th November in Training Room 3 (TR3) in the Brynmor Jones Library (BJL).
I’ll have some robots with me and we can have a go at controlling them during the seminar. Should be fun.
On Thursday, as we were building robots I came across one of the most amazing bugs I’d ever seen. We’d reached the point where the robots had been built and they were connected to the computer. My HullOS Editor program lets you write programs and send them into the robot for it to run them. But something weird was happening.
The editor was displaying things that it should not. It seemed to be duplicating program code that had been typed in. And nothing was working. It was very confusing. I thought back to the time I spent the day before testing the code and had to confess that I’d never seen anything like it before. In fact, if I’d set out to write a program that was doing what the editor seemed to be doing, I was not sure how I would do it.
After a bit of head scratching I found the fault. And it wasn’t software. The robot has a speaker - more of a buzzer actually - which makes all kinds of irritating buzzing noises. Normally you’d connect a speaker across an output pin and a ground connection so that when the voltage on the pin goes up and down the speaker is driven in and out.
However, the Arduino doesn’t have many ground connections, and the ones it does have are all in use by the pixel and the distance sensor. So I use this rather clever (for me) trick of putting the loudspeaker across pins A0 and A1. If I make sure that A1 is always at the low logic level I can produce a potential difference between the pins by setting A0 high. This drives the speaker and sound comes out. I’m happy to trade a signal pin I don’t need for a ground connection.
This is probably deeply dodgy in electrical design terms. But since it works I think I have the last laugh on this one. Actually, if I had the time I’d experiment with swapping the ground level from one pin to the other while I play the waveform and seeing if this means I can make louder sounds by driving the speaker in and out, not just out.
Anyhoo, enough about my dodgy cleverness. Turns out that the fellow making the robot had wired his speaker incorrectly. Rather than wire the speaker between pins A0 and A1 he had wired the speaker between pins D0 and D1. These are two data pins on the Arduino which are also used for the serial port that is connected to the host PC. One of the pins is the data going into the Arduino and the other is the data coming out of the Arduino. Linking these pins together has the effect of sending every character that the PC sends to the robot right back to the PC again. Hence the terminal madness.
We put the speaker on the right pins and it worked a treat.
This illustrates one of things I said at the start of the robot building. Making robots is both fun and tricky because the combination of hardware and software makes for very “Interesting” misbehaviour.
Had a lovely day making robots today. I was working with Tristan and Mac, who were visiting the university from Scarborough, taking part in a work experience program. I had to robot kits all ready and a set of nicely printed instructions for them to follow.
They spent the morning building the robots and the afternoon programming them. It was great fun, and by the end they had left the suggested exercises well behind and were heading off in all kinds of interesting directions, which was wonderful.
It’s a couple of years since I stopped working at the university and it was lovely to see the campus looking so nice. There seem to be a lot more buildings than I remember and the Computer Science and Engineering Department have acquired some lovely new toys.
Another busy day. This time at TEDx Hull. It was great fun showing people my little robots. Everyone seems to like them. Perhaps I should try to sell a few…..
Despite arriving a tiny bit late, I had a great time at the evening event at Ron Dearing UTC today. A whole bunch of folks came to see me to talk about technology and I showed off some Hull Pixelbots, my silly goggles and the prototype air quality sensor that we’re working on over at Connected Humber.
Of course, I totally forgot to take any pictures at the event. Silly me. That’s why there’s a rather splendid picture of Whitby pier at the top of this post instead of anything relevant to the night.
Anyhoo, I talked to a bunch of folks and gave out a bunch of advice. Summarised thusly (posh prose)
If you’re into computing, start playing with the Arduino device. It’s cheap to get started (much less than a video game) and extremely creative. Buy a Sintron Arduino kit (search ebay or Amazon for “Sintron Arduino” to see a selection of kits. The one that is around thirty pounds is good value. If you want to start cheaper, come along to a Connected Humber event (we have them on the first and third Thursday of the month at c4di starting at 6:00pm in the evening). We’ll sell you an Arduino and some hardware for five pounds and give you some things to do with it. You can find out more here.
Start learning about 3D design. Lots of people that I spoke to were already doing this. The ability to think in 3D will stand you in good stead whether you go into fields ranging from video games to product design. There are lots of free packages you can use, I quite like FreeCad, although it can be a brute to get to grips with. If you’re a programming type, take a look at OpenScad. If you want to use a free, professional level, tool take a look at Blender. It will really make your head hurt, but you can do awesome things with it. Take a look online for howto videos for these tools. If you don’t like the ones that you find, make some better ones of your own.
Which brings me to my third point. Lean to write and talk. When you start doing something, start writing about it too. Put your writings into a blog, a personal diary or a log. I don’t mind. The important thing is that you do this. I made the point lots of times that you can learn a good living, and have fun, as a programmer. But if you also have the ability to write well and are good at communicating your ideas this makes you much more useful and interesting to employers, getting you even more interesting and rewarding things to do. So you should work at getting those skills. Deliberately do things that take you out of your comfort zone. Practice talking to people (networking is a big part of success) and try to force yourself to speak in public. Trust me. It really pays off.
By the end of the evening my voice had just about worn out, as had the batteries in the robots. But it was great fun. And then I went home and had bananas and custard for supper. Such fun.
I had Phil come to see me last week from the Hull Daily Mail. He was interested in my award nominated robots. We had a great chat, pictures were taken and videos were recorded. You can see the result here. And yes, I am going to be selling some Hull Pixelbot kits.
I'm totally gobsmacked (a great phrase) to discover that the Hull Pixelbot has been made a finalist in not one, but two categories in the The Digital Awards 2018.
"The little robot from Hull" is up for an award in the "Best Hardware" and "Best Use of Technology within Education" categories. Awesome stuff. Thanks so much folks. The awards ceremony is in September.
There's some impressive competition in the categories, including some from companies that are also based at c4di. I'm really pleased just to have made it as a finalist. If you want to read what I wrote about the robot, you can find my entry description here.
Spent a great evening with a bunch of folks from Child Dynamix. I showed off the Hull Pixelbots and then we had a go at programming them in HullOS. Such fun.
Turns out that Dot Net North is a great place to go and talk about robots. It's in Manchester and they run regular events about technology. Pete had offered me a chance to take along some Hull Pixelbots and explain that they are all about. Great fun. You can find the explanation here.
We had Pizza, and at the end a Robot Carrying Cheese Race.
The audience was splendid, most things worked (although one of the cheese carrying robots could probably have used some new batteries).
You can find out about more Dot Net North events here.
Well, that was great fun. Spent the morning at the Hull Raspberry Pi Jam. It was something of a "RobotFest". I had my Hull Pixelbots and Coretec Robotics were there with their balloon Raspberry Pi powered balloon busting robots. I was trialling a new idea I've had, called the "Robot Rumble". The idea is that players code up their robot warriors to get as far into their opponents area as possible. You can find the draft rules here.
As it turned out we didn't get that many rumbles going, but folks had great fun making their robots do things, including some things I'd never have thought of, which was rather nice. And from the sounds of bursting balloons and cries of victory coming from the other side of the library, fun was being had there too.
The second part of this post was going to have the title "Three Thing Game Judging Fun". But instead I'd have to use the title "I probably shouldn't have eaten that chicken from the fridge". Number one wife did ask me to check the sell by date but I was confident it was fine. And besides, I'd thrown the package away.
By 2:30 it was turning out that the chicken might not have been that fine after all. And an attempt to "kill or cure" by drinking a can full of "Old English Ginger Beer" didn't have the desired effect. Which meant I had to beat a hasty retreat from the event and head home for a lie down amongst other things.
Fortunately the effects don't seem to have been too long lasting, which is a good thing as I'm supposed to be driving to Birmingham tomorrow.
Another Hull Pixelbot event coming up. On Tuesday next week I'm going across the Pennines to Dot Net North in Manchester. You can sign up here. I'm going to try and crowd source some robot control. And apparently the pizza is really good.
If you want me to bring my Hull Pixelbots to your neck of the woods (do woods have necks?) then let me know.
Don't forget the Hull Raspberry Pi Jam this coming Saturday at Central Library. There are going to be lots of robots, including a bunch of my Hull Pixelbots.
I'm going to be testing a new "Hull Pixelbot Robot Rumble" in which two teams of robots face off against each other in a test of programming skills and strategy. Should be fun. You can sign up here.
Rob Miles is technology author and educator who spent many years as a lecturer in Computer Science at the University of Hull. He is also a Microsoft Developer Technologies MVP. He is into technology, teaching and photography. He is the author of the World Famous C# Yellow Book and almost as handsome as he thinks he is.
Make your own programming language. Find out more here.