1516X High Stakes 2.0
Codebase for 1516X High Stakes season
Loading...
Searching...
No Matches
Robot::Intake Class Reference

The Intake class represents a robot intake system. More...

#include <intake.h>

Public Member Functions

void run ()
 Runs the main function of the intake system.
 
void score ()
 Outakes alliance rings into latched mobile goal and ejects enemy rings.
 
 Intake ()
 
void toggle ()
 Toggles intake elevation.
 

Private Attributes

bool elevated
 
bool alliance_color
 blue is false, red is true.
 

Detailed Description

The Intake class represents a robot intake system.

Definition at line 9 of file intake.h.

Constructor & Destructor Documentation

◆ Intake()

Intake::Intake ( )

Definition at line 8 of file intake.cpp.

9{
10 elevated = false;
11 alliance_color = false;
12 controller.print(0, 0, "Intake initialized");
13}
bool alliance_color
blue is false, red is true.
Definition intake.h:37
bool elevated
Definition intake.h:32
pros::Controller controller(pros::E_CONTROLLER_MASTER)

References alliance_color, Robot::Globals::controller(), and elevated.

Member Function Documentation

◆ run()

void Intake::run ( )

Runs the main function of the intake system.

Takes optional user input to control the direction of the intake system in autonomous.

Definition at line 15 of file intake.cpp.

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}
pros::Motor IntakeMotor(-9, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees)
pros::Motor HookMotor(4, pros::v5::MotorGears::blue, pros::v5::MotorUnits::degrees)

References Robot::Globals::controller(), Robot::Globals::HookMotor(), and Robot::Globals::IntakeMotor().

Referenced by opcontrol().

◆ score()

void Intake::score ( )

Outakes alliance rings into latched mobile goal and ejects enemy rings.

Definition at line 35 of file intake.cpp.

35 {
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}
pros::Optical colorSensor(4)

References alliance_color, Robot::Globals::colorSensor(), and Robot::Globals::IntakeMotor().

Referenced by Robot::Autonomous::Auton1(), and Robot::Autonomous::Auton2().

◆ toggle()

void Intake::toggle ( )

Toggles intake elevation.

Definition at line 29 of file intake.cpp.

30{
32 IntakeToggle.toggle();
33}
pros::adi::Pneumatics IntakeToggle('B', false)

References elevated, and Robot::Globals::IntakeToggle().

Referenced by Robot::Autonomous::Auton1(), and Robot::Autonomous::Auton2().

Member Data Documentation

◆ alliance_color

bool Robot::Intake::alliance_color
private

blue is false, red is true.

Definition at line 37 of file intake.h.

Referenced by Intake(), and score().

◆ elevated

bool Robot::Intake::elevated
private

Definition at line 32 of file intake.h.

Referenced by Intake(), and toggle().


The documentation for this class was generated from the following files: