1516X High Stakes 2.0
Codebase for 1516X High Stakes season
Loading...
Searching...
No Matches
intake.cpp
Go to the documentation of this file.
1#include "robot/intake.h"
2
3#include "globals.h"
4
5using namespace Robot;
6using namespace Robot::Globals;
7
9{
10 elevated = false;
11 alliance_color = false;
12 controller.print(0, 0, "Intake initialized");
13}
14
16{
17 if (controller.get_digital(pros::E_CONTROLLER_DIGITAL_L1)) {
18 IntakeMotor.move_velocity(-375);
19 HookMotor.move_velocity(-600);
20 } else if (controller.get_digital(pros::E_CONTROLLER_DIGITAL_R1)) {
21 IntakeMotor.move_velocity(375);
22 HookMotor.move_velocity(600);
23 } else {
24 IntakeMotor.brake();
25 HookMotor.brake();
26 }
27}
28
30{
32 IntakeToggle.toggle();
33}
34
36 double color = colorSensor.get_hue();
37 bool red = color < 30.0 && color >= 0.0 || color > 330.0 && color <= 359.999;
38 bool blue = color > 200.0 && color < 230.0;
39 while (blue || red) {
40 color = colorSensor.get_hue();
41 red = color < 30.0 && color >= 0.0 || color > 330.0 && color <= 359.999;
42 blue = color > 200.0 && color < 230.0;
43 if (blue) {
44 if (alliance_color) {
45 IntakeMotor.move(-127);
46 }
47 else {
48 IntakeMotor.move(127);
49 }
50 } else if (red) {
51 if (alliance_color) {
52 IntakeMotor.move(127);
53 }
54 else {
55 IntakeMotor.move(-127);
56 }
57 } else {
58 IntakeMotor.brake();
59 break;
60 }
61 pros::delay(10);
62 }
63}
void score()
Outakes alliance rings into latched mobile goal and ejects enemy rings.
Definition intake.cpp:35
void toggle()
Toggles intake elevation.
Definition intake.cpp:29
bool alliance_color
blue is false, red is true.
Definition intake.h:37
void run()
Runs the main function of the intake system.
Definition intake.cpp:15
bool elevated
Definition intake.h:32
pros::Motor IntakeMotor(-9, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees)
pros::Optical colorSensor(4)
pros::Motor HookMotor(4, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees)
pros::adi::Pneumatics IntakeToggle('B', false)
pros::Controller controller(pros::E_CONTROLLER_MASTER)
Definition auton.h:8