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] Clean up drive class implementations #1691

Closed
wants to merge 1 commit into from

Conversation

calcmogul
Copy link
Member

These return the inverse kinematic values, so they can be composed with
feedback controllers. The internal implementation for DifferentialDrive
was massively simplified as well.

Input limits were removed since the normalization takes care of that.
The deadband functionality was moved to GenericHID::GetRawAxis class
since the deadband is generally applied to joystick axes.

MotorSafety was removed since that's handled by the drivetrain's motor
controllers already.

@calcmogul calcmogul force-pushed the new-drive branch 2 times, most recently from b28e760 to cc7919c Compare May 18, 2019 01:05
@AustinShalit
Copy link
Member

What is the merge plan for this?

@calcmogul
Copy link
Member Author

Good question. The Drive, PIDController, LinearFilter, and command-based rewrites are all in the same boat, so whatever we decide can be applied to all of them, essentially. The main issue is namespace conflicts. We can put them in an "experimental" namespace, but having effectively half the API like that feels strange. We could also try making a subpackage based on the year. Either way, there would be breakage (albeit minor) when it gets moved out of the subpackage after the old package's deprecation period.

public void normalize(double maxSpeed) {
double maxMagnitude = Math.max(Math.abs(left), Math.abs(right));
if (maxMagnitude > maxSpeed) {
left /= maxMagnitude * maxSpeed;
Copy link
Contributor

@ArchdukeTim ArchdukeTim May 21, 2019

Choose a reason for hiding this comment

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

Why are other classes
out *= speed/magnitude

but this is
out /= magnitude*speed

Copy link
Member Author

Choose a reason for hiding this comment

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

Dangit. I missed that one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is one better than the other?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. One is actually correct. :)

@calcmogul calcmogul force-pushed the new-drive branch 2 times, most recently from 15fc72c to ef98998 Compare May 31, 2019 22:52
@calcmogul calcmogul force-pushed the new-drive branch 2 times, most recently from 008d99f to 4863903 Compare July 1, 2019 05:57
@calcmogul calcmogul force-pushed the new-drive branch 3 times, most recently from 2d8fb54 to b65817b Compare August 21, 2019 04:10
@calcmogul calcmogul force-pushed the new-drive branch 4 times, most recently from a7765d5 to 108eb04 Compare August 25, 2019 08:38
@calcmogul calcmogul changed the title Add replacement drive classes Clean up drive class implementations Aug 25, 2019
@calcmogul calcmogul marked this pull request as ready for review August 25, 2019 08:38
@calcmogul calcmogul added this to the 2021 milestone Aug 25, 2019
@calcmogul calcmogul force-pushed the new-drive branch 6 times, most recently from ca71ded to b78fa05 Compare August 30, 2019 03:24
@@ -31,7 +33,7 @@ bool GenericHID::GetRawButtonReleased(int button) {
}

double GenericHID::GetRawAxis(int axis) const {
return m_ds->GetStickAxis(m_port, axis);
return ApplyDeadband(m_ds->GetStickAxis(m_port, axis), m_deadband);
Copy link
Member

Choose a reason for hiding this comment

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

Commonly teams would want to apply different deadbands to different axes, for example the twist on a joystick, or the triggers on a gamepad, will likely have different deadzones to the X/Y axes.

It seems that this would not be useful to teams that want to utilise these other axes.

Copy link
Member Author

@calcmogul calcmogul Jan 16, 2021

Choose a reason for hiding this comment

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

That use case isn't supported by the current drive class implementation either; the same deadband in the drive class applies to all axes.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, but it looks like this would apply regardless of whether you're using the axis for driving.

Base automatically changed from master to main January 30, 2021 19:54
@calcmogul calcmogul force-pushed the new-drive branch 5 times, most recently from b76a2ef to 15da046 Compare April 10, 2021 07:24
@calcmogul calcmogul changed the base branch from main to 2022 April 10, 2021 08:27
Left and right sides of the differential drive and mecanum drive classes
are now both forward and the "inversion multiplier" was removed.

The deadband functionality was moved to GenericHID::GetRawAxis() since
the deadband is generally applied to joystick axes.

MotorSafety was removed since that's handled by the drivetrain's motor
controllers already.
@calcmogul
Copy link
Member Author

Superseded by #3340.

@calcmogul calcmogul closed this May 9, 2021
@calcmogul calcmogul deleted the new-drive branch May 9, 2021 06:59
pjbuterbaugh pushed a commit to pjbuterbaugh/allwpilib that referenced this pull request Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants