CTRE Phoenix C++ 5.33.1
TalonFXSimCollection.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 TalonFX motor controller.
23 *
24 * Use the getSimCollection() routine inside your motor controller to create the respective sim collection.
25 *
26 * @deprecated This device's Phoenix 5 API is deprecated for removal in the
27 * 2025 season. Users should update to Phoenix 6 firmware and migrate to the
28 * Phoenix 6 API. A migration guide is available at
29 * https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html.
30 *
31 * If the Phoenix 5 API must be used for this device, the device must have 22.X
32 * firmware. This firmware is available in Tuner X after selecting Phoenix 5 in
33 * the firmware year dropdown.
34 */
36 public:
37 /**
38 * Constructor for TalonFXSimCollection
39 * @param motorController TalonFX Motor Controller to connect Collection to
40 */
42
43 /**
44 * Gets the last error generated by this object. Not all functions return an
45 * error code but can potentially report errors. This function can be used
46 * to retrieve those error codes.
47 *
48 * @return Last Error Code generated by a function.
49 */
51
52 /**
53 * Gets the simulated output voltage across M+ and M- for the motor.
54 *
55 * @return applied voltage to the motor in volts
56 */
58
59 /**
60 * Sets the simulated bus voltage of the TalonFX.
61 *
62 * The minimum allowed bus voltage is 4 V - values
63 * below this will be promoted to 4 V.
64 *
65 * @param vbat the bus voltage in volts
66 *
67 * @return error code
68 */
70
71 /**
72 * Sets the simulated supply current of the TalonFX.
73 *
74 * @param currA the supply current in amps
75 *
76 * @return error code
77 */
79
80 /**
81 * Sets the simulated stator current of the TalonFX.
82 *
83 * @param currA the stator current in amps
84 *
85 * @return error code
86 */
88
89 /**
90 * Sets the simulated forward limit switch of the TalonFX.
91 *
92 * @param isClosed true if the limit switch is closed
93 *
94 * @return error code
95 */
96 ErrorCode SetLimitFwd(bool isClosed);
97
98 /**
99 * Sets the simulated reverse limit switch of the TalonFX.
100 *
101 * @param isClosed true if the limit switch is closed
102 *
103 * @return error code
104 */
105 ErrorCode SetLimitRev(bool isClosed);
106
107 /**
108 * Sets the simulated raw integrated sensor position of the TalonFX.
109 *
110 * The TalonFX integrates this to calculate the true reported integrated sensor
111 * position.
112 *
113 * When using the WPI Sim GUI, you will notice a readonly 'position' and
114 * settable 'rawPositionInput'. The readonly signal is the emulated position
115 * which will match self-test in Tuner and the hardware API. Changes to
116 * 'rawPositionInput' will be integrated into the emulated position. This way
117 * a simulator can modify the position without overriding your
118 * hardware API calls for home-ing your sensor.
119 *
120 * Inputs to this function over time should be continuous,
121 * as user calls of SetSelectedSensorPosition() and SetIntegratedSensorPosition()
122 * will be accounted for in the calculation.
123 *
124 * @param newPos the new raw position in native units
125 *
126 * @return error code
127 */
129
130 /**
131 * Adds to the simulated integrated sensor position of the TalonFX.
132 *
133 * @param dPos the change in position in native units
134 *
135 * @return error code
136 */
138
139 /**
140 * Sets the simulated integrated sensor velocity of the TalonFX.
141 *
142 * @param newVel the new velocity in native units per 100ms
143 *
144 * @return error code
145 */
147
148 private:
149 int _id;
150
151 };
152
153 } // namespace motorcontrol
154 } // namespace phoenix
155} // namespace ctre
Collection of simulation commands available to a TalonFX motor controller.
Definition: TalonFXSimCollection.h:35
ErrorCode GetLastError()
Gets the last error generated by this object.
ErrorCode SetLimitFwd(bool isClosed)
Sets the simulated forward limit switch of the TalonFX.
ErrorCode SetStatorCurrent(double currA)
Sets the simulated stator current of the TalonFX.
ErrorCode SetIntegratedSensorVelocity(int newVel)
Sets the simulated integrated sensor velocity of the TalonFX.
double GetMotorOutputLeadVoltage()
Gets the simulated output voltage across M+ and M- for the motor.
TalonFXSimCollection(ctre::phoenix::motorcontrol::can::BaseTalon &motorController)
Constructor for TalonFXSimCollection.
ErrorCode SetLimitRev(bool isClosed)
Sets the simulated reverse limit switch of the TalonFX.
ErrorCode AddIntegratedSensorPosition(int dPos)
Adds to the simulated integrated sensor position of the TalonFX.
ErrorCode SetSupplyCurrent(double currA)
Sets the simulated supply current of the TalonFX.
ErrorCode SetBusVoltage(double vbat)
Sets the simulated bus voltage of the TalonFX.
ErrorCode SetIntegratedSensorRawPosition(int newPos)
Sets the simulated raw integrated sensor position of the TalonFX.
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