|
Camera code says "output not being updated enough"
We're attempting to get the image at this phase, and we just stuck the code in the DriveTrain subsystem for the time being. This is through the Command-Base style. Anyone know what's giving the update error? We think that it has something with the timer, but we're not really sure since we're a brand new team of programmers. This is why there is a timer. Again, we are totally clueless on what is causing the error.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.wpilibj.templates.subsystems;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Servo;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.camera.AxisCamera;
import edu.wpi.first.wpilibj.camera.AxisCameraException;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.image.ColorImage;
import edu.wpi.first.wpilibj.image.NIVisionException;
import edu.wpi.first.wpilibj.templates.RobotMap;
import edu.wpi.first.wpilibj.templates.commands.DriveWith Joysticks;
/**
*
* @author John
*/
public class DriveTrain extends Subsystem //no PID...
{
RobotDrive drive;
Servo vexMotor;
Victor motor;
AxisCamera camera;
public DriveTrain() {
super("drivetrain");
drive = new RobotDrive(RobotMap.leftBackMotor, RobotMap.leftFrontMotor, RobotMap.rightBackMotor, RobotMap.rightFrontMotor);
//vexMotor = new Servo(RobotMap.vexMotor);
//motor = new Victor(RobotMap.rightFrontMotor);
//throw new RuntimeException("lolol");
}
public ColorImage obtainImage() throws AxisCameraException, NIVisionException
{
camera = AxisCamera.getInstance("10.40.64.11");
camera.writeResolution(AxisCamera.ResolutionT.k640 x480);
camera.writeBrightness(0);
// Timer timer1 = new Timer();
//
// timer1.start();
// while(timer1.get() < .005)
// {
// System.out.println(timer1.get());
// drive.tankDrive(.3, .3);
// }
System.out.println("hi");
//Timer.delay(1);
//camera.writeMaxFPS(10);
ColorImage image;
System.out.println("brightness: "+ camera.getBrightness() + "\n camera rotation" +camera.getRotation());
//getWatchdog().kill();
// while(!camera.freshImage())
// {
// System.out.println("help im stuck in a loop making factory");
//
// image = camera.getImage();
// image.free();
// Timer.delay(.005);
// }
image = camera.getImage();
return image;
}
protected void initDefaultCommand() {
setDefaultCommand(new DriveWithJoysticks());
}
public void tankDrive(double left, double right) {
drive.tankDrive(left, right);
}
public void tankDrive(double time)
{
Timer timer1 = new Timer();
timer1.start();
while(timer1.get() < time)
{
System.out.println(timer1.get());
drive.tankDrive(.5, .5);
}
}
public void testDrive()
{
drive.setExpiration(1);
drive.tankDrive(0.01, 0);
Timer.delay(4);
drive.tankDrive(0,.1);
Timer.delay(4);
drive.tankDrive(0,0);
}
public void servo(double left) //testing servo
{
vexMotor.set(left);
}
public void victorTest(double number)
{
motor.set(number);
}
}
__________________
Pedro
Ocala InZombiacs
|