# Task#2: Basic Robot Programing

Robotics, 2nd Semester (Jan-May) 2012

– Build a differential drive robot using parts from the Lego Mindstorm kit.
– Write a program to get my robot to drive 2m in a straight line (using RobotC and NXT visual programing language).
– Write another program to get my robot to drive in a closed shape of my choice (using RobotC and NXT visual programing language).
– Perform a task using sensors from the Lego Mindstorm kit.

This is a report to discuss the completion of the stated objectives above.

Figure1.1 Images of my differential drive robot

In programming my robot to drive in a straight line for 2m, I attempted to use the measured value of the wheel radius to figure how long the robot should drive for to achieve the desired distance. I calculated the time to be 7.5 seconds. The calculated theoretical value for the distance to be covered needed to be adjusted to work in reality. The actual time needed was 8.2 seconds. After this experience in programming my robot using the NXT visual programing language, re-programing it in RobotC programming language was straight forward.

I used the NXT visual programming language to program my robot to move in closed loop. This time I anticipated the difference between the the theoretical calculated turn angles and the real turn angles. I then repeated the program in RobotC programming language.

In my final objective which is to use sensors from the Mindstorm kit, I used the sonar sensor. I programmed the robot using the NXT visual programing language to search for an obstacle in front of it and follow. My robot was programed to turn left and right in succession in a spot in search of an object. It would repeat this behavior until an obstacle is found using the sonar sensor. Once found, it would move towards the object.

I implemented these programs several times on the robot. The robot accurately and consistently performed the task as expected. On a few occasions, it deviated a little because it was unable to move in a straight path. The only occasion that the robot did not behave as described by the program was when the robot’s battery was low.

When the surface was changed from the tile floor to the wooden table top, the results were similar with little or no difference in the behaviour of the robot. I however presume that, if the surface was sandy or muddy instead on the tiled floor, the robot would have encountered mobility issues.

Summary (what I have done and learnt):
I have learnt two robot programming languages (RobotC and Mindstorm NXT visual programming language). I also learnt how to manoeuvre a 3-wheel differential drive robot and the calculations involved in programming robots to move.

Challenges faced:
My biggest challenge was building the robot from all those tiny Lego pieces.