|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Axis Camera to Dashboard
I'm fairly new to programming, and I'm my team's only programmer, with no mentors knowing any programming. So far I've been able to piece together some Java, but the camera is beyond me.
I've looked at the Javadocs for the Axis camera, and the Circle Tracker demo, but I really don't understand how it works. If anyone could explain that, and how to implement it (at least to the effect of outputting camera to the dashboard) and the basic idea of image processing, I would be really grateful. Thanks! |
|
#2
|
||||
|
||||
|
Re: Axis Camera to Dashboard
Hey. Theoretically the camera should just show up on the dashboard when you call AxisCamera.getInstance(). At least, that's what I've read. You can see how it's done in the CircleTrackerDemo example code that's supplied in netbeans. Unfortunately, neither the example code nor a routine I've written seems to be written seems to be working for my team, we're investigating possible solutions. Anyway, I'm proficient in Java so if you need any help getting anything else working let me know.
|
|
#3
|
|||
|
|||
|
Re: Axis Camera to Dashboard
Okay, thanks. I'll try that tomorrow. (And I really need to have a mockup bot in my basement...)
|
|
#4
|
||||
|
||||
|
Re: Axis Camera to Dashboard
Tell me about it. I've written around 1500 lines of code that I have no way to test because the robot is yet to be wired.
![]() |
|
#5
|
|||||
|
|||||
|
Re: Axis Camera to Dashboard
What I just did was just customizing a copy of the sample CircleTrackerDemo to include our other functions, since the camera code took up most of the coding. That's probably not the most efficient way, but it works for us.
Let us know what you find, though, since I'd love to shave off a few lines by using the minimal amount of code required. |
|
#6
|
|||
|
|||
|
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) {
}
Code:
turnController.setSetpoint(gyroAngle + targets[0].getHorizontalAngle()); Code:
PIDController turnController = new PIDController(.08, 0.0, 0.5, gyro, new PIDOutput() {
public void pidWrite(double output) {
drive.arcadeDrive(0, output);
}
}, .005);
EDIT: I know the targeting part probably won't end up in TeleOp, but for now it can stay. Last edited by EthanMiller : 12-02-2010 at 16:23. Reason: Addendum |
|
#7
|
|||||
|
|||||
|
Re: Axis Camera to Dashboard
turnController drives the robot to point it directly at the target using the gyro angle.
The PIDController is designed to slow the robot turn down as it approaches the target gyro angle. Those values (.08, 0.0, 0.5) are coefficients that must match your robot's turning characteristics, so plan to adjust those when you get a real robot to practice with. The gyro angle was calculated from the camera image by the offset of the target from the center line. |
|
#8
|
|||
|
|||
|
Re: Axis Camera to Dashboard
Okay, thanks.
Let me make sure I got that straight - I'd be able to use that code in autonomous to point towards the target. If that's the case, how would I make it tell the next part that it's pointing at the target to shoot (Ignoring getting a ball for now)? |
|
#9
|
|||||
|
|||||
|
Re: Axis Camera to Dashboard
You'll be pointed at the target when targets[0].getHorizontalAngle() gets small. You'll have to pick your tolerance, e.g., +/- 1 degree, and test for it.
|
|
#10
|
|||
|
|||
|
Re: Axis Camera to Dashboard
Ok, thanks. If I need more help, I'll post it, but I think I've got the gist of this.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 2010 Axis Camera Dashboard Problems | Kohala2460 | General Forum | 0 | 04-02-2010 13:34 |
| 2010 Axis Camera Dashboard Problems | JesterKarrde | Programming | 12 | 04-02-2010 13:11 |
| Java/Netbeans Camera Code for Classmate PC and Axis Camera | joshholat | Programming | 1 | 23-01-2010 14:59 |
| Dashboard and Robot main with Axis camera | Team2883 | General Forum | 9 | 10-01-2009 07:35 |
| AXIS Camera | nickmagus | Programming | 1 | 03-01-2009 20:06 |