Lab 4


In this lab, I developed methods to map the environment that the robot is moving in. This is done by using a DIRRS (Digital InfraRed Ranging System) sensor as well as a Sonar sensor located on the "head" of the robot. Using the code from the previous lab, I did the following: Note that each robot has been calibrated to the best of my ability before being worked on.

Additionally, I've written a Java program that parses through the trace files obtained from the robot tracker and "cleans" it from invalid data as well as interpolates any "missing" points. The java file can also combine multiple trace files together to obtain a better trace file.

The pdf file that specifies the lab instructions can be found here.
For the entire lab, I have prepared the following environment for testing:

Part 1: BorderMap

The code for this part was based from the previous lab's WallFollow code. The main change is that the robot moves its head to the left so that it's facing the wall at all times. As a result, the sonar and the DIRRS sensor also faces the wall at all times. As the robot follows the wall, the sonar and the DIRRS keep sensing the walls and sending the readings to the station where they are recorded in the trace file.

Here is an image depicting the robot's wall follow behaviour.


By obtaining the data from the tracefile and plotting it in a mapping application, we get the following images.

This image depicts the raw DIRRS data.


This image depicts the raw Sonar data.


This image depicts both the DIRRS and the sonar data combined with error ranges.


This image depicts the Gaussian distance with DIRRS Data


This image depicts the Gaussian distance with Sonar Data


This image depicts full Gaussian with both DIRRS and Sonar Data (grayscale)


This image depicts full Gaussian with both DIRRS and Sonar Data (color)


The results seem to do a great job with mapping the walls, but an obvious limitation is that it does not detect obstacles placed in the middle of the environment, such as the right angled wall piece.

Note: there may be some "missing" points of data in these pictures. This is because the camera software sometimes loses track of the robot when it is close to the edges. This issue will be dealt with in part 3.

Robot SPIN code: BorderMap.spin

Desktop Station Java Planner Code: BorderMapPlanner.java

Video: BorderMap.avi

Trace File: BorderMap.trc


Part 2: NavigateMap

The code for this part was based from the previous lab's Navigation code. The code was modified so that the robot would go through a set of hardcoded points one after the other, and as soon as it reaches any one of those points, it would stop, do a 360 degree spin (while making a sensor sweep), then continue to the next point.

Here is an image depicting the robot's behaviour


By obtaining the data from the tracefile and plotting it in a mapping application, we get the following images.

This image depicts the raw DIRRS data.


This image depicts the raw Sonar data.


This image depicts both the DIRRS and the sonar data combined with error ranges.


This image depicts the Gaussian distance with DIRRS data


This image depicts the Gaussian distance with Sonar data


This image depicts full Gaussian with both DIRRS and Sonar data (grayscale)


This image depicts full Gaussian with both DIRRS and Sonar data (color)


The results give a better image of the overall environment including the obstacles around the middle (such as the right-angled wall piece). The sonar doesn't do very well when it comes to corners however (as evident by the corners in the environment and the right-angled wallpiece), but its high range is very useful in this application.

Robot SPIN code: NavigateMap.spin

Desktop Station Java Planner Code: NavigateMapPlanner.java

Video: NavigateMap.avi

Trace File: NavigateMap.trc


Part 3: TraceFixer

The tracefiles generated by the planners aren't exactly very "clean". They have a lot of invalid data, and you can also find multiple sensor readings for one pose, which makes no sense. As such, I have written a java program called "TraceFixer" that takes multiple trace files as input, cleans it, then outputs a single clean trace file. The process in which it does the cleaning is this:

Running the data on both BorderMap.trc and NavigateMap.trc, we get a new tracefile. This tracefile can be found here.

Combination Fixed tracefile: BestMap.trc


Running the Map Application on this BestMap.trc file gives us the following pictures





As you can see this is a much better map than either of the previous maps from part 1 and 2. You can also notice the effects of interpolation on the map. The sensor data near the walls were missing in BorderMap due to the tracker not being able to track the robot properly when it is near the walls. The TraceFixer compensates for this using interpolation and it has "filled in" the missing data.

Java source code: TraceFixer.java

More information: TraceFixer.txt