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

Switch inch conversion to use WPILib #2

Open
prensing opened this issue Jan 5, 2021 · 3 comments
Open

Switch inch conversion to use WPILib #2

prensing opened this issue Jan 5, 2021 · 3 comments
Labels
good first issue Good for newcomers

Comments

@prensing
Copy link
Member

prensing commented Jan 5, 2021

WPILib supplies Units.inchesToMeters(), the reverse conversion, and a few others.

Get rid of Constants.inchToMetersConversionFactor and replace all uses to use the Units methods. Mostly this is FieldMap.

@prensing prensing added the good first issue Good for newcomers label Jan 5, 2021
@kvnyng
Copy link

kvnyng commented Jan 5, 2021

Do you just want us to ctrl + f and go through each file to replace it, or to write a program that goes through all the files, searchs for Constants.inchToMetersConversionFactor and replace it with Units.inchesToMeters().
Also, do we happen to know which files to convert?

(I could probs do this)

@prensing
Copy link
Member Author

prensing commented Jan 5, 2021

Kevin,

I think it is only in 2 files, so easiest to go by hand. FieldMap.java has most of the reference. I think subsystems/Vision.java has a couple. If you delete the variable and try to compile, it will be obvious.

The replacement will need a little care and handwork. Our variable is a multiplication constant, while the WPILib is a function call. Will end up with the same result, but it will be cleaner over time to use what WPILib provides.

@prensing
Copy link
Member Author

prensing commented Jan 5, 2021

Just to make sure it is clear, we have code like:
x = 5.0 * Constants.inchToMetersConversionFactor;
and that will become:
x = Units.inchesToMeters(5.0);

Of course, some of the code is a little more complicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants