<< return to Pixycam.com

Mbed Library for Pixy2

Hello.

First of all thank you for your great work… We use CMUCAM since CMUCAM1 and since then you rocks and pixy2 looks really great !

I’m working on a Mbed library for pixy2 for my studdents (after having made the UART communication for pixy). But I can’t get clear informations about many feature (and especially the line following features data).

As I don’t use arduino it’s quite hard to understood without any test.

I would like to know many things about pixy and pixy2. Let’s start with pixy2 :

In the line tracking section the “getMainFeatures”. I’ve understood that there are 3 kinds of objects : vectors, intersections and barcodes. But what does pixy2 return exactly for those objects ?

Looking at Pixy2Line.h, I can find struct objects :

  • Vector are defined by 6 bytes : x0, Y0, x1, Y1, index and flag.

I understand the meaning of x and y but is there one for 0 and 1 ? I mean looking at your example in the line quickstart it looks like 0 is the nearest point and 1 the farthest. Am I true ?
What does index and flag stands for ? It’s unclear for me in the example… (is it usefull ?)

  • Intersection are defined by 4 bytes : x, y, n and a reserved byte, and then a bunch of intesection lines defined by 2 bytes : index and reserved and a word : angle.

Looking at the library I saw that n is the number of intersection lines in the intersection and x and y are the coordinate of the intersection. But it’s realy unclear to me what is the meaning of index in the intersection line.

  • Barcodes are defined by 4 bytes : x, y, flag and code.

It is unclear to me what is flag (I beleive that code is the numerical value associated with the barecode featured in all_code.pdf)…

Also in this the getMainFeature it’s written that there can only be 3 differents objects types (vector, intersection or barcode) transmitted. So what append if 4 objects are presents, ie a vector, an intersection and 2 barcodes ?
Looking to protocol reference it looks like the barcode feature data will be the agregation of the 2 barcodes feature data (one for each) and of course I beleive that feature length is twice a single barcode length. Am I right ?

Also is it possible (by setting the filters) to detect 2 or more intersections ? What happend if there are 2 intersections, a vector and a barcode ? Does you agregate intersections too ? And how to change filters parameters without USB ?

In the request, is there a difference between : request type = 0 with feature = 7, and request type = 1 ? Either does the feature has any meaning if type is set to all features ?

There is a setMode function. What are the possible values of mode ? Is it only “Turn delayed”, “Manual Select Vector” and “White line” ? Is there others features ? Is it really possible to have the whole list of mode parameters accessible (with UART) ? For exemple “White Line” parameter is undocumented in the Pixy2 documentation website (or I haven’t find it) but it can be found in the source code.

More generally in the documentation I can see “32-bit result/acknowledge”. What are the possible results and what numerical values are associated with error codes ?

I’ve read (on the website “Pixy2 communicates with “packets” in both directions – request and response. Each packet has the following structure, if no checksums are used” ) that it’s possible to communicate without checksum. So how to desactivate checksum ? If it’s impossible then how checksums are calculated ?

This is such a long mail so, I thanks you a lot for the time you will spent to bring me an answer.

Best Regards

H. Angelis (Professor)

Hello,
This page will answer many of your questions.
https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api

Pixy.line.vectors, Pixy.line.intersections and Pixy.line.barcodes are arrays, so there can be multiple elements. But with getMainFeatures, there will only be 1 of each (if present).

getMainFeatures() tries to send only the most relevant information. Some notes:

  • The line tracking algorithm finds the best Vector candidate and begins tracking it from frame to frame 1). The Vector is often the only feature getMainFeatures() returns.

  • Intersections are reported after they meet the filtering constraint. Only intersections that connect to the Vector are reported.

  • Barcodes are reported after they meet the filtering constraint.

  • Each new barcode and intersection is reported only one time so your program doesn’t need to keep track of which features it has/hasn’t seen previously.

getAllFeatures() will return everything, all features Pixy2 currently sees, but this can (usually) result in more complicated client software.

Regarding the protocol, this page has good information:

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide

Edward

Hi !
Thanks for the reply.
I found a lot of answers looking at APIs.

But still I keep with lots of questions :

  • How to compute checksums ? modular sum of 1-complements ? with or without header sync ?
  • Is it possible to remove checksum in pixy responses ?
  • In getAllFeature how many features are returned in the reply frame ?
  • How to access filtering function with uart ?
  • How to switch from line to ccc or vice-versa with old firmware ? Is it the changeProg function ? If so what string to send ? Is it “Line” and “ccc” ?

I’m sorry but making a real library is quite complicated and some functions remains unclear to me.
But still thank you !

The checksum is just the sum of the payload bytes. There is more information here:
https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:porting_guide

It is not possible to remove checksums, although you can ignore.

Check out numVectors, numIntersections and numBarcodes in this page
https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:line_api

Please see this page:
https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:general_api

Edward

Thanks a lot edward for this answer.

I’haven’t look to program switching yet, I will look for it soon and maybe ask you some other questions, but for line features and especialy for intersection, looking at Arduino code I have a question concerning this line

numIntersections = fsize/sizeof(Intersection);

It means that pixy will always send the same amount of data regarless the number of intersection lines.

I mean, if there is 2 intersections, one with 3 lines and the other with 4 lines, this mean that PIXY send each time a six intersection line tab with only 3 used for the first and 4 for the second intersection. Am I true ?

This code is saying that the number of intersections is the amount of intersection data (in bytes) divided by the size of an intersection (in bytes).

That sounds like you have the right idea. There can be as many as 6 lines, but not all of them are going to be valid.

Hope this helps!

Edward