wpilibsuite / allwpilib

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

Improvements to DCMotorSim and SingleJointedArmSim #6656

Open narmstro2020 opened 1 month ago

narmstro2020 commented 1 month ago

This PR does the following

  1. Renames DCMotorSim to AngularMechanismSim. I'm not opposed to other options. This serves as a base class for mechanisms with both angular position and velocity states.
  2. AngularMechanismSim provides all of the same overloads that were added to FlywheelSim in this PR along with their positional counterparts.
  3. SingleJointedArmSim inherits from AngularMechanismSim to save on method duplication.
  4. Both classes have only one constructor.
  5. SingleJointedArmSim now works for alternative pivot positions not just the end of the arm.
  6. SingleJointedArmSim now provides methods for setting position and velocity independently, getting the arm length, getting the pivot point, getting the arm's mass.
  7. LinearSystemID has been modified to provide methods for creating the plants needed for both of these classes along with some duplication removal.

Items to check/get feedback on.

  1. Should I remove estimateMOI from SingleJointedArmSim or modify it?
  2. The arm tests are failing with actual values somewhat close to their expected value, but not close enough. I'm not sure how to fix.
  3. EDIT: The arm tests are working. I noticed that the comments in the ArmSimulation example didn't have the correct values as listed in the Constants file. I corrected the comments.
narmstro2020 commented 1 month ago

/format

narmstro2020 commented 1 month ago

/format

narmstro2020 commented 2 weeks ago

Any thoughts or feedback on this PR?