Go to Post It is a little known fact that Team 1114 is actually "General Motors Canada and Hogwarts Academy" The whole Niagara FIRST thing is just a cover to keep the magic arts concealed from us muggles. - dtengineering [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 05-02-2014, 20:29
Mr.Roboto3335's Avatar
Mr.Roboto3335 Mr.Roboto3335 is offline
Wait, What?
AKA: Jimmy
FRC #3335 (Cy-Borgs)
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Texas
Posts: 47
Mr.Roboto3335 is an unknown quantity at this point
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() {

    }

}
__________________
Wait, what?
Reply With Quote
  #2   Spotlight this post!  
Unread 05-02-2014, 21:07
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,561
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Robots don't quit

Quote:
Originally Posted by Mr.Roboto3335 View Post
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.
Reply With Quote
  #3   Spotlight this post!  
Unread 05-02-2014, 21:25
Mr.Roboto3335's Avatar
Mr.Roboto3335 Mr.Roboto3335 is offline
Wait, What?
AKA: Jimmy
FRC #3335 (Cy-Borgs)
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Texas
Posts: 47
Mr.Roboto3335 is an unknown quantity at this point
Re: Robots don't quit

Thank you! moving the initiatives worked.
__________________
Wait, what?
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 09:30.

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