Mapping Out the Terrain


Trig functions can be useful for creating a map of known objects and their location.

For example:

Upon start up the NXT establishes either an arbitrary direction or a compass heading (if you have a magnetic sensor) as the x coordinate direction. Ninety degrees (or orthogonal) to the x direction, the NXT establishes the y coordinate direction. The start up location establishes the origin of the NXT's x-y coordinate system. At this point the NXT can rotate, staying fixed at the origin, and map out x-y coordinates of objects it sees with the ultrasonic sensor.

Then moving along the x-axis, the NXT can take additional readings with the ultrasound sensor, and use the next readings to refine or verify the previous set of readings. In team play, two or more NXTs could communicate readings to each other via BlueTooth messages. The diagram below shows how the concept of triangulation can be used to establish coordinate locations of objects seen with the ultrasonic sensor.

These locations can be stored in a table along with our own location so that at any moment we can always have an “on-board” map of the world outside.

Table 1
Itemx (inches)y (inches)
Our NXT1015
Object 156
Object 22010
Object 3105