My first foray into Python programming was in 15-112 Fundamentals of Programming and Computer Science. One of the reasons I came back to school was to increase my programming ability, and this class allowed to build a solid programming foundation.
Overview
The term project for 15-112 required you to create some substantive programming project. Because I knew I wanted to apply programming to robotics, I figured I would build and code a robot. We weren’t graded on anything but our code, so I hacked what I could together with a Raspberry Pi and some hobby components from Amazon, so please don’t judge me too harshly on any of the mechanical or electrical aspects of this!

Looking for a suitable project that could be accomplished in a relatively short amount of time as a term project was a little difficult, but I came across a good paper by Philip John McKerrow of the University of Wollongong that you can find here. In this paper, the authors used echolocation from ultrasonic sensors to map a room. The basic premise of this method is that ultrasonic sensors send out a sound wave and then that wave bounces back if there is an object near by. The sensor and code take the time that the sound wave took to bounce back and converts that to a distance. This information isn’t enough to create a map of the room, though. The distance that the sensor calculates could be any distance to a locus of points within the angular range of the sensor. The diagrams below, taken from the McKerrow paper, illustrate that point.
To use this data to create a 2D map, you need at least two distance measurement at different locations, and to know the relative distances between those two measurement points. After having created two arcs representing the locus of possible points that the sensor is detecting, you can draw a tangent line between those two arcs. In theory, this is the true boundary that the sensor is detecting. With a robot moving in a straight line, the McKerrow paper achieved the results below:



Results
The results of my robot scanning my bedroom can be seen below:


Summary
Neither the McKerrow paper nor my robot achieved superb results, but considering this was my first attempt at a real programming project, and all components were hobby-grade, I was pretty proud. Given more time, I think that this could work very well, even with the hobby-grade hardware. As you can see, all the arcs don’t have tangent lines drawn in-between them, so that’s one of the first bugs to fix.
Secondly, the robot only moved in a straight line, and had to be turned straight every couple of times it moved forward. I added encoders onto the wheels, but they moved too fast for the encoder to pick up all of the counts, and there wasn’t enough time to set up an interrupt that would allow for all counts to be registered. If I had some wheel position feedback, I would be able to get this robot moving in a straight line, and perhaps have it make turns and avoid obstacles.
The github link to the code can be found here and the full video of the project that was made for the class can be found below: