Passing Parameters with Command-Based Robot Structure

This year our team just switched over from LabVIEW to Windriver and we’ve decided to go with a Command-Based structure. After looking through various guides, we were able to get the Teleop part of the program going but the Autonomous portion is giving us problems. How do we pass through parameters to specify how far we want the robot to drive (for example)? If anyone could help us out with this, it would be greatly appreciated. (3.05 MB) (3.05 MB)

Where do you want to pass parameters from?

You can make command constructors that take parameters and use those. Have you see WPI’s GearsBot videos? They lead you through a complete command based program (albeit in java).

Our autonomous code reads the desired motions from a text file and executes them. We make up our own command language each year, build a parser and call functions/methods to execute a series of motions or actions. That way we do not have to change the code for each match or before playoffs, we just FTP a new command file to the robot.


Thanks for the quick responses! We’ll look into constructors and also reading commands in from a text file.

Update: We got the autonomous up and running. Had to use a “this” pointer and make it equal to a variable of with a different name from the parameter. In our code we used power, leftdistance, and rightdistance parameters/local variables. Format: “this->localvariable = parameter” (3.02 MB) (3.02 MB)

You can also choose which command, and therefore which autonomous program runs during autonomous using some radio buttons or combo box on the driver station.

Hope this helps.