View Single Post
  #2   Spotlight this post!  
Unread 11-09-2012, 21:40
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Java, The Next Fronteir

Here's some documentation, most of it you should already have seen before but if you haven't, you should look through it.

Quote:
Java Starter Guide

http://firstforge.wpi.edu/sf/docman/...tation/doc1199


The starter guide uses the "Iterative Robot" style, but that's been replaced by the "Command-based" style which is a bit more flexible. Command-based splits up the program into Subsystems and Commands instead of having a monolithic block of code. This explains the Command-based model a little bit better.

https://dl.dropbox.com/u/27736599/FR...20Overview.pdf


This is the WPIlib robotics library users guide. WPIlib is the library FRC uses to interface with the various hardware and sensors. It gives a basic overview of all the different default methods which handle robot operation, the hardware and sensors and the functions available to interface with them, and describes some of that hardware.

http://www.wbrobotics.com/attachment...%20Guide. pdf


This is the "Programming Cookbook" which describes in-depth how the Command-based programming works with lots of code examples, and also goes into some of the user-side interface code like SmartDashboard

http://www.wbrobotics.com/attachment...ibCookbook.pdf


And the Javadoc for the WPIlib library, which you don't really need to read but it's there for reference:

http://www.wbrobotics.com/javadoc/in...e-summary.html

With that out of the way, I noticed that you're using the SimpleRobot template instead of Command-based. That's not a problem, and the SimpleRobot template should work fine for a testbed robot with very few peripherals or complex commands, but if you try to use it for competition code it's going to get very messy very fast. The new "standard" template to use is the Command-based robot template. Essentially what this does does is instead of having one monolithic chunk of code, it splits it up into separate blocks which each handle a different task. It takes a bit more work to set up, but once you have it's much more manageable and you can add on new functions very quickly without re-writing much code. The 2nd link above and the Cookbook goes into that in a little bit more detail.

Here's a series of video tutorials which cover it:
http://www.youtube.com/watch?v=v0vt9yKLxUQ

If you're going to be using Java code for a competition robot, I would definitely recommend that you go ahead and get familiar with the Command-based style beforehand.

A very brief overview of how the C-b template works...

Subsystems are primary robot components. The chassis, arms, shooters, etc. are all subsystems.

Commands are specific actions taken by subsystems. ExtendArm, DriveStraight, DriveWithJoysticks, etc. are all commands.

Now, whenever you need to do something, all you need to do is create a command to do it and you can call it as needed. You can also daisy-chain commands together to perform autonomous tasks without actually writing any new code, and you can call those same commands during teleop as well. All your code that handles the Chassis goes in one file, all the code that handles the shooter goes in another, all the code that handles the Operator Interface goes in another, and all the constants like port numbers and Jaguar IDs goes in another, so you're only ever really looking at one part of the robot at the time. Much easier to read, much easier to troubleshoot, and much easier to find what you need to change.

I attached a screenshot of what some of our code looks like at the moment. Even though it looks like a lot, most of the commands only require a few lines of code, and they can do a heck of a lot. Our code, for instance, is able to switch between tank drive, arcade drive, kinect drive, etc with the press of a button on the dashboard, and all of that is achievable with less than 2 dozen lines of additional user-generated code more than what we would have needed anyway.
Attached Thumbnails
Click image for larger version

Name:	Untitled.png
Views:	30
Size:	219.5 KB
ID:	12981  

Last edited by F22Rapture : 11-09-2012 at 22:05.
Reply With Quote