Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Robots don't quit (http://www.chiefdelphi.com/forums/showthread.php?t=125890)

Mr.Roboto3335 05-02-2014 20:29

Robots don't quit
 
When I try to upload the code it says "Robots don't quit!" I would like to know why it does that and how to fix it. Thanks!
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.                                                              */
/*----------------------------------------------------------------------------*/
/* Written by T0xicFail                                                      */
/* (c) 2014                                                                  */
/*----------------------------------------------------------------------------*/
package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.DriverStationLCD;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.SpeedController;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Compressor;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.Timer;

public class Voltage2014 extends IterativeRobot {

    private RobotDrive Drive;
    private Solenoid LeftLowGear, LeftHighGear, RightLowGear, RightHighGear; // Gear Shift
    private Joystick Controller;
    private Compressor Compressor;
    private SpeedController FrontLeft, FrontRight, BackLeft, BackRight;
    private final DriverStationLCD lcd = DriverStationLCD.getInstance();
    private boolean HasShifted;

    public void robotInit() {
        RobotDriveInit();
        CompressorInit();
        ControllerInit();
        TalonInit();

        HasShifted = false;
    }
   

    public void RobotDriveInit() {
        Drive = new RobotDrive(FrontLeft, FrontRight, BackLeft, BackRight);
    }

    public void CompressorInit() {
        Compressor = new Compressor(1, 1);// Digital I/O, Relay
        LeftLowGear = new Solenoid(2);
        LeftHighGear = new Solenoid(3);
        RightLowGear = new Solenoid(4);
        RightHighGear = new Solenoid(5);
    }

    public void ControllerInit() {
        Controller = new Joystick(1);
    }

    public void TalonInit() {
        FrontLeft = new Talon(1);
        FrontRight = new Talon(2);
        BackLeft = new Talon(3);
        BackRight = new Talon(4);
    }

    public void autonomousPeriodic() {
    }

    public void teleopPeriodic() {
        //Drive
        Drive.arcadeDrive(getDeadZone(Controller.getY(), 0.25),
                getDeadZone(Controller.getThrottle(), 0.25) * 0);

        // Compressor
        if (Controller.getRawButton(1)) {
            Compressor.start();
            lcd.println(DriverStationLCD.Line.kUser1, 1, "Compressor: ON ");
        } else if (Controller.getRawButton(2)) {
            Compressor.stop();
            lcd.println(DriverStationLCD.Line.kUser1, 1, "Compressor: OFF");
        }

        // Shifter
        if (Controller.getRawButton(5) && !HasShifted) {
            LeftHighGear.set(true);
            RightHighGear.set(true);
            Timer.delay(0.1);
            LeftLowGear.set(false);
            RightLowGear.set(false);
            HasShifted = true;
            lcd.println(DriverStationLCD.Line.kUser2, 1, "Speed: High");
            lcd.updateLCD();
        } else if (Controller.getRawButton(5) && HasShifted) {
            LeftLowGear.set(true);
            RightLowGear.set(true);
            Timer.delay(0.1);
            LeftHighGear.set(false);
            RightHighGear.set(false);
            HasShifted = false;
            lcd.println(DriverStationLCD.Line.kUser2, 1, "Speed: Low ");
            lcd.updateLCD();
        }

    }

    private double getDeadZone(double num, double dead) {
        if (num < 0) {
            if (num < dead) {
                return num;
            } else {
                return 0;
            }
        } else {
            if (num > dead) {
                return num;
            } else {
                return 0;
            }
        }
    }

    public void testPeriodic() {

    }

}


Joe Ross 05-02-2014 21:07

Re: Robots don't quit
 
Quote:

Originally Posted by Mr.Roboto3335 (Post 1338231)
When I try to upload the code it says "Robots don't quit!" I would like to know why it does that and how to fix it. Thanks!

When it tells you Robots don't quit!, it will also give you a stack trace which will show the path through the code (including line numbers) which triggered the problem. By looking through that path, you should be able to identify your bug.

One thing I notice immediately is that you call TalonInit after RobotDriveInit, so the talons are null when RobotDriveInit tries to use them. This will cause it to crash.

Mr.Roboto3335 05-02-2014 21:25

Re: Robots don't quit
 
Thank you! moving the initiatives worked.


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

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