Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wpilib] Adding torque input classes to PhysicsSim classes (Fly, DC, Elev, Arm, DriveTrain) #7157

Open
wants to merge 96 commits into
base: main
Choose a base branch
from

Conversation

narmstro2020
Copy link
Contributor

@narmstro2020 narmstro2020 commented Oct 3, 2024

Addresses Issue #7130

I have PR #7021 waiting for merging. So I'm starting with the FlywheelSim class. I'm also planning on a PR for ElevatorSim and SingleJointedArmSim in line with PR#7021 that I plan on implementing here instead unless these need to be separate.

I've also added units class overloads to each sim and LinearSystemId

Requested Guidance/Feedback

  1. Clamping function for Torque control:
    I marked it with a TODO comment in the affected classes.
  2. Naming: Current the base classes are named as such, voltage is unchanged, torque adds torque to the end.
    Examples: DCMotorSimBase for base class, DCMotorSim for voltage control, DCMotorSimTorque for torque control
  3. Deprecating the createDCMotorSystem with kv and ka. Now you can just use identifyPositionSystem
  4. Lots of methods in LinearSystemId. Wonder if each system should have an inputType enum for either VOLTAGE or TORQUE to reduce the method list.
  5. @calcmogul Working through the derivations was fun. Especially when I caught some mistakes. Our discussion thread about this was very support thank you. It took me a minute to realize that the gearing wasn't going to be necessary since I was already at the level of the mechanism for moment of inertia. I do wonder if these derivations should be added to the controls engineering book in the equations of motion section and the state space control section. They are more or less there in the equations of motion section though.
  6. Also Should I move the derivations to algorithms.md

EDIT and Update
Left to do

  1. DriveTrainSim. It will take me a minute to work out the equation of motion.
  2. Torque based tests
  3. C++

I would like to use PR #7168 here for DCMotors resistance unit.

At this point I’ve finished the basics for the non drivetrain classes. I still have some documentation cleanup to do. I’m sure questions, corrections, and changes will abound.

DCMotorType will be named DCMotor. It’s just a temporary name while I focus on one Sim at a time without breaking all of them.

Other than that I’m more than ready to move on to the drivetrain sim. I’d like to integrate the odometry class into this but it may not be necessary. Question on the sim. I know the pose information is part of the calculation, but should the getPose methods be removed as this would be a concern for the geometry class. I'm only thinking this way because someone wanting to use this class may want to model it closely to the real setup in their user code.

Also I’m assuming there is no way or no easy way to use or create a linear plant for mecanum or swerve.

Currently still working on Java. I’d like to get an affirmative go ahead after I finish the drivetrain and tests in Java before I create the C++

@narmstro2020 narmstro2020 marked this pull request as ready for review October 4, 2024 22:07
@narmstro2020 narmstro2020 requested review from a team as code owners October 4, 2024 22:07
@narmstro2020 narmstro2020 changed the title [wpilib] Adding torque input classes to PhysicsSim classes (Fly, DC, Elev, Arm) [wpilib] Adding torque input classes to PhysicsSim classes (Fly, DC, Elev, Arm, DriveTrain) Oct 4, 2024
@narmstro2020
Copy link
Contributor Author

/format

@narmstro2020
Copy link
Contributor Author

narmstro2020 commented Oct 11, 2024

So at this point I have the Java written for all of the sim classes new and old. I'm still doing some fine tuning of the DifferentialDriveTrainSim classes. I need some feedback before I can really continue on in any meaningful way. @PeterJohnson, @calcmogul, @ThadHouse, @sciencewhiz or all and/or others at the top level of wpilibj and wpimath any feedback would be appreciated and of course is welcome, but please don't feel like I'm rushing anyone. Status updates like this help my thought process and organization.

Things I know I need to do.

  1. clamp inputs for torque (need some help with this)
  2. new tests. (I can handle this based on what already exists, but feedback is welcome either way).
  3. C++. (I don't want to dive into this until I have all of the Java done (just so I don't have to fix two things).

Things that are ready for checking/feedback.
I wanted to cleanup the following classes/methods in both code and documentation first. I'm not saying it's perfect, but I did go through with a fine toothed comb. I'll continue working on cleanup of the other classes/methods in the meanwhile and add the ready for review ones to the list below.

-DCMotor
-Gearbox
-Wheel
-LinearSystemId.createFlywheelSystem methods
-LinearSystemid.identifyVelocitySystem methods
-LinearSystemId.identifyPositionSystem methods
-LinearSystemId.createDCMotorSystem methods
-FlywheelSimBase
-FlywheelSim
-FlywheeSimTorque
-DCMotorSimBase
-DCMotorSim
-DCMotorSimTorque

I'm going to thank anyone that provides feedback in advance. I know this PR is a biggie.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant