-
Notifications
You must be signed in to change notification settings - Fork 0
FlashLib in FRC
From the start, FlashLib was meant to support FRC teams, but was never intended to replace WPILib. We wanted to provided an extended and more enhanced support and development enviornment allowing users to easily create advanced algorithms and robots.
FlashLib was built with the concept of abstraction, allowing user to use it anywhere including in FRC. We already provided implementations of the library for FRC, but it is still possible to provide custom implementations.
To allow teams to use both WPILib and FlashLib, we designed the library to function in individual parts, so that it is possible to use only a part of FlashLib. That means that systems provided by both libraries won't intersect, but rather allow users to choose which of the two they wish to use.
Systems like the Robot Scheduling System and the Communication Management System are available in both libraries with different implementations, each with its own advantages and disadvantages. It is advised to try each of the systems in order to decide which is preferable for you.
There are 2 basic types of initializations of FlashLib for FRC:
- Full: When using the full version of FlashLib, all FRC features are available and certain WPILib systems are replaced. This is the prefered mode when you wish to take full advantage of FlashLib. But the WPILib scheduling system should not be used.
- Limited: When using the limited version of FlashLib, it is necessary to manually initialize wanted features in FlashLib. This allows the possible to choose what to initialize. This is the prefered mode for those who prefer WPILib bu want several tools from FlashLib.
FlashLib does not provide any input-output capabilities with electronic components for the RoboRIO, meaning it is still necessary to use WPILib. However, to allow integration with motion algorithms and systems in FlashLib, wrappers are available. Use those wrapper if you wish to take advantage of built-in algorithms and systems.
Both FlashLib and WPILib provide dashboard for operators: Flashboard and SmartDashboard respectively. When initializing FlashLib, it is possible to select whether you wish to use Flashboard. So it is very simple to decide which dashboard you wish to use, but using both is always possible.
While FlashLib provides the Communication Management System, WPILib has its NetworkTables. The two do not intersect which means they both can be used at the same time. It is even possible to convert FlashLib Sendables to WPILib Tables.
When initializing FlashLib, it is possible to decide whether to use the Scheduling system. Since systems from both libraries provide similar service, choosing which is based on comfort and performance. Although it is possible to convert between Action and Command, convering between System and Subsystem cannot be done. Using both Schedulers is not a advisable and you should choose which is better for you before starting to write your program.
Using FlashLib in an FRC Java Project in very simple and there are many ways to use the library.
First it is required to build the library (or use downloaded binaries) and copy flashlib.jar
to the wpilib user libraries folder under your user/wpilib/user/java/lib
. Once there, FlashLib will be automatically imported when a new project is created and automatically deployed to the RoboRio with the robot project.
There are many ways to use FlashLib with your robot project, so before creating the project, it is necessary to choose how you want to use FlashLib.
To fully use FlashLib, ignoring most WPILib features, follow the next steps:
- Create a
Sample Robot Project
- Delete the contents of the created
Robot
class - Extend
FlashRio
instead ofSampleRobot
FlashRio
is the base for an iterative robot fully using FlashLib. The base automatically initializes FlashLib according to given parameters and runs a control loop similar to IterativeRobot
provided by WPILib. When extending this class you must implement the following methods:
- preInit: This method is called before initializing FlashLib and receives an instance of
RobotInitializer
. This class holds variables which provide data about the initialization of FlashLib. - initRobot: called after FlashLib was initialized. Here you should initialize your robot and systems.
- disabledInit: called when the control loop enters
disabled
mode. Use to initialize your robot systems todisabled
mode. - disabledPeriodic: called while the robot is in
disabled
mode every ~10 ms after the scheduler has run. - teleopInit: called when the control loop enters
teleop
mode. Use to initialize your robot systems toteleop
mode. - teleopPeriodic: called while the robot is in
teleop
mode every ~10 ms after the scheduler has run. - autonomousInit: called when the control loop enters
autonomous
mode. Use to initialize your robot systems toautonomous
mode. - autonomousPeriodic: called while the robot is in
autonomous
mode every ~10 ms after the scheduler has run. - testInit: called when the control loop enters
test
mode. Use to initialize your robot systems totest
mode. - testPeriodic: called while the robot is in
test
mode every ~10 ms after the scheduler has run.
Each time the robot loop has switched control mode (disabled, autonomous, teleop, test), the scheduler removes all Actions
currently executing.
An important feature of FlashRio
is power tracking. While running, the robot loop tracks the power status in the PDP. If the voltage is too low, the current draw is too high or a brownout is detected, data will be logged into a power log allowing users to track power issues. It is possible to set the voltage and current draw thresholds in preInit
. It is also possible to set whether or not to track power problems in in preInit
.
For examples on using FlashRio
please refer to the examples folder.