team3309 / 6cimdrive Goto Github PK
View Code? Open in Web Editor NEWOff-season of 2015 season, 6 Cim Drive
Off-season of 2015 season, 6 Cim Drive
There are a lot of well-established best practices for code in Java that you should be following.
Google has published a really good style guide that you should familiarize yourself with and follow. A lot of people, especially relatively new programmers don't understand the importance of good style but it is very important for other people reading your code and your future self.
A few that I've noticed you're not following:
Controller
should not be capitalized heremodifiedGyro
should be ModifiedGyro
It is generally best practice to declare all member variables at the top of the class. You have some declarations interspersed everywhere in Drive mixed in among the methods, that way it's impossible to look in one place and see all of the variables contained in the class
Sometimes your indentation and other spacing is messed up and it bothers me. I always run auto-format in my IDE before saving a file. It might not seem like a big deal but the code is much more aesthetically pleasing and easier to read if the formatting is consistent everywhere
You should have everything in a package. (org.team3309.frc2015 is a good name for the season's code). When you have everything in the default package, other classes cannot import them, it is always best practice to never use the default package and always specify a package name. See 2014 for a sample package organization
Class names should always start with an upper case character and then camel-case after that. This would then be ModifiedGyro
You should also add a Javadoc comment on the declaration of the class to say what it does. Specifically, what does it do that a regular Gyro doesn't? I know, but other people reading it might not
Might want to update with proper class/package
Instead of having 6 separate variables to hold the 3 Victors for each side, you can declare two arrays of 3 Victors each, and loop through the array when you set a value for them
You should have comments on parts of code that people are likely to have difficulty understanding. Comments are also useful for yourself in the future, not just other people.
Comments like the following are useless:
I felt bad for giving so many bad examples so here are some examples of good comments (from your code):
I've read a lot about teams like 33 experiment with auto-shifting like it seems as if you are doing here and the general consensus is that it's a bad thing to do. My opinion (and maybe Michael has a different one) is that the driver should have full control over when they shift gears. There are countless different scenarios that could happen during a match, and you can't possibly think of all of them beforehand. Auto-shifting could have undesired consequences if for example you can't try and ram someone in low gear because it shifted to high automatically and now you brown-out while trying to push another robot.
Speaking from experience, it is really easy to forget to update all necessary variables when some are linked like this. Instead of having haloDriveEnabled
and tankDriveEnabled
, you should use an int for driveMode
and private static final int
s to represent something like MODE_HALO_DRIVE = 0
MODE_TANK_DRIVE = 1
, etc and check if driveMode ==
one of those (this way you could also have more than 2 states)
As a general rule of thumb, everything other than static variables should always be declared as private. If you need to access or set the value of a class's member variable, you should have getter and setter methods to access/set the value respectively.
Here are some spots where I noticed you either didn't declare an access modifier or used it incorrectly:
There's no reason to have anything with a Scheduler in there if you don't have any Commands. See my 2014 code or the WPILib docs for more info. If you are going to use the Command based architecture, there should be a Command subclass for driving that you just start in teleopInit and stop in disabledInit again see 2014 code for more info
This should not be its own class, but instead make all of the fields in here (public static) members of XboxController. You really only need to use it in XboxController so it would make the code cleaner, but you still want them to be accessible if you want to use the JoystickButton class provided with the command-based framework from FRC
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.