After updating to 2025 robotpy, when I simulate my code, which is basically 1 fairly minimal subsystem, I get the following error:
22:35:07:729 ERROR : robotpy : The robot program quit unexpectedly. This is usually due to a
code error.
The above stacktrace can help determine where the error occurred.
Traceback (most recent call last):
File "/home/leo/programming/FRC2429_2025/other_robots/crank_rewritten/.venv/lib/python3.11/site-packages/
pyfrc/physics/core.py", line 195, in _simulationPeriodic
self.engine.update_sim(now, tm_diff)
File "/home/leo/programming/FRC2429_2025/other_robots/crank_rewritten/robot/physics.py", line 54, in upda
te_sim
self.robot.container.lower_crank.sparkmax_sim.iterate(math.radians(self.arm_sim.getVelocityDps()), volt
age, tm_diff)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x97 in position 29: invalid start byte
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/leo/programming/FRC2429_2025/other_robots/crank_rewritten/.venv/lib/python3.11/site-packages/
wpilib/_impl/start.py", line 160, in start
return self._start(robot_cls)
^^^^^^^^^^^^^^^^^^^^^^
File "/home/leo/programming/FRC2429_2025/other_robots/crank_rewritten/.venv/lib/python3.11/site-packages/
wpilib/_impl/start.py", line 247, in _start
self.robot.startCompetition()
File "/home/leo/programming/FRC2429_2025/other_robots/crank_rewritten/.venv/lib/python3.11/site-packages/
pyfrc/physics/core.py", line 197, in _simulationPeriodic
raise Exception(
Exception: User physics code raised an exception (see above)
The subsystem creates a SparkMax object, creates a configuration, then uses SparkMax.configure to apply it. If it’s simulated, the subsystem will create an attribute of itself containing a SparkMaxSim.
Every answer I found when I looked up the error related to reading files, which is not happening here as far as I can tell.
For convenience, here’s my update_sim method, which is causing the problem.
def update_sim(self, now, tm_diff):
wpilib.simulation.RoboRioSim.setVInVoltage(
wpilib.simulation.BatterySim.calculate([self.arm_sim.getCurrentDraw()])
)
voltage = wpilib.simulation.RoboRioSim.getVInVoltage()
self.arm_sim.setInputVoltage(voltage * self.robot.container.lower_crank.sparkmax_sim.getAppliedOutput())
self.arm_sim.update(tm_diff)
self.robot.container.lower_crank.sparkmax_sim.iterate(math.radians(self.arm_sim.getVelocityDps()), voltage, tm_diff)
# self.robot.container.lower_crank.set_encoder_position(self.arm_sim.getAngle())
self.crank_mech2d.setAngle(math.degrees(self.arm_sim.getAngle()))
# l_encoder = self.drivetrain.wheelSpeeds.left * tm_diff