-
Unhandled exception: java.lang.NullPointerException
-
Error at org.usfirst.frc3719.driveTrain2020.subsystems.ColorWheel.(ColorWheel.java:50): Unhandled exception: java.lang.NullPointerException
-
at org.usfirst.frc3719.driveTrain2020.subsystems.ColorWheel.(ColorWheel.java:50)
-
at org.usfirst.frc3719.driveTrain2020.Robot.robotInit(Robot.java:62)
-
at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:64)
-
at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:276)
-
at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:348)
-
at org.usfirst.frc3719.driveTrain2020.Main.main(Main.java:31)
-
Robots should not quit, but yours did!
-
at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:64)
-
at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:276)
-
The startCompetition() method (or methods called by it) should have handled the exception above.
-
at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:348)
-
at org.usfirst.frc3719.driveTrain2020.Main.main(Main.java:31)
-
Warning at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:291): Robots should not quit, but yours did!
-
Error at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:293): The startCompetition() method (or methods called by it) should have handled the exception above.
robot code is here
my code in robot.java is
//
// This file was generated by RobotBuilder. It contains sections of
// code that are automatically generated and assigned by robotbuilder.
// These sections will be updated in the future when you export to
// Java from RobotBuilder. Do not put any code or make any change in
// the blocks indicating autogenerated code or it will be lost on an
// update. Deleting the comments indicating the section will prevent
// it from being updated in the future.
package org.usfirst.frc3719.driveTrain2020;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.command.Command;
import edu.wpi.first.wpilibj.command.Scheduler;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import org.usfirst.frc3719.driveTrain2020.commands.*;
import org.usfirst.frc3719.driveTrain2020.subsystems.*;
import org.usfirst.frc3719.driveTrain2020.subsystems.ColorWheel;
import edu.wpi.first.wpilibj.GenericHID.Hand;
import edu.wpi.first.wpilibj.I2C;
import edu.wpi.first.wpilibj.util.Color;
import com.revrobotics.ColorSensorV3;
import com.revrobotics.ColorMatch;
import com.revrobotics.ColorMatchResult;
import edu.wpi.first.wpilibj.DriverStation;
/**
* The VM is configured to automatically run this class, and to call the
* functions corresponding to each mode, as described in the TimedRobot
* documentation. If you change the name of this class or the package after
* creating this project, you must also update the build.properties file in
* the project.
*/
public class Robot extends TimedRobot {
Command autonomousCommand;
SendableChooser<Command> chooser = new SendableChooser<>();
public static OI oi;
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
public static DrivetrainSub drivetrainSub;
public static FieldMinipulator fieldMinipulator;
public static ColorWheel colorWheel;
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=DECLARATIONS
private final I2C.Port i2cPort = I2C.Port.kOnboard;
private final ColorSensorV3 colorSensor = new ColorSensorV3(i2cPort);
private final ColorMatch colorMatcher = new ColorMatch();
public static final Color kBlueTarget = ColorMatch.makeColor(0.143, 0.427, 0.429);
public static final Color kGreenTarget = ColorMatch.makeColor(0.197, 0.561, 0.240);
public static final Color kRedTarget = ColorMatch.makeColor(0.561, 0.232, 0.114);
public static final Color kYellowTarget = ColorMatch.makeColor(0.361, 0.524, 0.113);
public static Color colorCase;
public static char fieldColor;
/**
* This function is run when the robot is first started up and should be
* used for any initialization code.
*/
@Override
public void robotInit() {
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
drivetrainSub = new DrivetrainSub();
fieldMinipulator = new FieldMinipulator();
colorWheel = new ColorWheel();
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=CONSTRUCTORS
// OI must be constructed after subsystems. If the OI creates Commands
//(which it very likely will), subsystems are not guaranteed to be
// constructed yet. Thus, their requires() statements may grab null
// pointers. Bad news. Don't move it.
oi = new OI();
// Add commands to Autonomous Sendable Chooser
// BEGIN AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS
chooser.setDefaultOption("Autonomous Command", new AutonomousCommand());
// END AUTOGENERATED CODE, SOURCE=ROBOTBUILDER ID=AUTONOMOUS
SmartDashboard.putData("Auto mode", chooser);
}
/**
* This function is called when the disabled button is hit.
* You can use it to reset subsystems before shutting down.
*/
@Override
public void disabledInit(){
}
@Override
public void disabledPeriodic() {
Scheduler.getInstance().run();
}
@Override
public void autonomousInit() {
autonomousCommand = chooser.getSelected();
// schedule the autonomous command (example)
if (autonomousCommand != null) autonomousCommand.start();
}
/**
* This function is called periodically during autonomous
*/
@Override
public void autonomousPeriodic() {
Scheduler.getInstance().run();
}
@Override
public void teleopInit() {
// This makes sure that the autonomous stops running when
// teleop starts running. If you want the autonomous to
// continue until interrupted by another command, remove
// this line or comment it out.
if (autonomousCommand != null) autonomousCommand.cancel();
colorMatcher.addColorMatch(kBlueTarget);
colorMatcher.addColorMatch(kGreenTarget);
colorMatcher.addColorMatch(kRedTarget);
colorMatcher.addColorMatch(kYellowTarget);
}
/**
* This function is called periodically during operator control
*/
@Override
public void teleopPeriodic() {
Scheduler.getInstance().run();
// Robot.drivetrainSub.SetDrive(Robot.oi.xboxController.getY(Hand.kLeft), Robot.oi.xboxController.getX(Hand.kRight));
}
}```