mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
@@ -13,7 +13,7 @@ RobotContainer::RobotContainer() {
|
||||
ConfigureButtonBindings();
|
||||
|
||||
// Set up default drive command
|
||||
m_drive.SetDefaultCommand(wpi::cmd::cmd::Run(
|
||||
m_drive.SetDefaultCommand(wpi::cmd::Run(
|
||||
[this] {
|
||||
m_drive.ArcadeDrive(-m_driverController.GetLeftY(),
|
||||
-m_driverController.GetRightX());
|
||||
@@ -42,5 +42,5 @@ void RobotContainer::ConfigureButtonBindings() {
|
||||
|
||||
wpi::cmd::CommandPtr RobotContainer::GetAutonomousCommand() {
|
||||
// Runs the chosen command in autonomous
|
||||
return wpi::cmd::cmd::None();
|
||||
return wpi::cmd::None();
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ class RobotContainer {
|
||||
|
||||
// RobotContainer-owned commands
|
||||
wpi::cmd::CommandPtr m_driveHalfVelocity =
|
||||
wpi::cmd::cmd::RunOnce([this] { m_drive.SetMaxOutput(0.5); }, {});
|
||||
wpi::cmd::RunOnce([this] { m_drive.SetMaxOutput(0.5); }, {});
|
||||
wpi::cmd::CommandPtr m_driveFullVelocity =
|
||||
wpi::cmd::cmd::RunOnce([this] { m_drive.SetMaxOutput(1); }, {});
|
||||
wpi::cmd::RunOnce([this] { m_drive.SetMaxOutput(1); }, {});
|
||||
|
||||
void ConfigureButtonBindings();
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ RobotContainer::RobotContainer() {
|
||||
ConfigureButtonBindings();
|
||||
|
||||
// Set up default drive command
|
||||
m_drive.SetDefaultCommand(wpi::cmd::cmd::Run(
|
||||
m_drive.SetDefaultCommand(wpi::cmd::Run(
|
||||
[this] {
|
||||
m_drive.ArcadeDrive(-m_driverController.GetLeftY(),
|
||||
-m_driverController.GetRightX());
|
||||
@@ -41,9 +41,8 @@ void RobotContainer::ConfigureButtonBindings() {
|
||||
m_driverController.WestFace().OnTrue(m_hatch.ReleaseHatchCommand());
|
||||
// While holding Right Bumper, drive at half velocity
|
||||
m_driverController.RightBumper()
|
||||
.OnTrue(wpi::cmd::cmd::RunOnce([this] { m_drive.SetMaxOutput(0.5); }, {}))
|
||||
.OnFalse(
|
||||
wpi::cmd::cmd::RunOnce([this] { m_drive.SetMaxOutput(1.0); }, {}));
|
||||
.OnTrue(wpi::cmd::RunOnce([this] { m_drive.SetMaxOutput(0.5); }, {}))
|
||||
.OnFalse(wpi::cmd::RunOnce([this] { m_drive.SetMaxOutput(1.0); }, {}));
|
||||
}
|
||||
|
||||
wpi::cmd::Command* RobotContainer::GetAutonomousCommand() {
|
||||
|
||||
@@ -33,7 +33,7 @@ wpi::cmd::CommandPtr autos::SimpleAuto(DriveSubsystem* drive) {
|
||||
|
||||
wpi::cmd::CommandPtr autos::ComplexAuto(DriveSubsystem* drive,
|
||||
HatchSubsystem* hatch) {
|
||||
return wpi::cmd::cmd::Sequence(
|
||||
return wpi::cmd::Sequence(
|
||||
// Drive forward the specified distance
|
||||
wpi::cmd::FunctionalCommand(
|
||||
// Reset encoders on command start
|
||||
|
||||
@@ -31,7 +31,7 @@ void RapidReactCommandBot::ConfigureBindings() {
|
||||
|
||||
// Fire the shooter with the South Face button
|
||||
m_driverController.SouthFace().OnTrue(
|
||||
wpi::cmd::cmd::Parallel(
|
||||
wpi::cmd::Parallel(
|
||||
m_shooter.ShootCommand(ShooterConstants::kShooterTarget),
|
||||
m_storage.RunCommand())
|
||||
// Since we composed this inline we should give it a name
|
||||
|
||||
@@ -21,7 +21,7 @@ Shooter::Shooter() {
|
||||
|
||||
wpi::cmd::CommandPtr Shooter::ShootCommand(
|
||||
wpi::units::turns_per_second_t setpoint) {
|
||||
return wpi::cmd::cmd::Parallel(
|
||||
return wpi::cmd::Parallel(
|
||||
// Run the shooter flywheel at the desired setpoint using
|
||||
// feedforward and feedback
|
||||
Run([this, setpoint] {
|
||||
@@ -32,7 +32,7 @@ wpi::cmd::CommandPtr Shooter::ShootCommand(
|
||||
}),
|
||||
// Wait until the shooter has reached the setpoint, and then
|
||||
// run the feeder
|
||||
wpi::cmd::cmd::WaitUntil([this] {
|
||||
wpi::cmd::WaitUntil([this] {
|
||||
return m_shooterFeedback.AtSetpoint();
|
||||
}).AndThen([this] { m_feederMotor.SetThrottle(1.0); }))
|
||||
.WithName("Shoot");
|
||||
|
||||
@@ -20,8 +20,8 @@ void RobotContainer::ConfigureButtonBindings() {
|
||||
[this] { return -m_controller.GetRawAxis(2); }));
|
||||
|
||||
// Example of how to use the onboard IO
|
||||
m_onboardButtonA.OnTrue(wpi::cmd::cmd::Print("Button A Pressed"))
|
||||
.OnFalse(wpi::cmd::cmd::Print("Button A Released"));
|
||||
m_onboardButtonA.OnTrue(wpi::cmd::Print("Button A Pressed"))
|
||||
.OnFalse(wpi::cmd::Print("Button A Released"));
|
||||
|
||||
// Setup SmartDashboard options.
|
||||
m_chooser.SetDefaultOption("Auto Routine Distance", &m_autoDistance);
|
||||
|
||||
@@ -23,8 +23,8 @@ Drive::Drive() {
|
||||
|
||||
wpi::cmd::CommandPtr Drive::ArcadeDriveCommand(std::function<double()> fwd,
|
||||
std::function<double()> rot) {
|
||||
return wpi::cmd::cmd::Run(
|
||||
[this, fwd, rot] { m_drive.ArcadeDrive(fwd(), rot()); }, {this})
|
||||
return wpi::cmd::Run([this, fwd, rot] { m_drive.ArcadeDrive(fwd(), rot()); },
|
||||
{this})
|
||||
.WithName("Arcade Drive");
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ Shooter::Shooter() {
|
||||
|
||||
wpi::cmd::CommandPtr Shooter::RunShooterCommand(
|
||||
std::function<double()> shooterVelocity) {
|
||||
return wpi::cmd::cmd::Run(
|
||||
return wpi::cmd::Run(
|
||||
[this, shooterVelocity] {
|
||||
m_shooterMotor.SetVoltage(
|
||||
wpi::units::volt_t{m_shooterFeedback.Calculate(
|
||||
|
||||
@@ -21,16 +21,16 @@ void RobotContainer::ConfigureButtonBindings() {
|
||||
[this] { return -m_controller.GetRawAxis(2); }));
|
||||
|
||||
// Example of how to use the onboard IO
|
||||
m_userButton.OnTrue(wpi::cmd::cmd::Print("USER Button Pressed"))
|
||||
.OnFalse(wpi::cmd::cmd::Print("USER Button Released"));
|
||||
m_userButton.OnTrue(wpi::cmd::Print("USER Button Pressed"))
|
||||
.OnFalse(wpi::cmd::Print("USER Button Released"));
|
||||
|
||||
wpi::cmd::JoystickButton(&m_controller, 1)
|
||||
.OnTrue(wpi::cmd::cmd::RunOnce([this] { m_arm.SetAngle(45_deg); }, {}))
|
||||
.OnFalse(wpi::cmd::cmd::RunOnce([this] { m_arm.SetAngle(0_deg); }, {}));
|
||||
.OnTrue(wpi::cmd::RunOnce([this] { m_arm.SetAngle(45_deg); }, {}))
|
||||
.OnFalse(wpi::cmd::RunOnce([this] { m_arm.SetAngle(0_deg); }, {}));
|
||||
|
||||
wpi::cmd::JoystickButton(&m_controller, 2)
|
||||
.OnTrue(wpi::cmd::cmd::RunOnce([this] { m_arm.SetAngle(90_deg); }, {}))
|
||||
.OnFalse(wpi::cmd::cmd::RunOnce([this] { m_arm.SetAngle(0_deg); }, {}));
|
||||
.OnTrue(wpi::cmd::RunOnce([this] { m_arm.SetAngle(90_deg); }, {}))
|
||||
.OnFalse(wpi::cmd::RunOnce([this] { m_arm.SetAngle(0_deg); }, {}));
|
||||
|
||||
// Setup SmartDashboard options.
|
||||
m_chooser.SetDefaultOption("Auto Routine Distance", &m_autoDistance);
|
||||
|
||||
@@ -36,13 +36,12 @@ class RobotContainer {
|
||||
// takes a generic type, so the selector does not have to be an enum; it could
|
||||
// be any desired type (string, integer, boolean, double...)
|
||||
wpi::cmd::CommandPtr m_exampleSelectCommand =
|
||||
wpi::cmd::cmd::Select<CommandSelector>(
|
||||
wpi::cmd::Select<CommandSelector>(
|
||||
[this] { return m_chooser.GetSelected(); },
|
||||
// Maps selector values to commands
|
||||
std::pair{ONE, wpi::cmd::cmd::Print("Command one was selected!")},
|
||||
std::pair{TWO, wpi::cmd::cmd::Print("Command two was selected!")},
|
||||
std::pair{THREE,
|
||||
wpi::cmd::cmd::Print("Command three was selected!")});
|
||||
std::pair{ONE, wpi::cmd::Print("Command one was selected!")},
|
||||
std::pair{TWO, wpi::cmd::Print("Command two was selected!")},
|
||||
std::pair{THREE, wpi::cmd::Print("Command three was selected!")});
|
||||
|
||||
void ConfigureButtonBindings();
|
||||
};
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
#include "wpi/commands2/Commands.hpp"
|
||||
|
||||
wpi::cmd::CommandPtr autos::ExampleAuto(ExampleSubsystem* subsystem) {
|
||||
return wpi::cmd::cmd::Sequence(subsystem->ExampleMethodCommand(),
|
||||
ExampleCommand(subsystem).ToPtr());
|
||||
return wpi::cmd::Sequence(subsystem->ExampleMethodCommand(),
|
||||
ExampleCommand(subsystem).ToPtr());
|
||||
}
|
||||
|
||||
@@ -13,5 +13,5 @@ RobotContainer::RobotContainer() {
|
||||
void RobotContainer::ConfigureBindings() {}
|
||||
|
||||
wpi::cmd::CommandPtr RobotContainer::GetAutonomousCommand() {
|
||||
return wpi::cmd::cmd::Print("No autonomous command configured");
|
||||
return wpi::cmd::Print("No autonomous command configured");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user