Important
Due to the large number of breaking and substantial changes between 2021 and 2022, it is advised that existing teams thoroughly read this document!
A number of improvements have been made to FRC|reg| Control System software for 2022. This article will describe and provide a brief overview of the new changes and features as well as a more complete changelog for Java/C++ WPILib changes. This document only includes the most relevant changes for end users, the full list of changes can be viewed on the various WPILib GitHub repositories. WPILib recognizes that some of these changes may cause teams issues in the short term upgrading. We expect it to pay off over the long term as we better improve the internals of WPILib.
Due to internal GradleRIO changes, it is necessary to update previous years projects. After :doc:`Installing WPILib for 2022 </docs/zero-to-robot/step-2/wpilib-setup>`, any 2020 or 2021 projects must be :doc:`imported </docs/software/vscode-overview/importing-gradle-project>` to be compatible.
It's recommended to also review the list of :doc:`known issues <known-issues>`.
These changes contain some of the major changes to the library that it's important for the user to recognize. This does not include all of the breaking changes, see the other sections of this document for more changes.
- Drive class functions such as
DifferentialDrive
andMecanumDrive
no longer invert the right side by default. Please usesetInverted
on your motor controllers to invert the right side to maintain the same behavior - Old Command-Based has been removed from the list of new templates in VS Code. Please migrate to the new Command-Based library. The Old Command Based remains available to support existing code.
- IterativeRobot has been removed. Please use the TimedRobot template instead
- Rewrite :doc:`Mechanism2d </docs/software/dashboards/glass/mech2d-widget>` to utilize NetworkTables
- Improved the error message when a program crashes
- Added support for DMA to Java
- Added
TimesliceRobot
project template. This allows users to timeslice schedule periodic functions - Added C++ TankDrive example
- Added
PS4Controller
controller class - Added better message for when an I2C port is out of range
- Added
Debouncer
(Java, C++) class. This helps with filtering rising and falling edges when dealing with boolean values - Added
PneumaticHub
class for use with the REV Pneumatic Hub - GenericHID has been updated to static functions to use for non-defined controller types.
XboxController
has migrated away from taking arguments in functions and instead has functions with no arguments. An example conversion is below:controller.getTriggerAxis(GenericHID.Hand.kLeft)
->controller.getLeftTriggerAxis()
controller.getX(GenericHID.Hand.kLeft)
->controller.getLeftX()
getInstance()
functions inCameraServer
,DriverStation
,LiveWindow
,Preferences
,SendableRegistry
, have been deprecated and replaced with static functionsTimer::HasPeriodPassed()
andTimer.hasPeriodPassed()
have been deprecated. UseAdvanceIfElapsed()
instead- Several new classes have been added to enable simpler access to
Counter
:ExternalDirectionCounter
(Java/ C++),Tachometer
(Java/ C++), andUpDownCounter
(Java/ C++) DutyCycleEncoder
: add support for setting duty cycle range- Added
ADIS16448_IMU
andADIS16470_IMU
classes. - Added
BangBangController
class (Java, C++) for maximally-aggressive velocity control of high-inertia mechanisms, which is useful for flywheel shooters.
PDP
is nowPowerDistribution
- Various
PCM
related classes (Solenoid, Compressor) now require aPneumaticsModuleType
to support either the CTRE Pneumatics Control Module or REV Pneumatic Hub. Vendor specific methods have been moved to thePneumaticsControlModule
orPneumaticHub
classes - Sendable has been broken up into NetworkTables components (called NTSendable*,
nt
namespace) and non-NetworkTables components (moved to wpiutil,wpi
namespace). This will make it easier for vendors and external libraries to integrate Sendable InterruptableSendableBase
has been broken up intoAsynchronousInterrupt
&SynchronousInterrupt
. Rather then a class, likeDigitalInput
extendingInterruptableSendableBase
and all interrupt methods being accessed through theDigitalInput
, teams should instead constructAsynchronousInterrupt
orSynchronousInterrupt
, and pass it theDigitalSource
(e.g.DigitalInput
).- C++:
DriverStation.ReportWarning
andDriverStation.ReportError
have been removed. UseFRC_ReportError
infrc\Errors.h
header. Status offrc::err::Error
can be used for Errors andfrc::warn::Warning
can be used for warnings. SpeedController
has been renamed toMotorController
- Various portions of the API still refers to
SpeedController
for backwards compatibility. Users should passMotorController
instead
- Various portions of the API still refers to
- Several duplicate
SpeedController
methods have been removed. Useset
instead ofsetSpeed
. Usedisable
instead ofsetDisable
. Several low level methods have been removed: position, bounds, periodMultiplier, zeroLatch, and raw methods. Use thePWM
class directly if this level of control is needed. - Various DriverStation In[Mode] functions has been renamed (IE:
InDisabled
->inDisabled
) Normalize
has been renamed toDesaturate
inDifferentialDrive
,MecanumDrive
,KilloughDrive
,MecanumDriveWheelSpeeds
,DifferentialDriveWheelSpeeds
.NormalizeWheelSpeeds
has been renamed toDesaturateWheelSpeeds
inSwerveDriveKinematics
.- Deprecated
wpilibj.cameraserver
has been removed. Usecameraserver
instead - Deprecated
RobotDrive
has been removed. UseDifferentialDrive
instead - Deprecated
GearTooth
has been removed. Use theCounter
class instead - C++: Deprecated
WPILib.h
has been removed. Please only include what you need - C++:
wpi::StringRef
is replaced withstd::string_view
. This is a drop in replacement in most cases - C++:
wpi::ArrayRef
is replaced withwpi::span
. This is a modified backport of the C++20std::span
- C++:
wpi::Twine
is replaced with fmtlib. It has more features and is standard in C++20 - C++:
wpi::sys::path
is replaced withfs::path
from#include <wpi/fs.h>
which is based onstd::filesystem
- C++:
frc::filesystem
methods have been simplified to returnstd::string
, rather then using a pointer parameter - C++:
wpi::math
is replaced withwpi::numbers
which is based on C++20std::numbers
. - C++: Support for
std::cout
was removed from units because<iostream>
has significant compile-time overhead. Use fmtlib instead, an analog for C++20'sstd::format()
(e.g.,fmt::print("{}", 2_m)
). The units headers automatically include fmtlib. If you still want to usestd::cout
, callvalue()
on the variable being printed (e.g.,std::cout << velocity.value()
). - C++: Various classes have migrated to use :doc:`units </docs/software/basic-programming/cpp-units>`:
Ultrasonic
,CommandScheduler
,CommandState
,WaitUntilCommand
,MecanumControllerCommand
,RamseteCommand
,SwerveControllerCommand
,TrapezoidProfileCommand
,WaitCommand
,Counter
,CounterBase
,DriverStation
,Encoder
,InterruptableSensorBase
,MotorSafety
,Notifier
,SPI
,SerialPort
,SlewRateLimiter
,Solenoid
,Timer
,Watchdog
, and Old Commands:Command
,CommandGroup
,CommandGroupEntry
,TimedCommand
,WaitCommand
,WaitForChildren
,WaitUntilCommand
- The old
PIDController
,PIDSource
andPIDOutput
classes have been moved from the main library to the Old Commands Vendordep. Wrapper classes in the pidwrappers package have been added for PIDSource and PIDoutput support for WPILib classes, also in the Old Commands Vendordep. These classes have been deprecated since 2020. The new PID Controller inedu.wpi.first.math.controller
for Java andfrc2
for C++ is the recommended replacement. Preferences
putX methods (e.g. putDouble) have been deprecated and replaced with setX methods for consistency with the rest of WPILib API.
We have committed to several organizational renames that will allow us greater flexible with new classes in the future. The VS Code project importer will update existing projects to use the new packages/headers.
- Several packages moved from
wpilibj
tomath
:controller
,estimator
,geometry
,kinematics
,math
,spline
,system
,trajectory
wpiutil.math
was moved tomath
wpiutil
is nowutil
SlewRateLimiter
,LinearFilter
, andMedianFilter
now live inmath.filters
, along with the newly-addedDebouncer
.Timer
has moved fromfrc2
tofrc
- Motor controllers (
VictorSPX
,PWMSparkMax
, etc) have been moved to amotorcontrol
package. edu.wpi.cscore
has moved toedu.wpi.first.cscore
- Uses multi-file
json
save formats instead ofini
and supports loading/saving the workspace; when started from the VS Code tool menu, these default to using the project directory for saving rather than the system-global location
- Add widget for
Field2d
- Add icons to widget layouts
- Add titles for widgets
- Show exit save prompt only if not saved
- Use system menubar
- Add tab clear confirmation
- Save widget titles display mode preference
- Fix: CameraServer streams
- Fix: Shuffleboard not starting on Windows N. Media Feature Pack is still needed for camera support.
- No new changes
- Uses multi-file
json
save formats instead ofini
and supports loading/saving the workspace; when started from the VS Code tool menu, these default to using the project directory for saving rather than the system-global location
We have made a new tool for machine learning in the FIRST Robotics Competition. Axon allows users to view and create datasets, train machine learning models, test your models within the browser-based GUI, and export them for use on a Raspberry Pi. Detecting complex objects (such as hatch panels and other robots) has never been easier and an end-to-end user guide is available in the :doc:`WPILib docs </docs/software/wpilib-tools/axon/index>`. Axon provides the functionality to train machine learning models to recognize any object you want (defined in a homemade dataset), or generic objects such as cats, airplanes, and hot dogs.
Axon is a replacement for the previous AWS-based Jupyter Notebook solution released in the 2019 season. Axon has a smooth installation and user experience overall, and a much more friendly GUI for beginners and experts alike.
Running machine learning models on the WPILib Raspberry Pi image has never been easier either; the new Python script for the Pi features time-synchronous NetworkTables data streaming, as well as a better quality live inference MJPEG stream.
- No new changes
- Gradle has been updated to version 7.3.2
- Internals of GradleRIO have been updated to be easier to read, more maintainable and easier for advanced teams to modify.
- Deployment is more customizable
- The supported OpenCV version has been bumped to OpenCV4
OutlineViewer has been updated to be C++ based using the ImGui library. This makes OutlineViewer more maintainable and performant.
Important
The Java version of OutlineViewer is discontinued and is no longer supported!
- Simplified installation choices
- Visual Studio Code has been updated to 1.63.2
- Updated Java and C++ language extensions
- Fix Linux desktop icon permissions
- Add year to tools shortcuts name
- Handle issues with JDK running and UAC canceled
Important
The project importer will only import 2020/2021 projects!
- Project Importer has been updated for the 2022 season. The project importer will attempt update the imported code, but manual changes may still be necessary due to the complexity of the breaking changes this year.
- Remove Eclipse Project Importer
- Fix chcp not found warning during simulation on Windows
- Add additional information to the project information command display
Important
Due to project file changes, Robotbuilder will not import yaml save files from 2021 or earlier.
- Update to compile with WPILib 2022 (remove RobotDrive and GearTooth), update PID Controllers, and pneumatics
- Improve type detection to detect changes in certain C++ types that were not previously detected as changes
- Add project setting to enable or disable desktop support
- Fix Java export of DoubleSolenoid, RobotDrive4, MecanumDrive, and Killough drive to avoid extra local copy
- Fix C++ export of ConditionalCommand
- Don’t validate timeout parameters that are less than 0
:doc:`SysId </docs/software/pathplanning/system-identification/index>` is a fully featured system identification utility that supersedes frc-characterization. It features an easy-to-use interface, advanced graphing analytics, Romi integration and other cool features!.
Important
frc-characterization is discontinued and is no longer supported!
- A Romi Library has been created to contain several helper classes that are a part of the
RomiReference
example. Romi Vendordep.