ElevatorSim output is not initially valid (until update
has been called)
#7761
Labels
component: wpilibc
WPILib C++
component: wpilibj
WPILib Java
good first issue
Good for newcomers.
os: simulation
type: bug
Something isn't working.
Describe the bug
Immediately after creating an ElevatorSim with non-zero starting position, a call to
getPositionInMeters
returns 0. I have not investigated whether other mechanism Sim classes are also affected. The problem may be even more general in that ElevatorSim usesLinearSystemSim.setState
to put the starting position into the state, butsetState
does not update the Y matrix (outputs) to correspond. It is unclear to me whether it would be desirable (or even possible) for it to do so.To Reproduce
Observe
initialPos
is 0.0 when it should be -0.05.Expected behavior
Calling
getPositionInMeters
returns the correct position at all times after construction. If that is not possible then the behavior should be documented (though that is much less desirable in my opinion).WPILib Information:
Project Version: 2025.2.1
VS Code Version: 1.94.2
WPILib Extension Version: 2025.2.1
C++ Extension Version: 1.23.2
Java Extension Version: 1.38.0
Java Debug Extension Version: 0.58.2024090204
Java Dependencies Extension Version 0.24.1
Java Version: 17
Java Location: /home/hauser/wpilib/2025/jdk
Vendor Libraries:
PathplannerLib (2025.2.1)
CTRE-Phoenix (v5) (5.35.1)
CTRE-Phoenix (v6) (25.2.1)
REVLib (2025.0.2)
ReduxLib (2025.0.1)
Studica (2025.0.1)
ThriftyLib (2025.0.1)
WPILib-New-Commands (1.0.0)
maplesim (0.3.1)
photonlib (v2025.1.1)
Additional context
Workaround: call
update
on the ElevatorSim object immediately after construction.The text was updated successfully, but these errors were encountered: