CTRE Phoenix C++ 5.33.1
TalonSRXSimCollection.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2#pragma once
3
5
6/* forward proto's */
7namespace ctre {
8 namespace phoenix {
9 namespace motorcontrol {
10 namespace can {
11 class BaseTalon;
12 }
13 }
14 }
15}
16
17namespace ctre {
18 namespace phoenix {
19 namespace motorcontrol {
20
21 /**
22 * Collection of simulation commands available to a TalonSRX motor controller.
23 *
24 * Use the getSimCollection() routine inside your motor controller to create the respective sim collection.
25 */
27 public:
28 /**
29 * Constructor for TalonSRXSimCollection
30 * @param motorController TalonSRX Motor Controller to connect Collection to
31 */
33
34 /**
35 * Gets the last error generated by this object. Not all functions return an
36 * error code but can potentially report errors. This function can be used
37 * to retrieve those error codes.
38 *
39 * @return Last Error Code generated by a function.
40 */
42
43 /**
44 * Gets the simulated output voltage across M+ and M- for the motor.
45 *
46 * @return applied voltage to the motor in volts
47 */
49
50 /**
51 * Sets the simulated bus voltage of the TalonSRX.
52 *
53 * The minimum allowed bus voltage is 4 V - values
54 * below this will be promoted to 4 V.
55 *
56 * @param vbat the bus voltage in volts
57 *
58 * @return error code
59 */
61
62 /**
63 * Sets the simulated supply current of the TalonSRX.
64 *
65 * @param currA the supply current in amps
66 *
67 * @return error code
68 */
70
71 /**
72 * Sets the simulated stator current of the TalonSRX.
73 *
74 * @param currA the stator current in amps
75 *
76 * @return error code
77 */
79
80 /**
81 * Sets the simulated forward limit switch of the TalonSRX.
82 *
83 * @param isClosed true if the limit switch is closed
84 *
85 * @return error code
86 */
87 ErrorCode SetLimitFwd(bool isClosed);
88
89 /**
90 * Sets the simulated reverse limit switch of the TalonSRX.
91 *
92 * @param isClosed true if the limit switch is closed
93 *
94 * @return error code
95 */
96 ErrorCode SetLimitRev(bool isClosed);
97
98 /**
99 * Sets the simulated analog position of the TalonSRX.
100 *
101 * @param newPos the new position in native units
102 *
103 * @return error code
104 */
106
107 /**
108 * Adds to the simulated analog position of the TalonSRX.
109 *
110 * @param dPos the change in position in native units
111 *
112 * @return error code
113 */
115
116 /**
117 * Sets the simulated analog velocity of the TalonSRX.
118 *
119 * @param newVel the new velocity in native units per 100ms
120 *
121 * @return error code
122 */
124
125 /**
126 * Sets if the simulated pulse width sensor is connected to the TalonSRX.
127 *
128 * @param isConnected true if the pulse width sensor is connected
129 *
130 * @return error code
131 */
133
134 /**
135 * Sets the simulated pulse width rise to rise time of the TalonSRX.
136 *
137 * @param periodUs the pulse width rise to rise time in microseconds
138 *
139 * @return error code
140 */
142
143 /**
144 * Sets the simulated pulse width position of the TalonSRX.
145 *
146 * @param newPos the new position in native units
147 *
148 * @return error code
149 */
151
152 /**
153 * Adds to the simulated pulse width position of the TalonSRX.
154 *
155 * @param dPos the change in position in native units
156 *
157 * @return error code
158 */
160
161 /**
162 * Sets the simulated pulse width velocity of the TalonSRX.
163 *
164 * @param newVel the new velocity in native units per 100ms
165 *
166 * @return error code
167 */
169
170 /**
171 * Sets the simulated raw quadrature position of the TalonSRX.
172 *
173 * The TalonSRX integrates this to calculate the true reported quadrature
174 * position.
175 *
176 * When using the WPI Sim GUI, you will notice a readonly 'position' and
177 * settable 'rawPositionInput'. The readonly signal is the emulated position
178 * which will match self-test in Tuner and the hardware API. Changes to
179 * 'rawPositionInput' will be integrated into the emulated position. This way
180 * a simulator can modify the position without overriding your
181 * hardware API calls for home-ing your sensor.
182 *
183 * Inputs to this function over time should be continuous,
184 * as user calls of SetSelectedSensorPosition() and SetQuadraturePosition()
185 * will be accounted for in the calculation.
186 *
187 * @param newPos the new raw position in native units
188 *
189 * @return error code
190 */
192
193 /**
194 * Adds to the simulated quadrature position of the TalonSRX.
195 *
196 * @param dPos the change in position in native units
197 *
198 * @return error code
199 */
201
202 /**
203 * Sets the simulated quadrature velocity of the TalonSRX.
204 *
205 * @param newVel the new velocity in native units per 100ms
206 *
207 * @return error code
208 */
210
211 private:
212 int _id;
213
214 };
215
216 } // namespace motorcontrol
217 } // namespace phoenix
218} // namespace ctre
Collection of simulation commands available to a TalonSRX motor controller.
Definition: TalonSRXSimCollection.h:26
ErrorCode SetPulseWidthVelocity(int newVel)
Sets the simulated pulse width velocity of the TalonSRX.
ErrorCode SetAnalogVelocity(int newVel)
Sets the simulated analog velocity of the TalonSRX.
ErrorCode SetPulseWidthPosition(int newPos)
Sets the simulated pulse width position of the TalonSRX.
ErrorCode AddAnalogPosition(int dPos)
Adds to the simulated analog position of the TalonSRX.
ErrorCode SetPulseWidthConnected(bool isConnected)
Sets if the simulated pulse width sensor is connected to the TalonSRX.
ErrorCode GetLastError()
Gets the last error generated by this object.
TalonSRXSimCollection(ctre::phoenix::motorcontrol::can::BaseTalon &motorController)
Constructor for TalonSRXSimCollection.
ErrorCode SetBusVoltage(double vbat)
Sets the simulated bus voltage of the TalonSRX.
ErrorCode AddQuadraturePosition(int dPos)
Adds to the simulated quadrature position of the TalonSRX.
ErrorCode SetQuadratureRawPosition(int newPos)
Sets the simulated raw quadrature position of the TalonSRX.
ErrorCode SetPulseWidthRiseToRiseUs(double periodUs)
Sets the simulated pulse width rise to rise time of the TalonSRX.
ErrorCode SetQuadratureVelocity(int newVel)
Sets the simulated quadrature velocity of the TalonSRX.
ErrorCode AddPulseWidthPosition(int dPos)
Adds to the simulated pulse width position of the TalonSRX.
ErrorCode SetLimitFwd(bool isClosed)
Sets the simulated forward limit switch of the TalonSRX.
ErrorCode SetSupplyCurrent(double currA)
Sets the simulated supply current of the TalonSRX.
ErrorCode SetStatorCurrent(double currA)
Sets the simulated stator current of the TalonSRX.
double GetMotorOutputLeadVoltage()
Gets the simulated output voltage across M+ and M- for the motor.
ErrorCode SetAnalogPosition(int newPos)
Sets the simulated analog position of the TalonSRX.
ErrorCode SetLimitRev(bool isClosed)
Sets the simulated reverse limit switch of the TalonSRX.
CTRE Talon SRX Motor Controller when used on CAN Bus.
Definition: BaseTalon.h:267
ErrorCode
Definition: ErrorCode.h:13
namespace ctre
Definition: paramEnum.h:5