New features in Java and C++ WPILib for 2012
The 2012 version of WPILib for Java and C++ will have a host of new features, all currently in beta. Here are some previews of the coolest new stuff:
- Command-based programming
You can easily get control of complex actions in your robot using the Command-based programming design patterns. The idea is that you create Subsystem classes for each of the pieces of the robot, i.e. chassis, gripper, shooter, claw, elevator, etc. Then you create commands to animate tasks using the subsystem. These commands can control one of more subsystems, can be nested, and run concurrently. So it becomes simple to create robot programs with multiple mechanisms moving at the same time without the complexity of using threads. The commands can be used and reused in either the autonomous or teleop programs so an autonomous scoring sequence can be tied to a button in the operator interface with one line of code. - Operator Interface design
The buttons on your joysticks, extended I/O module, or even pushbuttons on your dashboards can be tied to commands in the robot program. Pushing on one of the buttons can automatically trigger a sequence of actions to begin on the robot with only a few lines of code. - Smart Dashboard
The Smart Dashboard for 2012 has been extended to not only display values that you log from your robot program, but also the complete status of the robot – what commands are currently running and the status of each subsystem. In addition there are many widgets that do other tricks like let you select one of many autonomous programs to run on the robot or set other options. You no longer need to build complex mechanical boxes just to set program options. - Network Tables
There is an easy mechanism for transmitting data between the robot and the dashboard computer. Just create a name for the data and set its value. It will automatically show up on the other side. For example, you can process camera images on the laptop, set some network table entries on the laptop, and the values appear automatically on the robot to be used for guidance.
All these features are described in the WPILib cookbook, a document that is problem-domain centric and will be available with the software when it ships at kickoff.