This repository has been archived by the owner on Mar 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Climber.cpp.old
56 lines (48 loc) · 1.58 KB
/
Climber.cpp.old
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
#include "Climber.hpp"
#include "Constants.hpp"
Climber::Climber()
{
climber_1.RestoreFactoryDefaults();
climber_2.RestoreFactoryDefaults();
climber_1.SetIdleMode(CLIMBER::IDLE_MODE);
climber_2.SetIdleMode(CLIMBER::IDLE_MODE);
climber_1.SetP(CLIMBER::P);
climber_1.SetI(CLIMBER::I);
climber_1.SetD(CLIMBER::D);
climber_1.SetOutputRange(-CLIMBER::MAX_OUTPUT, CLIMBER::MAX_OUTPUT);
climber_2.SetPositionRange(Climber::POSITION::ZERO, Climber::POSITION::UP);
climber_1.SetTarget(Climber::POSITION::ZERO);
climber_2.SetP(CLIMBER::P);
climber_2.SetI(CLIMBER::I);
climber_2.SetD(CLIMBER::D);
climber_2.SetOutputRange(-CLIMBER::MAX_OUTPUT, CLIMBER::MAX_OUTPUT);
climber_2.SetPositionRange(-Climber::POSITION::UP, Climber::POSITION::ZERO);
climber_2.SetTarget(Climber::POSITION::ZERO);
}
void Climber::set(Climber::POSITION position)
{
climber_1.SetTarget(position, rev::ControlType::kPosition);
climber_2.SetTarget(-position, rev::ControlType::kPosition);
}
void Climber::joystickControl(double val)
{
climber_1.Set(val);
climber_2.Set(-val);
printStatus();
}
void Climber::printStatus()
{
std::cout << "Climber 1: " << climber_1.encoder.GetPosition() << std::endl;
std::cout << "Climber 2: " << climber_2.encoder.GetPosition() << std::endl;
}
void Climber::ButtonManager()
{
static bool hasBeenPressed = false;
if(BUTTON::CLIMBER::RAISE && BUTTON::oStick.GetThrottle() < 0)
{
hasBeenPressed = true;
set(Climber::POSITION::UP);
}
else if(hasBeenPressed)
set(Climber::POSITION::DOWN);
}