CTRE Phoenix Pro C++ 23.0.12
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 phoenixpro {
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.
50 *
51 * \param device
52 * Device to which this simulation state is attached
53 */
56 {}
57 /**
58 * \brief Creates an object to control the state of the given hardware#CANcoder.
59 *
60 * \param device
61 * Device to which this simulation state is attached
62 * \param orientation
63 * Orientation of the device relative to the robot chassis
64 */
66 /* disallow copy, allow move */
71
72 /**
73 * \brief Sets the simulated supply voltage of the CANcoder.
74 *
75 * \details The minimum allowed supply voltage is 4 V - values below this
76 * will be promoted to 4 V.
77 *
78 * \param volts
79 * The supply voltage in Volts
80 * \returns Status code
81 */
82 ctre::phoenix::StatusCode SetSupplyVoltage(units::voltage::volt_t volts);
83 /**
84 * \brief Sets the simulated raw position of the CANcoder.
85 *
86 * Inputs to this function over time should be continuous, as user calls of hardware#CANcoder#SetPosition will be accounted for in the callee.
87 *
88 * \details The CANcoder integrates this to calculate the true reported position.
89 *
90 * When using the WPI Sim GUI, you will notice a readonly `position` and settable `rawPositionInput`.
91 * The readonly signal is the emulated position which will match self-test in Tuner and the hardware API.
92 * Changes to `rawPositionInput` will be integrated into the emulated position.
93 * This way a simulator can modify the position without overriding hardware API calls for home-ing the sensor.
94 *
95 * \param rotations
96 * 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
112 * The new velocity in rotations per second
113 * \returns Status code
114 */
115 ctre::phoenix::StatusCode SetVelocity(units::angular_velocity::turns_per_second_t rps);
116 };
117
118}
119
120}
121}
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition: CoreCANcoder.hpp:331
Class to control the state of a simulated hardware::CANcoder.
Definition: CANcoderSimState.hpp:31
CANcoderSimState(CANcoderSimState const &)=delete
CANcoderSimState & operator=(CANcoderSimState const &)=delete
CANcoderSimState(hardware::core::CoreCANcoder const &device)
Creates an object to control the state of the given hardware::CANcoder.
Definition: CANcoderSimState.hpp:54
ChassisReference Orientation
The orientation of the CANcoder relative to the robot chassis.
Definition: CANcoderSimState.hpp:43
ctre::phoenix::StatusCode SetSupplyVoltage(units::voltage::volt_t volts)
Sets the simulated supply voltage of the CANcoder.
CANcoderSimState(CANcoderSimState &&)=default
CANcoderSimState(hardware::core::CoreCANcoder const &device, ChassisReference orientation)
Creates an object to control the state of the given hardware::CANcoder.
CANcoderSimState & operator=(CANcoderSimState &&)=default
ctre::phoenix::StatusCode AddPosition(units::angle::turn_t dRotations)
Adds to the simulated position of the CANcoder.
ctre::phoenix::StatusCode SetVelocity(units::angular_velocity::turns_per_second_t rps)
Sets the simulated velocity of the CANcoder.
ctre::phoenix::StatusCode SetRawPosition(units::angle::turn_t rotations)
Sets the simulated raw position of the CANcoder.
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: string_util.hpp:14