Task 3 – Treasure Hunt

Emmanuel Nkansah

Selase Attah Kwamuar


The task is to have a robot locate “treasures” in an environment set-up in the lab, and deposit them in the appropriate color-coded holding station. The robot will use its sensors to find the treasures in its environment and make its way to the holding stations. The robot may be guided in any way that does not involve physical human contact. For example, a flashlight may be used to guide a robot with its light sensors but the robot may not be pulled along with a string. There will be 6 treasures in the environment, and the robot has a time limit of 3 minutes to find and sort as many treasures as possible.

Design Concept:

Learn About various Sensors: We started by learning how to use various sensors. Some of the sensors that we tried are the magnetic compass, the color sensor, and the ultrasonic sensor. We were able to use the magnetic compass sensor to get the magnetic fields of the earth. With that we were able to cause the robot detect the North Pole and the South Pole of the earth. We were also able to use the color sensors to detect different colors. While using the color sensor, we realized that the default color for the environment is black. With the help of the ultrasonic sensor we were able to detect and avoid obstacles. This process of learning about the sensors helped us to decide on a strategy to adopt.

Driving along a Wall: In order to implement wall following, we observed or recalled the concept of line following: reading or collecting data from the sensors and adjusting the power of the motors when necessary to ensure the wall is followed accurately. The bang-bang control implementation involved constantly checking the distance of the robot from the wall and adjusting the current distance away from the wall by moving one of the two wheels, usually one after the other. However, the P control took a more calculated or careful approach and involved turning the robot by the amount of the error. We discovered that overall this was a better approach to wall following. However, to achieve a smooth translation from error to motor power or output we had to employ or use a low gain kp. We found this kp by experimenting. We learnt a lot from our experience. Specifically, it helped to understand p control, a concept that wasn’t quite clear before the task.

Writing code in block methods: The wall following exercise required little code and hence did not merit block methodology or modular programming. Nonetheless, in the subsequent exercise (treasure hunt), we disintegrated the code into methods in order to effectively tackle the various steps involved. For instance, right, forward, left and reverse functionality was written in method form and called when necessary.  The modular or block nature of the methods helped us with our thought process and was implemented after drawing a flow chart of our algorithm.


Subsequently, we fused the code from the two programs to enable us successfully grab and sort the various treasures. However, with our implementation we discovered the limitation associated with using the sensors provided in the Lego kit; noise. This was especially evident in the distance measurement readings we obtained from the ultrasonic sensor. These values disrupted the logic of our program and interfered with the treasure-hunting task. The accuracy of this sensor was mostly needed to initiate a wall following process after grabbing treasure. However, the noise led to the wall following process being started a few centimeters before the wall. This problem was solved by implementing a method to obtain and find the average of several distance readings to allow the robot calculate a more precise distance. We learnt about the importance of planning or creating diagrammatical representations of the task at hand before implementing to ensure the process was tackled in a piece wise manner.


From the carefully outlined paragraphs above, it can be stated that sensors are as trust worthy as their error margin. Hence, in order to achieve maximum efficiency in their use, several measurements or readings have to be taken and the most appropriate or efficient reading picked and used in decision making. In the African and Ghanaian context, sensors play major roles in industry and problem solving scenarios. Some of these scenarios include water-monitoring system, such as the one implemented by the iStep Programme. This system could use an ultrasonic sensor that checks the distance from the top of the tank to the water level and calculates the water depth by preforming calculations. Other scenarios include beverage manufacturing plants or distilleries that use thermometers to monitor the temperature of chemicals at different stages of the mixing process. Sensors used in these environments require attention, as their reading could “make or break” a company’s performance on the market in terms of quality control.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s