Robotics

This week we have been working on robotics. This was a very new experience and I found that I actually really enjoy robotics!

The robot we used was a Lego Mindstroms NXT robot, which we programmed using Python. In order for the robot to recieve the code, we connected it to the computer via bluetooth.

Over the course of the week, we have had the robot move in many ways, including travel in a square using commands and also color sensing, move randomly while avoiding objects using a sonar senser, and more. The most challegeing task was to get the color senser square to work.

The most fun task was having our robot 'compete' against other robots and avoid the while moving randomly. Below are some pictures and videos of our robot and the code we wrote...

1. This is the color sensing square task that I had the robot perform. This was by-far the most challenging task and it took me literally all day to get the robot to stop moving off the track.

To program it, we made a function(a task that can be referred to and repeated) and the used while loops to have it check for certain conditions. Depending on whether the computer determined the statement was true/false, it would move accordingly. This is the track that the robot had to follow (green).

Here's the code that made the robot follow the path....

2. This is a video of our "robot competition" where we used our "scatterbot" program to make the robot move randomly while avoiding obstacles. The scatterbot program was a program we made that used the sonar sensor to avoid obstacles and go the other way while the robot was moving in random directions and speeds.

Sorry it's kinda sideways.... :-(

Here's the scatterbot code....

3. One of the most interesting things we did was program the robot to sense the wall. Using the bluetooth and a sonar senser, we got it to stop and not crash into the wall from 20 cm away. We had it move forward and every few seconds check for the wall. If it sensed it, it would stop.

Here's a video:

Here's the code that made the robot sense the wall & stop....

4. To conclude our unit on robotics, we programmed the robots to be "Mars Travellers" and sense their way around a mars-like surface using color and sonar sensers.

The thought process behind this was to have the robot move forward and then when it senses something such as a crater or "water", it will back away and go in the other direction.

The first time I tried this, the sensers weren't working and the code was. I adjusted the sensors and it worked the way I wanted it to, but the only thing was when it sensed a crater or water, it would sometimes fall off the surface of Mars and could not get back on.

In order to "prevent" this, I added two more sonar sensers, which just ended up making the problem worse and confusing me in the process. :-(

In the end, I just decided to take the extra sensors off and run the program like before. I don't know what happened, but in the end it was not working the same way as before.

I liked this activity because it made me feel like I was attempting to solve a problem that programmers analyse in the real world. I just wish I was able to get it work... :-)

Here's a video of my robot using the mars code that I wrote. There are definitely some mistakes in the program, but this was the final version.

Here's the code for the Mars robot...

Home