Skip to content

Commit

Permalink
Update robot to use cmdptr operator bool
Browse files Browse the repository at this point in the history
  • Loading branch information
ncorrea210 committed Dec 2, 2023
1 parent 08ed91e commit f385d91
Show file tree
Hide file tree
Showing 24 changed files with 49 additions and 61 deletions.
4 changes: 2 additions & 2 deletions wpilibcExamples/src/main/cpp/examples/ArmBot/cpp/Robot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_container.GetAutonomousCommand();

if (m_autonomousCommand) {
m_autonomousCommand->Schedule();
m_autonomousCommand.Schedule();
}
}

Expand All @@ -52,7 +52,7 @@ void Robot::TeleopInit() {
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand) {
m_autonomousCommand->Cancel();
m_autonomousCommand.Cancel();
}
}

Expand Down
6 changes: 3 additions & 3 deletions wpilibcExamples/src/main/cpp/examples/ArmBot/include/Robot.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#pragma once

#include <optional>

#include <frc/TimedRobot.h>
#include <frc2/command/Command.h>
#include <frc2/command/Commands.h>


#include "RobotContainer.h"

Expand All @@ -26,7 +26,7 @@ class Robot : public frc::TimedRobot {
private:
// Have it null by default so that if testing teleop it
// doesn't have undefined behavior and potentially crash.
std::optional<frc2::CommandPtr> m_autonomousCommand;
frc2::CommandPtr m_autonomousCommand = frc2::cmd::None();

RobotContainer m_container;
};
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) {
m_autonomousCommand->Schedule();
m_autonomousCommand.Schedule();
}
}

Expand All @@ -50,7 +50,7 @@ void Robot::TeleopInit() {
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand) {
m_autonomousCommand->Cancel();
m_autonomousCommand.Cancel();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

#pragma once

#include <optional>

#include <frc/TimedRobot.h>
#include <frc2/command/Command.h>
#include <frc2/command/Commands.h>

#include "RobotContainer.h"

Expand All @@ -26,7 +25,7 @@ class Robot : public frc::TimedRobot {
private:
// Have it null by default so that if testing teleop it
// doesn't have undefined behavior and potentially crash.
std::optional<frc2::CommandPtr> m_autonomousCommand;
frc2::CommandPtr m_autonomousCommand = frc2::cmd::None();

RobotContainer m_container;
};
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) {
m_autonomousCommand->Schedule();
m_autonomousCommand.Schedule();
}
}

Expand All @@ -50,7 +50,7 @@ void Robot::TeleopInit() {
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand) {
m_autonomousCommand->Cancel();
m_autonomousCommand.Cancel();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

#pragma once

#include <optional>

#include <frc/TimedRobot.h>
#include <frc2/command/Command.h>
#include <frc2/command/Commands.h>

#include "RobotContainer.h"

Expand All @@ -26,7 +25,7 @@ class Robot : public frc::TimedRobot {
private:
// Have it null by default so that if testing teleop it
// doesn't have undefined behavior and potentially crash.
std::optional<frc2::CommandPtr> m_autonomousCommand;
frc2::CommandPtr m_autonomousCommand = frc2::cmd::None();

RobotContainer m_container;
};
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) {
m_autonomousCommand->Schedule();
m_autonomousCommand.Schedule();
}
}

Expand All @@ -50,7 +50,7 @@ void Robot::TeleopInit() {
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand) {
m_autonomousCommand->Cancel();
m_autonomousCommand.Cancel();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

#pragma once

#include <optional>

#include <frc/TimedRobot.h>
#include <frc2/command/Command.h>
#include <frc2/command/Commands.h>

#include "RobotContainer.h"

Expand All @@ -26,7 +25,7 @@ class Robot : public frc::TimedRobot {
private:
// Have it null by default so that if testing teleop it
// doesn't have undefined behavior and potentially crash.
std::optional<frc2::CommandPtr> m_autonomousCommand;
frc2::CommandPtr m_autonomousCommand = frc2::cmd::None();

RobotContainer m_container;
};
4 changes: 2 additions & 2 deletions wpilibcExamples/src/main/cpp/examples/GearsBot/cpp/Robot.cpp
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) {
m_autonomousCommand->Schedule();
m_autonomousCommand.Schedule();
}
}

Expand All @@ -50,7 +50,7 @@ void Robot::TeleopInit() {
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand) {
m_autonomousCommand->Cancel();
m_autonomousCommand.Cancel();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

#pragma once

#include <optional>

#include <frc/TimedRobot.h>
#include <frc2/command/Command.h>
#include <frc2/command/Commands.h>

#include "RobotContainer.h"

Expand All @@ -26,7 +25,7 @@ class Robot : public frc::TimedRobot {
private:
// Have it null by default so that if testing teleop it
// doesn't have undefined behavior and potentially crash.
std::optional<frc2::CommandPtr> m_autonomousCommand;
frc2::CommandPtr m_autonomousCommand = frc2::cmd::None();

RobotContainer m_container;
};
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) {
m_autonomousCommand->Schedule();
m_autonomousCommand.Schedule();
}
}

Expand All @@ -50,7 +50,7 @@ void Robot::TeleopInit() {
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand) {
m_autonomousCommand->Cancel();
m_autonomousCommand.Cancel();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

#pragma once

#include <optional>

#include <frc/TimedRobot.h>
#include <frc2/command/Command.h>
#include <frc2/command/Commands.h>

#include "RobotContainer.h"

Expand All @@ -26,7 +25,7 @@ class Robot : public frc::TimedRobot {
private:
// Have it null by default so that if testing teleop it
// doesn't have undefined behavior and potentially crash.
std::optional<frc2::CommandPtr> m_autonomousCommand;
frc2::CommandPtr m_autonomousCommand = frc2::cmd::None();

RobotContainer m_container;
};
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) {
m_autonomousCommand->Schedule();
m_autonomousCommand.Schedule();
}
}

Expand All @@ -59,7 +59,7 @@ void Robot::TeleopInit() {
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand) {
m_autonomousCommand->Cancel();
m_autonomousCommand.Cancel();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

#pragma once

#include <optional>

#include <frc/TimedRobot.h>
#include <frc2/command/Command.h>
#include <frc2/command/Commands.h>

#include "RobotContainer.h"

Expand All @@ -26,7 +25,7 @@ class Robot : public frc::TimedRobot {
private:
// Have it null by default so that if testing teleop it
// doesn't have undefined behavior and potentially crash.
std::optional<frc2::CommandPtr> m_autonomousCommand;
frc2::CommandPtr m_autonomousCommand = frc2::cmd::None();

RobotContainer m_container;
};
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) {
m_autonomousCommand->Schedule();
m_autonomousCommand.Schedule();
}
}

Expand All @@ -59,7 +59,7 @@ void Robot::TeleopInit() {
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand) {
m_autonomousCommand->Cancel();
m_autonomousCommand.Cancel();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

#pragma once

#include <optional>

#include <frc/TimedRobot.h>
#include <frc2/command/Command.h>
#include <frc2/command/Commands.h>

#include "RobotContainer.h"

Expand All @@ -26,7 +25,7 @@ class Robot : public frc::TimedRobot {
private:
// Have it null by default so that if testing teleop it
// doesn't have undefined behavior and potentially crash.
std::optional<frc2::CommandPtr> m_autonomousCommand;
frc2::CommandPtr m_autonomousCommand = frc2::cmd::None();

RobotContainer m_container;
};
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) {
m_autonomousCommand->Schedule();
m_autonomousCommand.Schedule();
}
}

Expand All @@ -50,7 +50,7 @@ void Robot::TeleopInit() {
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand) {
m_autonomousCommand->Cancel();
m_autonomousCommand.Cancel();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

#pragma once

#include <optional>

#include <frc/TimedRobot.h>
#include <frc2/command/Command.h>
#include <frc2/command/Commands.h>

#include "RobotContainer.h"

Expand All @@ -26,7 +25,7 @@ class Robot : public frc::TimedRobot {
private:
// Have it null by default so that if testing teleop it
// doesn't have undefined behavior and potentially crash.
std::optional<frc2::CommandPtr> m_autonomousCommand;
frc2::CommandPtr m_autonomousCommand = frc2::cmd::None();

RobotContainer m_container;
};
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) {
m_autonomousCommand->Schedule();
m_autonomousCommand.Schedule();
}
}

Expand All @@ -50,8 +50,7 @@ void Robot::TeleopInit() {
// continue until interrupted by another command, remove
// this line or comment it out.
if (m_autonomousCommand) {
m_autonomousCommand->Cancel();
m_autonomousCommand.reset();
m_autonomousCommand.Cancel();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

#pragma once

#include <optional>

#include <frc/TimedRobot.h>
#include <frc2/command/CommandPtr.h>
#include <frc2/command/Commands.h>

#include "RobotContainer.h"

Expand All @@ -25,7 +24,7 @@ class Robot : public frc::TimedRobot {

private:
// Have it empty by default
std::optional<frc2::CommandPtr> m_autonomousCommand;
frc2::CommandPtr m_autonomousCommand = frc2::cmd::None();

RobotContainer m_container;
};
Loading

0 comments on commit f385d91

Please sign in to comment.