View Single Post
  #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