<< return to Pixycam.com

User Tools

Site Tools


wiki:v2:line_quickstart

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:line_quickstart [2018/07/03 19:22]
pixycam
wiki:v2:line_quickstart [2019/01/30 01:50] (current)
pixycam
Line 1: Line 1:
-==== Line tracking quickstart ====+===== Line tracking quickstart ​=====
  
 This guide will help you get started with the line tracking algorithm on the Pixy2. ​ This guide will help you get started with the line tracking algorithm on the Pixy2. ​
  
-=== Running line tracking through PixyMon === +==== Running line tracking through PixyMon ​==== 
  
 PixyMon will display what Pixy2 detects graphically and is a good way to familiarize yourself with what the line tracking algorithm is capable of, and it's a good way to make adjustments. ​ Start by selecting the line tracking algorithm in the _Program_ menu.  PixyMon will display what Pixy2 detects graphically and is a good way to familiarize yourself with what the line tracking algorithm is capable of, and it's a good way to make adjustments. ​ Start by selecting the line tracking algorithm in the _Program_ menu. 
Line 17: Line 17:
  
  
-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 move the paper and see that Pixy2 can track the line fairly quickly. ​ PixyMon slows down the tracking algorithm typically to 20-30 frames-per-second because it takes some time to send the raw frame data across USB, but if you change the view to "no background",​ you can get a feel for what the tracking algorithm looks like at the native 60 frames-per-second.  This is framerate your robot will see+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 move the paper and see that Pixy2 can track the line fairly quickly. ​ PixyMon slows down the tracking algorithm typically to 20-30 frames-per-second because it takes some time to send the raw frame data across USB, but if you change the view to "no background" ​(see pic below), you can get a feel for what the tracking algorithm looks like at the native 60 frames-per-second.
  
-You can also see what happens when you turn on Pixy2'​s lamp.  
  
 +{{wiki:​v2:​image_369.png}}
  
-{{wiki:​v2:​image_370.png}} 
  
 +This (60 fps) is framerate your robot will see. 
  
-Note, with the lamp on, Pixy2 can 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. ​ The result is that Pixy2'​s lamp can improve the speed your robot can move!+You can also see what happens ​when you turn on Pixy2'​s lamp
  
  
 +{{wiki:​v2:​image_370.png}}
  
-{{wiki:​v2:​image_369.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!
  
  
Line 47: Line 49:
  
  
-Try changing the default turn angle to -90 and click on Apply.  ​+Try changing the default turn angle to -90 (right-most turn/​branch) ​and click on Apply.  ​
  
  
Line 59: Line 61:
  
  
-By default, Pixy2 will choose the branch automatically ​or 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.  ​ +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.  ​
- +
- +
-FIXME pic enable delayed turn+
  
  
Line 77: Line 76:
  
  
-In delayed turn mode, Pixy2 will wait for the call to [[wiki:​v2:​line_api|setNextTurn()]] to choose the branch that matches the angle the closest.  ​+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.  ​
  
  
Line 84: Line 83:
  
  
-=== Barcodes ===+==== 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]].)
  
-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.  ​ 
  
  
Line 95: Line 95:
  
  
-=== Running a simple Arduino line tracking example ===+==== Running a simple Arduino line tracking example ​====
  
 If you haven'​t hooked your Arduino to your Pixy2 yet, use the supplied Arduino cable to connect Pixy to your Arduino as shown below. If you haven'​t hooked your Arduino to your Pixy2 yet, use the supplied Arduino cable to connect Pixy to your Arduino as shown below.
Line 101: Line 101:
 //Note: if you're using Arduino Nano, the ribbon cable faces the interior of the Nano, it doesn'​t exit off the side like on the Uno (pictured).\\ //Note: if you're using Arduino Nano, the ribbon cable faces the interior of the Nano, it doesn'​t exit off the side like on the Uno (pictured).\\
 If the cable is plugged in backwards, you won't be able to upload to the Nano, or have serial communication with it.// If the cable is plugged in backwards, you won't be able to upload to the Nano, or have serial communication with it.//
 +
  
 {{wiki:​img:​ce5166e65a245cce097741efef288fe09b08da8a.jpg?​400}}\\ {{wiki:​img:​ce5166e65a245cce097741efef288fe09b08da8a.jpg?​400}}\\
 {{wiki:​v2:​img_5257_result.jpg?​400}} {{wiki:​v2:​img_5257_result.jpg?​400}}
 +
  
 Next, download the latest Arduino library "​arduino\_pixy2-x.y.z.zip"​ [[https://​pixycam.com/​downloads-pixy2/​|here]]. Bring up the Arduino IDE and import the Pixy library by selecting **Sketch➜Include Library➜Add .ZIP Library...** (or if you're using an older version **Sketch➜Import Library**) in the Arduino IDE, and then browsing to the Arduino zip file that you just downloaded. Next, download the latest Arduino library "​arduino\_pixy2-x.y.z.zip"​ [[https://​pixycam.com/​downloads-pixy2/​|here]]. Bring up the Arduino IDE and import the Pixy library by selecting **Sketch➜Include Library➜Add .ZIP Library...** (or if you're using an older version **Sketch➜Import Library**) in the Arduino IDE, and then browsing to the Arduino zip file that you just downloaded.
Line 110: Line 112:
  
  
-FIXME 
 <​code>​ <​code>​
 +vector: (38 51) (39 9) index: 0 flags 4 
 +vector: (37 51) (38 10) index: 0 flags 4 
 +vector: (37 51) (40 12) index: 0 flags 4 
 +vector: (37 51) (37 13) index: 0 flags 4 
 +vector: (36 51) (40 15) index: 0 flags 4 
 +vector: (36 16) (38 0) index: 2 flags 4 
 +intersection:​ (36 16) 
 +  0: index: 7 angle: -88 
 +  1: index: 2 angle: -7 
 +  2: index: 1 angle: 93 
 +  3: index: 0 angle: 180 
 +vector: (34 16) (37 0) index: 2 flags 4 
 +vector: (36 19) (37 0) index: 2 flags 4 
 +vector: (39 21) (37 0) index: 2 flags 4 
 +vector: (35 22) (37 0) index: 2 flags 4 
 +vector: (35 23) (37 0) index: 2 flags 4 
 +vector: (35 24) (37 0) index: 2 flags 4 
 +vector: (35 25) (37 0) index: 2 flags 4 
 +...
 </​code>​ </​code>​
 +
  
 In particular, when you hold a barcode, line or intersection,​ you can see the numbers that Pixy2 returns. ​ Bear in mind that the numbers Pixy2 returns are based on the coordinate system below. ​ In particular, when you hold a barcode, line or intersection,​ you can see the numbers that Pixy2 returns. ​ Bear in mind that the numbers Pixy2 returns are based on the coordinate system below. ​
 +
  
 [{{wiki:​v2:​image_366.png?​500|Line tracking image coordinates from Pixy2'​s perspective.}}]  ​ [{{wiki:​v2:​image_366.png?​500|Line tracking image coordinates from Pixy2'​s perspective.}}]  ​
  
-=== The line tracking API ===+ 
 +Also note that the intersections and barcodes are only reported once every time the intersection or barcode comes into view.  This means you (the programmer) doesn'​t need to keep track of which intersections and barcodes have been seen before and which have not.   
 + 
 + 
 + 
 +==== The line tracking API ====
  
 The line tracking API can be found [[wiki:​v2:​line_api|here]]. ​ It applies to Arduino (SPI interface) as well as the Raspberry Pi, or similar controllers (USB interface).  ​ The line tracking API can be found [[wiki:​v2:​line_api|here]]. ​ It applies to Arduino (SPI interface) as well as the Raspberry Pi, or similar controllers (USB interface).  ​
wiki/v2/line_quickstart.1530645762.txt.gz · Last modified: 2018/07/03 19:22 by pixycam