-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeeder_limit_command.cpp
More file actions
91 lines (65 loc) · 2.58 KB
/
Copy pathfeeder_limit_command.cpp
File metadata and controls
91 lines (65 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "feeder_limit_command.hpp"
#include "tap/communication/gpio/leds.hpp"
#include "tap/control/command.hpp"
#include "subsystems/feeder/control/feeder.hpp"
#include "utils/tools/common_types.hpp"
#include "utils/ref_system/ref_helper_turreted.hpp"
#include "drivers.hpp"
#ifdef FEEDER_COMPATIBLE
namespace src::Feeder {
/*
Define any variables you need here!
We have provided some here to give you sensor data and other useful things
*/
bool limitPressed = false;
bool wantToShoot = false;
float currRPM = 0.0;
//Subsystem declarations, do not touch these
FeederLimitCommand::FeederLimitCommand(
src::Drivers* drivers,
FeederSubsystem* feeder,
src::Utils::RefereeHelperTurreted* refHelper,
int UNJAM_TIMER_MS)
: drivers(drivers),
feeder(feeder),
refHelper(refHelper),
UNJAM_TIMER_MS(UNJAM_TIMER_MS) {
addSubsystemRequirement(dynamic_cast<tap::control::Subsystem*>(feeder));
}
void FeederLimitCommand::initialize() {
//Makes sure robot doesn't shoot when turned on
feeder->ForFeederMotorGroup(ALL, &FeederSubsystem::deactivateFeederMotor);
//Initialized 6 timers, you can use as many or as few as you like
timer1.restart(0);
timer2.restart(0);
timer3.restart(0);
timer4.restart(0);
timer5.restart(0);
timer6.restart(0);
//System time on initialization, might be useful for heat managment
initialTime = tap::arch::clock::getTimeMilliseconds();
}
void FeederLimitCommand::execute() {
/*
Update calls to get sensor data and input, dont touch but do use these variables
to check input states and sensor data
*/
//Updates if the limit switch detects a ball
//True = ball detected, False means no ball detected
limitPressed = feeder->getPressed();
//Gets if the driver wants to shoot a ball
//Will hold true for a little bit before dropping back down to false
wantToShoot = (drivers->remote.getSwitch(Remote::Switch::RIGHT_SWITCH) == Remote::SwitchState::UP || drivers->remote.getMouseL()==true || drivers->cvCommunicator.shouldFire());
//Gets current rpm of the base feeder motor, might be useful for unjam
currRPM = feeder->getCurrentRPM(0);
//Write Here for Challenge 1, 2, 3!
}
/*Declare any helper functions down here (make sure to include in hpp)*/
//void exampleFunc(){
// do stuff
//};
//Do not touch these functions, they are required for the command to work properly
void FeederLimitCommand::end(bool) { feeder->ForFeederMotorGroup(ALL, &FeederSubsystem::deactivateFeederMotor); }
bool FeederLimitCommand::isFinished() const { return false; }
}
#endif