SCRIPT namespace replacements

This commit is contained in:
PJ Reiniger
2025-11-07 20:00:05 -05:00
committed by Peter Johnson
parent ae6c043632
commit 9aca8e0fd6
2622 changed files with 22275 additions and 22275 deletions

View File

@@ -32,7 +32,7 @@ void RapidReactCommandBot::ConfigureBindings() {
// Fire the shooter with the A button
m_driverController.A().OnTrue(
frc2::cmd::Parallel(
wpi::cmd::cmd::Parallel(
m_shooter.ShootCommand(ShooterConstants::kShooterTarget),
m_storage.RunCommand())
// Since we composed this inline we should give it a name
@@ -43,7 +43,7 @@ void RapidReactCommandBot::ConfigureBindings() {
m_pneumatics.DisableCompressorCommand());
}
frc2::CommandPtr RapidReactCommandBot::GetAutonomousCommand() {
wpi::cmd::CommandPtr RapidReactCommandBot::GetAutonomousCommand() {
return m_drive
.DriveDistanceCommand(AutoConstants::kDriveDistance,
AutoConstants::kDriveSpeed)

View File

@@ -15,7 +15,7 @@ void Robot::RobotPeriodic() {
// finished or interrupted commands, and running subsystem Periodic() methods.
// This must be called from the robot's periodic block in order for anything
// in the Command-based framework to work.
frc2::CommandScheduler::GetInstance().Run();
wpi::cmd::CommandScheduler::GetInstance().Run();
}
void Robot::DisabledInit() {}
@@ -26,7 +26,7 @@ void Robot::AutonomousInit() {
m_autonomousCommand = m_robot.GetAutonomousCommand();
if (m_autonomousCommand) {
frc2::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value());
wpi::cmd::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value());
}
}
@@ -46,13 +46,13 @@ void Robot::TeleopPeriodic() {}
void Robot::TestInit() {
// Cancels all running commands at the start of test mode.
frc2::CommandScheduler::GetInstance().CancelAll();
wpi::cmd::CommandScheduler::GetInstance().CancelAll();
}
void Robot::TestPeriodic() {}
#ifndef RUNNING_FRC_TESTS
int main() {
return frc::StartRobot<Robot>();
return wpi::StartRobot<Robot>();
}
#endif

View File

@@ -10,8 +10,8 @@
#include <wpi/system/RobotController.hpp>
Drive::Drive() {
wpi::SendableRegistry::AddChild(&m_drive, &m_leftLeader);
wpi::SendableRegistry::AddChild(&m_drive, &m_rightLeader);
wpi::util::SendableRegistry::AddChild(&m_drive, &m_leftLeader);
wpi::util::SendableRegistry::AddChild(&m_drive, &m_rightLeader);
m_leftLeader.AddFollower(m_leftFollower);
m_rightLeader.AddFollower(m_rightFollower);
@@ -34,7 +34,7 @@ Drive::Drive() {
DriveConstants::kTurnRateTolerance);
}
frc2::CommandPtr Drive::ArcadeDriveCommand(std::function<double()> fwd,
wpi::cmd::CommandPtr Drive::ArcadeDriveCommand(std::function<double()> fwd,
std::function<double()> rot) {
return Run([this, fwd = std::move(fwd), rot = std::move(rot)] {
m_drive.ArcadeDrive(fwd(), rot());
@@ -42,7 +42,7 @@ frc2::CommandPtr Drive::ArcadeDriveCommand(std::function<double()> fwd,
.WithName("ArcadeDrive");
}
frc2::CommandPtr Drive::DriveDistanceCommand(units::meter_t distance,
wpi::cmd::CommandPtr Drive::DriveDistanceCommand(wpi::units::meter_t distance,
double speed) {
return RunOnce([this] {
// Reset encoders at the start of the command
@@ -52,15 +52,15 @@ frc2::CommandPtr Drive::DriveDistanceCommand(units::meter_t distance,
// Drive forward at specified speed
.AndThen(Run([this, speed] { m_drive.ArcadeDrive(speed, 0.0); }))
.Until([this, distance] {
return units::math::max(units::meter_t(m_leftEncoder.GetDistance()),
units::meter_t(m_rightEncoder.GetDistance())) >=
return wpi::units::math::max(wpi::units::meter_t(m_leftEncoder.GetDistance()),
wpi::units::meter_t(m_rightEncoder.GetDistance())) >=
distance;
})
// Stop the drive when the command ends
.FinallyDo([this](bool interrupted) { m_drive.StopMotor(); });
}
frc2::CommandPtr Drive::TurnToAngleCommand(units::degree_t angle) {
wpi::cmd::CommandPtr Drive::TurnToAngleCommand(wpi::units::degree_t angle) {
return StartRun(
[this] { m_controller.Reset(m_imu.GetRotation2d().Degrees()); },
[this, angle] {
@@ -71,7 +71,7 @@ frc2::CommandPtr Drive::TurnToAngleCommand(units::degree_t angle) {
// normalize it to [-1, 1]
m_feedforward.Calculate(
m_controller.GetSetpoint().velocity) /
frc::RobotController::GetBatteryVoltage());
wpi::RobotController::GetBatteryVoltage());
})
.Until([this] { return m_controller.AtGoal(); })
.FinallyDo([this] { m_drive.ArcadeDrive(0, 0); });

View File

@@ -4,16 +4,16 @@
#include "subsystems/Intake.hpp"
frc2::CommandPtr Intake::IntakeCommand() {
return RunOnce([this] { m_piston.Set(frc::DoubleSolenoid::kForward); })
wpi::cmd::CommandPtr Intake::IntakeCommand() {
return RunOnce([this] { m_piston.Set(wpi::DoubleSolenoid::kForward); })
.AndThen(Run([this] { m_motor.Set(1.0); }))
.WithName("Intake");
}
frc2::CommandPtr Intake::RetractCommand() {
wpi::cmd::CommandPtr Intake::RetractCommand() {
return RunOnce([this] {
m_motor.Disable();
m_piston.Set(frc::DoubleSolenoid::kReverse);
m_piston.Set(wpi::DoubleSolenoid::kReverse);
})
.WithName("Retract");
}

View File

@@ -6,7 +6,7 @@
Pneumatics::Pneumatics() {}
frc2::CommandPtr Pneumatics::DisableCompressorCommand() {
wpi::cmd::CommandPtr Pneumatics::DisableCompressorCommand() {
return StartEnd(
[&] {
// Disable closed-loop mode on the compressor.
@@ -20,8 +20,8 @@ frc2::CommandPtr Pneumatics::DisableCompressorCommand() {
});
}
units::pounds_per_square_inch_t Pneumatics::GetPressure() {
wpi::units::pounds_per_square_inch_t Pneumatics::GetPressure() {
// Get the pressure (in PSI) from an analog pressure sensor connected to
// the RIO.
return units::pounds_per_square_inch_t{m_pressureTransducer.Get()};
return wpi::units::pounds_per_square_inch_t{m_pressureTransducer.Get()};
}

View File

@@ -19,19 +19,19 @@ Shooter::Shooter() {
.WithName("Idle"));
}
frc2::CommandPtr Shooter::ShootCommand(units::turns_per_second_t setpoint) {
return frc2::cmd::Parallel(
wpi::cmd::CommandPtr Shooter::ShootCommand(wpi::units::turns_per_second_t setpoint) {
return wpi::cmd::cmd::Parallel(
// Run the shooter flywheel at the desired setpoint using
// feedforward and feedback
Run([this, setpoint] {
m_shooterMotor.SetVoltage(
m_shooterFeedforward.Calculate(setpoint) +
units::volt_t(m_shooterFeedback.Calculate(
wpi::units::volt_t(m_shooterFeedback.Calculate(
m_shooterEncoder.GetRate(), setpoint.value())));
}),
// Wait until the shooter has reached the setpoint, and then
// run the feeder
frc2::cmd::WaitUntil([this] {
wpi::cmd::cmd::WaitUntil([this] {
return m_shooterFeedback.AtSetpoint();
}).AndThen([this] { m_feederMotor.Set(1.0); }))
.WithName("Shoot");

View File

@@ -9,6 +9,6 @@ Storage::Storage() {
RunOnce([this] { m_motor.Disable(); }).AndThen([] {}).WithName("Idle"));
}
frc2::CommandPtr Storage::RunCommand() {
wpi::cmd::CommandPtr Storage::RunCommand() {
return Run([this] { m_motor.Set(1.0); }).WithName("Run");
}

View File

@@ -24,7 +24,7 @@ inline constexpr bool kLeftEncoderReversed = false;
inline constexpr bool kRightEncoderReversed = true;
inline constexpr double kEncoderCPR = 1024;
inline constexpr units::meter_t kWheelDiameter = 6_in;
inline constexpr wpi::units::meter_t kWheelDiameter = 6_in;
inline constexpr double kEncoderDistancePerPulse =
// Assumes the encoders are directly mounted on the wheel shafts
((kWheelDiameter * std::numbers::pi) / kEncoderCPR).value();
@@ -76,7 +76,7 @@ inline constexpr auto kShooterTolerance = 50_tps;
// robot.
inline constexpr double kP = 1;
inline constexpr units::volt_t kS = 0.05_V;
inline constexpr wpi::units::volt_t kS = 0.05_V;
// Should have value 12V at free speed
inline constexpr auto kV = 12_V / kShooterFree;
@@ -88,7 +88,7 @@ inline constexpr int kDriverControllerPort = 0;
} // namespace OIConstants
namespace AutoConstants {
constexpr units::second_t kTimeout = 3_s;
constexpr units::meter_t kDriveDistance = 2_m;
constexpr wpi::units::second_t kTimeout = 3_s;
constexpr wpi::units::meter_t kDriveDistance = 2_m;
constexpr double kDriveSpeed = 0.5;
} // namespace AutoConstants

View File

@@ -29,7 +29,7 @@ class RapidReactCommandBot {
*
* <p>Should be called in the robot class constructor.
*
* <p>Event binding methods are available on the frc2::Trigger class.
* <p>Event binding methods are available on the wpi::cmd::Trigger class.
*/
void ConfigureBindings();
@@ -38,7 +38,7 @@ class RapidReactCommandBot {
*
* <p>Scheduled during Robot::AutonomousInit().
*/
frc2::CommandPtr GetAutonomousCommand();
wpi::cmd::CommandPtr GetAutonomousCommand();
private:
// The robot's subsystems
@@ -49,6 +49,6 @@ class RapidReactCommandBot {
Pneumatics m_pneumatics;
// The driver's controller
frc2::CommandXboxController m_driverController{
wpi::cmd::CommandXboxController m_driverController{
OIConstants::kDriverControllerPort};
};

View File

@@ -11,7 +11,7 @@
#include "RapidReactCommandBot.hpp"
class Robot : public frc::TimedRobot {
class Robot : public wpi::TimedRobot {
public:
Robot();
void RobotPeriodic() override;
@@ -26,5 +26,5 @@ class Robot : public frc::TimedRobot {
private:
RapidReactCommandBot m_robot;
std::optional<frc2::CommandPtr> m_autonomousCommand;
std::optional<wpi::cmd::CommandPtr> m_autonomousCommand;
};

View File

@@ -19,7 +19,7 @@
#include "Constants.hpp"
class Drive : public frc2::SubsystemBase {
class Drive : public wpi::cmd::SubsystemBase {
public:
Drive();
/**
@@ -28,7 +28,7 @@ class Drive : public frc2::SubsystemBase {
* @param fwd the commanded forward movement
* @param rot the commanded rotation
*/
frc2::CommandPtr ArcadeDriveCommand(std::function<double()> fwd,
wpi::cmd::CommandPtr ArcadeDriveCommand(std::function<double()> fwd,
std::function<double()> rot);
/**
@@ -38,7 +38,7 @@ class Drive : public frc2::SubsystemBase {
* @param distance The distance to drive forward in meters
* @param speed The fraction of max speed at which to drive
*/
frc2::CommandPtr DriveDistanceCommand(units::meter_t distance, double speed);
wpi::cmd::CommandPtr DriveDistanceCommand(wpi::units::meter_t distance, double speed);
/**
* Returns a command that turns to robot to the specified angle using a motion
@@ -46,32 +46,32 @@ class Drive : public frc2::SubsystemBase {
*
* @param angle The angle to turn to
*/
frc2::CommandPtr TurnToAngleCommand(units::degree_t angle);
wpi::cmd::CommandPtr TurnToAngleCommand(wpi::units::degree_t angle);
private:
frc::PWMSparkMax m_leftLeader{DriveConstants::kLeftMotor1Port};
frc::PWMSparkMax m_leftFollower{DriveConstants::kLeftMotor2Port};
frc::PWMSparkMax m_rightLeader{DriveConstants::kRightMotor1Port};
frc::PWMSparkMax m_rightFollower{DriveConstants::kRightMotor2Port};
wpi::PWMSparkMax m_leftLeader{DriveConstants::kLeftMotor1Port};
wpi::PWMSparkMax m_leftFollower{DriveConstants::kLeftMotor2Port};
wpi::PWMSparkMax m_rightLeader{DriveConstants::kRightMotor1Port};
wpi::PWMSparkMax m_rightFollower{DriveConstants::kRightMotor2Port};
frc::DifferentialDrive m_drive{
wpi::DifferentialDrive m_drive{
[&](double output) { m_leftLeader.Set(output); },
[&](double output) { m_rightLeader.Set(output); }};
frc::Encoder m_leftEncoder{DriveConstants::kLeftEncoderPorts[0],
wpi::Encoder m_leftEncoder{DriveConstants::kLeftEncoderPorts[0],
DriveConstants::kLeftEncoderPorts[1],
DriveConstants::kLeftEncoderReversed};
frc::Encoder m_rightEncoder{DriveConstants::kRightEncoderPorts[0],
wpi::Encoder m_rightEncoder{DriveConstants::kRightEncoderPorts[0],
DriveConstants::kRightEncoderPorts[1],
DriveConstants::kRightEncoderReversed};
frc::OnboardIMU m_imu{frc::OnboardIMU::kFlat};
wpi::OnboardIMU m_imu{wpi::OnboardIMU::kFlat};
frc::ProfiledPIDController<units::radians> m_controller{
wpi::math::ProfiledPIDController<wpi::units::radians> m_controller{
DriveConstants::kTurnP,
DriveConstants::kTurnI,
DriveConstants::kTurnD,
{DriveConstants::kMaxTurnRate, DriveConstants::kMaxTurnAcceleration}};
frc::SimpleMotorFeedforward<units::radians> m_feedforward{
wpi::math::SimpleMotorFeedforward<wpi::units::radians> m_feedforward{
DriveConstants::ks, DriveConstants::kv, DriveConstants::ka};
};

View File

@@ -13,22 +13,22 @@
#include "Constants.hpp"
class Intake : public frc2::SubsystemBase {
class Intake : public wpi::cmd::SubsystemBase {
public:
Intake() = default;
/** Returns a command that deploys the intake, and then runs the intake motor
* indefinitely. */
frc2::CommandPtr IntakeCommand();
wpi::cmd::CommandPtr IntakeCommand();
/** Returns a command that turns off and retracts the intake. */
frc2::CommandPtr RetractCommand();
wpi::cmd::CommandPtr RetractCommand();
private:
frc::PWMSparkMax m_motor{IntakeConstants::kMotorPort};
wpi::PWMSparkMax m_motor{IntakeConstants::kMotorPort};
// Double solenoid connected to two channels of a PCM with the default CAN ID
frc::DoubleSolenoid m_piston{0, frc::PneumaticsModuleType::CTREPCM,
wpi::DoubleSolenoid m_piston{0, wpi::PneumaticsModuleType::CTREPCM,
IntakeConstants::kSolenoidPorts[0],
IntakeConstants::kSolenoidPorts[1]};
};

View File

@@ -13,18 +13,18 @@
#include "Constants.hpp"
class Pneumatics : frc2::SubsystemBase {
class Pneumatics : wpi::cmd::SubsystemBase {
public:
Pneumatics();
/** Returns a command that disables the compressor indefinitely. */
frc2::CommandPtr DisableCompressorCommand();
wpi::cmd::CommandPtr DisableCompressorCommand();
/**
* Query the analog pressure sensor.
*
* @return the measured pressure, in PSI
*/
units::pounds_per_square_inch_t GetPressure();
wpi::units::pounds_per_square_inch_t GetPressure();
private:
// External analog pressure sensor
@@ -35,9 +35,9 @@ class Pneumatics : frc2::SubsystemBase {
// pressure is 250r-25
static constexpr double kScale = 250;
static constexpr double kOffset = -25;
frc::AnalogPotentiometer m_pressureTransducer{/* the AnalogIn port*/ 2,
wpi::AnalogPotentiometer m_pressureTransducer{/* the AnalogIn port*/ 2,
kScale, kOffset};
// Compressor connected to a PH with a default CAN ID
frc::Compressor m_compressor{0, frc::PneumaticsModuleType::CTREPCM};
wpi::Compressor m_compressor{0, wpi::PneumaticsModuleType::CTREPCM};
};

View File

@@ -17,7 +17,7 @@
#include "Constants.hpp"
class Shooter : public frc2::SubsystemBase {
class Shooter : public wpi::cmd::SubsystemBase {
public:
Shooter();
@@ -28,16 +28,16 @@ class Shooter : public frc2::SubsystemBase {
*
* @param setpointRotationsPerSecond The desired shooter velocity
*/
frc2::CommandPtr ShootCommand(units::turns_per_second_t setpoint);
wpi::cmd::CommandPtr ShootCommand(wpi::units::turns_per_second_t setpoint);
private:
frc::PWMSparkMax m_shooterMotor{ShooterConstants::kShooterMotorPort};
frc::PWMSparkMax m_feederMotor{ShooterConstants::kFeederMotorPort};
wpi::PWMSparkMax m_shooterMotor{ShooterConstants::kShooterMotorPort};
wpi::PWMSparkMax m_feederMotor{ShooterConstants::kFeederMotorPort};
frc::Encoder m_shooterEncoder{ShooterConstants::kEncoderPorts[0],
wpi::Encoder m_shooterEncoder{ShooterConstants::kEncoderPorts[0],
ShooterConstants::kEncoderPorts[1],
ShooterConstants::kEncoderReversed};
frc::SimpleMotorFeedforward<units::radians> m_shooterFeedforward{
wpi::math::SimpleMotorFeedforward<wpi::units::radians> m_shooterFeedforward{
ShooterConstants::kS, ShooterConstants::kV};
frc::PIDController m_shooterFeedback{ShooterConstants::kP, 0.0, 0.0};
wpi::math::PIDController m_shooterFeedback{ShooterConstants::kP, 0.0, 0.0};
};

View File

@@ -12,16 +12,16 @@
#include "Constants.hpp"
class Storage : frc2::SubsystemBase {
class Storage : wpi::cmd::SubsystemBase {
public:
Storage();
/** Returns a command that runs the storage motor indefinitely. */
frc2::CommandPtr RunCommand();
wpi::cmd::CommandPtr RunCommand();
/** Whether the ball storage is full. */
frc2::Trigger HasCargo{[this] { return m_ballSensor.Get(); }};
wpi::cmd::Trigger HasCargo{[this] { return m_ballSensor.Get(); }};
private:
frc::PWMSparkMax m_motor{StorageConstants::kMotorPort};
frc::DigitalInput m_ballSensor{StorageConstants::kBallSensorPort};
wpi::PWMSparkMax m_motor{StorageConstants::kMotorPort};
wpi::DigitalInput m_ballSensor{StorageConstants::kBallSensorPort};
};