From 10e04e2b1353bb02b7caa1bd90a13cea2a2b1921 Mon Sep 17 00:00:00 2001 From: Starlight220 <53231611+Starlight220@users.noreply.github.com> Date: Sun, 2 Oct 2022 16:18:43 +0300 Subject: [PATCH] [examples] FrisbeeBot: Fix reference capture (#4449) The parameter should be passed by value. --- .../HatchbotInlined/cpp/commands/ComplexAuto.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/commands/ComplexAuto.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/commands/ComplexAuto.cpp index f88850efa7..0123d9d8a7 100644 --- a/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/commands/ComplexAuto.cpp +++ b/wpilibcExamples/src/main/cpp/examples/HatchbotInlined/cpp/commands/ComplexAuto.cpp @@ -15,14 +15,14 @@ ComplexAuto::ComplexAuto(DriveSubsystem* drive, HatchSubsystem* hatch) { // Drive forward the specified distance frc2::FunctionalCommand( // Reset encoders on command start - [&] { drive->ResetEncoders(); }, + [drive] { drive->ResetEncoders(); }, // Drive forward while the command is executing - [&] { drive->ArcadeDrive(kAutoDriveSpeed, 0); }, + [drive] { drive->ArcadeDrive(kAutoDriveSpeed, 0); }, // Stop driving at the end of the command - [&](bool interrupted) { drive->ArcadeDrive(0, 0); }, + [drive](bool interrupted) { drive->ArcadeDrive(0, 0); }, // End the command when the robot's driven distance exceeds the // desired value - [&] { + [drive] { return drive->GetAverageEncoderDistance() >= kAutoDriveDistanceInches; }, @@ -34,14 +34,14 @@ ComplexAuto::ComplexAuto(DriveSubsystem* drive, HatchSubsystem* hatch) { // Drive forward the specified distance frc2::FunctionalCommand( // Reset encoders on command start - [&] { drive->ResetEncoders(); }, + [drive] { drive->ResetEncoders(); }, // Drive backward while the command is executing - [&] { drive->ArcadeDrive(-kAutoDriveSpeed, 0); }, + [drive] { drive->ArcadeDrive(-kAutoDriveSpeed, 0); }, // Stop driving at the end of the command - [&](bool interrupted) { drive->ArcadeDrive(0, 0); }, + [drive](bool interrupted) { drive->ArcadeDrive(0, 0); }, // End the command when the robot's driven distance exceeds the // desired value - [&] { + [drive] { return drive->GetAverageEncoderDistance() <= kAutoBackupDistanceInches; },