-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFieldOrientedIntakeCommand.cpp
More file actions
53 lines (41 loc) · 1.44 KB
/
FieldOrientedIntakeCommand.cpp
File metadata and controls
53 lines (41 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <frc2/command/CommandBase.h>
#include <frc2/command/CommandHelper.h>
#include "Utils.h"
#include "subsystems/Intake.h"
#include "commands/intake/FieldOrientedIntakeCommand.h"
FieldOrientedIntakeCommand::FieldOrientedIntakeCommand(std::shared_ptr<Intake> intake, std::shared_ptr<SwerveDrive> swerve, double angle, double reverse_angle) {
// Set everything.
intake_ = intake;
angle_ = angle;
swerve_drive_ = swerve;
reverse_angle_ = reverse_angle;
if (intake_ != nullptr) {
this->AddRequirements(intake_.get());
}
}
void FieldOrientedIntakeCommand::Initialize() {
VOKC_CHECK(intake_ != nullptr)
VOKC_CALL(intake_->SetControlMode(Auto));
}
void FieldOrientedIntakeCommand::Execute() {
VOKC_CHECK(intake_ != nullptr);
// get the current robot heading
double heading = 0.0;
VOKC_CALL(swerve_drive_->GetHeading(&heading));
// convert to [-180, 180]
TeamOKC::WrapAngle(&heading);
// if the heading is pointing away from the scoring area
if (abs(heading) < 90.0) {
// score on the normal side of the robot
// set the desired state of the arm
VOKC_CALL(intake_->SetIntakeTilt(angle_));
} else {
// otherwise, score on the other side
// set the desired state of the arm
VOKC_CALL(intake_->SetIntakeTilt(reverse_angle_));
}
}
bool FieldOrientedIntakeCommand::IsFinished() {
// Always end this command.
return true;
}