Class SimMotor
-
Method Summary
Modifier and TypeMethodDescriptionstatic TalonFXSimStateReturns the motor's sim state, flippingOrientationwhen the sim's travel runs opposite the motor's positive direction.
-
Method Details
-
simState
Returns the motor's sim state, flippingOrientationwhen the sim's travel runs opposite the motor's positive direction.The physics sims here are driven by
getMotorVoltage()and feed position back throughsetRawRotorPosition();Orientationnegates both as a matched pair, so flipping it mirrors the whole loop and leaves it self-consistent.Deliberately not derived from the motor's invert. CTRE documents
Orientationas describing mechanical linkage, not the invert, and the invert alone does not determine the sign. What matters is the direction each sim's geometry produces:ElevatorSimtravels[minHeight, max]with min normally 0, so its rotor term is always positive.ArmSimfeeds backangle - startingAngle, which is negative whenever the arm starts at its maximum.
So an inverted motor is fine on a sim whose geometry already runs negative, and broken on one that runs positive: the model clamps at its limit, feeds the same position back, and the mechanism never moves. Only the mechanism author knows which case applies, hence the explicit per-sim flag.
- Parameters:
motor- the motor driving the simulated mechanismreversedLinkage-truewhen the sim's travel opposes the motor's positive direction- Returns:
- the motor's (cached) sim state, with orientation set
-