CTRE Phoenix 6 C++ 25.0.0-beta-4
Loading...
Searching...
No Matches
CANcoderSimState.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
16namespace ctre {
17namespace phoenix6 {
18
19namespace hardware {
20namespace core {
21 /* forward proto */
22 class CoreCANcoder;
23}
24}
25
26namespace sim {
27
28 /**
29 * \brief Class to control the state of a simulated hardware#CANcoder.
30 */
32 {
33 private:
34 int _id;
35
36 public:
37 /**
38 * \brief The orientation of the CANcoder relative to the robot chassis.
39 *
40 * This value should not be changed based on the CANcoder invert.
41 * Rather, this value should be changed when the mechanical linkage
42 * between the CANcoder and the robot changes.
43 */
45
46 /**
47 * \brief Creates an object to control the state of the given hardware#CANcoder.
48 *
49 * \details This constructor defaults to a counter-clockwise positive orientation
50 * relative to the robot chassis. Note the recommended method of accessing
51 * simulation features is to use hardware#CANcoder#GetSimState.
52 *
53 * \param device Device to which this simulation state is attached
54 */
58 /**
59 * \brief Creates an object to control the state of the given hardware#CANcoder.
60 *
61 * \details Note the recommended method of accessing simulation features is to
62 * use hardware#CANcoder#GetSimState.
63 *
64 * \param device Device to which this simulation state is attached
65 * \param orientation Orientation of the device relative to the robot chassis
66 */
68 /* disallow copy, allow move */
73
74 /**
75 * \brief Sets the simulated supply voltage of the CANcoder.
76 *
77 * \details The minimum allowed supply voltage is 4 V - values below this
78 * will be promoted to 4 V.
79 *
80 * \param volts The supply voltage in Volts
81 * \returns Status code
82 */
83 ctre::phoenix::StatusCode SetSupplyVoltage(units::voltage::volt_t volts);
84 /**
85 * \brief Sets the simulated raw position of the CANcoder.
86 *
87 * Inputs to this function over time should be continuous, as user calls of hardware#CANcoder#SetPosition will be accounted for in the callee.
88 *
89 * \details The CANcoder integrates this to calculate the true reported position.
90 *
91 * When using the WPI Sim GUI, you will notice a readonly `position` and settable `rawPositionInput`.
92 * The readonly signal is the emulated position which will match self-test in Tuner and the hardware API.
93 * Changes to `rawPositionInput` will be integrated into the emulated position.
94 * This way a simulator can modify the position without overriding hardware API calls for home-ing the sensor.
95 *
96 * \param rotations The raw position in rotations
97 * \returns Status code
98 */
99 ctre::phoenix::StatusCode SetRawPosition(units::angle::turn_t rotations);
100 /**
101 * \brief Adds to the simulated position of the CANcoder.
102 *
103 * \param dRotations
104 * The change in position in rotations
105 * \returns Status code
106 */
107 ctre::phoenix::StatusCode AddPosition(units::angle::turn_t dRotations);
108 /**
109 * \brief Sets the simulated velocity of the CANcoder.
110 *
111 * \param rps The new velocity in rotations per second
112 * \returns Status code
113 */
114 ctre::phoenix::StatusCode SetVelocity(units::angular_velocity::turns_per_second_t rps);
115 /**
116 * \brief Sets the simulated magnet health of the CANcoder.
117 *
118 * \param value The magnet health to simulate. This directly correlates to the
119 * red/green/orange state of the simulated LED.
120 * \returns Status code
121 */
123 };
124
125}
126
127}
128}
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition CoreCANcoder.hpp:631
Magnet health as measured by CANcoder.
Definition SpnEnums.hpp:2830
Class to control the state of a simulated hardware::CANcoder.
Definition CANcoderSimState.hpp:32
ctre::phoenix::StatusCode SetSupplyVoltage(units::voltage::volt_t volts)
Sets the simulated supply voltage of the CANcoder.
ChassisReference Orientation
The orientation of the CANcoder relative to the robot chassis.
Definition CANcoderSimState.hpp:44
ctre::phoenix::StatusCode SetVelocity(units::angular_velocity::turns_per_second_t rps)
Sets the simulated velocity of the CANcoder.
CANcoderSimState & operator=(CANcoderSimState &&)=default
CANcoderSimState(CANcoderSimState const &)=delete
CANcoderSimState(hardware::core::CoreCANcoder const &device, ChassisReference orientation)
Creates an object to control the state of the given hardware::CANcoder.
CANcoderSimState(hardware::core::CoreCANcoder const &device)
Creates an object to control the state of the given hardware::CANcoder.
Definition CANcoderSimState.hpp:55
ctre::phoenix::StatusCode SetRawPosition(units::angle::turn_t rotations)
Sets the simulated raw position of the CANcoder.
ctre::phoenix::StatusCode AddPosition(units::angle::turn_t dRotations)
Adds to the simulated position of the CANcoder.
ctre::phoenix::StatusCode SetMagnetHealth(ctre::phoenix6::signals::MagnetHealthValue value)
Sets the simulated magnet health of the CANcoder.
CANcoderSimState(CANcoderSimState &&)=default
CANcoderSimState & operator=(CANcoderSimState const &)=delete
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 StatusCodes.h:18