-
Notifications
You must be signed in to change notification settings - Fork 611
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
[wpimath] Add cosineScale method to SwerveModuleState and instance optimize #7114
[wpimath] Add cosineScale method to SwerveModuleState and instance optimize #7114
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cosineScale() needs a unit test, and a C++ port is needed. Otherwise, looks good.
No problem. Working on it. Also I should've mentioned earlier. This makes cosineScaling more visible. I just stumbled on this last year when doing a random look through examples. |
Should I model the unit test like the test for optimize? |
You could just write a single test that tests a positive and negative speed for different angles around the unit circle (e.g., 0°, 45°, -45°, 135°, -135°, 180°). |
Just to clarify. Just pick an angle. And test both positive and negative speed against it. |
Yea, for a range of angles. Just needs to be a representative sample of inputs. |
What are my c++ issues in the example SwerveModule's? |
You need to switch all uses of the static method to the instance method, including in the C++ tests. |
I was getting local build errors on just using the void method. I wanted to clear that up before the test. Maybe I was misreading things. |
/format |
This PR adds an instance method for cosineScaling to the SwerveModuleState object and makes the static optimize method an instance method.