diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/MecanumControllerCommand.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/MecanumControllerCommand.cpp index c521f8b8ff..96824cc171 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/MecanumControllerCommand.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/MecanumControllerCommand.cpp @@ -81,9 +81,6 @@ MecanumControllerCommand::MecanumControllerCommand( m_outputVolts(std::move(output)), m_usePID(true) { AddRequirements(requirements); - m_desiredRotation = [&] { - return m_trajectory.States().back().pose.Rotation(); - }; } MecanumControllerCommand::MecanumControllerCommand( @@ -158,9 +155,6 @@ MecanumControllerCommand::MecanumControllerCommand( m_outputVolts(std::move(output)), m_usePID(true) { AddRequirements(requirements); - m_desiredRotation = [&] { - return m_trajectory.States().back().pose.Rotation(); - }; } MecanumControllerCommand::MecanumControllerCommand( @@ -203,9 +197,6 @@ MecanumControllerCommand::MecanumControllerCommand( m_outputVel(std::move(output)), m_usePID(false) { AddRequirements(requirements); - m_desiredRotation = [&] { - return m_trajectory.States().back().pose.Rotation(); - }; } MecanumControllerCommand::MecanumControllerCommand( @@ -248,12 +239,12 @@ MecanumControllerCommand::MecanumControllerCommand( m_outputVel(std::move(output)), m_usePID(false) { AddRequirements(requirements); - m_desiredRotation = [&] { - return m_trajectory.States().back().pose.Rotation(); - }; } void MecanumControllerCommand::Initialize() { + m_desiredRotation = [&] { + return m_trajectory.States().back().pose.Rotation(); + }; m_prevTime = 0_s; auto initialState = m_trajectory.Sample(0_s); diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/SwerveControllerCommand.inc b/wpilibNewCommands/src/main/native/include/frc2/command/SwerveControllerCommand.inc index 1f65b788f1..ba63b9c31b 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/SwerveControllerCommand.inc +++ b/wpilibNewCommands/src/main/native/include/frc2/command/SwerveControllerCommand.inc @@ -43,9 +43,6 @@ SwerveControllerCommand::SwerveControllerCommand( m_controller(xController, yController, thetaController), m_outputStates(output) { this->AddRequirements(requirements); - m_desiredRotation = [&] { - return m_trajectory.States().back().pose.Rotation(); - }; } template @@ -80,13 +77,13 @@ SwerveControllerCommand::SwerveControllerCommand( m_controller(xController, yController, thetaController), m_outputStates(output) { this->AddRequirements(requirements); - m_desiredRotation = [&] { - return m_trajectory.States().back().pose.Rotation(); - }; } template void SwerveControllerCommand::Initialize() { + m_desiredRotation = [&] { + return m_trajectory.States().back().pose.Rotation(); + }; m_timer.Reset(); m_timer.Start(); } diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/RobotContainer.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/RobotContainer.cpp index f958cde4d8..a35314e23b 100644 --- a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/RobotContainer.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/RobotContainer.cpp @@ -86,7 +86,7 @@ frc2::Command* RobotContainer::GetAutonomousCommand() { // no auto return new frc2::SequentialCommandGroup( - std::move(swerveControllerCommand), std::move(swerveControllerCommand), + std::move(swerveControllerCommand), frc2::InstantCommand( [this]() { m_drive.Drive(units::meters_per_second_t(0),