From 0d215d8d1dd4575461ded27e05d356ff3df1198c Mon Sep 17 00:00:00 2001 From: Gold856 <117957790+Gold856@users.noreply.github.com> Date: Wed, 18 Sep 2024 01:26:22 -0400 Subject: [PATCH] More fixes --- .../edu/wpi/first/wpilibj2/command/Command.java | 2 +- .../native/cpp/frc2/command/button/Trigger.cpp | 14 +++++++------- .../main/native/include/frc2/command/CommandPtr.h | 3 +++ .../cpp/frc2/command/CommandSendableButtonTest.cpp | 2 +- .../examples/DriveDistanceOffboard/cpp/Robot.cpp | 2 +- .../cpp/examples/HatchbotTraditional/cpp/Robot.cpp | 2 +- .../MecanumControllerCommand/cpp/Robot.cpp | 2 +- .../examples/RapidReactCommandBot/cpp/Robot.cpp | 2 +- .../examples/SwerveControllerCommand/cpp/Robot.cpp | 2 +- .../main/cpp/examples/SysIdRoutine/cpp/Robot.cpp | 2 +- .../main/cpp/templates/commandbased/cpp/Robot.cpp | 2 +- .../templates/commandbasedskeleton/cpp/Robot.cpp | 2 +- 12 files changed, 20 insertions(+), 17 deletions(-) diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java index 9367a80f80c..d46ce313c66 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/Command.java @@ -615,7 +615,7 @@ public void initSendable(SendableBuilder builder) { value -> { if (value) { if (!isScheduled()) { - schedule(); + CommandScheduler.getInstance().schedule(this); } } else { if (isScheduled()) { diff --git a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/Trigger.cpp b/wpilibNewCommands/src/main/native/cpp/frc2/command/button/Trigger.cpp index 68305967d51..6afdbb2b2cc 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/Trigger.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/button/Trigger.cpp @@ -38,7 +38,7 @@ Trigger Trigger::OnChange(Command* command) { Trigger Trigger::OnChange(CommandPtr&& command) { AddBinding([command = std::move(command)](bool previous, bool current) { if (previous != current) { - command.Schedule(); + frc2::CommandScheduler::GetInstance().Schedule(command); } }); return *this; @@ -56,7 +56,7 @@ Trigger Trigger::OnTrue(Command* command) { Trigger Trigger::OnTrue(CommandPtr&& command) { AddBinding([command = std::move(command)](bool previous, bool current) { if (!previous && current) { - command.Schedule(); + frc2::CommandScheduler::GetInstance().Schedule(command); } }); return *this; @@ -74,7 +74,7 @@ Trigger Trigger::OnFalse(Command* command) { Trigger Trigger::OnFalse(CommandPtr&& command) { AddBinding([command = std::move(command)](bool previous, bool current) { if (previous && !current) { - command.Schedule(); + frc2::CommandScheduler::GetInstance().Schedule(command); } }); return *this; @@ -94,7 +94,7 @@ Trigger Trigger::WhileTrue(Command* command) { Trigger Trigger::WhileTrue(CommandPtr&& command) { AddBinding([command = std::move(command)](bool previous, bool current) { if (!previous && current) { - command.Schedule(); + frc2::CommandScheduler::GetInstance().Schedule(command); } else if (previous && !current) { command.Cancel(); } @@ -116,7 +116,7 @@ Trigger Trigger::WhileFalse(Command* command) { Trigger Trigger::WhileFalse(CommandPtr&& command) { AddBinding([command = std::move(command)](bool previous, bool current) { if (!previous && current) { - command.Schedule(); + frc2::CommandScheduler::GetInstance().Schedule(command); } else if (previous && !current) { command.Cancel(); } @@ -143,7 +143,7 @@ Trigger Trigger::ToggleOnTrue(CommandPtr&& command) { if (command.IsScheduled()) { command.Cancel(); } else { - command.Schedule(); + frc2::CommandScheduler::GetInstance().Schedule(command); } } }); @@ -169,7 +169,7 @@ Trigger Trigger::ToggleOnFalse(CommandPtr&& command) { if (command.IsScheduled()) { command.Cancel(); } else { - command.Schedule(); + frc2::CommandScheduler::GetInstance().Schedule(command); } } }); diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h b/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h index 81a255a9a73..7c4947863e3 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h @@ -296,7 +296,10 @@ class CommandPtr final { /** * Schedules this command. + * + * @deprecated Use CommandScheduler::GetInstance().Schedule() instead */ + [[deprecated("Use CommandScheduler::GetInstance().Schedule() instead.")]] void Schedule() const&; // Prevent calls on a temporary, as the returned pointer would be invalid diff --git a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandSendableButtonTest.cpp b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandSendableButtonTest.cpp index 1e97f7cfc55..1f2c8446b17 100644 --- a/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandSendableButtonTest.cpp +++ b/wpilibNewCommands/src/test/native/cpp/frc2/command/CommandSendableButtonTest.cpp @@ -82,7 +82,7 @@ TEST_F(CommandSendableButtonTest, falseAndNotScheduledNoOp) { TEST_F(CommandSendableButtonTest, falseAndScheduledCancel) { // Scheduled and false -> cancel - frc2::CommandScheduler::GetInstance().Schedule(m_command); + frc2::CommandScheduler::GetInstance().Schedule(m_command.value()); GetScheduler().Run(); frc::SmartDashboard::UpdateValues(); EXPECT_TRUE(m_command->IsScheduled()); diff --git a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/Robot.cpp index 08952dfed1d..18be09af708 100644 --- a/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/DriveDistanceOffboard/cpp/Robot.cpp @@ -38,7 +38,7 @@ void Robot::AutonomousInit() { m_autonomousCommand = m_container.GetAutonomousCommand(); if (m_autonomousCommand) { - frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand); + frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value()); } } diff --git a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/Robot.cpp index d731edc1c90..fdd7a4941fc 100644 --- a/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/HatchbotTraditional/cpp/Robot.cpp @@ -47,7 +47,7 @@ void Robot::AutonomousInit() { m_autonomousCommand = m_container.GetAutonomousCommand(); if (m_autonomousCommand != nullptr) { - m_autonomousCommand->Schedule(); + frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand); } } diff --git a/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/cpp/Robot.cpp index 08952dfed1d..18be09af708 100644 --- a/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/MecanumControllerCommand/cpp/Robot.cpp @@ -38,7 +38,7 @@ void Robot::AutonomousInit() { m_autonomousCommand = m_container.GetAutonomousCommand(); if (m_autonomousCommand) { - frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand); + frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value()); } } diff --git a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/Robot.cpp index 53b470bf35d..51c6813ac52 100644 --- a/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/RapidReactCommandBot/cpp/Robot.cpp @@ -26,7 +26,7 @@ void Robot::AutonomousInit() { m_autonomousCommand = m_robot.GetAutonomousCommand(); if (m_autonomousCommand) { - frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand); + frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value()); } } diff --git a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/Robot.cpp index 08952dfed1d..18be09af708 100644 --- a/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SwerveControllerCommand/cpp/Robot.cpp @@ -38,7 +38,7 @@ void Robot::AutonomousInit() { m_autonomousCommand = m_container.GetAutonomousCommand(); if (m_autonomousCommand) { - frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand); + frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value()); } } diff --git a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/Robot.cpp index 494e73b9988..5666887c981 100644 --- a/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SysIdRoutine/cpp/Robot.cpp @@ -22,7 +22,7 @@ void Robot::AutonomousInit() { m_autonomousCommand = m_container.GetAutonomousCommand(); if (m_autonomousCommand) { - frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand); + frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value()); } } diff --git a/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/Robot.cpp index 6902d0217af..14844d189fc 100644 --- a/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/templates/commandbased/cpp/Robot.cpp @@ -37,7 +37,7 @@ void Robot::AutonomousInit() { m_autonomousCommand = m_container.GetAutonomousCommand(); if (m_autonomousCommand) { - frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand); + frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value()); } } diff --git a/wpilibcExamples/src/main/cpp/templates/commandbasedskeleton/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/templates/commandbasedskeleton/cpp/Robot.cpp index 494e73b9988..5666887c981 100644 --- a/wpilibcExamples/src/main/cpp/templates/commandbasedskeleton/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/templates/commandbasedskeleton/cpp/Robot.cpp @@ -22,7 +22,7 @@ void Robot::AutonomousInit() { m_autonomousCommand = m_container.GetAutonomousCommand(); if (m_autonomousCommand) { - frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand); + frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value()); } }