[commands] Fix C++ SysIdRoutine crashing when passed nullptr or {} (#6508)

Flattens parameter from a `std::optional<std::function<...>>` to just a `std::function<...>`.  This is a breaking change but a trivial one for teams to fix.
This commit is contained in:
Drew Williams
2024-05-01 12:09:15 -04:00
committed by GitHub
parent ae4bcefefc
commit 0afc35f336
4 changed files with 20 additions and 10 deletions

View File

@@ -39,8 +39,7 @@ class Drive : public frc2::SubsystemBase {
constants::drive::kRightEncoderReversed};
frc2::sysid::SysIdRoutine m_sysIdRoutine{
frc2::sysid::Config{std::nullopt, std::nullopt, std::nullopt,
std::nullopt},
frc2::sysid::Config{std::nullopt, std::nullopt, std::nullopt, nullptr},
frc2::sysid::Mechanism{
[this](units::volt_t driveVoltage) {
m_leftMotor.SetVoltage(driveVoltage);

View File

@@ -33,8 +33,7 @@ class Shooter : public frc2::SubsystemBase {
constants::shooter::kEncoderReversed};
frc2::sysid::SysIdRoutine m_sysIdRoutine{
frc2::sysid::Config{std::nullopt, std::nullopt, std::nullopt,
std::nullopt},
frc2::sysid::Config{std::nullopt, std::nullopt, std::nullopt, nullptr},
frc2::sysid::Mechanism{
[this](units::volt_t driveVoltage) {
m_shooterMotor.SetVoltage(driveVoltage);