From 1a1552ff2cc448ea1bfdd9de987eb57bf944c46c 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 +- .../src/main/cpp/examples/SysId/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 35b23cb8365..27a90430cd1 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 @@ -596,7 +596,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 6ed138bcced..c654b2cd3c1 100644 --- a/wpilibNewCommands/src/main/native/cpp/frc2/command/button/Trigger.cpp +++ b/wpilibNewCommands/src/main/native/cpp/frc2/command/button/Trigger.cpp @@ -35,7 +35,7 @@ Trigger Trigger::OnChange(CommandPtr&& command) { bool current = condition(); if (previous != current) { - command.Schedule(); + frc2::CommandScheduler::GetInstance().Schedule(command); } previous = current; @@ -63,7 +63,7 @@ Trigger Trigger::OnTrue(CommandPtr&& command) { bool current = condition(); if (!previous && current) { - command.Schedule(); + frc2::CommandScheduler::GetInstance().Schedule(command); } previous = current; @@ -91,7 +91,7 @@ Trigger Trigger::OnFalse(CommandPtr&& command) { bool current = condition(); if (previous && !current) { - command.Schedule(); + frc2::CommandScheduler::GetInstance().Schedule(command); } previous = current; @@ -121,7 +121,7 @@ Trigger Trigger::WhileTrue(CommandPtr&& command) { bool current = condition(); if (!previous && current) { - command.Schedule(); + frc2::CommandScheduler::GetInstance().Schedule(command); } else if (previous && !current) { command.Cancel(); } @@ -153,7 +153,7 @@ Trigger Trigger::WhileFalse(CommandPtr&& command) { bool current = condition(); if (!previous && current) { - command.Schedule(); + frc2::CommandScheduler::GetInstance().Schedule(command); } else if (previous && !current) { command.Cancel(); } @@ -190,7 +190,7 @@ Trigger Trigger::ToggleOnTrue(CommandPtr&& command) { if (command.IsScheduled()) { command.Cancel(); } else { - command.Schedule(); + frc2::CommandScheduler::GetInstance().Schedule(command); } } @@ -226,7 +226,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 e2f534f7547..2ce3e1cdd0b 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/CommandPtr.h @@ -286,7 +286,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/SysId/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/SysId/cpp/Robot.cpp index 494e73b9988..5666887c981 100644 --- a/wpilibcExamples/src/main/cpp/examples/SysId/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/SysId/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()); } }