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

added better slew rate for drivetrain #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

moreheadm
Copy link
Member

No description provided.

@@ -96,7 +100,7 @@ public Drivetrain(Settings settings) {
rightLeader.setSmartCurrentLimit(60);
leftLeader.setSmartCurrentLimit(60);
rightLeader.setSmartCurrentLimit(60);
applytoAllMotors((motor) -> {motor.setOpenLoopRampRate(0.2);});
// applytoAllMotors((motor) -> {motor.setOpenLoopRampRate(0.2);});
Copy link
Member Author

@moreheadm moreheadm Mar 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized you should do


applytoAllMotors((motor) -> {motor.setOpenLoopRampRate(0);});

because the previous setting of 0.2 is saved in flash on the SparkMax.

// There is a different system used than previous years because MotorControlGroup is deprecated :(.
// We set a motor to a leader, and make followers follow the leader in the constructor.
// Front wheels are leaders for no reason because its redundant
BetterSlewRateLimiter slewRateLimiter = new BetterSlewRateLimiter(60, 0, 0);
Copy link
Member Author

@moreheadm moreheadm Mar 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized two things. One, we calculate 60 in terms of volts, but when we actually use this function it's in terms of percent output. So, it should be 5, not 60 (1 / 0.2 = 5).

Second, the deceleration limit is currently 0 which means it will never decelerate. You should set it to something high, like 100.

If you want to be better, move these numbers to constants.

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.

2 participants