Skip to content

Commit

Permalink
added stop to swerve drive
Browse files Browse the repository at this point in the history
  • Loading branch information
r4stered committed Oct 20, 2024
1 parent b397bca commit 6355b9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/cpp/subsystems/SwerveSubsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ void SwerveSubsystem::SetupPathplanner() {
swerveDrive.SetModuleStates(
consts::swerve::physical::KINEMATICS.ToSwerveModuleStates(
speedsToSend),
true, false,
{ff[0].torqueCurrent, ff[1].torqueCurrent, ff[2].torqueCurrent,
ff[3].torqueCurrent});
true, false);
},
ppControllers, consts::swerve::pathplanning::config,
[]() { return str::IsOnRed(); }, this);
Expand All @@ -143,6 +141,12 @@ frc::Translation2d SwerveSubsystem::GetFrontAmpLocation() {
return ampToGoTo;
}

frc2::CommandPtr SwerveSubsystem::Stop() {
return frc2::cmd::RunOnce([this] {
swerveDrive.Drive(0_fps, 0_fps, 0_rad_per_s, false, false);
}, {this});
}

bool SwerveSubsystem::IsNearAmp() {
return GetRobotPose().Translation().Distance(GetAmpLocation()) <
consts::yearSpecific::closeToAmpDistance;
Expand Down
2 changes: 2 additions & 0 deletions src/main/include/subsystems/SwerveSubsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class SwerveSubsystem : public frc2::SubsystemBase {
return autoFactory;
}

frc2::CommandPtr Stop();

private:
void SetupPathplanner();
frc::Translation2d GetAmpLocation();
Expand Down

0 comments on commit 6355b9e

Please sign in to comment.