Trouble with Command-Based coding

So, our team wants to go with command-based coding this year, since we’ve been going for a good four years now, but were having quite a few issues.

To start, we’re using Netbeans and Java (I believe 7.0.4, but I’d need to check to be sure). My computer is windows 8, and the other one that we use is windows 7, with the files synced via google drive.

The problem we’re having (for now at least) is that we can’t seem to figure out how to call up the motors as a subsystem. We’ve even gone as far as to copy the code directly from the guide, yet for some reason it still refuses to compile properly. It continuously says errors like “class not found” and “variable cannot be resolved”, despite it working in both the example, and in simple code.

Basically, I’m begging for either some sample code, or a more comprehensive guide. We should be able to figure it out from there, but we just can’t seem to get off the starting line.

Thank you in advance,
The Programmers of Team Cold Logic

If you’re looking for example code and you have the plugins installed, you can go to file-> new project -> samples -> FRC Java -> GearsBot. The gearsbot example is a great example for command based programming. If you’re still having trouble, post your code, and we can figure out what’s not working.

Also, check out these videos for command based programming

You can see our previous years code at – plenty of examples of command-based control code there. It’s C++, but translateds pretty directly to Java.

Brad Miller has some videos on Youtube that have more information as well.

(Hopefully) got it working after numerous error-fixes in their template file (I suspect my download was partially corrupted, or something equally absurd).

  1. temporarily removing joystick input
  2. adding numerous imports to nearly all included classes
  3. refactoring to deal with the actual command names
  4. initiating OI class after ExampleSubsystem, rather than it’s original position before
  5. testing autonomous with motors set to 30%
  6. flipping a wire
  7. making methods to output joystickx and joysticky in OI class
  8. testing teleopertation mode (yet to be done, waiting on belly pan replacement).

This took me, and the programmer from last year ~16 man-hours to figure out, 11 of which came from me.

Question is, is this somehow my fault? Or was it on WPI’s end?

The templates are intended as just that, templates. It represents a starting point for your code where you have to add your own logic and control for your robot. A tool that might help since you are just getting started at this is RobotBuilder. It actually writes more of the boilerplate code for your commands and subsystems and there are good tutorials and examples for it.

Generic command based programming documentation in ScreenSteps:

ScreenSteps documentation on RobotBuilder:

Youtube video tutorial:

Good luck with your robot!


But a template doesn’t help you if the systems are initiated in ways that are known to cause errors… I mean, the OI thing is an easy fix, once you realize what’s wrong, but the point is that the template shouldn’t even have that error built into it.

I also would suggest using RobotBuilder - it simplifies things immensely and, from what I can tell from using C++, generates very few errors. (There were a few, but they were minor.) I assume it would be roughly the same for Java.

Here is a Java Command Based guide that our team presented at the VA FRC Workshop this past fall if you’re interested. It will walk you through all of the files associated with the Command Based environment and how to write code for a drivetrain.