Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Robot Connection Resetting (http://www.chiefdelphi.com/forums/showthread.php?t=134755)

Dinnesy 17-02-2015 08:38

Robot Connection Resetting
 
Recently, my team has noticed our robot's connection resetting itself for no apparent reason and giving us the following output in the console:
Connection reset at edu.wpi.first.wpilibj.CameraServer.serve(CameraSer ver.java:346)
edu.wpi.first.wpilibj.CameraServer$1.run(CameraSer ver.java:77)
java.lang.Thread.run(Thread.java:745)

I'm assuming there is something wrong with the camera code, but I have no idea what.

Here is the code we are using:
Code:


package org.usfirst.frc.team4968.robot;


import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.Victor;

/**
 * Robot Drive sample code, modified by Ryley Ongarato for use by the Robohawks/team 4968's robot.
 * Allows robot to be driven arcade style and Microsoft vision camera to be displayed on frc dashboard (cameraHW).
 * Also allows for a crate to be grabbed via the grabbing system, and (WIP) lifted via the lifting system.
 * Features a brake(button 1) and a one axis camera.
 **/
public class Robot extends SampleRobot {
    RobotDrive myRobot;
    Victor grabSystem = new Victor(2);
    double grabSystemSpeed;
    Victor liftSystem = new Victor(3);
    double lifeSystemSpeed;
    Victor camAxis = new Victor(4);
    double camAxisSpeed;
    Joystick stick;
    Joystick leftstick;
    CameraServer server;

    public Robot() {
            myRobot = new RobotDrive(0, 1);
            myRobot.setExpiration(0.1);
            stick = new Joystick(0);
            leftstick = new Joystick(1);
            server = CameraServer.getInstance();
            server.setQuality(30);                                                //Camera Compression rate/Quality
            server.startAutomaticCapture("cam0");                //the camera is displayed on the frc dashboard as cameraHW.
    }

    /**
    * Basic Autonomous Drive at speed x for x seconds.
    **/
    public void autonomous() {
        myRobot.setSafetyEnabled(false);
        myRobot.drive(0.1, 0.0);                                        // drive forwards at (x) speed
        Timer.delay(1.0);                                                        // for (x) seconds
        myRobot.drive(0.0, 0.0);                                        // stop robot after x seconds
    }

    /**
    * Runs during Teleop mode. This code drives the robot via arcade steering. Also includes the brake, lift, and grabbing code.
    **/
            public void operatorControl() {
            myRobot.setSafetyEnabled(true);
            while (isOperatorControl() && isEnabled()) {

            //-------------------------Robot Drive-------------------------//
                    if (stick.getRawButton(1)){
                    myRobot.arcadeDrive(stick.getX() * 0.3, stick.getY() * 0.3);                //Brake (stops motors, will flip robot at high speed)             
                    System.out.println("Button 1 pressed!");               
                        }
                else{ myRobot.arcadeDrive(stick.getX() * 0.5, stick.getY() * 0.5);                //Arcade style driving, using the right stick with speed capped at 50%
                        }
        //-------------------------Grab System-------------------------//
            double grabSystemSpeed = 0;
                    grabSystemSpeed = leftstick.getX();                                                                        //Retrieves value from the leftstick's x axis and sets it to grabSystemSpeed
                    grabSystem.set(grabSystemSpeed);                                                                          //Apply grabSystemSpeed to the grabSystem
                           
            //-------------------------Lift System-------------------------//
                double liftSystemSpeed = 0;
                        liftSystemSpeed = -leftstick.getY();                                                                //Retrieves value from the leftstick's x axis and sets it to grabSystemSpeed
                        liftSystem.set(liftSystemSpeed);                                                                          //Apply grabSystemSpeed to the grabSystem
                            }
            //-------------------------Camera Axis-------------------------//
            double camAxisSpeed = 0;
                    if (stick.getRawButton(3)){
                            camAxisSpeed = (1.0);                                                                                        //Move camera axis up             
                            }
                    else if (stick.getRawButton(4)){
                            camAxisSpeed = (-1.0);                                                                                        //Move camera axis down
                            }
                    camAxis.set(camAxisSpeed);
        }
   
    /**
    * Runs during test mode. Used for testing new code/code changes.
    **/
    public void test() {
   
    }
}



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

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