Finally I have my hands on a Lego MindStorms Kit. $380 later mind you. Luckily I had a win on poker which paid for it. The first thing I noticed when I open up the box was how much shit you get. I really didn’t expect to get as much stuff as you do.
I started by building the “Startup” robot which took about an hour. It was pretty simple and straight forward (as you’d hope for the beginners robot). I tested out some sample programs that are built into the NXT microprocessor. Basically the robot could play a sound, drive forward, turn 180 degrees and drive back again.
I plugged in all the different sensors that come with it too. I was really impressed with the sensitivity of them. However the only sensor that I think I will really be able to use for the stuff I want to do, is the Ultrasonic sensor. It basically returns a value of how far away the nearest object is that its facing.
My main goal was to build a robot that can move around a room (whilst avoiding objects of course) and when it finds something interesting it would be able to take readings on the object with all its sensors and report back.
So with the sensors it comes with it would -
- See how far away the object is (or maybe measure how far across it is)
- Take a reading in dB of how loud the object is
- Take a reading of what colour (or greyscale colour) the object is.
The touch sensor doesn’t seem to be of any use to me. It can be used to object avoidance but I like the idea of the robot figuring out how to not hit the wall in the first place.
With all this in mind I had the idea to make a spinning sensor rig of doom. All the sensors would be mounted on a spinning platform. This would allow the robot to drive up to the object and then just cycle through each of the sensors and take readings. Sounds like a bomb idea right? Well I didn’t think of it, NASA did. I started to modify the basic robot I had built so it would be able to do this.
It was here (without diagrams and instructions to guide me) that I realised that I completely suck at building things. When I did robotics in Uni, the robot was basically built for me and I had to program it. Even with the really easy connections that the Lego Technic provides, I had a lot of trouble creating good supports for things. I didn’t really know what most of the obscure connectors were for. I struggled through I came up with this.
The big problem I had was the rig was only supported by one pole in the middle. Because of its centre of gravity this meant it leaned slighty forward, looking down. I didn’t think it was that big of a deal. Then when I connected the wires up to the NXT block, I realised a problem I would have. The rig wouldn’t be able to spin in the same direction for more then maybe 270 degrees. Obviously because the wires would strech and twist until they stopped the motors from turning. No problem I thought. There is only 3 sensors so it can go 90 degrees either way from the start postion and back again. How wrong I was. The “gears system” I was using to spin the rig completely failed the first time any pressure was put on it from the leads on the rig.
At this point I was “programming” the robot with the software that comes with it. Basically its for kids. You use drag and drop blocks onto a line which represents the senquence of instructions the code is executing. You can’t (without doing some crazy shit) do simple switch statements or complex if statements. Loops are a nightmare because you go across the page and when there are a lot on instructions in a loop the whole program is really hard to read.
I had looked into other ways to program the NXT before I got the kit. RobotC and NXT#
were the two I found. I wanted to use NXT# as it would allow me to do more (multithreading etc). However for it to sent commands to the brick you have to have a bluetooth connection on your computer. So I went out and bought a Bluetooth dongle and installed it. It was the cheapest one I could get which was my downfall in the end. I found out after a full day of googling that the driver for this dongle isn’t supported by the NXT Bluetooth on the brick.
So I looked into the RobotC option. It allows you to write in C (a cut down version). You can access the motors and different sensor ports and then you can download the assembly to the brick via USB just by pressing F5.
So with this new way of programming I decided to redesign my “MidgeBot” to only be able to see. My new plan was to make the object avoidance a lot smarted buy making the ultrasonic sensor be able to be moved around to look in different directions. After a couple of iterations I came up with this.
After a day of programming I have it doing the following (with a few bugs left to go).
- When the program first runs it turns the head back and forth until an object is placed in front of it. This sets the head in a forward position.
- It then moves forward until it senses an object in its way.
- It then stops and scans the 180 degrees in front of it for a path that doesn’t have an obstruction.
- It then turns (almost on a dime, more design work is needed) to the heading that the “eyes” are reporting.
- Then the eyes return to the forward position.
- Then it goes on its merry way.
So at this point I have a few things I’d like to do. First, I’d like MidgeBot to reverse and turn 180 degrees if it can’t find a path. I’d also like to use the same gear system to rotate other sensors (as I’ve used up all 3 motors already).
When I go back to work this week I will return the Bluetooth dongle and try to get one that works.
I’m still on crappy dial up while TPG gets there fucking arse in gear so I’ll upload some videos of it in the next post hopefully.
Posted by midge
Posted by midge