wpilibsuite / allwpilib

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

PDP CAN Monitoring example crashes in simulation #3696

Closed sciencewhiz closed 3 years ago

sciencewhiz commented 3 years ago

Describe the bug The PDP CAN Monitoring example crashes when run in simulation in both Java and C++. The error indicates that invalid pdp module number was used, -1.

Java:

Error at frc.robot.Robot.<init>(Robot.java:16): Unhandled exception instantiating robot edu.wpi.first.hal.PowerDistributionJNI edu.wpi.first.hal.util.UncleanStatusException:  Code: -1028. Invalid pdp module -1
        at edu.wpi.first.hal.PowerDistributionJNI.initialize(Native Method)  
        at edu.wpi.first.wpilibj.PowerDistribution.<init>(PowerDistribution.java:43)
        at edu.wpi.first.wpilibj.PowerDistribution.<init>(PowerDistribution.java:56)
        at frc.robot.Robot.<init>(Robot.java:16)
        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.hal.PowerDistributionJNI!

C++:

Error at frc::PowerDistribution::PowerDistribution [PowerDistribution.cpp:42]: Invalid pdp module -1: Module -1
Error at frc::impl::RunRobot: Error: 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.

To Reproduce Steps to reproduce the behavior:

  1. create new PDP CAN Monitoring example project
  2. run in desktop simulation

Expected behavior It should not crash

Desktop (please complete the following information):

Additional context The example does not crash when deployed to the roboRIO.

sciencewhiz commented 3 years ago

The athena HAL has logic to detect -1 and change to either 0 or 1 for CTRE or Rev. Something similar would need to be done in the simulation HAL.