Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Code Not Uploading to Bot (http://www.chiefdelphi.com/forums/showthread.php?t=138365)

xcountry413 01-10-2015 13:57

Code Not Uploading to Bot
 
I'm a new programmer for my team and am having trouble uploading code to the bot. The output of the program is:
Code:

run:
java.lang.ExceptionInInitializerError
Caused by: edu.wpi.first.wpilibj.util.BaseSystemNotInitializedException: The Interface for the HLUsageReporting was never set.
        at edu.wpi.first.wpilibj.HLUsageReporting.reportScheduler(HLUsageReporting.java:21)
        at edu.wpi.first.wpilibj.command.Scheduler.<init>(Scheduler.java:92)
        at edu.wpi.first.wpilibj.command.Scheduler.getInstance(Scheduler.java:48)
        at edu.wpi.first.wpilibj.command.Subsystem.<init>(Subsystem.java:60)
        at org.usfirst.frc.team2022.robot.subsystems.TankDriveSubsystem.<init>(TankDriveSubsystem.java:21)
        at org.usfirst.frc.team2022.robot.Robot.<clinit>(Robot.java:25)
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

I'm not sure what the HLUsageReporting is and what the exception is saying.

Here's the code for the main class:
Code:

package org.usfirst.frc.team2022.robot;

import org.usfirst.frc.team2022.robot.commands.CompressorCommand;
import org.usfirst.frc.team2022.robot.commands.ForkliftCommand;
import org.usfirst.frc.team2022.robot.commands.IntakeCommand;
import org.usfirst.frc.team2022.robot.commands.TankDriveCommand;
//import org.usfirst.frc.team2022.robot.commands.autonomous.Autonomous;
import org.usfirst.frc.team2022.robot.subsystems.ForkliftSubsystem;
import org.usfirst.frc.team2022.robot.subsystems.GyroSubsystem;
import org.usfirst.frc.team2022.robot.subsystems.IntakeSubsystem;
import org.usfirst.frc.team2022.robot.subsystems.TankDriveSubsystem;

import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.command.Scheduler;

/**
 * The VM is configured to automatically run this class, and to call the
 * functions corresponding to each mode, as described in the IterativeRobot
 * 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 Robot extends IterativeRobot {

        public static final TankDriveSubsystem tankSubsystem = new TankDriveSubsystem();
        public static final ForkliftSubsystem forkliftSubsystem = new ForkliftSubsystem();
        public static final GyroSubsystem gyroSubsystem = new GyroSubsystem();
        public static OI oi;
        public static final IntakeSubsystem intakeSubsystem = new IntakeSubsystem();

//        CommandGroup autonomousCommand;
        TankDriveCommand tankCommand;
        ForkliftCommand forkliftCommand;
        IntakeCommand intakeCommand;
        CompressorCommand compressorCommand;

        /**
        * This function is run when the robot is first started up and should be
        * used for any initialization code.
        */
        @Override
        public void robotInit() {
                oi = new OI();
                // instantiate the command used for the autonomous period
//                autonomousCommand = new Autonomous();
                // instantiate the real commands
                tankCommand = new TankDriveCommand();
                forkliftCommand = new ForkliftCommand();
                intakeCommand = new IntakeCommand();
                compressorCommand = new CompressorCommand();
        }

        @Override
        public void disabledPeriodic() {
                Scheduler.getInstance().run();
        }

        @Override
        public void autonomousInit() {
                // schedule the autonomous command
//                if (autonomousCommand != null)
//                        autonomousCommand.start();
        }

        /**
        * This function is called periodically during autonomous
        */
        @Override
        public void autonomousPeriodic() {
                Scheduler.getInstance().run();
        }

        @Override
        public void teleopInit() {
//                if (autonomousCommand != null)
//                        autonomousCommand.cancel();
                tankCommand.start();
                forkliftCommand.start();
                intakeCommand.start();
                compressorCommand.start();
        }

        /**
        * This function is called when the disabled button is hit. You can use it
        * to reset subsystems before shutting down.
        */
        @Override
        public void disabledInit() {
                //
        }

        /**
        * This function is called periodically during operator control
        */
        @Override
        public void teleopPeriodic() {
                Scheduler.getInstance().run();
        }

        /**
        * This function is called periodically during test mode
        */
        @Override
        public void testPeriodic() {
        }
}

The error in the subsystem is at the constructor of the class. Any help is appreciated

GeeTwo 01-10-2015 14:44

Re: Code Not Uploading to Bot
 
What's in TankDriveSubsystem.java, particularly line 21?

Is it (wild stab in the dark) trying to schedule its autonomous actions?

xcountry413 01-10-2015 17:30

Re: Code Not Uploading to Bot
 
It's actually the constructor of the class. Here's the code:
Code:

package org.usfirst.frc.team2022.robot.subsystems;


import org.usfirst.frc.team2022.robot.RobotMap;
import org.usfirst.frc.team2022.robot.commands.TankDriveCommand;

import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.Talon;
import edu.wpi.first.wpilibj.command.Subsystem;

/**
 *
 */
public class TankDriveSubsystem extends Subsystem {
        private final Talon frontLeft, frontRight, rearLeft, rearRight;
        private double leftSpeed, rightSpeed;
        private boolean inverted;
        private long lastTime;
        private Encoder encoder;

        public TankDriveSubsystem(){
                // SmartDashboard.putString("TankDrive", "SUBSYSTEM_INIT"); //Will
                // crash. TODO: fix?
            frontLeft = new Talon(RobotMap.leftMotorFront);
            frontRight = new Talon(RobotMap.rightMotorFront);
            rearLeft = new Talon(RobotMap.leftMotorBack);
            rearRight = new Talon(RobotMap.rightMotorBack);

            inverted = false;
            lastTime = System.currentTimeMillis();
               
//                encoder = new Encoder(RobotMap.encoder1, RobotMap.encoder2, false);
//                encoder.setDistancePerPulse(4.7);
//                encoder.setDistancePerPulse((6 * Math.PI) / 360); //No idea if this is right, diameter * pi / pulses per revolution. Change to correct measurements
//               
//                encoder.reset();
               
        }
       
        public double getEncoderDistance(){
                return encoder.getDistance();
        }
       
        public void resetEncoder(){
                encoder.reset();
        }

        @Override       
        // this is important for WPILib.
        public void initDefaultCommand() {
                setDefaultCommand(new TankDriveCommand());

        }

        // Speed Manipulation Methods-these are more fine grained
        public double getLeftSpeed() {
                return leftSpeed;
        }

        public double getRightSpeed() {
                return rightSpeed;
        }

        public void setLeftSpeed(double ls) {
                leftSpeed = ls;
                frontLeft.set(ls);
                rearLeft.set(ls);
        }

        public void setRightSpeed(double rs) {
                rightSpeed = rs;
                frontRight.set(rs);
                rearRight.set(rs);
        }

        // Inversion
        public boolean isInverted() {
                return inverted;
        }

        public void toggleInversion() {
                if (System.currentTimeMillis() > lastTime + 250) {
                        lastTime = System.currentTimeMillis();
                        inverted = !inverted;
                        leftSpeed *= -1;
                        rightSpeed *= -1;
                }
        }

        // Forwards and Reverse Control for each side.
        public void stop() {
                frontRight.set(0);
                frontLeft.set(0);
                rearRight.set(0);
                rearLeft.set(0);
                rightSpeed = 0;
                leftSpeed = 0;
        }
}


GeeTwo 01-10-2015 18:00

Re: Code Not Uploading to Bot
 
Looking at our code for last year, we declared our subsystems as public static (though not final), then initialized them (set them = new Subsystem()) in robotInit() rather than the declaration line. Your usage appears to me to be correct, but I see that we didn't do it that way; there may be a good reason. Perhaps static initializers don't work correctly on subsystems?

JesseK 02-10-2015 09:41

Re: Code Not Uploading to Bot
 
This particular error is happening at the instantiation of the parent of TankDriveSubsystem.

Since the declaration for TankDriveSubsystem is the very first static declaration of your main class, I suspect it has little to do with your code and more to do with your environment. I don't know FRC code specifically, but I'd start by figuring out what extends HLUsageReporting and figure out what's missing from your runtime classpath from there.

From the robot, verify that the jars on the classpath actually exist. From Eclipse verify that everything on that classpath is correct (nothing's missing). I don't know the WPILib toolchain, but you may also have the wrong parameters in your build.


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

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