-
Notifications
You must be signed in to change notification settings - Fork 0
/
Transmission.hpp
65 lines (57 loc) · 1.45 KB
/
Transmission.hpp
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
/*
* Transmission.hpp
*
* Created on: Jan 18, 2016
* Author: ryanmchale
*/
#ifndef SRC_TRANSMISSION_HPP_
#define SRC_TRANSMISSION_HPP_
#include"robotMap.h"
Solenoid* shift = new Solenoid(SHIFT_SOLENOID);
struct Transmission : CANTalon
{
public:
explicit Transmission(int t1,int t2)
{
con1 = new CANTalon(t1);
con1->SetFeedbackDevice(CANTalon::QuadEncoder);
con1->SetControlMode(CANSpeedController::kCurrent);
con1->ConfigNeutralMode(CANSpeedController::kNeutralMode_Coast);
con1->EnableControl();
con2 = new CANTalon(t2);
con2->SetFeedbackDevice(CANTalon::QuadEncoder);
con2->SetControlMode(CANSpeedController::kCurrent);
con2->ConfigNeutralMode(CANSpeedController::kNeutralMode_Coast);
con2->EnableControl();
}
virtual ~Transmission();
/**
* General percentage based speed control
* params: -1 - 1
*/
void Set(float set)
{
if(con1->GetControlMode()!=CANSpeedController::kPercentVbus)
con1->SetControlMode(CANSpeedController::kPercentVbus);
con1->Set(set);
con2->Set(set);
}
/**
* Prevents the breaker from blowing and
* increases torque in a shoving match
*/
void Shove(double set)
{
shift->Set(0); // Shift to low gear
set-=set/80; // Prevent breaker from blowing
set*=40;
if(con1->GetControlMode()!=CANSpeedController::kCurrent)
con1->SetControlMode(CANSpeedController::kCurrent);
con1->Set(set);
con2->Set(set);
}
private:
CANTalon *con1,
*con2;
};
#endif /* SRC_TRANSMISSION_HPP_ */