Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Team 111 Wildstang 2013 Robot Code (Java) (http://www.chiefdelphi.com/forums/showthread.php?t=116780)

sirchadwick 09-05-2013 10:04

Team 111 Wildstang 2013 Robot Code (Java)
 
Similar to Team 254, we also decided to switch to Java from C++ this year. Java is easier to teach, many students already had some instruction in school, and the students can grasp the concepts faster. Also the students and mentors could work on both Windows or Mac computers.

After the initial heartburn from Squawk's and Java ME's limitations, we feel the change was a success and will continue using Java in future years. I would recommend it for any team thinking about making the switch. However, they should understand how limited this version of Java really is. We lost about 2 weeks just trying to get basic functionality to compile and run because the compile/run time error messages are very cryptic. It took examining the WPI libraries design patterns and their use of this "Java" to understand how to recreate "simple" things like an unsynchronized List or a way to do a type-safe "enum".

Without further ado..........

https://github.com/wildstang111/2013_robot_software

The repository contains two Netbeans projects; crioTarget and WsSimulation. The crioTarget is what is run on the robot. The WsSimulation links against the crioTarget and replaces many of WPI classes with its own stub or simulation implementation.

The robot framework was designed using the Subject/Observer object oriented design pattern and inputs and outputs can notify any registered object when they change. To keep things simple and synchronous, all updates occurred during the 20 ms periodic loop.

The simulation allows the software team to test all of its logic before loading it on the hardware. The simulation was originally based on the project frcjcss ( https://code.google.com/p/frcjcss/ ) released under GNU GPL v3. frcjcss stubbed out a lot of the classes from the WPI library like Victors, Solenoids, Relays, and Joysticks and got us quickly started in getting our cRio code running on the desktop. Our adapted version simulates a variety of hardware including the drive encoders, flywheel encoders, gyro, and limit switches to test proper control schemes. frcjcss had an onscreen joystick and we added support for a USB joystick for inputs. The USB joysticks are supported using the javahidapi project (https://code.google.com/p/javahidapi/) released under the BSD license. We used two different PS3/Xbox type controllers and aside from the Directional Pad (see known issues), all buttons and axises read as expected.

After the build season, it was determined that the SmartDashboard would work by linking in the desktop version of the Smartdashboard/Network table jars into the Simulation. SmartDashboard justs needs to be started with the command line parameter for the ip as localhost. This greatly impacts the entire UI and alot of the single UI windows can be removed.

Feel free to ask any questions or point out any issues. There is already a growing list of known issues. :)

joelg236 09-05-2013 10:41

Re: Team 111 Wildstang 2013 Robot Code (Java)
 
This is awesome. Thank you guys so much for sharing this. I'll be looking over it the next few days ;)

Domenic Rodriguez 09-05-2013 11:38

Re: Team 111 Wildstang 2013 Robot Code (Java)
 
Thanks for releasing this to the community. My team just switched from LabVIEW to C++ this past year, and we're looking at Java for next year, so it's been very helpful to have access to full robot programs from teams like you guys and 254.

joelg236 09-05-2013 13:07

Re: Team 111 Wildstang 2013 Robot Code (Java)
 
I'm curious why every class name starts with Ws. I'd think that your programmers know it's wildstang's code. :p

sirchadwick 09-05-2013 13:30

Re: Team 111 Wildstang 2013 Robot Code (Java)
 
It started when we would want to "wrap" WPI code with additional functionality and want to easily see we were using the wrapped version. (ie WsTimer wraps Timer)

For all the other files, it doesn't make sense outside of habit and that code completion can be limited only to "Wildstang" results quickly by just typing the prefix + first letter and then Ctrl + Space.

It did get out of hand with prefixes though in some cases like typing WsAutonomousStep before every type of auto step got annoying and should have been shorter .

joelg236 09-05-2013 13:59

Re: Team 111 Wildstang 2013 Robot Code (Java)
 
Makes sense. I'm seeing a lot of weird naming conventions in the code. I assume that's just due to a different standard that was started on your team or just transferring to Java. This is what the standard for Java is.

joelg236 09-05-2013 14:04

Re: Team 111 Wildstang 2013 Robot Code (Java)
 
Another quick question, it looks like you have a lot of "preferences" in your config file. How did you manage so many values in one file? We found ourselves using 2-3 files for different things and we didn't have nearly as many things to save.

sirchadwick 09-05-2013 15:05

Re: Team 111 Wildstang 2013 Robot Code (Java)
 
Our standard naming convention had evolved over the years from C++. Last year we were really strict about holding to it and even had a tool to reformat it to be more like the standard. This year.....not so much.

We had so many other issues with the transition to java that it was never even really considered. We definitely missed the mark there. There are some really weird things in there.

It could definitely be improved and I will look over the Java standard again.

sirchadwick 09-05-2013 15:15

Re: Team 111 Wildstang 2013 Robot Code (Java)
 
We didn't really have any issues managing the one preference file. A lot of them were "tuned" during the first use and then never touched again.

What were the issues you guys were having with the one file? Simply sheer quantity from the user side or read/lookup time from the software side?

The auton parameters were the ones we were constantly changing. Originally the file was even worse when we had separate parameters for each program regardless if it was just a variant of 5 disc. Rather late in the season, we condensed them and were able to remove about 300 parameters, which had become unmanageable.

SteveGarward 09-05-2013 15:36

Re: Team 111 Wildstang 2013 Robot Code (Java)
 
Quote:

Originally Posted by joelg236 (Post 1273660)
Makes sense. I'm seeing a lot of weird naming conventions in the code. I assume that's just due to a different standard that was started on your team or just transferring to Java. This is what the standard for Java is.

There is a difference between a convention and a standard. Conventions say 'most people are doing it this way', whereas standards say 'you must do it this way'.

Most differences between our code and the Java conventions are likely because the code was at first ported from C++, and people were familiar with that. In any case, there is nothing wrong with having a team standard different from normal conventions. The important part is that everyone working with the code knows what the standard is and sticks to it. :)

joelg236 09-05-2013 16:00

Re: Team 111 Wildstang 2013 Robot Code (Java)
 
Quote:

Originally Posted by sirchadwick (Post 1273684)
What were the issues you guys were having with the one file? Simply sheer quantity from the user side or read/lookup time from the software side?

We had problems with both. Read time isn't crazy when using FileZilla (since local copies are saved), but upload time was a concern since we were constantly changing things in queue (and didn't want to mess up anything before a match).

That coupled with it taking very long just to find a property (Ctrl-F with the classmate is slow).

Quote:

Originally Posted by SteveGarward (Post 1273691)
...

Yeah, sorry if the terminology wasn't exactly accurate. I was mostly curious why you went with a different standard than is convention. Most classes just stick with what is convention, so I'd assume your students were used to that.

joelg236 09-05-2013 16:06

Re: Team 111 Wildstang 2013 Robot Code (Java)
 
Quote:

Originally Posted by sirchadwick (Post 1273585)
It took examining the WPI libraries design patterns and their use of this "Java" to understand how to recreate "simple" things like an unsynchronized List or a way to do a type-safe "enum".

There is an unsynchronized List class in edu.wpi.first.wpilibj.networktables2.util.List.

sirchadwick 09-05-2013 16:32

Re: Team 111 Wildstang 2013 Robot Code (Java)
 
Quote:

Originally Posted by joelg236 (Post 1273701)
There is an unsynchronized List class in edu.wpi.first.wpilibj.networktables2.util.List.

Exactly. Fortunately we didn't end up having to "create" it after we looked through the NetworkTable source for what they did and saw that they already created one. That's what we used once we found it. Finding it was the trick.

apples000 09-05-2013 17:05

Re: Team 111 Wildstang 2013 Robot Code (Java)
 
Just a quick question, when you use the I2C communication in WsLED, are you communicating directly to an addressable LED strip, or are you communicating to something like an arduino/basic stamp, then to the LED strip?

nathanwalters 09-05-2013 17:10

Re: Team 111 Wildstang 2013 Robot Code (Java)
 
Quote:

Originally Posted by joelg236 (Post 1273698)
We had problems with both. Read time isn't crazy when using FileZilla (since local copies are saved), but upload time was a concern since we were constantly changing things in queue (and didn't want to mess up anything before a match).

I'm curious as to what issues you had with upload time. Using FTP from the command prompt was very fast for me. The transfer itself took only about half a second; I could do the entire process in about 9 seconds flat. Your file must have been very big if upload time was a concern :)


All times are GMT -5. The time now is 03:24.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi