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
10
using namespace
Robot
;
11
using namespace
Robot::Globals
;
12
13
bool
LadyBrown::needs_warning
=
false
;
14
15
LadyBrown::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());
18
LadyBrown::needs_warning
=
false
;
19
LadyBrown::kP
= kiP;
20
LadyBrown::kI
= kiI;
21
LadyBrown::kD
= kiD;
22
}
23
24
LadyBrown::LadyBrown
() {
25
LadyBrownMotor
.set_brake_mode(pros::E_MOTOR_BRAKE_HOLD);
26
LadyBrownMotor
.set_zero_position(
LadyBrownMotor
.get_position());
27
LadyBrown::needs_warning
=
false
;
28
LadyBrown::kP
= 0;
29
LadyBrown::kI
= 0;
30
LadyBrown::kD
= 0;
31
}
32
33
void
LadyBrown::run
() {
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
{
40
if
(!
LadyBrown::needs_warning
) {
41
LadyBrownMotor
.brake();
42
}
43
}
44
}
45
46
void
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();
50
LadyBrown::needs_warning
=
false
;
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) {
56
LadyBrown::needs_warning
=
true
;
57
controller
.rumble(
"."
);
58
}
59
while
(
LadyBrownMotor
.get_position() >= 800) {
60
LadyBrown::needs_warning
=
true
;
61
controller
.rumble(
"-"
);
62
}
63
}
64
LadyBrown::needs_warning
=
false
;
65
pros::Task::delay_until(&time, TASK_DELAY_MILLIS);
66
}
67
}
68
69
void
LadyBrown::toggle
() {}
70
71
// Vision sensor only works with LadyBrown, therefore it should not on
72
double
LadyBrown::pid_update
() {
return
0; }
Robot::LadyBrown::pid_update
double pid_update()
Definition
ladybrown.cpp:72
Robot::LadyBrown::edge_check
static void edge_check(void *param)
Definition
ladybrown.cpp:46
Robot::LadyBrown::run
void run()
Runs the main function of the intake system.
Definition
ladybrown.cpp:33
Robot::LadyBrown::kI
double kI
Definition
ladybrown.h:41
Robot::LadyBrown::LadyBrown
LadyBrown()
Definition
ladybrown.cpp:24
Robot::LadyBrown::needs_warning
static bool needs_warning
Definition
ladybrown.h:20
Robot::LadyBrown::kD
double kD
Definition
ladybrown.h:42
Robot::LadyBrown::toggle
void toggle()
Toggles intake elevation.
Definition
ladybrown.cpp:69
Robot::LadyBrown::kP
double kP
Definition
ladybrown.h:40
SLOWER_VELOCITY
#define SLOWER_VELOCITY
Definition
intake.cpp:5
ladybrown.h
Robot::Globals
Definition
globals.cpp:20
Robot::Globals::LadyBrownMotor
pros::Motor LadyBrownMotor(3, pros::v5::MotorGears::green, pros::v5::MotorUnits::degrees)
Robot::Globals::controller
pros::Controller controller(pros::E_CONTROLLER_MASTER)
Robot
Definition
auton.h:8
src
subsystems
ladybrown.cpp
Generated on Sat Jan 11 2025 13:28:26 for 1516X High Stakes by
1.13.1