View Full Version : Team 254 2013 FRC Code
Tom Bottiglieri
03-05-2013, 17:49
Hi everyone,
Now that the official 2013 FRC season has come to a close, we would like to share the software that drove Overkill with the FIRST community. We have released our code to the public every year since 2010 and the programming sub team is especially proud of the work they have put together for the 2013 submission.
This year we made the switch from C++ to Java. We did this as the Java tools can be run on any platform and are freely available to download on the Internet, which made it very easy for our students and mentors to hit the ground running and contribute commits. Java is also taught in the school, so we figured this would be a great way for students to apply the skills they are learning in the classroom.
https://github.com/Team254/FRC-2013
If you have any questions please do not hesitate to ask... We love talking about our work! Also please feel free to try/learn from/re-use this code as much as you see fit.
Thanks!
The link is 404ing for me.
EDIT: Now it's working, thanks 254!
Tom Bottiglieri
03-05-2013, 17:54
The link is 404ing for me.
It took a second for the repo to go public (we use Github's private repo feature to develop our code). Check again now!
hiyou102
03-05-2013, 18:20
The auto hang code is amazing!
(we use Github's private repo feature to develop our code).
Do you guys use the educational offers that GitHub has? If you don't, you should consider it. My team got a 2 year bronze plan for free that way.
Also, why does your code style talk about enums, even though they aren't available in JDK 1.4?
Pat Fairbank
03-05-2013, 18:27
Do you guys use the educational offers that GitHub has? If you don't , you should consider it. My team got a 2 year bronze plan for free that way.
Also, why does your code style talk about enums, even though they aren't available in JDK 1.4?
One of our leaders got in touch with GitHub a few years back and got us free private repos. We have more than 10 so I'm not sure what plan we're on, but we haven't been sent a bill so I'm not about to complain. :)
We ported the style guide over from our C++ one before discovering the (many) limitations of Java ME. Enums aside, we could have made the constants management stuff a lot cleaner with generics and reflection.
joelg236
03-05-2013, 19:08
We ported the style guide over from our C++ one before discovering the (many) limitations of Java ME. Enums aside, we could have made the constants management stuff a lot cleaner with generics and reflection.
Generics... I wish... :(
joelg236
03-05-2013, 21:00
I did a diff on your CheezyGyro class, and the only important change was making initGyro() public. Is this only to calibrate the gyro when you want to? Why didn't you just adjust it in the wpilibj and compile with the custom version?
I did a diff on your CheezyGyro class, and the only important change was making initGyro() public. Is this only to calibrate the gyro when you want to? Why didn't you just adjust it in the wpilibj and compile with the custom version?
Then anyone checking it out would have to have the modified WPILibJ
joelg236
03-05-2013, 21:05
Then anyone checking it out would have to have the modified WPILibJ
I suppose so. Although who would compile it? Not everybody has an Overkill :p
I suppose so. Although who would compile it? Not everybody has an Overkill :p
Any other 254 programmer with a new dev environment? :p
joelg236
03-05-2013, 21:07
Another question, I haven't seen a single final variable, even in cases where I can't see a good reason not to. Any reasoning behind that or is it just because you know you won't write code to mess with them?
You actually can use the DPad up and down if the switch on the controller is set to D. Then it is axis 6.
My compliments to Team 254's Programming team and mentors. That's some beautifully structured code you have there. I especially love how elegant your seven disc auto sequence is.
Could you explain the purpose of the negative inertia maths in CheesyDriveCommand.java? Is it to limit the change in PWM?
I did a diff on your CheezyGyro class, and the only important change was making initGyro() public. Is this only to calibrate the gyro when you want to? Why didn't you just adjust it in the wpilibj and compile with the custom version?
In industry, modifying the source of an external library is a bad practice that should be avoided if a better technical solution exists.
The bigger issue is if the other library receives updates from the original source. Then you have to re-implement the changes into the updates. If the custom change were in runtime logic (not detected by a compile error, like the Poof's would be) then your robot wouldn't act correctly, causing a lot of wasted time in trying to figure out why.
Here's an example of a situation where I was forced to modify COTS code at work. It required a full write-up and sign-off by the program manager. This type of thing isn't detected by a compiler, but it caused several runtime Exceptions when we tried to load the map format.
At work, we use NASA WorldWind. WorldWind has some static file name extensions that are hard-coded to lower case. On Linux, the files we have are upper case, and case matters on Linux. One of the map formats we use contains the upper-case file names in a header table embedded within a single file binary file -- not possible to change. Additionally, if the issue were brought up to NASA, the fix would likely be seen in WorldWind 1.5 or 1.6, whereas we're using 1.4. WorldWind 1.5, at the time the decision was made, was having hotspot issues on Linux -- so waiting for a fix in an update was considered a risk. Thus, we had to modify WorldWind's code (added .toUpperCase() in the proper spots). We then CM'ed the specific patch files so we would know exactly what changes had to be made in the future. Any time we want to update WorldWind (perhaps in the project's next iteration), we can pull the patch files out of the code repository and analyze if they're still relevant.
As a Java programmer, lets just say this has fulfilled the second letter of this great organization we compete in for me.
:eek: *picks jaw up off of floor*
Did Team 254 use visioning on OverKill? If not, how did the drivers line up to shoot so accurately?
Pat Fairbank
05-05-2013, 20:50
Did Team 254 use visioning on OverKill? If not, how did the drivers line up to shoot so accurately?
We deemed it an unnecessary complexity, given the wide goals and ability to use the pyramid for alignment. We just made sure the drivers got a lot of practice.
Jeremy Germita
05-05-2013, 23:30
Thanks to everyone at 254 for the yearly release of your software. Since you began doing this, 254 software releases have been a source of inspiration and learning for me as a programmer. I especially appreciate the style guide. I will be using it to format 399 code for release later this month.
Could you explain the purpose of the negative inertia maths in CheesyDriveCommand.java? Is it to limit the change in PWM?
As a user of a variant of cheesy drive, I've observed that negative inertia calculations and outputs help prevent overshooting during turns by momentarily outputting a calculated output(whose sign is opposite the actual turning direction) to help act as a tuneable brake. This makes turning on a dime and other quick yaw-axis motions a little more controllable when coupled with the rest of the cheesy drive algorithm. Cheesy drive aids controllability on robots that are fast(14+fps) and can turn quickly because of that.
Tom Bottiglieri
06-05-2013, 22:16
I did a diff on your CheezyGyro class, and the only important change was making initGyro() public. Is this only to calibrate the gyro when you want to? Why didn't you just adjust it in the wpilibj and compile with the custom version?
This route would require maintaining a fork of the library and requiring anyone who wants to build our software to use the forked library. Putting it in our source tree makes it easier to maintain AND gives the added benefit of giving compile time errors if something changes upstream.
otherguy
07-05-2013, 00:15
Thanks for posting, I find going through other teams code to be the best way to learn new ways of approaching problems.
I haven't gotten through all the source yet, but it is nice to be able to see how your code has matured through the season. It interesting to look back to see what other teams were working on to prep for regionals and champs.
If we can get our code cleaned up, we will be releasing ours as well this year.
We've also made some changes to your PID Tuner from last year, it allows us to make changes to the gains and modify set points on the fly through the web page. Certainly would have been more useful for last years game, but it's still a great tool to have in the toolbox.
http://s21.postimg.org/ktjv51ohf/PID_Tuner.jpg (http://postimg.org/image/ktjv51ohf/)
feverittm
27-06-2013, 12:04
Thanks to team 254 for posting their code. This is very instructional to the mentors as well as our student programmers :)
I have a number of questions, but a few are quite simple. You have defined a pressureTransducer in your code to read the pneumatic pressure. Where in the system is this transducer located? I ask because we got into some questions on the legality of using any form of transducer on the high pressure side (120psi) of the pneumatics system.
I am also assuming that since you are using the smaller Vlair compressor (as seen on some photos I have seen of the robot) that you are not cycling very much air and therefore the compressor does not have to run very long (and burn out). Is this correct?
Thanks for the great opportunity you are giving other teams to learn from your development.
Enjoy!
apples000
27-06-2013, 12:55
From what I understand, the pressure transducer on the 120 psi side is not legal, but many teams have gotten away with it.
AdamHeard
27-06-2013, 13:03
From what I understand, the pressure transducer on the 120 psi side is not legal, but many teams have gotten away with it.
Curious, what rule gives you this idea?
KrazyCarl92
27-06-2013, 13:12
I am also assuming that since you are using the smaller Vlair compressor (as seen on some photos I have seen of the robot) that you are not cycling very much air and therefore the compressor does not have to run very long (and burn out). Is this correct?
I would not make this assumption based on the compressor choice (I would make this assumption from looking at their robot and visiting their pit at competition). We used the same small VIair compressor on our robot this year. We have 5 40 cu. in. pneumatic tanks and some really large pneumatic cylinders on this years robot. We replaced the compressor on the competition robot once all season as a preventative measure at champs, and only saw a failure on the practice bot during a 6 hour drive practice session. They sure heated up a lot, but they can take the abuse if you don't test the limits too much.
The VIair compressor is rated for about the same output, but weighs about half as much as the older compressors. Ours took 2-4 minutes to charge before each match and would usually run most of the match.
We are not using a Viair compressor. We're using a Thomas compressor that is similar in size to the Viair (but a little smaller). We use a ton of air. Our compressor can barely keep up with our air usage. There have been a handful of times where we didn't quite have enough air when we started our hang and would end up taking awhile to get off the ground.
We are using the pressure sensor to determine when we are below 60 PSI. Before championships our shooting performance would degrade dramatically at that point, as well as the aforementioned hanging issues.
feverittm
27-06-2013, 13:50
Regarding the legality of pressure transducers on the high side. This was a question I asked directly to the QA and was told that they are illegal. Pretty clear there. If you read the rules it states the the ONLY things allowed on the high side are the compressor, high-pressure gauge, pressure relief valve, storage tanks and the regulator. Nothing else. However, as someone else pointed out it was not checked very well and teams got away with it in a number of instances.
The Vlair compressor has a 9% duty cycle rating that makes it very difficult to use on a pneumatic intensive robot as it will tend to overheat. I have heard of instances where teams have gotten away with running them for awhile, but I have also heard many stories where these compressors have failed as well. I cannot guarantee that the CheesyPoofs used the 090C or found a better model, but I was just going by the pictures I have seen. Educated guess, no assumptions.
(sorry for being off-topic).
Another item of the code the I will have to spend a long time trying to digest is the large number of 'controller' classes that are used. Not just a simple PID controller, but a number of other things (like the StateSpaceController). It is going to take awhile to unwrap this code in my brain. :yikes:
Again Thanks!
Enjoy!
apples000
27-06-2013, 15:13
Wow, you guys did a great job with organizing your code. I love that the PID controller doesn't need to start it's own thread to call the pidSet() method. Also, I think you forgot to update your feed-forward value when the table listen finds a change in the pid gains. You check to see if the key is named "f", but you never end up comparing/changing "f".
private ITableListener listener = new ITableListener() {
public void valueChanged(ITable table, String key, Object value, boolean isNew) {
if (key.equals("p") || key.equals("i") || key.equals("d") || key.equals("f")) {
if (gains.getP() != table.getNumber("p", 0.0) || gains.getI() != table.getNumber("i", 0.0) ||
gains.getD() != table.getNumber("d", 0.0)) {
System.out.println("Got new PID gains!");
gains.set(table.getNumber("p", 0.0), table.getNumber("i", 0.0), table.getNumber("d", 0.0));
}
} else if (key.equals("setpoint")) {
if (goal != ((Double) value).doubleValue()) {
setGoal(((Double) value).doubleValue());
}
} else if (key.equals("enabled")) {
if (isEnabled() != ((Boolean) value).booleanValue()) {
if (((Boolean) value).booleanValue()) {
enable();
} else {
disable();
}
}
}
}
};
Travis Covington
27-06-2013, 16:25
We did not use the pressure transducer on the high pressure side of the comp bot. It was only used that way on the practice bot to give us an idea of how much air we were consuming.
AdamHeard
27-06-2013, 16:47
Regarding the legality of pressure transducers on the high side. This was a question I asked directly to the QA and was told that they are illegal. Pretty clear there. If you read the rules it states the the ONLY things allowed on the high side are the compressor, high-pressure gauge, pressure relief valve, storage tanks and the regulator. Nothing else. However, as someone else pointed out it was not checked very well and teams got away with it in a number of instances.
Thank you for that. We didn't end up running one (weight), but we would have done that wrong on accident.
feverittm
27-06-2013, 22:27
To Cory and other 254 people, Thanks for replying on the compressor. We were running into similar issues (large cylinders, limited capacity) and used the old Thomas version because of the duty cycle issues. Great job!
I am still really impressed by the style and organization of the code, Very well done across a large number of classes and modules.
Great job and great execution!
To Cory and other 254 people, Thanks for replying on the compressor. We were running into similar issues (large cylinders, limited capacity) and used the old Thomas version because of the duty cycle issues. Great job!
I am still really impressed by the style and organization of the code, Very well done across a large number of classes and modules.
Great job and great execution!
To be clear, it is a Thomas, but not the old one that came in the kit. It's substantially lighter than that one and produces slightly higher flow, at the penalty of heating up faster due to less thermal mass.
iyermihir
28-06-2013, 02:10
To be clear, it is a Thomas, but not the old one that came in the kit. It's substantially lighter than that one and produces slightly higher flow, at the penalty of heating up faster due to less thermal mass.
Would you mind giving us a model number for this compressor?
-Mihir Iyer
Travis Covington
28-06-2013, 02:14
http://www.gd-thomas.com/productlist.aspx?id=10124&tp=p
215ADC38/12
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.