<< return to Pixycam.com

Using Line Tracking API to See Line at at Distance

Hello, we are trying to use a Pixy2 on a robot to find a line ahead of the robot, drive to it, and then turn to follow it. We have it setup our Pixy2 to be on the robot about 6.5" off the ground, and can see a white line on the floor about 18" in front of the robot. From the returned vector, we are hoping to calculate the distance from the robot’s current location to the nearest end of the vector, assuming the 79×52 grid the Pixy2 returns found vectors in. We are assuming that the Pixy2 is sitting at the position (39,0) on the grid.

We are getting data back, but have trouble calculating the distance to the end of the vector as the Pixy2 gets further away from the end of the vector. Since the Pixy2 is facing down at a 45 degree angle from 6.5 inches above the floor, we are assuming there is something wrong in our math for that distance as it gets further away.

Does anyone have a good way to calculate this distance to a line/vector found out ahead of the Pixy2 in this situation?

Thank you!

Hello Jared,
Here’s the original topic.