CTRE Phoenix C++ 5.33.1
WPI_TalonSRX.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2/**
3 * WPI Compliant motor controller class.
4 * WPILIB's object model requires many interfaces to be implemented to use
5 * the various features.
6 * This includes...
7 * - Software PID loops running in the robot controller
8 * - LiveWindow/Test mode features
9 * - Motor Safety (auto-turn off of motor if Set stops getting called)
10 * - Single Parameter set that assumes a simple motor controller.
11 */
12#pragma once
13
16#include "ctre/phoenix/platform/Platform.hpp"
18
19
20//Turn off dominance warning
21#if _MSC_VER
22 #pragma warning(push)
23 #pragma warning(disable : 4250)
24#endif
25
26using namespace ctre::phoenix;
27
28namespace ctre {
29namespace phoenix {
30namespace motorcontrol {
31namespace can {
32
33/**
34 * CTRE Talon SRX Motor Controller when used on CAN Bus.
35 */
36class WPI_TalonSRX : public virtual TalonSRX,
37 public virtual WPI_BaseMotorController
38{
39public:
40 /**
41 * Constructor for a WPI_TalonSRX
42 * @param deviceNumber Device ID of TalonSRX
43 */
44 WPI_TalonSRX(int deviceNumber);
45 virtual ~WPI_TalonSRX();
46
47 WPI_TalonSRX() = delete;
48 WPI_TalonSRX(WPI_TalonSRX const &) = delete;
50
51 /* ----- virtual re-directs ------- */
52 virtual void Set(double value);
53 virtual void Set(ControlMode mode, double value);
54 virtual void Set(ControlMode mode, double demand0, DemandType demand1Type, double demand1);
55 virtual void Set(TalonSRXControlMode mode, double value);
56 virtual void Set(TalonSRXControlMode mode, double demand0, DemandType demand1Type, double demand1);
57 virtual void SetVoltage(units::volt_t output);
58 virtual void SetInverted(InvertType invertType);
59 virtual void SetInverted(bool bInvert);
60 virtual ctre::phoenix::ErrorCode ConfigSelectedFeedbackSensor(FeedbackDevice feedbackDevice, int pidIdx = 0, int timeoutMs = 0);
61 virtual ctre::phoenix::ErrorCode ConfigSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice, int pidIdx = 0, int timeoutMs = 0);
62protected:
63
64private:
65
66 hal::SimDevice m_simMotor;
67 hal::SimDouble m_simPercOut;
68 hal::SimDouble m_simMotorOutputLeadVoltage;
69 hal::SimDouble m_simSupplyCurrent;
70 hal::SimDouble m_simMotorCurrent;
71 hal::SimDouble m_simVbat;
72
73 hal::SimDevice m_simAnalogEnc;
74 hal::SimBoolean m_simAnalogInit;
75 hal::SimDouble m_simAnalogVoltage;
76
77 hal::SimDevice m_simPulseWidthEnc;
78 hal::SimBoolean m_simPulseWidthConnected;
79 hal::SimDouble m_simPulseWidthPos;
80
81 hal::SimDevice m_simQuadEnc;
82 hal::SimDouble m_simQuadPos;
83 hal::SimDouble m_simQuadRawPos;
84 hal::SimDouble m_simQuadVel;
85
86 hal::SimDevice m_simFwdLim;
87 hal::SimBoolean m_simFwdLimInit;
88 hal::SimBoolean m_simFwdLimInput;
89 hal::SimBoolean m_simFwdLimValue;
90
91 hal::SimDevice m_simRevLim;
92 hal::SimBoolean m_simRevLimInit;
93 hal::SimBoolean m_simRevLimInput;
94 hal::SimBoolean m_simRevLimValue;
95
96 static void OnValueChanged(const char* name, void* param, HAL_SimValueHandle handle,
97 HAL_Bool readonly, const struct HAL_Value* value);
98 static void OnPeriodic(void* param);
99
100};
101
102} // namespace can
103} // namespace motorcontrol
104} // namespace phoenix
105} // namespace ctre
106
107#if _MSC_VER
108 #pragma warning(pop)
109#endif
CTRE Talon SRX Motor Controller when used on CAN Bus.
Definition: TalonSRX.h:145
VEX Victor SPX Motor Controller when used on CAN Bus.
Definition: WPI_BaseMotorController.h:57
CTRE Talon SRX Motor Controller when used on CAN Bus.
Definition: WPI_TalonSRX.h:38
WPI_TalonSRX(int deviceNumber)
Constructor for a WPI_TalonSRX.
virtual void Set(ControlMode mode, double value)
Sets the appropriate output on the talon, depending on the mode.
virtual void Set(ControlMode mode, double demand0, DemandType demand1Type, double demand1)
virtual void Set(double value)
Common interface for setting the speed of a simple speed controller.
virtual void Set(TalonSRXControlMode mode, double value)
WPI_TalonSRX & operator=(WPI_TalonSRX const &)=delete
virtual ctre::phoenix::ErrorCode ConfigSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice, int pidIdx=0, int timeoutMs=0)
Select the remote feedback device for the motor controller.
virtual void SetInverted(InvertType invertType)
Common interface for inverting direction of a speed controller.
virtual void SetInverted(bool bInvert)
Common interface for inverting direction of a speed controller.
WPI_TalonSRX(WPI_TalonSRX const &)=delete
virtual void Set(TalonSRXControlMode mode, double demand0, DemandType demand1Type, double demand1)
virtual ctre::phoenix::ErrorCode ConfigSelectedFeedbackSensor(FeedbackDevice feedbackDevice, int pidIdx=0, int timeoutMs=0)
Select the feedback device for the motor controller.
virtual void SetVoltage(units::volt_t output)
Sets the voltage output of the SpeedController.
ControlMode
Choose the control mode for a motor controller.
Definition: ControlMode.h:11
DemandType
How to interpret a demand value.
Definition: DemandType.h:10
InvertType
Choose the invert type of the motor controller.
Definition: InvertType.h:14
RemoteFeedbackDevice
Choose the remote feedback device for a motor controller.
Definition: FeedbackDevice.h:179
FeedbackDevice
Choose the feedback device for a motor controller.
Definition: FeedbackDevice.h:14
TalonSRXControlMode
Choose the control mode for a Talon SRX.
Definition: ControlMode.h:114
namespace phoenix
Definition: paramEnum.h:6
ErrorCode
Definition: ErrorCode.h:13
namespace ctre
Definition: paramEnum.h:5