2010 Vision targetting code

Now that our team is done for the season, we are starting to look at some of the post season projects. One of such projects is to resurrect the 2010 Breakaway bot and update it with this year’s code library. The reason why we want to do that is we like our 2010 bot and want to use it for demos. Because of time constraint last year, we did not quite get the vision targetting code debugged plus the fact that our 2011 library code has a new feature that allows PID controlled vision targetting. So you can drive the robot around with mecanum wheels forward, backward and sideways and PID control will take care of always facing the robot to the goal. We debugged the PID control code and it seemed it was working “in theory”. It means when we moved the target to the left, the robot would turn left. If we moved the target to the right, it would turn right. However, the turn was delayed for about half a second. Eventually, we time-stamped our calls to the targetting code provided by FIRST and found that calling GetImage() and FindCircularTargets() together took somewhere between 500 to 1000 msec. It got worse if the room was dimly lit (could be up to 3 seconds). Is this a known problem with the vision targetting code? I remember when we tested that last year, we did not see this issue? Just to make it clear, we did not change a line in the provided vision targetting code. If it is a known issue with the provided code, did somebody fix it in a newer version. If not, I may have to dig into the vision targetting code and figure out why it took so long. At first, we didn’t realize it took a long time but when we saw the WatchDog was starving, then we suspected the time it took was long and thus put in the code to time it.


if (m_camera.IsFreshImage())
{
    UINT32 timeStart = GetMsecTime();
    // find FRC targets in the image
    HSLImage *image = m_camera.GetImage();
    vector<Target> targets = Target::FindCircularTargets(image);
    delete image;
    if ((targets.size() > 0) &&
        (targets[0].m_score >= MIN_TARGET_SCORE))
    {
        input = targets[0].GetHorizontalAngle();
        prevInput = input;
        m_dsLCD->PrintfLine(DriverStationLCD::kUser_Line3,
                                     "Target found at %f", input);
    }
    m_dsLCD->PrintfLine(DriverStationLCD::kUser_Line4,
                                 "Time: %d", GetMsecTime() - timeStart);
}

Check the image size and the rake parameters to the FindEllipse. Also keep in mind that the camera exposure time goes up in low light --if using auto exposure.

Greg McKaskle