wpilibsuite / allwpilib

Official Repository of WPILibJ and WPILibC
https://wpilib.org/
Other
1.07k stars 614 forks source link

Array Index Out of Bounds when using trajectory generator #2060

Closed AustinShalit closed 4 years ago

AustinShalit commented 4 years ago
    Trajectory exampleTrajectory = TrajectoryGenerator.generateTrajectory(
        // Start at the origin facing the +X direction
        new Pose2d(0, 0, new Rotation2d(0)),
        List.of(
            new Translation2d(0.5, 0.5),
            new Translation2d(1.0, 0.0),
            new Translation2d(1.5, 0.5),
            new Translation2d(2.0, 0.0),
            new Translation2d(2.5, 0.5)
        ),
        // End 3.5 meters straight ahead of where we started, facing forward
        new Pose2d(3.5, 0, new Rotation2d(0)),
        // Pass config
        config
    );
Unhandled exception: java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5
Error at frc.robot.RobotContainer.getSplineCommand(RobotContainer.java:138): Unhandled exception: java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5
Robots should not quit, but yours did!
at edu.wpi.first.wpilibj.spline.SplineHelper.getCubicSplinesFromControlVectors(SplineHelper.java:136)
The startCompetition() method (or methods called by it) should have handled the exception above.
at edu.wpi.first.wpilibj.trajectory.TrajectoryGenerator.generateTrajectory(TrajectoryGenerator.java:62)
at edu.wpi.first.wpilibj.trajectory.TrajectoryGenerator.generateTrajectory(TrajectoryGenerator.java:101)
at frc.robot.RobotContainer.getSplineCommand(RobotContainer.java:138)
at frc.robot.RobotContainer.getAutonomousCommand(RobotContainer.java:114)
at frc.robot.Robot.autonomousInit(Robot.java:71)
at edu.wpi.first.wpilibj.IterativeRobotBase.loopFunc(IterativeRobotBase.java:220)
at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:81)
at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:258)
at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:303)
at frc.robot.Main.main(Main.java:27)
Warning at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:269): Robots should not quit, but yours did!
Error at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:271): The startCompetition() method (or methods called by it) should have handled the exception above.
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(3.4.7) /__w/1/s/opencv/modules/core/src/system.cpp:1654: error: (-215:Assertion failed) key_ != -1 && "Can't fetch data from terminated TLS container." in function 'getData'
PeterJohnson commented 4 years ago

Fixed by #2061.