Standard Units and Measurements
All code must use the following SI units:
- Rotations-per-minute (RPM)
All irregular uses of units are written in JavaDocs. Here are explanations of when we don't follow our standard use of units.
Due to the fact that the Raider Robotics build, design, and mechanical teams use Imperial measurements, we must sometimes include them in our code. When dealing with robot measurements such as:
- Chassis size
- Wheel radius
these measurements must be written in the
RobotConstants (sometimes called
RobotConfig) file, and converted in that file. For example, if I had the radius of a wheel, and I was putting it in our code, I would add the following to
public static final double WHEEL_RADIUS = Units.inchesToMeters(3.0);
This way, the only file that knows about imperial measurements is
RobotConstants, and everything else sees the converted measurement in meters.
Everything in our code is measured in milliseconds, with the only exception being ramp-rate measurements. These are measured in seconds.
While the team works in degrees, and all our sensors work in degrees, our coordinate system uses radians. We solve this by using the WPILib's Rotation2d object:
// Create an angle from degrees Rotation2d myAngle = Rotation2d.fromDegrees(360.0); // Get the angle as degrees double myDegrees = myAngle.toDegrees();