View Single Post
  #6   Spotlight this post!  
Unread 12-02-2010, 15:58
EthanMiller EthanMiller is offline
Lead Programmer
AKA: Socks
FTC #4356 (The Zip Ties)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2009
Location: Clayton, NY
Posts: 121
EthanMiller has a spectacular aura aboutEthanMiller has a spectacular aura aboutEthanMiller has a spectacular aura about
Re: Axis Camera to Dashboard

Well, having done some extensive tracing and finally copying the Target.java and the TrackerDashboard.java files to my project, then copying the following code into the Teleop section:

Code:
ColorImage image = null;
try {
       if (cam.freshImage()) {
       image = cam.getImage();
       Thread.yield();
       Target[] targets = Target.findCircularTargets(image);
       Thread.yield();
        if (targets.length == 0 || targets[0].m_score < kScoreThreshold) {
             System.out.println("No target found");
             Target[] newTargets = new Target[targets.length + 1];
             newTargets[0] = new Target();
             newTargets[0].m_majorRadius = 0;
             newTargets[0].m_minorRadius = 0;
             newTargets[0].m_score = 0;
             for (int i = 0; i < targets.length; i++) {
                   newTargets[i + 1] = targets[i];
             }
             trackerDashboard.updateVisionDashboard(0.0, gyro.getAngle(), 0.0, 0.0, newTargets);
             } else {
             System.out.println(targets[0]);
             System.out.println("Target Angle: " + targets[0].getHorizontalAngle());
             turnController.setSetpoint(gyroAngle + targets[0].getHorizontalAngle());
             trackerDashboard.updateVisionDashboard(0.0, gyro.getAngle(), 0.0, targets[0].m_xPos / targets[0].m_xMax, targets);
              }
      }
} catch (NIVisionException ex) {
       ex.printStackTrace();
} catch (AxisCameraException ex) {
       ex.printStackTrace();
} finally {
    try {
         if (image != null) {
         image.free();
         }
    } catch (NIVisionException ex) {
}
I've gone through and figured out (mostly) what this code does, but I don't understand what the line
Code:
turnController.setSetpoint(gyroAngle + targets[0].getHorizontalAngle());
does. In the original file, turnController is:
Code:
PIDController turnController = new PIDController(.08, 0.0, 0.5, gyro, new PIDOutput() {

        public void pidWrite(double output) {
            drive.arcadeDrive(0, output);
        }
    }, .005);
but I have no clue what PIDController does. Any help?

EDIT: I know the targeting part probably won't end up in TeleOp, but for now it can stay.
__________________
When all else fails, read the manual.

FRC 1713 K Island Gears 2009, 2010 (Not 2011 due to budget, hopefully 2012!) - Fingerlakes Regional

FTC 4356 The Zip Ties 2010-2011 Season - NNYRC (2010 9th seed).

Last edited by EthanMiller : 12-02-2010 at 16:23. Reason: Addendum
Reply With Quote