1516b Over Under 2.0
Codebase for 1516b over under season
Loading...
Searching...
No Matches
puncher.cpp
Go to the documentation of this file.
1#include "robot/drivetrain.h"
2#include "robot/puncher.h"
3#include "api.h"
4#include "globals.h"
5#include "pros/apix.h"
6
7using namespace Robot;
8using namespace Robot::Globals;
9
10void Puncher::setDistancePuncher(bool punch) {
11 distancePuncher = punch;
12}
13
14
15void Puncher::run(int autonVal) {
16
17 // Manual Puncher Control
18 if (Puncher::toShoot() == 2 || distancePuncher == false) {
19 if(controller.get_digital(pros::E_CONTROLLER_DIGITAL_R2)) {
20 punchers.move(127);
21 }
22 else {
23 punchers.brake();
24 }
25 }
26
27 // Auton Puncher Control using the distance sensor
28 if (distancePuncher == true && autonVal == 3) {
29 if (Puncher::toShoot() == 0) {
30 punchers.move_absolute(30, 95);
31 }
32 else {
33 punchers.brake();
34 }
35 }
36
37
38}
39
41 if (pros::c::registry_get_plugged_type(13) != pros::c::E_DEVICE_DISTANCE) {
42 distancePuncher = false;
43 return 2;
44 }
45 if (distance.get() <= 12 && distancePuncher == true) {
46 return 1;
47 }
48 if (distance.get() > 12 && distancePuncher == true) {
49 return 0;
50 }
51 return 2;
52}
53
54
56
57 if(controller.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_LEFT)) {
58
59 // Toggles the puncher distance sensor
61
62
63 // Prints the state of the puncher distance sensor to the brain(as a boolean)
64 if (distancePuncher == true) {
65 controller.print(0, 0, "Puncher: True");
66 }
67 else {
68 controller.print(0, 0, "Puncher: False");
69 }
70
71
72 }
73
74
75
76}
Represents a Puncher mechanism for a robot.
Definition puncher.h:12
bool distancePuncher
Determines whether to use the distance sensor or not.
Definition puncher.h:61
void setDistancePuncher(bool punch)
Sets the distancePuncher variable based on the punch parameter.
Definition puncher.cpp:10
void PuncherSwitch()
Toggles whether the distance sensor is activated or not and prints it out.
Definition puncher.cpp:55
int toShoot()
Checks if the distance sensor is connected and whether to shoot.
Definition puncher.cpp:40
void run(int autonVal)
Runs the puncher based on the given autonomous value.
Definition puncher.cpp:15
Contains global variables and type definitions for the Robot namespace.
Definition globals.cpp:18
pros::Controller controller
pros::Distance distance
pros::Motor_Group punchers
Contains all objects generated by the 1516B team - Contains all of the subsystems,...
Definition globals.cpp:17