Go to Post Yeah, yeah...those who aren't spotlit, spotlight.... - Jessica Boucher [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 31-01-2010, 21:09
team1512's Avatar
team1512 team1512 is offline
Registered User
FRC #1512
 
Join Date: Jan 2008
Location: Concord
Posts: 10
team1512 is an unknown quantity at this point
Robot Dropping the Code

Hello all, I am part of team 1512 and our robot is running using 2010 v19 imaging and a net beans java code. We have have had quite a bit of major success loading the code from a seperate PC and using the supplied classmate for the driver station. Usually the robot communicates well and then can be operated through teleoperated and autonomous, however our most recent code has seen that the robot communicates and stays in sync but somehow suddenly drops the code going from "teleoperated enabled" to "no robot code" even if the lights on the speed controllers still register a code. Both the disable and emergency stop buttons still work but the classmate won't even say "emergency stopped" if the button is pressed like it normally does. I reverted back again to our default code and that works so it is not the wiring something in the program is causing the robot to drop the code but there are no errors in the text as far as we can see. Please help... Thanks

Here is the code:
/*----------------------------------------------------------------------------*/

/* Copyright (c) FIRST 2008. All Rights Reserved. */

/* Open Source Software - may be modified and shared by FRC teams. The code */

/* must be accompanied by the FIRST BSD license file in the root directory of */

/* the project. */

/*----------------------------------------------------------------------------*/



package edu.wpi.first.wpilibj.templates;

//import edu.wpi.first.wpilibj.SensorBase;

//import edu.wpi.first.wpilibj.Encoder;

import edu.wpi.first.wpilibj.SimpleRobot;

import edu.wpi.first.wpilibj.RobotDrive;

import edu.wpi.first.wpilibj.Timer;

import edu.wpi.first.wpilibj.Joystick;

import edu.wpi.first.wpilibj.Servo;

import edu.wpi.first.wpilibj.camera.AxisCamera;

import edu.wpi.first.wpilibj.camera.AxisCameraException;

//import edu.wpi.first.wpilibj.image.HSLImage;

import edu.wpi.first.wpilibj.DigitalInput;

import edu.wpi.first.wpilibj.image.ColorImage;

import edu.wpi.first.wpilibj.image.NIVisionException;

//import edu.wpi.first.wpilibj.CounterBase;







/**

* The VM is configured to automatically run this class, and to call the

* functions corresponding to each mode, as described in the SimpleRobot

* documentation. If you change the name of this class or the package after

* creating this project, you must also update the manifest file in the resource

* directory.

*/

public class RobotTemplate extends SimpleRobot {





//HSLImage image;// = new HSLImage ();

RobotDrive drive = new RobotDrive(1, 2);

Joystick leftStick = new Joystick(1);

Joystick rightStick = new Joystick(2);

AxisCamera camera = AxisCamera.getInstance();

ColorImage image;// = camera.getImage();

Servo servo5 = new Servo(5);

DigitalInput button1 = new DigitalInput(1);

/**

* This function is called once each time the robot enters autonomous mode.

*/

public void autonomous()

{

for (int i = 0; i < 4; i++)

{

drive.drive(-0.5, 0.0); //drive 50% fwd 0% turn

Timer.delay(2.0); // wait 2 seconds

drive.drive (0.0, 0.75); // drive 0% 75% turn



}

drive.drive(0.0, 0.0); //stops all drive/turn

}



/**

* This function is called once each time the robot enters operator control.

*/

public void operatorControl() {



getWatchdog().setEnabled(false);

float f=0;

float increment = (float) 0.5;

int direction=0;



while (true && isOperatorControl() && isEnabled()) // loop until change

{

try {

image = camera.getImage();

}

catch (AxisCameraException ex) {

ex.printStackTrace();

}

catch (NIVisionException ex) {

ex.printStackTrace();

}



drive.tankDrive(leftStick, rightStick); // drive with joysticks

camera.writeResolution(AxisCamera.ResolutionT.k320 x240);

camera.writeBrightness(0);

//Timer.delay(3.0);

// servo5.setAngle(rightStick.getX()*100.0);

servo5.setAngle(f);

if (direction==0) f=f+increment; else f=f-increment;

if (f>255.0) direction=1;

if (f<0.0) direction=0;



System.out.println("leftstickx="+leftStick.getX()+ "leftSticky="+leftStick.getY());

System.out.println(" rightstickx="+rightStick.getX()+"rightSticky="+rig htStick.getY());

System.out.println(" servo angle="+servo5.getRaw() + " f=" + f);

System.out.println(" Button1="+button1.get());

Timer.delay(0.005);



}

}

}
Reply With Quote
  #2   Spotlight this post!  
Unread 01-02-2010, 18:36
Robototes2412's Avatar
Robototes2412 Robototes2412 is offline
1 * 4 != 14
FRC #2412 (Robototes)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Bellevue
Posts: 312
Robototes2412 is on a distinguished road
Re: Robot Dropping the Code

Yeah, the camera is a b*tch, try manually reconfing it and then pray.
Reply With Quote
  #3   Spotlight this post!  
Unread 01-02-2010, 22:32
Brent Strysko Brent Strysko is offline
President
AKA: JCODER
FRC #1672 (Mahwah Robo T-Birds)
Team Role: Webmaster
 
Join Date: Mar 2009
Rookie Year: 2007
Location: Mahwah
Posts: 14
Brent Strysko is an unknown quantity at this point
Re: Robot Dropping the Code

Team 1672 had a very similar problem today. Your best bet is just to start a new project and then re-paste the code as that fixed our problem. It seems to be a strange but in the linking portion of the code.
Reply With Quote
  #4   Spotlight this post!  
Unread 02-02-2010, 20:04
ericarseneau ericarseneau is offline
Registered User
no team
 
Join Date: Jan 2010
Location: San Diego
Posts: 30
ericarseneau is an unknown quantity at this point
Re: Robot Dropping the Code

I strongly recommend you get the console output and see if there wasn't some kind of exeption that came out. I think we capture some exceptions and put them out on the LCD, but there is nothing that beats having the console up.

You can use NetConsole, or run the echo target in the build.xml of your project, or use ant echo from a shell inside your project directory.
Reply With Quote
  #5   Spotlight this post!  
Unread 02-02-2010, 23:07
will_1359 will_1359 is offline
Registered User
FRC #1359
 
Join Date: Jan 2010
Location: lebanon
Posts: 15
will_1359 is an unknown quantity at this point
Re: Robot Dropping the Code

yeah 1359 is having the same problem, first i did a reimage of the Classmate(there was another issue with half the DS not showing up) and that didn't fix the robot code problem, we also formatted and reloaded v19 to the cRIO and loaded our code in again, no worky. then i just did what was suggested here in this thread and whipped up some copy pasta with what used to be a working code, and it still doesn't work. kinda sucks. any other ideas?
Reply With Quote
  #6   Spotlight this post!  
Unread 03-02-2010, 00:48
ericarseneau ericarseneau is offline
Registered User
no team
 
Join Date: Jan 2010
Location: San Diego
Posts: 30
ericarseneau is an unknown quantity at this point
Re: Robot Dropping the Code

Did you connect the console to see if an exception was coming out? If so then can we see what the exception output was?
Reply With Quote
  #7   Spotlight this post!  
Unread 03-02-2010, 14:05
omalleyj omalleyj is offline
Registered User
AKA: Jim O'Malley
FRC #1279 (Cold Fusion)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2008
Location: New Jersey
Posts: 132
omalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to behold
Re: Robot Dropping the Code

Guys you need to free the image. If you don't you run out of memory pretty quick. Check the output as Eric suggested.

Further tip: your code needs better organization. You waste a lot of cpu and bandwidth resetting the camera to the same values every single loop. That stuff should be moved into a constructor and done once.
Reply With Quote
  #8   Spotlight this post!  
Unread 03-02-2010, 14:39
omalleyj omalleyj is offline
Registered User
AKA: Jim O'Malley
FRC #1279 (Cold Fusion)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2008
Location: New Jersey
Posts: 132
omalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to behold
Re: Robot Dropping the Code

1512 try this:

/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/

package edu.wpi.first.wpilibj.templates;
//import edu.wpi.first.wpilibj.SensorBase;
//import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.SimpleRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Servo;
import edu.wpi.first.wpilibj.camera.AxisCamera;
import edu.wpi.first.wpilibj.camera.AxisCameraException;
//import edu.wpi.first.wpilibj.image.HSLImage;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.image.ColorImage;
import edu.wpi.first.wpilibj.image.NIVisionException;
//import edu.wpi.first.wpilibj.CounterBase;

/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the SimpleRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the manifest file in the resource
* directory.
*/

public class RobotTemplate extends SimpleRobot {

RobotDrive drive = new RobotDrive(1, 2);
Joystick leftStick = new Joystick(1);
Joystick rightStick = new Joystick(2);
AxisCamera camera;
ColorImage image;// = camera.getImage();
Servo servo5 = new Servo(5);
DigitalInput button1 = new DigitalInput(1);

public RobotTemplate(){
Timer.delay(5.0);
camera = AxisCamera.getInstance();
Timer.delay(5.0);
camera.writeResolution(AxisCamera.ResolutionT.k320 x240);
camera.writeBrightness(0);
}

/**
* This function is called once each time the robot enters autonomous mode.
*/

public void autonomous()
{
//don't use this code unless you know your robot won't
//hit something at 50% speed for 2 seconds
for (int i = 0; i < 4; i++)
{
drive.drive(-0.5, 0.0); //drive 50% fwd 0% turn
Timer.delay(2.0); // wait 2 seconds
//this turn may not be enough for your robot
drive.drive (0.25, 0.75); // drive 25% 75% turn
Timer.delay(2.0);
}

drive.drive(0.0, 0.0); //stops all drive/turn

}



/**
* This function is called once each time the robot enters operator control.
*/

public void operatorControl() {

getWatchdog().setEnabled(false);
float f=0;
float increment = (float) 0.5;
int direction=0;

while (true && isOperatorControl() && isEnabled()) // loop until change
{

try {
image = camera.getImage();
} catch (AxisCameraException ex) {
ex.printStackTrace();
} catch (NIVisionException ex) {
ex.printStackTrace();
}

/* do stuff with the image */
try {
image.free();
} catch (NIVisionException ex){
ex.printStackTrace();
}

drive.tankDrive(leftStick, rightStick); // drive with joysticks


//Timer.delay(3.0);
// servo5.setAngle(rightStick.getX()*100.0);

servo5.setAngle(f);
if (direction==0) f=f+increment; else f=f-increment;
if (f>255.0) direction=1;
if (f<0.0) direction=0;


System.out.println("leftstickx="+leftStick.getX()+ "leftSticky="+leftStick.getY());
System.out.println(" rightstickx="+rightStick.getX()+"rightSticky="+rig htStick.getY());
System.out.println(" servo angle="+servo5.getRaw() + " f=" + f);
System.out.println(" Button1="+button1.get());

Timer.delay(0.020);//.005? Really need it that fast?
}

}

}

be careful cutting and pasting, your code as posted has two typos
Reply With Quote
  #9   Spotlight this post!  
Unread 09-02-2010, 14:29
alex42 alex42 is offline
Registered User
FRC #1072
 
Join Date: Jan 2010
Location: San Jose
Posts: 36
alex42 is an unknown quantity at this point
Re: Robot Dropping the Code

When it loses the code, does it then regain the code after a few seconds, then repeat ad infinitum? If so, team 1072 has been having the same problem, although we're using LabVIEW. We've found that if we reimage the cRIO, the problem will usually go away for a few days (and if it doesn't fix it, we reimage it again until it does). We're still looking for a permanent fix though.
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[FTC]: FMS Dropping only the joystick possibly? ttldomination FIRST Tech Challenge 8 24-02-2009 18:13
Adjustable Way of Dropping the Center Wheel R.C. Technical Discussion 15 06-08-2008 18:37
Hex code loader for the robot! paulcd2000 Programming 4 22-10-2006 01:58
default code and the actual robot tml240 Programming 15 24-01-2004 11:31


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

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