Homework 2
Michael Edelson
medelson@andrew
I am using OpenGL as my rendering method. Objects are read from a jpeg with black being an obstacle, a single green pixel is a start location and a single red pixel is the goal. In the event of multiple pixels that are red or green, the first (most up-left) pixel is the pixel used. The jpg is given to the program as the first argument. Size does not matter, the workspace is always 50m by 50m. A higher resolution picture results in higher-resolution obstacles (each pixel will be smaller in the world). Additionally the x and y axes are scaled separately, so non-square images are acceptable. Note while my images have black obstacles, the program only checks the blue value of the pixel. Thus the obstacles could be blue. Below is an image I used to create the failure video of the robot.

Since I was rendering in openGL, I figured I would make it more fun to watch a robot. There is now a 3rd person follow camera and a 1st person camera option available in the right-click menu from before. The robot leaves behind small spheres to show the path. They are white by default. A red sphere is left behind when the robot had been heading towards the goal and hit an obstacle. A green sphere is left behind when the robot encounters the m-line at a point closer than the one where an obstacle was hit.
Here's the first person view (originally it locked to the robot's
angle, too, but that was unbearable)
;
To follow an obstacle, the robot calculates a local tangent to the obstacle and attempts to follow that tangent at a given distance (currently set to 0.8m from the center of the robot to the obstacle. The robot has a radius of around 0.75m). If the robot is further away from the wall, it turns towards the wall, and if it is too close it turns away from the wall. In the event of lag, since the program is keeping time between updates, it is possible for the robot to stray off of the course by a reasonable amount. This correction allows the robot to recover quickly with a curved trajectory.
Since I had made my robot a yellow sphere for now, and it dropped white spheres, I reasoned that it was similar enough to be like pacman. Therefore the “waka waka” sounds from pacman were thrown in while it was moving, and at the program's start the pacman start sound plays. In hindsight this was probably a poor idea. That noise is pretty annoying.
If the robot fails to find a path, it turns red and stops where it encountered the point on the m-line where it found an obstacle previously.
I chose to implement the Bug2 algorithm because I really hate that bug1 goes all the way around obstacles. It is painful to watch. I was originally going to convert mine to work on 2-link manipulators, but I ran out of time. Since OpenGL handles matrices for graphics, the kinematics would have been easy to solve on the fly.