mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
SCRIPT: wpiformat
This commit is contained in:
committed by
Peter Johnson
parent
ae6bdc9d25
commit
2109161534
@@ -26,7 +26,8 @@ void Robot::AutonomousInit() {
|
||||
m_autonomousCommand = m_robot.GetAutonomousCommand();
|
||||
|
||||
if (m_autonomousCommand) {
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(m_autonomousCommand.value());
|
||||
wpi::cmd::CommandScheduler::GetInstance().Schedule(
|
||||
m_autonomousCommand.value());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ Drive::Drive() {
|
||||
}
|
||||
|
||||
wpi::cmd::CommandPtr Drive::ArcadeDriveCommand(std::function<double()> fwd,
|
||||
std::function<double()> rot) {
|
||||
std::function<double()> rot) {
|
||||
return Run([this, fwd = std::move(fwd), rot = std::move(rot)] {
|
||||
m_drive.ArcadeDrive(fwd(), rot());
|
||||
})
|
||||
@@ -43,7 +43,7 @@ wpi::cmd::CommandPtr Drive::ArcadeDriveCommand(std::function<double()> fwd,
|
||||
}
|
||||
|
||||
wpi::cmd::CommandPtr Drive::DriveDistanceCommand(wpi::units::meter_t distance,
|
||||
double speed) {
|
||||
double speed) {
|
||||
return RunOnce([this] {
|
||||
// Reset encoders at the start of the command
|
||||
m_leftEncoder.Reset();
|
||||
@@ -52,8 +52,9 @@ wpi::cmd::CommandPtr Drive::DriveDistanceCommand(wpi::units::meter_t distance,
|
||||
// Drive forward at specified speed
|
||||
.AndThen(Run([this, speed] { m_drive.ArcadeDrive(speed, 0.0); }))
|
||||
.Until([this, distance] {
|
||||
return wpi::units::math::max(wpi::units::meter_t(m_leftEncoder.GetDistance()),
|
||||
wpi::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
|
||||
|
||||
@@ -19,7 +19,8 @@ Shooter::Shooter() {
|
||||
.WithName("Idle"));
|
||||
}
|
||||
|
||||
wpi::cmd::CommandPtr Shooter::ShootCommand(wpi::units::turns_per_second_t setpoint) {
|
||||
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
|
||||
|
||||
@@ -29,7 +29,7 @@ class Drive : public wpi::cmd::SubsystemBase {
|
||||
* @param rot the commanded rotation
|
||||
*/
|
||||
wpi::cmd::CommandPtr ArcadeDriveCommand(std::function<double()> fwd,
|
||||
std::function<double()> rot);
|
||||
std::function<double()> rot);
|
||||
|
||||
/**
|
||||
* Returns a command that drives the robot forward a specified distance at a
|
||||
@@ -38,7 +38,8 @@ class Drive : public wpi::cmd::SubsystemBase {
|
||||
* @param distance The distance to drive forward in meters
|
||||
* @param speed The fraction of max speed at which to drive
|
||||
*/
|
||||
wpi::cmd::CommandPtr DriveDistanceCommand(wpi::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
|
||||
|
||||
Reference in New Issue
Block a user