You can compile the Sup3r Car Program proposed in this page using Xamarin Studio 5.10.1 (Build 6), with Mono 4.2.1 as active runtime and the Monobrick Firmware Library 188.8.131.52486 to let it work on board the Lego Mindstorms Ev3 with the Monobrick firmware.
Part 1 – The track following problem
Part 2 – The control strategy
Part 3 – The (simple) code architecture
The track following problem
As shown in the video, I’ve programmed the Sup3r Car to perform the classic track following task. The track following problem is defined as follows: program the vehicle so that it follows a line drawn on the floor; the vehicle uses the EV3 Color Sensor to sense the line and must steer to stay on the path.
From the Lego website:
The digital EV3 Color Sensor distinguishes between eight different colors. It also serves as a light sensor by detecting light intensities. Measures reflected red light and ambient light, from darkness to very bright sunlight. It can tell the difference between color or black and white, or between blue, green, yellow, red, white and brown. Sample rate of 1 kHz. Auto-ID is built into the EV3 software.
The Ev3 Color Sensor has three modes of operation:
- Color mode: it will detect the eight colors black, white, blue, green, yellow, red, orange and brown.
- Reflected light mode: it will give back a number between 0 and 100 where 0 is minimum light reflection and 100 is maximum light reflection.
- Ambient light mode: it will give back a number between 0 and 100 where 0 represents a dark ambient and 100 much brighter one.
The Sup3r Car program proposed in this page uses the EV3 Color sensor in reflected light mode. The reflected light mode is used to see the right edge of the stripe that the vehicle has to follow (you can program the vehicle to follow the left edge instead, keep reading).
The picture on the left explains how the feedback from the Ev3 Color Sensor in reflected light mode varies from a minimum value when the sensor is on the tape (position ) to a maximum value when the sensor is on the floor (position ) while it transitions from the tape to the floor and vice versa.
and actual values depend on the colors and materials of the tape and the floor; they must be measured (or guessed !) case by case.
The position corresponds to the state where the Ev3 Color Sensor is half on the tape and half on the floor and is the value read from the sensor in this position. is the set point value around which to close the control loop to keep the vehicle following the edge.
The line that the Sup3r Car can follow must be at least 2.5cm (1.00 inch) wide, and its color must well stand out of the color of the floor. For example you can use black tape on a light grey floor.