Tracking_state confusion

I have already written a working autonomous code with my team’s robot, but I have a small problem that keeps occuring. Our robot will see the light and then a leg of the spider will obstruct the view of the camera, completely eclipsing the light. And if the camera is searching and can not find the light it will use those values and go into destroy mode killing everything around it. How can I use the tracking_state to stop the robot from moving if it doesn’t see the light or if it has lost the light? I honestly do not understand the many states of this camera.

One approach would be to keep track of your heading, independent of the camera. If you loose tracking (confidence<1), then basically DR using your last good heading. If you had held a good track before loosing the light, it would safe to assume you could keep going that way (for a while, anyway).

Hope this helps

Jon Mittelman
Programming Mentor
Team 236

If I understand your problem correctly, you might consider mounting the camera at the rear of the 'bot.


Hey thanks guys, what I was really looking for was more of a statement that would read something similar to if (tracking_state == CAMERA_ON_TARGET){…} because we are unable to move the camera without destroying it with innertubes and the arm that we’re using. Because i’m uncertain as to what the states are, where they are located, and how i can use them to make sure that my code will only work while the camera is locked on.

Take a look at the Get_Tracking_State function in Kevin’s tracking.c I believe it has what you are looking for.

btw, our experience has been that you don’t want to use the camera data for chassis commands until you get a CAMERA_ON_TARGET, and once you have a lock, don’t ignore your camera until the tracking state has transitioned all the way to SEARCHING. (a bit of hysteresis seems helpful)