rambunction4330 / librmb

A library designed to ease the pain of FRC robot programming. TLDR; Make motor spin good better
https://rambunction4330.github.io/librmb/
MIT License
1 stars 1 forks source link

Extract SparkMax constructor arguments to CreateInfo struct #30

Closed theVerySharpFlat closed 1 year ago

theVerySharpFlat commented 1 year ago

I think that this makes creating motorControllers less messy. One can create a motorcontroller by doing something like this instead:

SparkMaxVelocityController::CreateInfo createInfo{};
createInfo.motorConfig.id = 1;
createInfo.pidConfig.p = 1.0;
createInfo.pidCOnfig = {
    .d = 0.02;
    .ff = 0.01;
};

SparkMaxVelocityController velocityController(createInfo);

rather than having a really long constructor call.

I think that this will help with ownership of motorcontrollers in the swerve module class where you pass in the motorcontroller create info (we could have multiple constructors, each for a different vendor, and thus a different createInfo type) and the SwerveModule class creates and owns the motorcontroller itself and only exposes needed functionality.

What do you think?

gcjurgiel commented 1 year ago

Something like this is much better! I didn’t realize struct declarations could work like that. As for your other point, I think we should go back to unique pointers clarifying the ownership model. Additionally, we may consider collapsing feedback classes like encoders and odometery into the control classes since we pretty much never have on without the other.