CTRE_Phoenix 5.20.2
TalonSRX.h
1#pragma once
2#if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
3#pragma warning (push)
4#pragma warning (disable : 4250)
5#endif
6
7#include "ctre/phoenix/motorcontrol/can/BaseTalon.h"
8#include "ctre/phoenix/motorcontrol/IMotorControllerEnhanced.h"
9#include "ctre/phoenix/CustomParamConfiguration.h"
10
11/* forward proto's */
12namespace ctre {
13 namespace phoenix {
14 namespace motorcontrol {
15 class SensorCollection;
16 class TalonSRXSimCollection;
17 }
18 }
19}
20
21namespace ctre {
22 namespace phoenix {
23 namespace motorcontrol {
24 namespace can {
25
34
67 {
68 }
69
73 std::string toString() {
74 return toString("");
75 }
76
82 std::string toString(std::string prependString) {
83
84 std::string retstr;
85 retstr += prependString + ".peakCurrentLimit = " + std::to_string(peakCurrentLimit) + ";\n";
86 retstr += prependString + ".peakCurrentDuration = " + std::to_string(peakCurrentDuration) + ";\n";
87 retstr += prependString + ".continuousCurrentLimit = " + std::to_string(continuousCurrentLimit) + ";\n";
88 retstr += BaseTalonConfiguration::toString(prependString);
89
90 return retstr;
91 }
92 };// struct TalonSRXConfiguration
93
98 private:
99 static struct TalonSRXConfiguration _default;
100 public:
107 static bool PeakCurrentLimitDifferent(const TalonSRXConfiguration& settings) { return (!(settings.peakCurrentLimit == _default.peakCurrentLimit)) || !settings.enableOptimizations; }
108 static bool PeakCurrentDurationDifferent(const TalonSRXConfiguration& settings) { return (!(settings.peakCurrentDuration == _default.peakCurrentDuration)) || !settings.enableOptimizations; }
109 static bool ContinuousCurrentLimitDifferent(const TalonSRXConfiguration& settings) { return (!(settings.continuousCurrentLimit == _default.continuousCurrentLimit)) || !settings.enableOptimizations; }
110
112 };
113
143 class TalonSRX : public virtual BaseTalon
144 {
145 private:
146
147 public:
152 TalonSRX(int deviceNumber);
153 ~TalonSRX();
154 TalonSRX() = delete;
155 TalonSRX(TalonSRX const&) = delete;
156 TalonSRX& operator=(TalonSRX const&) = delete;
157 // ------ Set output routines. ----------//
176 void Set(TalonSRXControlMode mode, double value);
215 void Set(TalonSRXControlMode mode, double demand0, DemandType demand1Type, double demand1);
216 //------ sensor selection ----------//
230 ctre::phoenix::ErrorCode ConfigSelectedFeedbackSensor(TalonSRXFeedbackDevice feedbackDevice, int pidIdx = 0, int timeoutMs = 0);
244 ctre::phoenix::ErrorCode ConfigSelectedFeedbackSensor(FeedbackDevice feedbackDevice, int pidIdx, int timeoutMs = 0);
245
261
262 //------ Current Limit ----------//
272 virtual ctre::phoenix::ErrorCode ConfigSupplyCurrentLimit(const SupplyCurrentLimitConfiguration& currLimitConfigs, int timeoutMs = 50);
319 int timeoutMs = 0);
344
357 void EnableCurrentLimit(bool enable);
358 //------ RAW Sensor API ----------//
363
364 //------ Simulation API ----------//
369
370 //------ All Configs ----------//
371
382 ctre::phoenix::ErrorCode ConfigurePID(const TalonSRXPIDSetConfiguration& pid, int pidIdx = 0, int timeoutMs = 50);
393 void GetPIDConfigs(TalonSRXPIDSetConfiguration& pid, int pidIdx = 0, int timeoutMs = 50);
415 void GetAllConfigs(TalonSRXConfiguration& allConfigs, int timeoutMs = 50);
416
417 /* ----- virtual re-directs ------- */
418 virtual void Set(ControlMode mode, double value);
419 virtual void Set(ControlMode mode, double demand0, DemandType demand1Type, double demand1);
420 };// class TalonSRX
421
422 } // namespace can
423 } // namespace motorcontrol
424 } // namespace phoenix
425} // namespace ctre
426
427#if defined(WIN32) || defined(_WIN32) || defined(_WIN64)
428#pragma warning (pop)
429#endif
Definition: SensorCollection.h:30
Definition: TalonSRXSimCollection.h:25
static bool PeakCurrentLimitDifferent(const TalonSRXConfiguration &settings)
Definition: TalonSRX.h:107
virtual ctre::phoenix::ErrorCode ConfigSupplyCurrentLimit(const SupplyCurrentLimitConfiguration &currLimitConfigs, int timeoutMs=50)
ctre::phoenix::ErrorCode ConfigurePID(const TalonSRXPIDSetConfiguration &pid, int pidIdx=0, int timeoutMs=50)
ctre::phoenix::ErrorCode ConfigSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice, int pidIdx, int timeoutMs)
ctre::phoenix::ErrorCode ConfigContinuousCurrentLimit(int amps, int timeoutMs=0)
ctre::phoenix::motorcontrol::TalonSRXSimCollection & GetSimCollection()
ctre::phoenix::ErrorCode ConfigSelectedFeedbackSensor(FeedbackDevice feedbackDevice, int pidIdx, int timeoutMs=0)
virtual void Set(ControlMode mode, double value)
ctre::phoenix::ErrorCode ConfigSelectedFeedbackSensor(TalonSRXFeedbackDevice feedbackDevice, int pidIdx=0, int timeoutMs=0)
ctre::phoenix::ErrorCode ConfigPeakCurrentLimit(int amps, int timeoutMs=0)
void GetAllConfigs(TalonSRXConfiguration &allConfigs, int timeoutMs=50)
void Set(TalonSRXControlMode mode, double value)
ctre::phoenix::motorcontrol::SensorCollection & GetSensorCollection()
void GetPIDConfigs(TalonSRXPIDSetConfiguration &pid, int pidIdx=0, int timeoutMs=50)
void Set(TalonSRXControlMode mode, double demand0, DemandType demand1Type, double demand1)
virtual void Set(ControlMode mode, double demand0, DemandType demand1Type, double demand1)
ctre::phoenix::ErrorCode ConfigAllSettings(const TalonSRXConfiguration &allConfigs, int timeoutMs=50)
ctre::phoenix::ErrorCode ConfigPeakCurrentDuration(int milliseconds, int timeoutMs=0)
ControlMode
Definition: ControlMode.h:10
DemandType
Definition: DemandType.h:9
RemoteFeedbackDevice
Definition: FeedbackDevice.h:169
FeedbackDevice
Definition: FeedbackDevice.h:13
TalonSRXFeedbackDevice
Definition: FeedbackDevice.h:75
TalonSRXControlMode
Definition: ControlMode.h:101
ErrorCode
Definition: ErrorCode.h:12
Definition: ErrorCode.h:5
bool enableOptimizations
Definition: CustomParamConfiguration.h:22
Definition: SupplyCurrentLimitConfiguration.h:13
std::string toString()
Definition: BaseTalon.h:196
std::string toString()
Definition: TalonSRX.h:73
std::string toString(std::string prependString)
Definition: TalonSRX.h:82