CTRE Phoenix 6 C++ 25.3.0
Loading...
Searching...
No Matches
CANdiSimState.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) Cross The Road Electronics.  All rights reserved.
3 * License information can be found in CTRE_LICENSE.txt
4 * For support and suggestions contact support@ctr-electronics.com or file
5 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
6 */
7#pragma once
8
12#include <units/angle.h>
13#include <units/angular_velocity.h>
14#include <units/voltage.h>
15#include <units/current.h>
16
17namespace ctre {
18namespace phoenix6 {
19
20namespace hardware {
21namespace core {
22 /* forward proto */
23 class CoreCANdi;
24}
25}
26
27namespace sim {
28
29 /**
30 * \brief Class to control the state of a simulated hardware#CANdi.
31 */
33 {
34 private:
35 int _id;
36
37 public:
38 /**
39 * \brief The orientation of the PWM1 sensor relative
40 * to the robot chassis.
41 *
42 * This value should not be changed based on the CANdi PWM1 invert.
43 * Rather, this value should be changed when the mechanical linkage
44 * between the sensor and the robot changes.
45 */
47
48 /**
49 * \brief The orientation of the PWM2 sensor relative
50 * to the robot chassis.
51 *
52 * This value should not be changed based on the CANdi PWM2 invert.
53 * Rather, this value should be changed when the mechanical linkage
54 * between the sensor and the robot changes.
55 */
57
58 /**
59 * \brief The orientation of the Quadrature sensor relative
60 * to the robot chassis.
61 *
62 * This value should not be changed based on the CANdi Quadrature invert.
63 * Rather, this value should be changed when the mechanical linkage
64 * between the sensor and the robot changes.
65 */
67 /**
68 * \brief The number of quadrature edges per sensor rotation for an
69 * external quadrature sensor attached to the CANdi.
70 */
72
73 /**
74 * \brief Creates an object to control the state of the given hardware#CANdi.
75 *
76 * \details Note the recommended method of accessing simulation features is to
77 * use hardware#CANdi#GetSimState.
78 *
79 * \param device Device to which this simulation state is attached
80 */
89 /**
90 * \brief Creates an object to control the state of the given hardware#CANdi.
91 *
92 * \details Note the recommended method of accessing simulation features is to
93 * use hardware#CANdi#GetSimState.
94 *
95 * \param device Device to which this simulation state is attached
96 * \param pwm1Orientation Orientation of the PWM1 sensor relative to the robot chassis
97 * \param pwm2Orientation Orientation of the PWM2 sensor relative to the robot chassis
98 * \param quadratureOrientation Orientation of the Quadrature sensor relative to the robot chassis
99 */
101 hardware::core::CoreCANdi const &device,
102 ChassisReference pwm1Orientation,
103 ChassisReference pwm2Orientation,
104 ChassisReference quadratureOrientation
105 );
106 /* disallow copy, allow move */
107 CANdiSimState(CANdiSimState const &) = delete;
111
112 /**
113 * \brief Sets the simulated supply voltage of the CANdi.
114 *
115 * \details The minimum allowed supply voltage is 4 V - values below this
116 * will be promoted to 4 V.
117 *
118 * \param volts The supply voltage in Volts
119 * \returns Status code
120 */
121 ctre::phoenix::StatusCode SetSupplyVoltage(units::voltage::volt_t volts);
122 /**
123 * \brief Sets the simulated output current of the CANdi.
124 *
125 * \param current The output current
126 * \return Status code
127 */
128 ctre::phoenix::StatusCode SetOutputCurrent(units::current::ampere_t current);
129 /**
130 * \brief Sets the simulated PWM1 Rise to Rise timing of the CANdi.
131 *
132 * \param time The time between two Rise events
133 * \return Status code
134 */
135 ctre::phoenix::StatusCode SetPwm1RiseRise(units::time::second_t time);
136 /**
137 * \brief Sets the simulated PWM1 Rise to Fall timing of the CANdi.
138 *
139 * \param time The time between the Rise and Fall events in seconds
140 * \return Status code
141 */
142 ctre::phoenix::StatusCode SetPwm1RiseFall(units::time::second_t time);
143 /**
144 * \brief Sets whether a PWM sensor is connected to the S1 pin.
145 *
146 * \param connected True if sensor is connected
147 * \return Status code
148 */
150 /**
151 * \brief Sets the simulated pulse width position of the CANdi. This is the position
152 * of an external PWM encoder connected to the S1 pin.
153 *
154 * \param position The new position
155 * \return Status code
156 */
157 ctre::phoenix::StatusCode SetPwm1Position(units::angle::turn_t position);
158 /**
159 * \brief Sets the simulated pulse width velocity of the CANdi. This is the velocity
160 * of an external PWM encoder connected to the S1 pin.
161 *
162 * \param velocity The new velocity
163 * \return Status code
164 */
165 ctre::phoenix::StatusCode SetPwm1Velocity(units::angular_velocity::turns_per_second_t velocity);
166 /**
167 * \brief Sets the simulated PWM2 Rise to Rise timing of the CANdi.
168 *
169 * \param time The time between two Rise events
170 * \return Status code
171 */
172 ctre::phoenix::StatusCode SetPwm2RiseRise(units::time::second_t time);
173 /**
174 * \brief Sets the simulated PWM2 Rise to Fall timing of the CANdi.
175 *
176 * \param time The time between the Rise and Fall events in seconds
177 * \return Status code
178 */
179 ctre::phoenix::StatusCode SetPwm2RiseFall(units::time::second_t time);
180 /**
181 * \brief Sets whether a PWM sensor is connected to the S2 pin.
182 *
183 * \param connected True if sensor is connected
184 * \return Status code
185 */
187 /**
188 * \brief Sets the simulated pulse width position of the CANdi. This is the position
189 * of an external PWM encoder connected to the S2 pin.
190 *
191 * \param position The new position
192 * \return Status code
193 */
194 ctre::phoenix::StatusCode SetPwm2Position(units::angle::turn_t position);
195 /**
196 * \brief Sets the simulated pulse width velocity of the CANdi. This is the velocity
197 * of an external PWM encoder connected to the S2 pin.
198 *
199 * \param velocity The new velocity
200 * \return Status code
201 */
202 ctre::phoenix::StatusCode SetPwm2Velocity(units::angular_velocity::turns_per_second_t velocity);
203 /**
204 * \brief Sets the simulated raw quadrature position of the CANdi.
205 *
206 * Inputs to this function over time should be continuous, as user calls of hardware#CANdi#SetQuadraturePosition will be accounted for in the callee.
207 *
208 * \details The CANdi integrates this to calculate the true reported quadrature position.
209 *
210 * When using the WPI Sim GUI, you will notice a readonly `position` and settable `rawPositionInput`.
211 * The readonly signal is the emulated position which will match self-test in Tuner and the hardware API.
212 * Changes to `rawPositionInput` will be integrated into the emulated position.
213 * This way a simulator can modify the position without overriding hardware API calls for home-ing the sensor.
214 *
215 * \param position The raw position
216 * \return Status code
217 */
219 /**
220 * \brief Sets the simulated pulse width velocity of the CANdi.
221 *
222 * \param velocity The new velocity
223 * \return Status code
224 */
225 ctre::phoenix::StatusCode SetQuadratureVelocity(units::angular_velocity::turns_per_second_t velocity);
226 /**
227 * \brief Sets the state of the S1 pin
228 *
229 * \param state The state to set the S1 pin to
230 * \return Status code
231 */
233 /**
234 * \brief Sets the state of the S2 pin
235 *
236 * \param state The state to St the S2 pin to
237 * \return Status code
238 */
240 };
241}
242
243}
244}
its the or e mails sent from or on behalf of the Company are free of trojan timebombs or other harmful components Some jurisdictions do not allow the exclusion of certain types of warranties or limitations on applicable statutory rights of a so some or all of the above exclusions and limitations may not apply to You But in such a case the exclusions and limitations set forth in this section shall be applied to the greatest extent enforceable under applicable law To the extent any warranty exists under law that cannot be the Company shall be solely responsible for such warranty Severability and Waiver Severability If any provision of this Agreement is held to be unenforceable or such provision will be changed and interpreted to accomplish the objectives of such provision to the greatest extent possible under applicable law and the remaining provisions will continue in full force and effect Waiver Except as provided the failure to exercise a right or to require performance of an obligation under this Agreement shall not affect a party s ability to exercise such right or require such performance at any time thereafter nor shall the waiver of a breach constitute waiver of any subsequent breach Product Claims The Company does not make any warranties concerning the Software United States Legal Compliance You represent and warrant or that has been designated by the United States government as a terrorist supporting at its sole to modify or replace this Agreement at any time If a revision is material we will provide at least days notice prior to any new terms taking effect What constitutes a material change will be determined at the sole discretion of the Company By continuing to access or use the Software after any revisions become You agree to be bound by the revised terms If You do not agree to the new You are no longer authorized to use the Software Governing Law The laws of the State of United States of excluding its conflicts of law shall govern this Agreement and your use of the Software Your use of the Software may also be subject to other state
Definition CTRE_LICENSE.txt:308
Class for CANdi, a CAN digital input device that detects when a digital signal is asserted or deasser...
Definition CoreCANdi.hpp:911
State of the Signal 1 input (S1IN).
Definition SpnEnums.hpp:3990
State of the Signal 2 input (S2IN).
Definition SpnEnums.hpp:4074
Class to control the state of a simulated hardware::CANdi.
Definition CANdiSimState.hpp:33
ctre::phoenix::StatusCode SetSupplyVoltage(units::voltage::volt_t volts)
Sets the simulated supply voltage of the CANdi.
ctre::phoenix::StatusCode SetPwm1RiseRise(units::time::second_t time)
Sets the simulated PWM1 Rise to Rise timing of the CANdi.
CANdiSimState & operator=(CANdiSimState const &)=delete
ctre::phoenix::StatusCode SetPwm2Connected(bool connected)
Sets whether a PWM sensor is connected to the S2 pin.
ctre::phoenix::StatusCode SetPwm2Position(units::angle::turn_t position)
Sets the simulated pulse width position of the CANdi.
ctre::phoenix::StatusCode SetRawQuadraturePosition(units::angle::turn_t position)
Sets the simulated raw quadrature position of the CANdi.
ctre::phoenix::StatusCode SetQuadratureVelocity(units::angular_velocity::turns_per_second_t velocity)
Sets the simulated pulse width velocity of the CANdi.
CANdiSimState & operator=(CANdiSimState &&)=default
int QuadratureEdgesPerRotation
The number of quadrature edges per sensor rotation for an external quadrature sensor attached to the ...
Definition CANdiSimState.hpp:71
ctre::phoenix::StatusCode SetS2State(ctre::phoenix6::signals::S2StateValue state)
Sets the state of the S2 pin.
CANdiSimState(hardware::core::CoreCANdi const &device, ChassisReference pwm1Orientation, ChassisReference pwm2Orientation, ChassisReference quadratureOrientation)
Creates an object to control the state of the given hardware::CANdi.
CANdiSimState(hardware::core::CoreCANdi const &device)
Creates an object to control the state of the given hardware::CANdi.
Definition CANdiSimState.hpp:81
ctre::phoenix::StatusCode SetPwm1Connected(bool connected)
Sets whether a PWM sensor is connected to the S1 pin.
ctre::phoenix::StatusCode SetOutputCurrent(units::current::ampere_t current)
Sets the simulated output current of the CANdi.
ctre::phoenix::StatusCode SetPwm2RiseRise(units::time::second_t time)
Sets the simulated PWM2 Rise to Rise timing of the CANdi.
ctre::phoenix::StatusCode SetS1State(ctre::phoenix6::signals::S1StateValue state)
Sets the state of the S1 pin.
CANdiSimState(CANdiSimState const &)=delete
ChassisReference Pwm2Orientation
The orientation of the PWM2 sensor relative to the robot chassis.
Definition CANdiSimState.hpp:56
ChassisReference QuadratureOrientation
The orientation of the Quadrature sensor relative to the robot chassis.
Definition CANdiSimState.hpp:66
ctre::phoenix::StatusCode SetPwm1RiseFall(units::time::second_t time)
Sets the simulated PWM1 Rise to Fall timing of the CANdi.
ctre::phoenix::StatusCode SetPwm1Position(units::angle::turn_t position)
Sets the simulated pulse width position of the CANdi.
ctre::phoenix::StatusCode SetPwm2Velocity(units::angular_velocity::turns_per_second_t velocity)
Sets the simulated pulse width velocity of the CANdi.
ChassisReference Pwm1Orientation
The orientation of the PWM1 sensor relative to the robot chassis.
Definition CANdiSimState.hpp:46
ctre::phoenix::StatusCode SetPwm2RiseFall(units::time::second_t time)
Sets the simulated PWM2 Rise to Fall timing of the CANdi.
ctre::phoenix::StatusCode SetPwm1Velocity(units::angular_velocity::turns_per_second_t velocity)
Sets the simulated pulse width velocity of the CANdi.
CANdiSimState(CANdiSimState &&)=default
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:27
ChassisReference
Represents the orientation of a device relative to the robot chassis.
Definition ChassisReference.hpp:16
@ CounterClockwise_Positive
The device should read a counter-clockwise rotation as positive motion.
Definition MotionMagicExpoTorqueCurrentFOC.hpp:18