<< return to Pixycam.com

User Tools

Site Tools


wiki:v2:lego_line_tracking_test

**This is an old revision of the document!**

Pixy2 LEGO Line Tracking Test

From the LEGO Mindstorms EV3 Software, go to the File menu and select Open Project.

Browse to the location where you unzipped the “LEGO blocks and examples” file, and then to the examples directory and then either to the EV3 or NXT directory depending on your brick version. Select “line_test.ev3” and click on Open.
v2

Run the program by clicking the play icon in the lower right corner of your EV3 software window. If you don't see the play icon, make sure your LEGO brick is powered on, finished booting, and connected to your computer via a USB cable.

Draw a line on a piece of paper and put it in front of Pixy2. Pencil will work, but black marker is usually better. If you are running PixyMon, you should see something like this:

Similarly, you should see a rendering of a line on the EV3's LCD. The line should move back and forth as you move the line side to side in front of Pixy2. What Pixy2 has done is found the best line candidate to track and has assigned it to the Vector. The Vector is the line that Pixy2 (or your robot) is currently tracking/following.

{{}}

You can also see what happens when you turn off and on Pixy2's lamp by setting it to false or true. You'll need to stop the program and re-run it for the change to take effect though.

{{}}

Note, with the lamp on, Pixy2 will typically reduce the exposure (sampling) time of the image, which reduces motion blur. In general, motion blur happens because a camera is sampling a subject while the subject is moving. In this case, the subject is a line (or set of lines). If they are blurred due to motion (the motion of your robot), it can make the lines more difficult for Pixy2 to detect and track. Pixy2's lamp can help with this. The upshot is that the lamp makes your robot go faster!

Make a 4-way intersection by drawing another line through the original line and place it in front of Pixy2. Pixy2 will identify the intersection and quickly choose the default branch of the intersection, which is the “straightest” branch of the intersection, assuming the Turn Angle input is set to 0 (default). You should notice that while Pixy2 sees the intersection, the EV3 LCD will show “Intsctn: 4”, meaning that it sees a 4-way intersection.

You can change the “default turn angle” in the Expert configure tab. You'll see that the default turn angle is 0 (by default), which is straight. The angle is based on a straight-referenced angle coordinate scheme.

Angle coordinates from Pixy2's perspective.

Try changing the default turn angle to -90 (right-most turn/branch) and click on Apply.

Now when you place the intersection in front of Pixy2, it will choose the right-most branch of the intersection.

By default, Pixy2 will choose the branch automatically based on default turn angle or the most recent call to setNextTurn(). You can change this behavior by enabling “delayed turn” in the Expert configure tab.

Go ahead and enable delayed turn and click on Apply.

Now when you place the intersection in front of Pixy2, it won't choose the branch automatically. Instead Pixy2 will label the intersection because, it doesn't know what action to take.

In delayed turn mode, Pixy2 will wait for your controller to call setNextTurn() which will instruct Pixy2 to choose the branch of the intersection that matches the angle the closest.

Barcodes

We wanted Pixy2 to be able to receive simple commands or information while it is performing line tracking, so we added the barcode feature. The barcodes are intended to act as “roadsigns”. You can add graphics to the barcodes that are human-readable as long as you keep the barcode unobstructed. To test the barcode functionality, download the print the all_codes.pdf document.

Holding the document in front of Pixy2 while it is running the line tracking algorithm will yield something like this:

wiki/v2/lego_line_tracking_test.1548812337.txt.gz · Last modified: 2019/01/30 01:38 by pixycam