<< return to Pixycam.com

User Tools

Site Tools


wiki:v2:pixy_zumo_howto

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:pixy_zumo_howto [2018/07/14 15:17]
pixycam [The code]
wiki:v2:pixy_zumo_howto [2019/02/15 21:37] (current)
jfrench
Line 10: Line 10:
   * [[https://​pixycam.com/​pixy2/​|Pixy2]]   * [[https://​pixycam.com/​pixy2/​|Pixy2]]
   * [[https://​pixycam.com/​pixy2-pan-tilt-kit/​|Pixy2 pan-tilt kit]]   * [[https://​pixycam.com/​pixy2-pan-tilt-kit/​|Pixy2 pan-tilt kit]]
-  * Zumo robot for Arduino, [[https://​www.pololu.com/​product/​2509|unassembled kit]] or [[https://​www.pololu.com/​product/​2510|assembled]]+  * Zumo robot for Arduino, [[https://​www.pololu.com/​product/​2509|unassembled kit]] or [[https://​www.pololu.com/​product/​2510|assembled]] ​(note that the new 32U4 Zumo model will not work with this tutorial!)
   * 2 [[https://​www.pololu.com/​product/​3063|50:​1 geared motors]] (not needed if you buy Zumo assembled)   * 2 [[https://​www.pololu.com/​product/​3063|50:​1 geared motors]] (not needed if you buy Zumo assembled)
   * Arduino Uno or similar   * Arduino Uno or similar
Line 59: Line 59:
   ​   ​
 After you assemble the Zumo base, run a simple Arduino program to test the motors and buzzer. ​ Below is a simple Arduino program you can cut and paste into the Arduino IDE.  Note, the files ZumoMotors.h and ZumoBuzzer.h are part of the Pixy2 Arduino library (found [[https://​pixycam.com/​downloads-pixy2/​|here]]). ​ Install the Pixy2 Arduino library if you haven'​t already.  ​ After you assemble the Zumo base, run a simple Arduino program to test the motors and buzzer. ​ Below is a simple Arduino program you can cut and paste into the Arduino IDE.  Note, the files ZumoMotors.h and ZumoBuzzer.h are part of the Pixy2 Arduino library (found [[https://​pixycam.com/​downloads-pixy2/​|here]]). ​ Install the Pixy2 Arduino library if you haven'​t already.  ​
 +
 +
 +It's easy to hook the Zumo motors up backwards. ​ This program will help you determine if your Zumo is working correctly. ​ If something isn't right, none of the Zumo demos will work!  So it's good to give this test a whirl...
        
  
Line 112: Line 115:
  
 ===== Making the cable ===== ===== Making the cable =====
 +
 +Making the cable is probably the most challenging step.  It requires some decent maker skills.
  
 1. Start by measuring 9 inches of 10-conductor ribbon cable and cut to length. ​ 1. Start by measuring 9 inches of 10-conductor ribbon cable and cut to length. ​
Line 124: Line 129:
 6. Cut wire number 2 on the ribbon cable close to the 10-pin connector, being careful not to cut the adjacent wires. ​ Cutting wire 2 prevents the 5V regulator on Zumo from fighting with the 5V regulator on Pixy2. ​ Refer to the picture below.  ​ 6. Cut wire number 2 on the ribbon cable close to the 10-pin connector, being careful not to cut the adjacent wires. ​ Cutting wire 2 prevents the 5V regulator on Zumo from fighting with the 5V regulator on Pixy2. ​ Refer to the picture below.  ​
  
-{{wiki:​v2:​img_5279_result.jpg}+{{wiki:​v2:​img_5279_result.jpg}}
  
  
Line 139: Line 144:
 {{wiki:​v2:​img_5291_result.jpg?​400}} {{wiki:​v2:​img_5291_result.jpg?​400}}
 {{wiki:​v2:​img_5290_result.jpg?​400}} {{wiki:​v2:​img_5290_result.jpg?​400}}
-3. Plug the Pixy2/​pan-tilt/​Arduino assembly on top of the Zumo as shown.  If all is correct, Pixy should be facing forward (away from the Zumo power switch and LEDs). The extra pin plugs into the Vin pin.  ​+3. Plug the Pixy2/​pan-tilt/​Arduino assembly on top of the Zumo via the I/O connectors.  If all is correct, Pixy should be facing forward (away from the Zumo power switch and LEDs). Note, because of the thickness of the Arduino cable connector, the Arduino won't be able to fully engage with the I/O connectors on the Zumo.  There will be about 0.050 inch gap, but it's no biggee. 
 + 
 +4. The extra pin plugs into the Vin pin.  ​
 {{wiki:​v2:​img_5310_result.jpg}} {{wiki:​v2:​img_5310_result.jpg}}
  
Line 178: Line 185:
  
  
-3. With the robot on its "​lift"​ (so it doesn'​t run off) hold the object directly in front of the robot, centered, about a foot from Pixy2'​s lens.  Both of Zumo's treads should be moving forward. ​ Move the object to the right. ​ Zumo's left tread should accelerate. ​ Move the object to the left.  Zumo's right tread should accelerate. ​ If one or more of the treads moves incorrectly or doesn'​t move at all, inspect the motor connections to Zumo's PCB, and use the Zumo test program (above) to better characterize how the motion is incorrect. ​ +3. With the robot on its "​lift"​ (so it doesn'​t run off) hold the object directly in front of the robot, centered, about a foot from Pixy2'​s lens.  Both of Zumo's treads should be moving forward. ​ Move the object to the right. ​ Zumo's left tread should accelerate. ​ Move the object to the left.  Zumo's right tread should accelerate. ​ If one or more of the treads moves incorrectly or doesn'​t move at all, inspect the motor connections to Zumo's PCB, and use the Zumo test program (above) to better characterize how the motion is incorrect.
  
  
Line 208: Line 215:
   * It calls setNextTurn() every time it sees a turn sign (barcode).   * It calls setNextTurn() every time it sees a turn sign (barcode).
  
-There is some interesting logic for setting the wheel velocities (setLeftSpeed() and setRightSpeed()).  ​In particular, if the Vector is pointing down (or down-ish), ​that is, the y1 value of the Vector is _greater than_ the y0 value.  If so, the robot will actually need to back-up to keep the line in view.  You can see this happen in [[https://​youtu.be/​EcCbEWiyiQY?​t=1m42s|the video]] when the robot makes a left-turn, because of the shape of the intersection. ​+There is some interesting logic for setting the wheel velocities (setLeftSpeed() and setRightSpeed()).  ​Sure, there is a PID loop wrapped around the robot heading. ​ But in particular, if the Vector is pointing down (or down-ish), ​i.e., the y1 value of the Vector is _greater than_ the y0 value -- if so, the robot will actually need to back-up to keep the line in view.  You can see this happen in [[https://​youtu.be/​EcCbEWiyiQY?​t=1m42s|the video]] when the robot makes a left-turn, because of the shape of the intersection. ​
  
-As an exercise to the reader (don't you love those?), modify the program to deal with a "U-turn" ​sign, such that when it sees a U-turn sign, the program issues a reverseVector() command, flipping the Vector. ​ What do you expect will happen? ​ Discuss with your lab partner. ​   +As an exercise to the reader (don't you love those?​), ​use the [[https://​github.com/​charmedlabs/​pixy2/​raw/​master/​documents/​other/​barcodes.zip|barcode images]] and your favorite drawing program to make a "​U-turn"​ sign.  Then modify the program to deal with a U-turn sign, such that when it sees it, the program issues a reverseVector() command, flipping the Vector. ​ What do you expect will happen? ​ Discuss with your lab partner. ​    ​
  
  
wiki/v2/pixy_zumo_howto.1531581454.txt.gz · Last modified: 2018/07/14 15:17 by pixycam