Error at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:342): Could not instantiate robot edu.wpi.first.wpilibj2.command.CommandScheduler!

Hey all,

I’m currently receiving yet another insantion error and I can’t seem to fix it. The code was functional until I added the intakeShooter File series.

This might also have something to do with the fact I’m trying to use a parallel command group to run both our teleop driving features and our teleop shooter features at the same time.

But the most likely cause is one of the new files I added is being declared far too early.

If anyone wishes to take a deeper look at the error run the ./gradlew simulateJava command in terminal.

Thanks for any help you all can provide.

Code:

Here is the full error message:

Error at frc.robot.RobotContainer.configureButtonBindings(RobotContainer.java:33): Unhandled exception instantiating robot edu.wpi.first.wpilibj2.command.CommandScheduler java.lang.IllegalArgumentException: Default commands should not end!
        at edu.wpi.first.wpilibj2.command.CommandScheduler.setDefaultCommand(CommandScheduler.java:364)
        at edu.wpi.first.wpilibj2.command.Subsystem.setDefaultCommand(Subsystem.java:50)
        at frc.robot.RobotContainer.configureButtonBindings(RobotContainer.java:33)
        at frc.robot.RobotContainer.<init>(RobotContainer.java:43)
        at frc.robot.Robot.<clinit>(Robot.java:39)
        at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:322)
        at edu.wpi.first.wpilibj.RobotBase.lambda$startRobot$0(RobotBase.java:443)
        at java.base/java.lang.Thread.run(Thread.java:829)

Error at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:336): The robot program quit unexpectedly. This is usually due to a code error.    
  The above stacktrace can help determine where the error occurred.
  See https://wpilib.org/stacktrace for more information.

Error at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:342): Could not instantiate robot edu.wpi.first.wpilibj2.command.CommandScheduler!

Have you read the top line of the error message?

I understand this is happening because I’m using a command group containing The intake shooter command and the driver command.

The intake and the shooter run of the same motor just inverted when the corresponding trigger is pressed as reflected by the if statement.

Ideally both the Mecanum Driver command and the Intake Shooter command would run simultaneously as the default command of the robot,

Do you have any better ideas for how to run this?

I dont think a command group will work because by default a command group must end.

Thanks

Don’t use your teleop sequence. Instead just have 2 different default commands. It doesn’t look like Mecanum drive and intakeshooter share any requirements.

You are limited to 1 default per subsystem not 1 per robot.

wait…

you can have two seperate default commands?

That sounds like it would definetly solve the issue.

I didn’t know this was even possible. Thanks

So i would just set both of these commands inside of Robot Container and they should both run whenever autonomous isn’t active?

Would they both run simultaneously or would there be some sort of favoritism depending on order?

Default command is something that runs continuously while a subsystem is not executing any other command. Each subsystem can have a default command. Like:

Robot.m_driveTrain.setDefaultCommand(new MecanumDriver());
Robot.m_intakeShooter.setDefaultCommand(new IntakeShooterDetection());

I implemented the change you suggested inside the Robot Container file (Github Updated)

but now I’m receiving the following error. Its depended on the order im instantiating my variables, but no order seems to work. Any ideas?

Error:

Error at frc.robot.RobotContainer.configureButtonBindings(RobotContainer.java:35): Unhandled exception instantiating robot edu.wpi.first.wpilibj2.command.CommandScheduler java.lang.IllegalArgumentException: Default commands must require their subsystem!
        at edu.wpi.first.wpilibj2.command.CommandScheduler.setDefaultCommand(CommandScheduler.java:360)
        at edu.wpi.first.wpilibj2.command.Subsystem.setDefaultCommand(Subsystem.java:50)
        at edu.wpi.first.wpilibj.RobotBase.lambda$startRobot$0(RobotBase.java:443)
        at java.base/java.lang.Thread.run(Thread.java:829)

Error at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:336): The robot program quit unexpectedly. This is usually due to a code error.    
  The above stacktrace can help determine where the error occurred.
  See https://wpilib.org/stacktrace for more information.

Error at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:342): Could not instantiate robot edu.wpi.first.wpilibj2.command.CommandScheduler!

I just cloned your most recent code where you have the requirements added and didn’t get an error.

did u run ./gradlew simulateJava in the terminal? (This simulated the deploy process without needing to be hooked up to your robot0

1 Like

I completly restarted and now its working properly

Thanks!

This was actually a huge help. I had no idea you could have two default commands which was incredibly helpful.

Sidenote while i’ve still got you here. Do you know what this warning might be referring to?

Warning:

Warning at edu.wpi.first.wpilibj.DriverStation.reportJoystickUnpluggedWarning(DriverStation.java:1489): Joystick axis 4 on port 0 not available, check if controller is plugged in

The keyboard only has axis 0 and 1. You are referencing axis 4. When I swap my xbox controller (or anything else that has axis 4) in place of the keyboard for joystick[0] the warning goes away.

Assuming you don’t have a xbox or similar available you can go to DS->Keyboard Setting->Add additional axis until you have 4 showing.

Okay Thanks,

We use an Xbox so that shouldn’t be an issue.

Thanks for the help.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.