My initial issue of my robot not moving during auton in simGUI has led me to discover that no forms of autonomous work at all. I tried pathweaver, pathplanner, switching between the 2022/2023 frameworks but nothing. Yet when I run these same paths using the code for last years robot (Falcons) everything works fine.
The best lead I got on my issue is that " CANSparkMax.get() not returning values that were set by methods other than set(double)" which @Starlight220 kindly pointed out for me. This is apparently a known bug so I know its not anything groundbreaking but as far as I’ve searched I dont see any solutions. If anybody knows anything about this please share.
First of all I just want to say thank you since when I changed (leftMotor.get()) to (leftMotor.getAppliedOutput()) the path finally ran. Just a few weird things that I noticed after making this change. For starters at the end of the path the robot just started erratically spinning in circles forever, even when disabling or changing to teleop. I tried to counteract this by adding this: return autonChooser.getSelected().andThen(() → driveTrain.tankDriveVolts(0, 0));
Now after that everything works all well until I try to move in teleop (nothing happens) or I try to enable autonomous again (The simGUI crashes), with this error code:
Error at frc.robot.RobotContainer.getAutonomousCommand(RobotContainer.java:84): Unhandled exception: java.lang.IllegalArgumentException: Commands cannot be added to more than one CommandGroup
at edu.wpi.first.wpilibj2.command.CommandGroupBase.requireUngrouped(CommandGroupBase.java:68)
at edu.wpi.first.wpilibj2.command.CommandGroupBase.requireUngrouped(CommandGroupBase.java:57)
at edu.wpi.first.wpilibj2.command.SequentialCommandGroup.addCommands(SequentialCommandGroup.java:34)
at edu.wpi.first.wpilibj2.command.SequentialCommandGroup.(SequentialCommandGroup.java:29)
at edu.wpi.first.wpilibj2.command.Command.andThen(Command.java:187)
at edu.wpi.first.wpilibj2.command.Command.andThen(Command.java:170)
at frc.robot.RobotContainer.getAutonomousCommand(RobotContainer.java:84)
at frc.robot.Robot.autonomousInit(Robot.java:59)
at edu.wpi.first.wpilibj.IterativeRobotBase.loopFunc(IterativeRobotBase.java:294)
at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:130)
at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:343)
at edu.wpi.first.wpilibj.RobotBase.lambda$startRobot$0(RobotBase.java:413)
at java.base/java.lang.Thread.run(Thread.java:833)
But regardless you still helped me alot so thank you
This is because the SendableChooser returns the same instance, which is then composed using andThen. Command instances can’t be composed more than once
Compose before adding the command to the chooser, have the chooser create a new instance every time (by having it select a Supplier<Command> rather than a Command), or compose with a proxy (ie .asProxy() – note this will affect requirements).