Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gold856 committed Oct 12, 2024
1 parent cb5b762 commit 1a1552f
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ public void initSendable(SendableBuilder builder) {
value -> {
if (value) {
if (!isScheduled()) {
schedule();
CommandScheduler.getInstance().schedule(this);
}
} else {
if (isScheduled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Trigger Trigger::OnChange(CommandPtr&& command) {
bool current = condition();

if (previous != current) {
command.Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}

previous = current;
Expand Down Expand Up @@ -63,7 +63,7 @@ Trigger Trigger::OnTrue(CommandPtr&& command) {
bool current = condition();

if (!previous && current) {
command.Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}

previous = current;
Expand Down Expand Up @@ -91,7 +91,7 @@ Trigger Trigger::OnFalse(CommandPtr&& command) {
bool current = condition();

if (previous && !current) {
command.Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}

previous = current;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -190,7 +190,7 @@ Trigger Trigger::ToggleOnTrue(CommandPtr&& command) {
if (command.IsScheduled()) {
command.Cancel();
} else {
command.Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}
}

Expand Down Expand Up @@ -226,7 +226,7 @@ Trigger Trigger::ToggleOnFalse(CommandPtr&& command) {
if (command.IsScheduled()) {
command.Cancel();
} else {
command.Schedule();
frc2::CommandScheduler::GetInstance().Schedule(command);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
2 changes: 1 addition & 1 deletion wpilibcExamples/src/main/cpp/examples/SysId/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down

0 comments on commit 1a1552f

Please sign in to comment.