CTRE Phoenix 6 C++ 26.0.0-beta-1
Loading...
Searching...
No Matches
QuadratureConfigs.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
10
11
12namespace ctre {
13namespace phoenix6 {
14
15
16namespace configs {
17
18/**
19 * \brief Configs related to the CANdi™ branded device's quadrature
20 * interface using both the S1IN and S2IN inputs
21 *
22 * \details All the configs related to the quadrature interface for
23 * the CANdi™ branded device , including encoder edges per
24 * revolution and sensor direction.
25 */
27public:
28 constexpr QuadratureConfigs() = default;
29
30 /**
31 * \brief The number of quadrature edges in one rotation for the
32 * quadrature sensor connected to the Talon data port.
33 *
34 * This is the total number of transitions from high-to-low or
35 * low-to-high across both channels per rotation of the sensor. This
36 * is also equivalent to the Counts Per Revolution when using 4x
37 * decoding.
38 *
39 * For example, the SRX Mag Encoder has 4096 edges per rotation, and a
40 * US Digital 1024 CPR (Cycles Per Revolution) quadrature encoder has
41 * 4096 edges per rotation.
42 *
43 * \details On the Talon FXS, this can be at most 2,000,000,000 / Peak
44 * RPM.
45 *
46 * - Minimum Value: 1
47 * - Maximum Value: 1000000
48 * - Default Value: 4096
49 * - Units:
50 */
52 /**
53 * \brief Direction of the quadrature sensor to determine positive
54 * rotation. Invert this so that forward motion on the mechanism
55 * results in an increase in quadrature position.
56 *
57 * - Default Value: False
58 */
59 bool SensorDirection = false;
60
61 /**
62 * \brief Modifies this configuration's QuadratureEdgesPerRotation parameter and returns itself for
63 * method-chaining and easier to use config API.
64 *
65 * The number of quadrature edges in one rotation for the quadrature
66 * sensor connected to the Talon data port.
67 *
68 * This is the total number of transitions from high-to-low or
69 * low-to-high across both channels per rotation of the sensor. This
70 * is also equivalent to the Counts Per Revolution when using 4x
71 * decoding.
72 *
73 * For example, the SRX Mag Encoder has 4096 edges per rotation, and a
74 * US Digital 1024 CPR (Cycles Per Revolution) quadrature encoder has
75 * 4096 edges per rotation.
76 *
77 * \details On the Talon FXS, this can be at most 2,000,000,000 / Peak
78 * RPM.
79 *
80 * - Minimum Value: 1
81 * - Maximum Value: 1000000
82 * - Default Value: 4096
83 * - Units:
84 *
85 * \param newQuadratureEdgesPerRotation Parameter to modify
86 * \returns Itself
87 */
88 constexpr QuadratureConfigs &WithQuadratureEdgesPerRotation(int newQuadratureEdgesPerRotation)
89 {
90 QuadratureEdgesPerRotation = std::move(newQuadratureEdgesPerRotation);
91 return *this;
92 }
93
94 /**
95 * \brief Modifies this configuration's SensorDirection parameter and returns itself for
96 * method-chaining and easier to use config API.
97 *
98 * Direction of the quadrature sensor to determine positive rotation.
99 * Invert this so that forward motion on the mechanism results in an
100 * increase in quadrature position.
101 *
102 * - Default Value: False
103 *
104 * \param newSensorDirection Parameter to modify
105 * \returns Itself
106 */
107 constexpr QuadratureConfigs &WithSensorDirection(bool newSensorDirection)
108 {
109 SensorDirection = std::move(newSensorDirection);
110 return *this;
111 }
112
113
114
115 std::string ToString() const override;
116
117 std::string Serialize() const final;
118 ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final;
119};
120
121}
122}
123}
Definition Configuration.hpp:17
Configs related to the CANdi™ branded device's quadrature interface using both the S1IN and S2IN inpu...
Definition QuadratureConfigs.hpp:26
int QuadratureEdgesPerRotation
The number of quadrature edges in one rotation for the quadrature sensor connected to the Talon data ...
Definition QuadratureConfigs.hpp:51
std::string ToString() const override
constexpr QuadratureConfigs & WithSensorDirection(bool newSensorDirection)
Modifies this configuration's SensorDirection parameter and returns itself for method-chaining and ea...
Definition QuadratureConfigs.hpp:107
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
bool SensorDirection
Direction of the quadrature sensor to determine positive rotation.
Definition QuadratureConfigs.hpp:59
constexpr QuadratureConfigs & WithQuadratureEdgesPerRotation(int newQuadratureEdgesPerRotation)
Modifies this configuration's QuadratureEdgesPerRotation parameter and returns itself for method-chai...
Definition QuadratureConfigs.hpp:88
Definition motor_constants.h:14