mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -17,7 +17,7 @@ Robot::Robot() {}
|
||||
* LiveWindow and SmartDashboard integrated updating.
|
||||
*/
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
wpi::cmd::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ void Robot::AutonomousInit() {
|
||||
m_autonomousCommand = m_container.GetAutonomousCommand();
|
||||
|
||||
if (m_autonomousCommand) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value());
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,6 @@ void Robot::SimulationPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
return wpi::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -20,7 +20,7 @@ void RobotContainer::ConfigureBindings() {
|
||||
// Configure your trigger bindings here
|
||||
|
||||
// Schedule `ExampleCommand` when `exampleCondition` changes to `true`
|
||||
frc2::Trigger([this] {
|
||||
wpi::cmd::Trigger([this] {
|
||||
return m_subsystem.ExampleCondition();
|
||||
}).OnTrue(ExampleCommand(&m_subsystem).ToPtr());
|
||||
|
||||
@@ -29,7 +29,7 @@ void RobotContainer::ConfigureBindings() {
|
||||
m_driverController.B().WhileTrue(m_subsystem.ExampleMethodCommand());
|
||||
}
|
||||
|
||||
frc2::CommandPtr RobotContainer::GetAutonomousCommand() {
|
||||
wpi::cmd::CommandPtr RobotContainer::GetAutonomousCommand() {
|
||||
// An example command will be run in autonomous
|
||||
return autos::ExampleAuto(&m_subsystem);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "commands/ExampleCommand.hpp"
|
||||
|
||||
frc2::CommandPtr autos::ExampleAuto(ExampleSubsystem* subsystem) {
|
||||
return frc2::cmd::Sequence(subsystem->ExampleMethodCommand(),
|
||||
wpi::cmd::CommandPtr autos::ExampleAuto(ExampleSubsystem* subsystem) {
|
||||
return wpi::cmd::cmd::Sequence(subsystem->ExampleMethodCommand(),
|
||||
ExampleCommand(subsystem).ToPtr());
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ ExampleSubsystem::ExampleSubsystem() {
|
||||
// Implementation of subsystem constructor goes here.
|
||||
}
|
||||
|
||||
frc2::CommandPtr ExampleSubsystem::ExampleMethodCommand() {
|
||||
wpi::cmd::CommandPtr ExampleSubsystem::ExampleMethodCommand() {
|
||||
// Inline construction of command goes here.
|
||||
// Subsystem::RunOnce implicitly requires `this` subsystem.
|
||||
return RunOnce([/* this */] { /* one-time action goes here */ });
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "RobotContainer.hpp"
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
class Robot : public wpi::TimedRobot {
|
||||
public:
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
@@ -28,7 +28,7 @@ class Robot : public frc::TimedRobot {
|
||||
private:
|
||||
// Have it empty by default so that if testing teleop it
|
||||
// doesn't have undefined behavior and potentially crash.
|
||||
std::optional<frc2::CommandPtr> m_autonomousCommand;
|
||||
std::optional<wpi::cmd::CommandPtr> m_autonomousCommand;
|
||||
|
||||
RobotContainer m_container;
|
||||
};
|
||||
|
||||
@@ -21,11 +21,11 @@ class RobotContainer {
|
||||
public:
|
||||
RobotContainer();
|
||||
|
||||
frc2::CommandPtr GetAutonomousCommand();
|
||||
wpi::cmd::CommandPtr GetAutonomousCommand();
|
||||
|
||||
private:
|
||||
// Replace with CommandPS4Controller or CommandJoystick if needed
|
||||
frc2::CommandXboxController m_driverController{
|
||||
wpi::cmd::CommandXboxController m_driverController{
|
||||
OperatorConstants::kDriverControllerPort};
|
||||
|
||||
// The robot's subsystems are defined here...
|
||||
|
||||
@@ -12,5 +12,5 @@ namespace autos {
|
||||
/**
|
||||
* Example static factory for an autonomous command.
|
||||
*/
|
||||
frc2::CommandPtr ExampleAuto(ExampleSubsystem* subsystem);
|
||||
wpi::cmd::CommandPtr ExampleAuto(ExampleSubsystem* subsystem);
|
||||
} // namespace autos
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
* Command will *not* work!
|
||||
*/
|
||||
class ExampleCommand
|
||||
: public frc2::CommandHelper<frc2::Command, ExampleCommand> {
|
||||
: public wpi::cmd::CommandHelper<wpi::cmd::Command, ExampleCommand> {
|
||||
public:
|
||||
/**
|
||||
* Creates a new ExampleCommand.
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
#include <wpi/commands2/CommandPtr.hpp>
|
||||
#include <wpi/commands2/SubsystemBase.hpp>
|
||||
|
||||
class ExampleSubsystem : public frc2::SubsystemBase {
|
||||
class ExampleSubsystem : public wpi::cmd::SubsystemBase {
|
||||
public:
|
||||
ExampleSubsystem();
|
||||
|
||||
/**
|
||||
* Example command factory method.
|
||||
*/
|
||||
frc2::CommandPtr ExampleMethodCommand();
|
||||
wpi::cmd::CommandPtr ExampleMethodCommand();
|
||||
|
||||
/**
|
||||
* An example method querying a boolean state of the subsystem (for example, a
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
Robot::Robot() {}
|
||||
|
||||
void Robot::RobotPeriodic() {
|
||||
frc2::CommandScheduler::GetInstance().Run();
|
||||
wpi::cmd::CommandScheduler::GetInstance().Run();
|
||||
}
|
||||
|
||||
void Robot::DisabledInit() {}
|
||||
@@ -22,7 +22,7 @@ void Robot::AutonomousInit() {
|
||||
m_autonomousCommand = m_container.GetAutonomousCommand();
|
||||
|
||||
if (m_autonomousCommand) {
|
||||
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value());
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ void Robot::TeleopPeriodic() {}
|
||||
void Robot::TeleopExit() {}
|
||||
|
||||
void Robot::TestInit() {
|
||||
frc2::CommandScheduler::GetInstance().CancelAll();
|
||||
wpi::cmd::CommandScheduler::GetInstance().CancelAll();
|
||||
}
|
||||
|
||||
void Robot::TestPeriodic() {}
|
||||
@@ -50,6 +50,6 @@ void Robot::TestExit() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
return wpi::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -12,6 +12,6 @@ RobotContainer::RobotContainer() {
|
||||
|
||||
void RobotContainer::ConfigureBindings() {}
|
||||
|
||||
frc2::CommandPtr RobotContainer::GetAutonomousCommand() {
|
||||
return frc2::cmd::Print("No autonomous command configured");
|
||||
wpi::cmd::CommandPtr RobotContainer::GetAutonomousCommand() {
|
||||
return wpi::cmd::cmd::Print("No autonomous command configured");
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "RobotContainer.hpp"
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
class Robot : public wpi::TimedRobot {
|
||||
public:
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
@@ -29,7 +29,7 @@ class Robot : public frc::TimedRobot {
|
||||
void TestExit() override;
|
||||
|
||||
private:
|
||||
std::optional<frc2::CommandPtr> m_autonomousCommand;
|
||||
std::optional<wpi::cmd::CommandPtr> m_autonomousCommand;
|
||||
|
||||
RobotContainer m_container;
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ class RobotContainer {
|
||||
public:
|
||||
RobotContainer();
|
||||
|
||||
frc2::CommandPtr GetAutonomousCommand();
|
||||
wpi::cmd::CommandPtr GetAutonomousCommand();
|
||||
|
||||
private:
|
||||
void ConfigureBindings();
|
||||
|
||||
@@ -20,10 +20,10 @@ void Robot::Teleop() {}
|
||||
void Robot::Test() {}
|
||||
|
||||
void Robot::StartCompetition() {
|
||||
frc::internal::DriverStationModeThread modeThread;
|
||||
wpi::internal::DriverStationModeThread modeThread;
|
||||
|
||||
wpi::Event event{false, false};
|
||||
frc::DriverStation::ProvideRefreshedDataEventHandle(event.GetHandle());
|
||||
wpi::util::Event event{false, false};
|
||||
wpi::DriverStation::ProvideRefreshedDataEventHandle(event.GetHandle());
|
||||
|
||||
// Tell the DS that the robot is ready to be enabled
|
||||
HAL_ObserveUserProgramStarting();
|
||||
@@ -34,28 +34,28 @@ void Robot::StartCompetition() {
|
||||
Disabled();
|
||||
modeThread.InDisabled(false);
|
||||
while (IsDisabled()) {
|
||||
wpi::WaitForObject(event.GetHandle());
|
||||
wpi::util::WaitForObject(event.GetHandle());
|
||||
}
|
||||
} else if (IsAutonomous()) {
|
||||
modeThread.InAutonomous(true);
|
||||
Autonomous();
|
||||
modeThread.InAutonomous(false);
|
||||
while (IsAutonomousEnabled()) {
|
||||
wpi::WaitForObject(event.GetHandle());
|
||||
wpi::util::WaitForObject(event.GetHandle());
|
||||
}
|
||||
} else if (IsTest()) {
|
||||
modeThread.InTest(true);
|
||||
Test();
|
||||
modeThread.InTest(false);
|
||||
while (IsTest() && IsEnabled()) {
|
||||
wpi::WaitForObject(event.GetHandle());
|
||||
wpi::util::WaitForObject(event.GetHandle());
|
||||
}
|
||||
} else {
|
||||
modeThread.InTeleop(true);
|
||||
Teleop();
|
||||
modeThread.InTeleop(false);
|
||||
while (IsTeleopEnabled()) {
|
||||
wpi::WaitForObject(event.GetHandle());
|
||||
wpi::util::WaitForObject(event.GetHandle());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,6 @@ void Robot::EndCompetition() {
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
return wpi::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <wpi/opmode/RobotBase.hpp>
|
||||
|
||||
class Robot : public frc::RobotBase {
|
||||
class Robot : public wpi::RobotBase {
|
||||
public:
|
||||
Robot();
|
||||
void Disabled();
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
Robot::Robot() {
|
||||
m_chooser.SetDefaultOption(kAutoNameDefault, kAutoNameDefault);
|
||||
m_chooser.AddOption(kAutoNameCustom, kAutoNameCustom);
|
||||
frc::SmartDashboard::PutData("Auto Modes", &m_chooser);
|
||||
wpi::SmartDashboard::PutData("Auto Modes", &m_chooser);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,7 @@ void Robot::AutonomousInit() {
|
||||
m_autoSelected = m_chooser.GetSelected();
|
||||
// m_autoSelected = SmartDashboard::GetString("Auto Selector",
|
||||
// kAutoNameDefault);
|
||||
wpi::print("Auto selected: {}\n", m_autoSelected);
|
||||
wpi::util::print("Auto selected: {}\n", m_autoSelected);
|
||||
|
||||
if (m_autoSelected == kAutoNameCustom) {
|
||||
// Custom Auto goes here
|
||||
@@ -73,6 +73,6 @@ void Robot::SimulationPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
return wpi::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <wpi/opmode/TimedRobot.hpp>
|
||||
#include <wpi/smartdashboard/SendableChooser.hpp>
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
class Robot : public wpi::TimedRobot {
|
||||
public:
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
@@ -25,7 +25,7 @@ class Robot : public frc::TimedRobot {
|
||||
void SimulationPeriodic() override;
|
||||
|
||||
private:
|
||||
frc::SendableChooser<std::string> m_chooser;
|
||||
wpi::SendableChooser<std::string> m_chooser;
|
||||
const std::string kAutoNameDefault = "Default";
|
||||
const std::string kAutoNameCustom = "My Auto";
|
||||
std::string m_autoSelected;
|
||||
|
||||
@@ -24,6 +24,6 @@ void Robot::SimulationPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
return wpi::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <wpi/opmode/TimedRobot.hpp>
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
class Robot : public wpi::TimedRobot {
|
||||
public:
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <wpi/util/print.hpp>
|
||||
|
||||
// Run robot periodic() functions for 5 ms, and run controllers every 10 ms
|
||||
Robot::Robot() : frc::TimesliceRobot{5_ms, 10_ms} {
|
||||
Robot::Robot() : wpi::TimesliceRobot{5_ms, 10_ms} {
|
||||
// Runs for 2 ms after robot periodic functions
|
||||
Schedule([=] {}, 2_ms);
|
||||
|
||||
@@ -21,7 +21,7 @@ Robot::Robot() : frc::TimesliceRobot{5_ms, 10_ms} {
|
||||
|
||||
m_chooser.SetDefaultOption(kAutoNameDefault, kAutoNameDefault);
|
||||
m_chooser.AddOption(kAutoNameCustom, kAutoNameCustom);
|
||||
frc::SmartDashboard::PutData("Auto Modes", &m_chooser);
|
||||
wpi::SmartDashboard::PutData("Auto Modes", &m_chooser);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,7 +49,7 @@ void Robot::AutonomousInit() {
|
||||
m_autoSelected = m_chooser.GetSelected();
|
||||
// m_autoSelected = SmartDashboard::GetString("Auto Selector",
|
||||
// kAutoNameDefault);
|
||||
wpi::print("Auto selected: {}\n", m_autoSelected);
|
||||
wpi::util::print("Auto selected: {}\n", m_autoSelected);
|
||||
|
||||
if (m_autoSelected == kAutoNameCustom) {
|
||||
// Custom Auto goes here
|
||||
@@ -80,6 +80,6 @@ void Robot::TestPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
return wpi::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <wpi/opmode/TimesliceRobot.hpp>
|
||||
#include <wpi/smartdashboard/SendableChooser.hpp>
|
||||
|
||||
class Robot : public frc::TimesliceRobot {
|
||||
class Robot : public wpi::TimesliceRobot {
|
||||
public:
|
||||
Robot();
|
||||
void RobotPeriodic() override;
|
||||
@@ -23,7 +23,7 @@ class Robot : public frc::TimesliceRobot {
|
||||
void TestPeriodic() override;
|
||||
|
||||
private:
|
||||
frc::SendableChooser<std::string> m_chooser;
|
||||
wpi::SendableChooser<std::string> m_chooser;
|
||||
const std::string kAutoNameDefault = "Default";
|
||||
const std::string kAutoNameCustom = "My Auto";
|
||||
std::string m_autoSelected;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "Robot.hpp"
|
||||
|
||||
// Run robot periodic() functions for 5 ms, and run controllers every 10 ms
|
||||
Robot::Robot() : frc::TimesliceRobot{5_ms, 10_ms} {
|
||||
Robot::Robot() : wpi::TimesliceRobot{5_ms, 10_ms} {
|
||||
// Runs for 2 ms after robot periodic functions
|
||||
Schedule([=] {}, 2_ms);
|
||||
|
||||
@@ -33,6 +33,6 @@ void Robot::TestPeriodic() {}
|
||||
|
||||
#ifndef RUNNING_FRC_TESTS
|
||||
int main() {
|
||||
return frc::StartRobot<Robot>();
|
||||
return wpi::StartRobot<Robot>();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <wpi/opmode/TimesliceRobot.hpp>
|
||||
|
||||
class Robot : public frc::TimesliceRobot {
|
||||
class Robot : public wpi::TimesliceRobot {
|
||||
public:
|
||||
Robot();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user