This is a repo containing the current, most up-to-date codebase for FRC Team 4817. This codebase is used as a barebones foundation when programming competition robots.
The following libraries need to be downloaded, extracted, and installed
The following libraries are the JSON files for online installation
ODN_Gyro
is the basic gyro interface which all gyros implement to allow easy switiching between different gyros in code
ODN_AHRS
implementsODN_Gyro
for the navX MXP sensorODN_Pigeon
implementsODN_Gyro
for the PigeonIMU sensor- Constructor takes the CAN id of the PigeonIMU
- If you do not have a gyro, but a subsystem requires one in the constructor, use
ODN_NullGyro
- Be careful that you don't do anything that would require an actual gyro in this situation
Rotation2d getYaw()
gets the rotation of the robot, positive being clockwise.
ODN_MotorController
is the basic motor controller interface which all motor controllers implement to allow easy switching between different motor controllers in code
ODN_SparkMax
implementsODN_MotorController
for the SparkMax connected using the CAN bus- Constructor second parameter is either
ODN_SparkMax.MotorType.brushed
for brushed motor configuration orODN_SparkMax.MotorType.brushless
for brushless motor configuration or
- Constructor second parameter is either
ODN_TalonFX
implementsODN_MotorController
for the TalonFX (Falcon 500)ODN_TalonSRX
implementsODN_MotorController
for the TalonSRXODN_VictorSPX
implementsODN_MotorController
for the VictorSPX
Constructors for all the motor controllers takes the CAN ID of the motor controller
void setInverted(boolean inverted)
is used to reverse the direction of the motor controllerEncoder getEncoder()
is used to get the integrated encoder from the motor controller
ODN_Encoder
is the basic gyro interface which all encoders implement to allow easy switiching between different encoder in code
-
ODN_CANCoder
implementsODN_Encoder
for the CANCoder magnetic encoder -
ODN_CANEncoder
implementsODN_Encoder
for the SparkMax integrated encoder -
ODN_TalonEncoder
implementsODN_Encoder
for a Talon (TalonSRX or TalonFX) integrated encoder -
ODN_VictorEncoder
implementsODN_Encoder
for a Victor integrated encoder -
If you do not have an encoder, but a subsystem requires one in the constructor, use
ODN_NullEncoder
- Be careful that you don't do anything that would require an actual encoder in this situation
-
void setPositionConversionFactor(double factor)
sets the factor for converting from raw encoder output to a meaurement in degrees -
void setVelocityConversionFactor(double factor)
sets the factor for converting from raw encoder velocity to a meaurement in degrees (these numbers should probably both be the same, but you do have to set both)
ODN_UltrasonicSensor
is the basic interface for ultrasonic sensors. There are two types of ultrasonic sensors in FRC, ping-response ultrasonic sensors, which use two seperate DIO pins for sending the ultrasonic signals and measuring the response. This is used in the codebase with the ODN_PingUltrasonicSensor
class. There are also analog ultrasonic sensors which return an analog voltage corresponding to the measured distance. This is used in the codebase with the ODN_AnalogUltrasonicSensor
class.
The only function of this class is double getDistanceInches()
which returns the distance in inches.
ODN_ColorSensor
is a class for the REV Robotics Color Sensor V3. There are two features with this sensor. Getting the sensed color with Color getColor()
, and matching a color to a set of possible colors with Color match(ColorMatch matcher)
. The color matcher object can be created with the ColorMatch ODN_ColorSensor::createMatcher(double confidence, Color... colors)
. colors
is a list of colors that you want to compare against. confidence
is a number between 0-1 which you will need to tune in order to detect when none of the given colors are present.
In frc.lib
there exists an ODN_Drivebase
class and an ODN_HolonomicDrivebase
class. Using ODN_Drivebase
allows for switching drivebases more easily in the code. However, not all drivebases are made equal. A tank drive cannot move sideways. This is what we have ODN_HolonomicDrivebase
which generalizes Swerve Drive and Mecanum Drive (but could also include Octocanum drive in the future along with other similarly abled drivebases).
Functions you may need to use from ODN_Drivebase
:
void rotate(double speed)
rotates in placevoid stop()
stops the robot in placeRotation2d getYaw()
gets the orientation of the robot (don't use this function if you are usingODN_NullGyro
for this drivebase)void resetYaw()
sets the current heading to 0 degreesvoid driveForward(double forward, double rotate)
drives the robot forward and rotates (arcade drive)void resetOdometry(Pose2d initialPose)
resets the odometry, defining the current pose to beinitialPose
(odometry only works if you have all the nessecary encoders and gyro on the drivebase, e.g. noODN_NullEncoder
orODN_NullGyro
)
Functions you may need to use from ODN_HolonomicDrivebase
:
void cartesianDriveAbsolute(double xSpeed, double ySpeed, double rotate)
drives with velocity given in cartesian coordinates field-relative- Cannot be used without a real gyro (not
ODN_NullGyro
)
- Cannot be used without a real gyro (not
void cartesianDriveRelative(double xSpeed, double ySpeed, double rotate)
drives with velocity given in cartesian coordinates robot-relativevoid polarDrive(double magnitude, Rotation2d direction, double rotate)
drives with velocity given in polar coordinates- Cannot be used without a real gyro (not
ODN_NullGyro
)
- Cannot be used without a real gyro (not
The ODN_State
interface is used for situations in which a motor needs to move itself to certain positions.
Functions you will need to use:
void setGoalLocation(double pos)
sets the goal location for the state subsystem. Units for this parameter are not specified, and will depend on afactor
constant passed into one ofODN_State
's subclasses.boolean atGoalLocation()
returns true if the subsystem has reached the set goal location.void resetPosition()
used for calibration, it sets the current position to zero.
This subsystem is for controlling the position of an arm. Look at the information for ODN_State
on how to interact with this subsystem. There are no other functions specific to this subsystem.
This subsystem is for controlling the position of an elevator. Look at the information for ODN_State
on how to interact with this subsystem. There are no other functions specific to this subsystem.
This subsystem is for playing music on the robot with Falcon motors. Remember that when falcons are playing music, they cannot be used for motion.
Functions you may need:
void loadMusic(String filename)
loads music from a file from the given filenamevoid play()
plays music. Music needs to be loaded before it can be playedvoid pause()
pauses the musicvoid stop()
stops the music
This is a wrapper subsystem for the limelight, simply for easy access to certain values.
Here are the functions you may need to use in this subsystem:
foundTarget()
returns true if the limelight has located a target, false otherwisegetOffsetHorizontal()
returns the horizontal position of the located target in degrees (or 0 if no target is located)getOffsetVertical()
returns the vertical position of the located target in degrees (or 0 if no target is located)getArea()
returns the fraction (between 0 to 1) of the camera view that is covered by the located target (or 0 if no target is located)getSkew()
returns the angle in degrees that the located target is rotated around the axis of viewing (or 0 if no target is located)setLED(boolean on)
turn the limelight lights on or offsetPipeline(int pipeNum)
choose which detection pipeline to use with the limelight
A subsystem to control a mecanum drivebase. There is no function specific to this subsystem that you would need to use. See ODN_HolonomicDrivebase
and ODN_Drivebase
for functions this subsystem has.
Literally just a subsystem with a motor controller whose speed you can set
Used when two ODN_State
subsystems need to move in unison. This should either be arms or elevators. Don't move an arm or an elevator in unison. The functions for this subsystem are the same as that of ODN_State
Subsystem to control a group of pneumatic pistons together. Only works with DoubleSolenoid
.
Functions you may need:
void toggle()
switches the direction of the pistons (forward->backwards or backwards->forwards)
A subsystem to control a swerve drivebase. There is no function specific to this subsystem that you would need to use. See ODN_HolonomicDrivebase
and ODN_Drivebase
for functions this subsystem has.
A subsystem to control a mecanum drivebase.
Functions you may need:
void tankDrive(double left, double right)
drives using the left and right speeds
You may need to add some of your own commands into this folder. Below is an explanation of the commands that are currently a part of the codebase.
This command uses an arm placed on an vertical elevator, moving the end of the arm horizontally at constant speed
This command locks the robot into only moving in an arc around a piece of reflective tape at a constant distance. This only works with ODN_HolonomicDrivebase
, so no tank drive with this command.
This command makes the robot follow a trajectory, either given with position data or as a PathPlanner path file.