RobotMap Conventions - Team1100/CodeExamples GitHub Wiki
X Marks the Spot
Sorry, no treasure here. The RobotMap is a mapping that contains all of the port numbers of the sensors, actuators, and every other part of the robot we program. This mapping wires every port number into a variable name. This provides flexibility when changing wiring, makes checking the wiring easier and significantly reduces the number of magic numbers floating around. To prove that yes, the RobotMap is important, an example is provided.
Here is a function for our famed and dangerous black hole shooter, which includes constants from the RobotMap.
public GravityMultiplier(){
blackHoleWinchMotor = new CANTalon(RobotMap.G_BLACK_HOLE_WINCH_MOTOR);
eventHorizonRotator = new CANTalon(RobotMap.G_EVENT_HORIZON_ROTATOR);
unSpaghettifier = new DoubleSolenoid(RobotMap.G_PCM,RobotMap.G_SPAGHETTI_A,RobotMap.G_SPAGHETTI_B);
deathSensor = new DigitalInput(RobotMap.G_DEATH_SENSOR);
}
It is easy to at least understand what each part is, even if you don't actually know what G_SPAGHETTI_B is. Here is the same code, without the RobotMap constants.
public GravityMultiplier(){
blackHoleWinchMotor = new CANTalon(78);
eventHorizonRotator = new CANTalon(5);
unSpaghettifier = new DoubleSolenoid(0, 24, 13);
deathSensor = new DigitalInput(1);
}
With all of these magic numbers, it is very confusing trying to understand what to which the code is referring.
Remember kids, RobotMap = love, RobotMap = life