1516X High Stakes 2.0
Codebase for 1516X High Stakes season
Loading...
Searching...
No Matches
ladybrown.cpp
Go to the documentation of this file.
1#include "robot/ladybrown.h"
2
3#include "globals.h"
4#include "pros/motors.h"
5#include "pros/rtos.hpp"
6
7#define SLOWER_VELOCITY 125
8#define FASTER_VELOCITY 150
9
10using namespace Robot;
11using namespace Robot::Globals;
12
13bool LadyBrown::needs_warning = false;
14
15LadyBrown::LadyBrown(double kiP, double kiI, double kiD) {
16 LadyBrownMotor.set_brake_mode(pros::E_MOTOR_BRAKE_HOLD);
17 LadyBrownMotor.set_zero_position(LadyBrownMotor.get_position());
19 LadyBrown::kP = kiP;
20 LadyBrown::kI = kiI;
21 LadyBrown::kD = kiD;
22}
23
25 LadyBrownMotor.set_brake_mode(pros::E_MOTOR_BRAKE_HOLD);
26 LadyBrownMotor.set_zero_position(LadyBrownMotor.get_position());
28 LadyBrown::kP = 0;
29 LadyBrown::kI = 0;
30 LadyBrown::kD = 0;
31}
32
34
35 if (controller.get_digital(pros::E_CONTROLLER_DIGITAL_R2)) {
36 LadyBrownMotor.move_velocity(-SLOWER_VELOCITY);
37 } else if (controller.get_digital(pros::E_CONTROLLER_DIGITAL_L2)) {
38 LadyBrownMotor.move_velocity(SLOWER_VELOCITY);
39 } else {
41 LadyBrownMotor.brake();
42 }
43 }
44}
45
46void LadyBrown::edge_check(void *param) {
47 constexpr int TASK_DELAY_MILLIS = 100;
48 constexpr int CONTROLLER_DELAY_MILLIS = 50;
49 uint32_t time = pros::millis();
51 // Check if the lady brown position is too low
52 while (true) {
53
54 if (LadyBrownMotor.get_position() < -5 || LadyBrownMotor.get_position() >= 800) {
55 while (LadyBrownMotor.get_position() < -5) {
57 controller.rumble(".");
58 }
59 while (LadyBrownMotor.get_position() >= 800) {
61 controller.rumble("-");
62 }
63 }
65 pros::Task::delay_until(&time, TASK_DELAY_MILLIS);
66 }
67}
68
70
71// Vision sensor only works with LadyBrown, therefore it should not on
72double LadyBrown::pid_update() { return 0; }
double pid_update()
Definition ladybrown.cpp:72
static void edge_check(void *param)
Definition ladybrown.cpp:46
void run()
Runs the main function of the intake system.
Definition ladybrown.cpp:33
static bool needs_warning
Definition ladybrown.h:20
void toggle()
Toggles intake elevation.
Definition ladybrown.cpp:69
#define SLOWER_VELOCITY
Definition intake.cpp:5
pros::Motor LadyBrownMotor(3, pros::v5::MotorGears::green, pros::v5::MotorUnits::degrees)
pros::Controller controller(pros::E_CONTROLLER_MASTER)
Definition auton.h:8