I am using the pixy2 for line following. I call the getAllfeatures routine and get the structure filled out with all the data. I use the coordinate for vector as the error for my PID loop. This all works fine for a simple track.
Now my code calls the setNextTurn routine when it sees an intersection. If a bar code is present at the same time the barcode is visible, I use +90 degrees as the argument, else I set it to 0. From what I have read, this should cause the “Vector” Pixy picks to either be the turn or the go straight line segment after the intersection.
But what I find is that as soon as I call the setNextTurn routine, all the data in the pixy.line structure seems to be all set to zero. When that happens, suddenly my PID loop thinks it is far to the right of the line and makes a hard left turn. It turns hard enough to not see the intersection but still see the main line and then it corrects by making a hard right turn.
Can anyone verify that pixy.line.vectors structure gets clears on calls to setNextTurn? And perhaps the developers have a solution for this behavior or at least an explanation? I am presenting this sensor to a robot group meeting on Sunday and would love to provide some explanation!