Arm simulation only moving to fraction of setpoint

I’m having an issue with simulating an arm mechanism on my team’s robot code. I’m using Phoenix 6 with a trapezoid motion profile to provide PID control and a SingleJointedArmSim to simulate movement. Whenever I set the setpoint of the arm to, say, 100 degrees, it only moves to a fraction of that setpoint.

The ratio does not remain consistent however. Here’s some data I gathered on it:

Setpoint Actual Ratio
100 27 3.703
150 41 3.658
200 48 4.166
400 105 3.809
600 150 4.000
1000 180 5.555

Because of this I’ve set a temporary 4x multiplier on each of the setpoints when grabbing them from the arm constants, but once you remove it the problem reappears.

My code is linked here:
https://github.com/4201VitruvianBots/Crescendo2024/blob/main/src/main/java/frc/robot/subsystems/Arm.java

I’m not sure whether the problem is due to my simulation code or the primary code since we don’t have the arm mechanism fully wired yet.

Steps to reproduce the problem:

  1. Simulate the repository
  2. Connect to controller port 2
  3. Press and hold “V” on the keyboard (this will activate the arm setpoint)
  4. Compare the setpoint and actual position under network tables in AdvantageKit/RealOutputs/Arm

This got fixed up by our mentor @jdao (thank you for your help!)

You can view the commit here:
https://github.com/4201VitruvianBots/Crescendo2024/commit/422bbdd775d0570f814e3745110edc7a9778016b

I’ll try to provide an explanation of the solution here at somepoint as I don’t wanna be this guy, but it might take a little bit.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.