-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPickup.cpp
69 lines (57 loc) · 1.85 KB
/
Pickup.cpp
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
#include "Subsystem.h"
#include "WPIObjMgr.h"
#include "Config.h"
class Pickup : public Spyder::Subsystem
{
Spyder::ConfigVar<UINT32> ClampSol;
Spyder::ConfigVar<UINT32> ReleaseSol;
Spyder::TwoIntConfig cSol;
Spyder::TwoIntConfig rSol;
Spyder::ConfigVar<UINT32> arm;
Spyder::TwoIntConfig stick;
public:
Pickup() : Spyder::Subsystem("Pickup"), ClampSol("pickup_close_sol",5), ReleaseSol("pickup_open_sol", 6),
cSol("bind_pickup_close", 3, 6), rSol("bind_pickup_open", 3, 7), //FIXME: get appropreate button numbers
arm("pickup_arm_mot", 12), stick("bind_pickup_arm_axis", 3, 2)
{
}
virtual ~Pickup()
{
}
virtual void Init(Spyder::RunModes runmode)
{
Spyder::GetSolenoid(ClampSol.GetVal())->Set(false);
Spyder::GetSolenoid(ReleaseSol.GetVal())->Set(true);
Spyder::GetVictor(arm.GetVal())->Set(0.0f);
}
virtual void Periodic(Spyder::RunModes runmode)
{
switch(runmode)
{
case Spyder::M_DISABLED:
Spyder::GetSolenoid(ClampSol.GetVal())->Set(false);
Spyder::GetSolenoid(ReleaseSol.GetVal())->Set(true);
Spyder::GetVictor(arm.GetVal())->Set(0.0f);
break;
case Spyder::M_TELEOP:
Spyder::GetVictor(arm.GetVal())->Set(Spyder::GetJoystick(stick.GetVar(1))->GetRawAxis(stick.GetVar(2)));
if(Spyder::GetJoystick(cSol.GetVar(1))->GetRawButton(cSol.GetVar(2))==true) {
Spyder::GetSolenoid(ClampSol.GetVal())->Set(true);
Spyder::GetSolenoid(ReleaseSol.GetVal())->Set(false);
}
else if(Spyder::GetJoystick(rSol.GetVar(1))->GetRawButton(rSol.GetVar(2))==true) {
Spyder::GetSolenoid(ClampSol.GetVal())->Set(false);
Spyder::GetSolenoid(ReleaseSol.GetVal())->Set(true);
}
break;
default:
Spyder::GetSolenoid(ClampSol.GetVal())->Set(false);
Spyder::GetSolenoid(ReleaseSol.GetVal())->Set(true);
Spyder::GetVictor(arm.GetVal())->Set(0.0f);
}
}
virtual void RobotInit()
{
}
};
Pickup pickup;