Jared Russell
23-10-2011, 00:05
Link to FIRST Forums post: http://forums.usfirst.org/showthread.php?p=52995#post52995
As Team 341 continues our Beta test of the 2012 FRC Control System Java programming language and hardware, I thought it would be a good time to explain some of the new features we have been testing. This post will focus exclusively on the software side - and most of the Java changes also go for C++.
Aside from support for the new hardware (4-slot cRIO II, Microsoft Kinect, and maybe a couple other things), the 2012 Java environment offers some new helpful utilities, a new SmartDashboard application, and an entirely new style of programming (CommandBasedRobot) that supplements the existing SimpleRobot and IterativeRobot styles.
In many cases, the extensions to the Java/C++ programming options are things that some enterprising teams have been doing for a few years now. For example, if you look at the code posted on ChiefDelphi by teams 125 and 254 in the past couple seasons, you will find a lot of similarities.
Here are some of the new features that we are currently testing:
A built-in "Preferences" class to load and save important values from/to the cRIO's non-volatile memory. Imagine things like PID constants, autonomous mode values, etc. What is even cooler, the Preferences class has a network interface to the new SmartDashboard - you can tweak your values on your Classmate, send them over, and have them stored onboard!
As part of the new CommandBasedRobot template, the idea of "Subsystems" has been created. A subsystem class is a single functional part of your robot - such as a driveline, an arm, a gripper, etc. For example, a gripper subsystem might have methods to Grip and Release game pieces. Subsystems help you logically group together the sensors and actuators that work together, and help you to define your robot code while the mechanical team is still putting it together.
Along with Subsystems, the 2012 version introduces Commands. Commands are discrete pieces of code that manipulate the Subsystems of your robot. For example, a "GrabATube" Command might tell a roller claw to run until a tube is detected by some sort of sensor on the claw. Commands have specific methods that get called when they start, as they execute, and when they finish (allowing you a lot of flexibility in what can be put into a Command). Commands can be scheduled in sequence or in parallel - you can imagine that button presses may create new Commands, just as your autonomous mode would be a sequence of Commands. Commands have a method of "requiring" specific Subsystems - this makes sure that you never have multiple commands telling your drive to do different things, for example (the second command which requires the drive would cancel the first).
There are new ways to interface with your Classmate and OI. A new OI class captures all of your Joystick, Kinect, and Cypress board interfacing in one place. New Button classes are used to asynchronously map button presses to Commands (when you create the Button, you associate it with a Command - no need to do anything else!)
The new SmartDashboard lets you tweak Preferences on the fly, as I previously mentioned. It also has a couple of other nifty features. Buttons that you define have a virtual interface in the SmartDashboard - simply point and click, and you can test that a piece of code is working. It also displays the currently active Commands for your Subsystems, helping you debug (did one of your Commands forget to finish?). Lastly, there is a new function to help you choose your autonomous mode directly from the dashboard - something that many teams have had to figure out how to do on their own for years.
You now have the option to do vision processing on your Driver Station Laptop in addition or instead of doing it on the cRIO! Your laptop (whether a Classmate or something else) definitely has more power available to it than the cRIO, so this gives you an option to move all of that processor-heavy image processing code offboard.
It is important to note that although there is a ton of new stuff in 2012, all of the 2011 templates and classes work in exactly the same way (for example, our 2011 robot code worked without modification using the 2012 libraries).
Per the beta test agreement, I am happy to answer any questions on these new features, but cannot provide code or documentation until after the beta period.
As Team 341 continues our Beta test of the 2012 FRC Control System Java programming language and hardware, I thought it would be a good time to explain some of the new features we have been testing. This post will focus exclusively on the software side - and most of the Java changes also go for C++.
Aside from support for the new hardware (4-slot cRIO II, Microsoft Kinect, and maybe a couple other things), the 2012 Java environment offers some new helpful utilities, a new SmartDashboard application, and an entirely new style of programming (CommandBasedRobot) that supplements the existing SimpleRobot and IterativeRobot styles.
In many cases, the extensions to the Java/C++ programming options are things that some enterprising teams have been doing for a few years now. For example, if you look at the code posted on ChiefDelphi by teams 125 and 254 in the past couple seasons, you will find a lot of similarities.
Here are some of the new features that we are currently testing:
A built-in "Preferences" class to load and save important values from/to the cRIO's non-volatile memory. Imagine things like PID constants, autonomous mode values, etc. What is even cooler, the Preferences class has a network interface to the new SmartDashboard - you can tweak your values on your Classmate, send them over, and have them stored onboard!
As part of the new CommandBasedRobot template, the idea of "Subsystems" has been created. A subsystem class is a single functional part of your robot - such as a driveline, an arm, a gripper, etc. For example, a gripper subsystem might have methods to Grip and Release game pieces. Subsystems help you logically group together the sensors and actuators that work together, and help you to define your robot code while the mechanical team is still putting it together.
Along with Subsystems, the 2012 version introduces Commands. Commands are discrete pieces of code that manipulate the Subsystems of your robot. For example, a "GrabATube" Command might tell a roller claw to run until a tube is detected by some sort of sensor on the claw. Commands have specific methods that get called when they start, as they execute, and when they finish (allowing you a lot of flexibility in what can be put into a Command). Commands can be scheduled in sequence or in parallel - you can imagine that button presses may create new Commands, just as your autonomous mode would be a sequence of Commands. Commands have a method of "requiring" specific Subsystems - this makes sure that you never have multiple commands telling your drive to do different things, for example (the second command which requires the drive would cancel the first).
There are new ways to interface with your Classmate and OI. A new OI class captures all of your Joystick, Kinect, and Cypress board interfacing in one place. New Button classes are used to asynchronously map button presses to Commands (when you create the Button, you associate it with a Command - no need to do anything else!)
The new SmartDashboard lets you tweak Preferences on the fly, as I previously mentioned. It also has a couple of other nifty features. Buttons that you define have a virtual interface in the SmartDashboard - simply point and click, and you can test that a piece of code is working. It also displays the currently active Commands for your Subsystems, helping you debug (did one of your Commands forget to finish?). Lastly, there is a new function to help you choose your autonomous mode directly from the dashboard - something that many teams have had to figure out how to do on their own for years.
You now have the option to do vision processing on your Driver Station Laptop in addition or instead of doing it on the cRIO! Your laptop (whether a Classmate or something else) definitely has more power available to it than the cRIO, so this gives you an option to move all of that processor-heavy image processing code offboard.
It is important to note that although there is a ton of new stuff in 2012, all of the 2011 templates and classes work in exactly the same way (for example, our 2011 robot code worked without modification using the 2012 libraries).
Per the beta test agreement, I am happy to answer any questions on these new features, but cannot provide code or documentation until after the beta period.