-
Notifications
You must be signed in to change notification settings - Fork 0
Motor Template Classes #9
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
base: main
Are you sure you want to change the base?
Conversation
|
@Purgso I've started to lay the base parts of this and implemented I had a few additional thoughts:
|
|
Yes, how you've organized it is exactly how I pictured. If you find yourself duplicating code a lot then I definitely think a base class is a good idea. Actually couldn't I don't see a reason to combine the motor configs. I prefer to keep drivetrain code entirely separate from the rest of the robot because they're developed completely differently. Drivetrain is reused with small changes each year while the rest of the robot is completely rewritten based on robot design with only the base building blocks reused. I'd rather keep them fully separate than risk a change to one breaking the other further down the road. Swerve configs contain exactly what we need for the swerve module and motor config should contain exactly what we need for one motor. About your todo for inverting the motors, Here's how I did it for the swerve motors: InvertedValue is an enum where the two directions have values 0 and 1. This means you can construct an inverted value directly from a boolean: I'm going through CTRE's example swerve drivetrain looking for ways we can improve our code. I'll let you know if I find anything. |
|
Alright thank you. I agree that making a base class to a degree is a good idea, I think I may just wait to see how much of it is duplicated once I'm done with all four and separate them into a base class from there. As for the motor configs I will separate that back out, I realize now that using the same one might be a bad idea for future proofing. And I'll make that change to the motor inversion as well. |
|
@Purgso, I think I've gotten
|
|
Agent Smith uses an
Motors should inherit from |
|
Okay thank you. I did my best to implement this, but I think I'm a little confused by how we need to set the PID and exactly when we need open loop vs closed loop control. It doesn't help that REV to CTRE is a good bit different and CTRE's examples are very minimal. If possible could we walk through it on Thursday just to make sure I'm understanding everything? I'll keep working on the position control bases as well, I think I just need a refresher on how the logic for the different control modes worked on Agent Smith. |
|
@Purgso I think I've gotten the base parts of
|
|
I'm still reviewing but here's what I've found so far:
|
|
Also the print_diagnostics function should just print diagnostics. Let the parent subsystem decide when it should be run. |
|
Okay thank you. I made most of those changes. I renamed Do you have an example of the correct stall percentage calculation? I'm not quite sure how that math worked, and what I did was just a copy of what we did last year. |
|
@Purgso I've adjusted the motor classes around to make them inherit from If you have time, could you check over to make sure I did the unit conversion math right in the |
Create motor template classes for power, velocity, linear position, and angular position. These classes can now later be used to greatly simplify our subsystems, and serve as a good foundation for implementing motion magic and other things later.
PowerMotorVelocityMotorLinearPositionMotorAngularPositionMotorPowerMotorto prevent duplicated code