LRT13  1.0
 All Classes Namespaces Functions Variables Enumerations Enumerator
Esc.h
1 #ifndef ESC_H_
2 #define ESC_H_
3 
4 #include <WPILib.h>
5 #include <utility>
6 #include <string>
7 
8 #include "AsyncCANJaguar.h"
9 #include "LRTTalon.h"
10 #include "..\Config\ConfigManager.h"
11 #include "..\Config\Configurable.h"
12 #include "..\Utils\AsyncPrinter.h"
13 #include "..\Sensors\DriveEncoders.h"
14 #include "..\Utils\RunningSum.h"
15 
16 #define TALON 0
17 
18 using namespace std;
19 
20 class ESC : public Configurable
21 {
22 public:
23 
31  ESC(int channel, LRTEncoder* encoder, string name, int brakeChannel);
41  ESC(int channelA, int channelB, int brakeChannelA, int brakeChannelB, LRTEncoder* encoder, string name);
42 
49  ESC(int channel, LRTEncoder* encoder, string name);
57  ESC(int channelA, int channelB, LRTEncoder* encoder, string name);
58 
59 
63  ~ESC();
64 
68  virtual void Configure();
69 
74  void SetDutyCycle(float dutycycle);
75 
76  void SetForwardCurrentLimit(float limit);
77  void SetReverseCurrentLimit(float limit);
78 
82  void ResetCache();
83 
84  void DecrementMaxVDiff();
85  void IncrementMaxVDiff();
86  void ResetMaxVDiff();
87 
88  void Disable();
89  LRTEncoder* m_encoder;
90 private:
91  float DitheredBraking(float dutyCycle, float speed);
92  float CurrentLimit(float dutyCycle, float speed);
93 
94  LRTSpeedController *m_controller1, *m_controller2;
95  std::string namea, nameb;
96 
97  float maxVDiff;
98  // CANJaguar *m_jag1, *m_jag2;
99 
100  float m_delta_voltage_limit;
101 
102  string m_name;
103  int m_cycle_count;
104 
105  float m_forwardCurrentLimit; // % stall current for acceleration
106  float m_reverseCurrentLimit; // % stall current for reversing direction
107 
108  struct brakeAndDutyCycle
109  {
110  float dutyCycle;
111  float braking;
112  };
113 
114  brakeAndDutyCycle CalculateBrakeAndDutyCycle(float target_speed,
115  float current_speed);
116 };
117 
118 #endif /* ESC_H_ */