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