Skip to content

(3) Structure

Ryan Tse edited this page Aug 8, 2016 · 2 revisions

Overview

449 robot code is organized in a modular fashion. The code structure serves to organize code as well as to provide the structure to parse the configuration JSON file that holds all the code's constants (port numbers, PID values, etc.).

Module structure

Directory Structure

449 robot code is organized into modules and submodules. Below is the structure of a generic module.

 └── module                     
   ├── ModuleName.java          
   ├── ModuleMap.java                        
   ├── components                        
   │   ├── Component1.java         
   │   └── Component2.java   
   ├── commands
   │   ├── Command1.java   
   │   └── Command2.java   
   └── submodule1                             
   │   ├── Submodule1Name.java                 
   │   ├── SubmoduleMap.java           
   │   ├── commands                      
   │   └── components                    
   └── submodule2                          
           ├── Submodule2Name.java         
           ├── Submodule2Map.java   
           ├── commands   
           │   └── Submodule2SpecialCommand.java 
           └── components                

Modules are ranked by dependence, where any module is the direct superclass of its submodule. All modules are based on the Subsystem WPILib class. This package structure is very convenient for code reuse and maintenance.

The only items in a module's directory should be the module class, the module's map class, the commands directory, and the components directory.

The root module (supermodule) in any project is located at /src/main/java/org/usfirst/frc/team449/robot/. The root module is unique in that in main robot code projects, it contains a file other than the module class and map class: Robot.java. This class is the base class that contains the code that is run when the robot is enabled.

Code Structure

  • Module class: Class that directly accesses the necessary hardware
  • Module's map class: Class that contains the JSON constants map's template (as explained later in this wiki on the Map page)
  • Commands directory: Contains pertinent commands for the module; should not have any subdirectories
  • Components directory: Contains pertinent hardware abstractions and utilities; should not have any subdirectories
Clone this wiki locally