Go to Post Someone once told me, "A smart man learns from his own mistakes, but a wise man learns from the smart man's mistakes." . - Pavan Dave [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-02-2012, 16:26
l0stboy l0stboy is offline
Registered User
FRC #4064 (InZombiacs)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: United States
Posts: 22
l0stboy is an unknown quantity at this point
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
Reply With Quote
  #2   Spotlight this post!  
Unread 09-02-2012, 16:52
Patrick Chiang Patrick Chiang is offline
Programming
FRC #3070 (Team Pronto)
Team Role: Mentor
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Seattle
Posts: 162
Patrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to allPatrick Chiang is a name known to all
Re: Camera code says "output not being updated enough"

This error is an indirect error message. It tells you that your program broke somewhere. What you want to post is the actual error message with actual line numbers that tell you exactly where it all went wrong. (It's called the stack trace. Use a try-catch block to print it.)

At the moment, I don't have a bot to test this code on, but it seems highly likely that this is a nullpointerexception error. The timer code looks okay, so if I were you, I would check if the motors are all plugged in right and if the camera is setup to the exact IP address you're querying (10.40.64.11).

Also, is that space deliberate between the 640 and x480 in line:
Code:
camera.writeResolution(AxisCamera.ResolutionT.k640 x480);
Reply With Quote
  #3   Spotlight this post!  
Unread 09-02-2012, 16:53
jesusrambo jesusrambo is offline
Self-Proclaimed Programmer Messiah
AKA: JD Russo
FRC #2035 (Robo Rockin' Bots)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2010
Location: Carmel, CA
Posts: 114
jesusrambo is an unknown quantity at this point
Re: Camera code says "output not being updated enough"

First off, I'd recommend putting your camera image acquisition code either in its own subsystem, or in your teleopPeriodic in your main robot class.

The error you're getting trips when the jaguars aren't getting their motor speed values updated often enough from the code, and from looking at this I'd bet you guys aren't actually calling the methods to update the jaguar values in your robot code anywhere.

EDIT: I think violinuxer is right, I think your image acquisition is causing the code to hang for a little while as it's capturing the image, and that delay is causing the error.
Reply With Quote
  #4   Spotlight this post!  
Unread 09-02-2012, 16:53
violinuxer violinuxer is offline
Registered User
FRC #2523
 
Join Date: Jan 2012
Location: Vermont
Posts: 13
violinuxer is an unknown quantity at this point
Re: Camera code says "output not being updated enough"

Hi there!

I have some experience with this problem... Luckily its an easy fix. The reason the message appears is the fact that your jaguars are not getting commands often enough. If you do not call RobotDrive.drive() (or its equivalent) the motors will stop and you will get the error. When you are doing image processing, the jaguars are not getting updated.

Hope this helps!

violinuxer
Reply With Quote
  #5   Spotlight this post!  
Unread 09-02-2012, 16:58
violinuxer violinuxer is offline
Registered User
FRC #2523
 
Join Date: Jan 2012
Location: Vermont
Posts: 13
violinuxer is an unknown quantity at this point
Re: Camera code says "output not being updated enough"

Quote:
Originally Posted by jesusrambo View Post
First off, I'd recommend putting your camera image acquisition code either in its own subsystem, or in your teleopPeriodic in your main robot class.

The error you're getting trips when the jaguars aren't getting their motor speed values updated often enough from the code, and from looking at this I'd bet you guys aren't actually calling the methods to update the jaguar values in your robot code anywhere.

EDIT: I think violinuxer is right, I think your image acquisition is causing the code to hang for a little while as it's capturing the image, and that delay is causing the error.
Yeah. We do it by putting all the subsystems in their own threads. We're still using SimpleRobot, but with a kinda-conmmand-based interface. It works quite well!

violinuxer
Reply With Quote
  #6   Spotlight this post!  
Unread 09-02-2012, 18:49
mfang mfang is offline
Registered User
FRC #4064 (Inzombiacs)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2012
Location: Ocala, FL
Posts: 5
mfang is an unknown quantity at this point
Re: Camera code says "output not being updated enough"

Hello!
I am the other programmer on the team. Thank you for all your advice. So: We've created a new project entirely which doesn't incorporate the drivetrain at all.
We now get an error, in which the "AxisCameraException: No image available" is thrown. This comes from camera.getImage(). Any help would be great. (Got to go home now, unfortunately...)
Reply With Quote
  #7   Spotlight this post!  
Unread 09-02-2012, 20:00
l0stboy l0stboy is offline
Registered User
FRC #4064 (InZombiacs)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: United States
Posts: 22
l0stboy is an unknown quantity at this point
Re: Camera code says "output not being updated enough"

Thanks for the help. The main aim of our robot is to use the camera to determine distance for our drivetrain during autonomous and tracking the hoops. This is why it's in the drivetrain subsystem. We'll obviously change that later. So in theory, the code should work if we are not calling on the drivetrain at all?
__________________

Pedro
Ocala InZombiacs
Reply With Quote
  #8   Spotlight this post!  
Unread 10-02-2012, 00:46
jesusrambo jesusrambo is offline
Self-Proclaimed Programmer Messiah
AKA: JD Russo
FRC #2035 (Robo Rockin' Bots)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2010
Location: Carmel, CA
Posts: 114
jesusrambo is an unknown quantity at this point
Re: Camera code says "output not being updated enough"

In that case, try just commenting out the vision code and see what happens.
Reply With Quote
  #9   Spotlight this post!  
Unread 11-02-2012, 17:27
l0stboy l0stboy is offline
Registered User
FRC #4064 (InZombiacs)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: United States
Posts: 22
l0stboy is an unknown quantity at this point
Re: Camera code says "output not being updated enough"

The problem was fixed by taking the code out of the drivetrain class. Thanks!
__________________

Pedro
Ocala InZombiacs
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:50.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi