-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Superbro525Alt/align
Added auto align
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,40 @@ | ||
#include "behaviour/LimelightBehaviours.h" | ||
|
||
|
||
AlignBehaviour::AlignBehaviour(Limelight *limelight, frc::XboxController &driver, wom::SwerveDrive *swerve) | ||
: _limelight(limelight), _driver(driver), _swerve(swerve) { | ||
Controls(limelight); | ||
Controls(swerve); | ||
} | ||
|
||
void AlignBehaviour::AlignToTarget(frc::Pose3d pose) { | ||
//swerve->SetPose(pose); | ||
|
||
_state = poseState::notAtPose; | ||
_setPoint = pose; | ||
} | ||
|
||
void AlignBehaviour::CancelAlign() { | ||
_state = poseState::atPose; | ||
} | ||
|
||
void AlignBehaviour::OnTick(units::second_t dt) { | ||
if (_driver.GetAButton()) { | ||
AlignToTarget(_SetPoints[0]); | ||
} else if (_driver.GetXButton()) { | ||
AlignToTarget(_SetPoints[1]); | ||
} else if (_driver.GetYButton()) { | ||
AlignToTarget(_SetPoints[2]); | ||
} else if (_driver.GetBButton()) { | ||
AlignToTarget(_SetPoints[3]); | ||
} else if (_driver.GetBackButtonPressed()) { | ||
CancelAlign(); | ||
} | ||
|
||
if (_state == poseState::notAtPose && !_limelight->IsAtSetPoseVision(_setPoint, dt)) { | ||
_swerve->SetPose(_setPoint.ToPose2d()); | ||
} | ||
else { | ||
_state = poseState::atPose; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters