The startCompetition() method (or methods called by it) should have handled the exception above error

  • Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:412): Loop time of 0.02s overrun

  • Unhandled exception: java.lang.IllegalStateException: A CANSparkMax instance has already been created with this device ID: 2

  • The robot program quit unexpectedly. This is usually due to a code error.
    The above stacktrace can help determine where the error occurred.
    See Reading Stacktraces — FIRST Robotics Competition documentation for more information.

  • Error at com.revrobotics.CANSparkLowLevel.(CANSparkLowLevel.java:157): Unhandled exception: java.lang.IllegalStateException: A CANSparkMax instance has already been created with this device ID: 2

  • at com.revrobotics.CANSparkLowLevel.(CANSparkLowLevel.java:157)

  • at com.revrobotics.CANSparkBase.(CANSparkBase.java:194)

  • The startCompetition() method (or methods called by it) should have handled the exception above.

  • at com.revrobotics.CANSparkMax.(CANSparkMax.java:47)

  • at frc.robot.subsystems.SwerveModule.(SwerveModule.java:45)

  • at frc.robot.subsystems.SwerveSubsystem.(SwerveSubsystem.java:15)

  • at frc.robot.commands.autoTop.(autoTop.java:30)

  • at frc.robot.RobotContainer.getAutonomousCommand(RobotContainer.java:127)

  • at frc.robot.Robot.autonomousInit(Robot.java:80)

  • at edu.wpi.first.wpilibj.IterativeRobotBase.loopFunc(IterativeRobotBase.java:345)

  • at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:131)

  • at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:365)

  • at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:453)

  • at frc.robot.Main.main(Main.java:27)

  • Warning at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:379): The robot program quit unexpectedly. This is usually due to a code error.

  • The above stacktrace can help determine where the error occurred.

  • See Reading Stacktraces — FIRST Robotics Competition documentation for more information.

  • Error at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:386): The startCompetition() method (or methods called by it) should have handled the exception above.

  • ********** Robot program starting **********

  • NT: Listening on NT3 port 1735, NT4 port 5810

  • CANSparkMax object created for CAN ID 10, which is not a SPARK MAX. Some functionalities may not work.

  • Warning at com.revrobotics.CANSparkMax.(CANSparkMax.java:50): CANSparkMax object created for CAN ID 10, which is not a SPARK MAX. Some functionalities may not work.

  • at com.revrobotics.CANSparkMax.(CANSparkMax.java:50)

  • at frc.robot.subsystems.ArmSubsystem.(ArmSubsystem.java:14)

  • at frc.robot.RobotContainer.(RobotContainer.java:35)

  • at frc.robot.Robot.robotInit(Robot.java:36)

  • at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:107)

  • at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:365)

  • at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:453)

  • at frc.robot.Main.main(Main.java:27)

the parts that talk about duplicate sparkmax, I looked but couldn’t find anything, can anyone help?

Do you have a Github repo for your code? Without seeing the code it is hard to diagnose, but looks like you have multiple devices with the same ID.

Likely you’re creating more than one ArmSubsystem

1 Like

This looks like your autoTop command is creating an instance of SwerveSubsystem, which is presumably already created elsewhere (i.e. RobotContainer).

1 Like