Creating a subsystem
Subsystems are classes that encapsulate (or contain) all the data and code that make a subsystem on your robot operate. The first step in creating a robot program with the RobotBuilder is to identify and create all the subsystems on the robot. Examples of subsystems are grippers, ball collectors, the drive base, elevators, arms, etc. Each subsystem contains all the sensors and actuators that are used to make it work. For example, an elevator might have a Jaguar speed controller and a potentiometer to provide feedback of the robot position.
Creating a subsystem by dragging from the palette
Creating a subsystem by using the context menu on the Subsystem folder
Name the subsystem
Adding constants (2016 only)
Constants are very useful to reduce the amount of magic numbers in your code. In subsystems, they can be used to keep track of certain values, such as sensor values for specific heights of an elevator, or the speed at which to drive the robot.
By default, there will be no constants in a subsystem. Press the button next to "Constants" to open a dialog to create some.
Creating constants (2016 only)
Add constants (2016 only)
- The name of the constant. Change this to something descriptive. In this example of a gripper, some good constants might be "open" and "close".
- The type of the constant. This will most likely be a double, but you can choose from one of: String, double, int, long int, boolean, or byte.
- The value of the constant.
If a constant is valid, it will be exported to the subsystem class as a public static final/public const static variable depending on the language. If it isn't, that constant will be highlighted red to show there's something wrong with it. Common problems are an invalid Java/C++ variable name (such as having spaces or non-letter characters in the name) or having non-numeral characters in the value field of a numeric constant.
Saving constants (2016 only)
Drag actuators and sensors into the subsystem
There are two steps to adding components to a subsystem:
- Drag actuators or sensors from the palette into the subsystem as required.
- Give the actuator or sensor a meaningful name
- Edit the properties such as module numbers and channel numbers for each item in the subsystem.
RobotBuilder will automatically use incrementing channel numbers for each module on the robot. If you haven't yet wired the robot you can just let RobotBuilder assign unique channel numbers for each sensor or actuator and wire the robot according to the generating wiring table.
This just creates the subsystem in RobotBuilder, and will subsequently generate skeleton code for the subsystem. To make it actually operate your robot please refer to: Writing the code for a subsystem in Java or Writing the code for a subsystem in C++.










0 Report Errors
Use this form to report any errors with the documentation. For help with WPILib, please use the FIRST Forums at http://forums.usfirst.org For reporting WPILib bugs, please submit an issue on GitHub at https://github.com/wpilibsuite/allwpilib/issues/new