<< return to Pixycam.com

User Tools

Site Tools


wiki:v2:lego_line_tracking_test

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
wiki:v2:lego_line_tracking_test [2019/01/30 01:45]
pixycam
wiki:v2:lego_line_tracking_test [2019/01/31 01:40] (current)
pixycam
Line 1: Line 1:
 ====== Pixy2 LEGO Line Tracking Test ====== ====== Pixy2 LEGO Line Tracking Test ======
  
-From the LEGO Mindstorms EV3 Software, go to the **File** menu and select **Open Project**.\\ +From the LEGO Mindstorms EV3 Software, go to the **File** menu and select **Open Project**.
-{{wiki:​img:​3e3b64f2ff052ac58280fa2315eff9d803714e6e.png}}\\ +
-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**.  ​+
  
-{{ }} 
  
 +{{wiki:​img:​3e3b64f2ff052ac58280fa2315eff9d803714e6e.png}}
  
-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.\\ 
-{{wiki:​v2:​image_704.png}} 
  
 +Browse to the location where you unzipped the "LEGO blocks and examples"​ file, and then to the **examples** directory. Select "​line\_test.ev3"​ and click on **Open**. ​ The program is shown below. ​
  
-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: 
  
 +{{wiki:​v1:​image_725.png}}
  
-{{wiki:​v2:​image_368.png}} 
  
 +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.
  
-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.  ​ 
  
 +{{wiki:​v2:​image_704.png}}
  
-{{}} 
  
 +===== Detecting and Tracking a Line (Vector) =====
  
-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+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:
  
-{{}} 
  
 +{{wiki:​v2:​image_368.png}}
  
-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! 
  
 +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.  ​
  
-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. ​   ​ 
  
 +{{wiki:​v1:​image_726.png}}
  
-{{wiki:​v2:​image_372.png}} 
  
 +===== The Lamp =====
  
-You can stop the program and change ​turn angle to 90 degrees.+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
  
  
-{{}}+{{wiki:​v1:​image_729.png}}
  
-90 degrees is a left turn according to the diagram below.  ​ 
  
 +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!
  
-[{{wiki:​v2:​image_364.png?​400|Angle coordinates from Pixy2'​s perspective.}}] 
  
 +===== Make an intersection =====
  
-Re-run the program ​and notice that when it sees the intersection ​it will choose the left-most ​branch ​as the Vector.  ​+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).  ​If you run the EV3 program, you should notice that while Pixy2 sees the intersection,​ the EV3 LCD will show "​Intsctn:​ 4", meaning that it sees a 4-way intersection. ​   ​
  
-Try changing the default turn angle to -90 (right-most turn/​branch) and click on Apply.  ​ 
  
 +{{wiki:​v2:​image_372.png}}
  
-{{wiki:​v2:​image_376.png}} 
  
 +===== Make a "​Turn"​ at an Intersection =====
  
-Now when you place the intersection in front of Pixy2, it will choose the right-most branch of the intersection +You can stop the program and change Turn Angle to -90 degrees.
  
  
-{{wiki:v2:image_377.png}}+{{wiki:v1:image_732.png}}
  
  
-By default, Pixy2 will choose the branch automatically based on default ​turn angle or the most recent call to [[wiki:​v2:​line_api|setNextTurn()]]. ​ You can change this behavior by enabling "​delayed turn" in the Expert configure tab.  ​+-90 degrees is a right turn according ​to the diagram below.  ​
  
  
-Go ahead and enable delayed turn and click on Apply +[{{wiki:​v2:​image_364.png?​400|Angle coordinates from Pixy2'​s perspective.}}]
  
  
-{{wiki:​v2:​image_371.png}}+Re-run the program and notice that when it sees the intersection it will choose the right-most branch of the intersection as the Vector (instead of the straightest.)   
  
  
-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+{{wiki:​v2:​image_377.png}}
  
  
-{{wiki:​v2:​image_375.png}}+===== 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 [[https://​github.com/​charmedlabs/​pixy2/​raw/​master/​documents/​other/​all_codes.pdf|all_codes.pdf]] document. ​ (Note, other barcode files and images can be found [[https://​pixycam.com/​downloads-pixy2/​|here]].)
  
-In delayed turn mode, Pixy2 will wait for your controller to call [[wiki:​v2:​line_api|setNextTurn()]] which will instruct Pixy2 to choose the branch of the intersection that matches the angle the closest.  ​ 
  
 +Holding the document in front of Pixy2 while it is running the line tracking algorithm will yield something like this in PixyMon:
  
  
 +{{wiki:​v2:​image_374.png}}
  
  
 +If you run the EV3 program, you should see the text "​Barcode:​ n" on the EV3 LCD, where "​n"​ is the barcode'​s number.  ​
  
-==== 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 [[https://​github.com/​charmedlabs/​pixy2/​raw/​master/​documents/​other/​all_codes.pdf|all_codes.pdf]] document. ​  +===== What's Next? =====
- +
- +
-Holding the document in front of Pixy2 while it is running the line tracking algorithm will yield something like this: +
- +
- +
-{{wiki:​v2:​image_374.png}}+
  
 +This is just a test program to help demonstrate Pixy2'​s line following capabilities. ​ From here, you might want to test things on a simple robot with the [[wiki:​v2:​lego_line_following_demo|Line Following Demo]].
  
  
wiki/v2/lego_line_tracking_test.1548812716.txt.gz · Last modified: 2019/01/30 01:45 by pixycam