CTRE Phoenix 6 C++ 26.0.0-beta-1
Loading...
Searching...
No Matches
SoftwareLimitSwitchConfigs.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#include <units/angle.h>
11
12namespace ctre {
13namespace phoenix6 {
14
15
16namespace configs {
17
18/**
19 * \brief Configs that affect how software-limit switches behave.
20 *
21 * \details Includes enabling software-limit switches and the
22 * threshold at which they are tripped.
23 */
25public:
26 constexpr SoftwareLimitSwitchConfigs() = default;
27
28 /**
29 * \brief If enabled, the motor output is set to neutral if position
30 * exceeds ForwardSoftLimitThreshold and forward output is requested.
31 *
32 * - Default Value: False
33 */
35 /**
36 * \brief If enabled, the motor output is set to neutral if position
37 * exceeds ReverseSoftLimitThreshold and reverse output is requested.
38 *
39 * - Default Value: False
40 */
42 /**
43 * \brief Position threshold for forward soft limit features.
44 * ForwardSoftLimitEnable must be enabled for this to take effect.
45 *
46 * - Minimum Value: -3.4e+38
47 * - Maximum Value: 3.4e+38
48 * - Default Value: 0
49 * - Units: rotations
50 */
51 units::angle::turn_t ForwardSoftLimitThreshold = 0_tr;
52 /**
53 * \brief Position threshold for reverse soft limit features.
54 * ReverseSoftLimitEnable must be enabled for this to take effect.
55 *
56 * - Minimum Value: -3.4e+38
57 * - Maximum Value: 3.4e+38
58 * - Default Value: 0
59 * - Units: rotations
60 */
61 units::angle::turn_t ReverseSoftLimitThreshold = 0_tr;
62
63 /**
64 * \brief Modifies this configuration's ForwardSoftLimitEnable parameter and returns itself for
65 * method-chaining and easier to use config API.
66 *
67 * If enabled, the motor output is set to neutral if position exceeds
68 * ForwardSoftLimitThreshold and forward output is requested.
69 *
70 * - Default Value: False
71 *
72 * \param newForwardSoftLimitEnable Parameter to modify
73 * \returns Itself
74 */
75 constexpr SoftwareLimitSwitchConfigs &WithForwardSoftLimitEnable(bool newForwardSoftLimitEnable)
76 {
77 ForwardSoftLimitEnable = std::move(newForwardSoftLimitEnable);
78 return *this;
79 }
80
81 /**
82 * \brief Modifies this configuration's ReverseSoftLimitEnable parameter and returns itself for
83 * method-chaining and easier to use config API.
84 *
85 * If enabled, the motor output is set to neutral if position exceeds
86 * ReverseSoftLimitThreshold and reverse output is requested.
87 *
88 * - Default Value: False
89 *
90 * \param newReverseSoftLimitEnable Parameter to modify
91 * \returns Itself
92 */
93 constexpr SoftwareLimitSwitchConfigs &WithReverseSoftLimitEnable(bool newReverseSoftLimitEnable)
94 {
95 ReverseSoftLimitEnable = std::move(newReverseSoftLimitEnable);
96 return *this;
97 }
98
99 /**
100 * \brief Modifies this configuration's ForwardSoftLimitThreshold parameter and returns itself for
101 * method-chaining and easier to use config API.
102 *
103 * Position threshold for forward soft limit features.
104 * ForwardSoftLimitEnable must be enabled for this to take effect.
105 *
106 * - Minimum Value: -3.4e+38
107 * - Maximum Value: 3.4e+38
108 * - Default Value: 0
109 * - Units: rotations
110 *
111 * \param newForwardSoftLimitThreshold Parameter to modify
112 * \returns Itself
113 */
114 constexpr SoftwareLimitSwitchConfigs &WithForwardSoftLimitThreshold(units::angle::turn_t newForwardSoftLimitThreshold)
115 {
116 ForwardSoftLimitThreshold = std::move(newForwardSoftLimitThreshold);
117 return *this;
118 }
119
120 /**
121 * \brief Modifies this configuration's ReverseSoftLimitThreshold parameter and returns itself for
122 * method-chaining and easier to use config API.
123 *
124 * Position threshold for reverse soft limit features.
125 * ReverseSoftLimitEnable must be enabled for this to take effect.
126 *
127 * - Minimum Value: -3.4e+38
128 * - Maximum Value: 3.4e+38
129 * - Default Value: 0
130 * - Units: rotations
131 *
132 * \param newReverseSoftLimitThreshold Parameter to modify
133 * \returns Itself
134 */
135 constexpr SoftwareLimitSwitchConfigs &WithReverseSoftLimitThreshold(units::angle::turn_t newReverseSoftLimitThreshold)
136 {
137 ReverseSoftLimitThreshold = std::move(newReverseSoftLimitThreshold);
138 return *this;
139 }
140
141
142
143 std::string ToString() const override;
144
145 std::string Serialize() const final;
146 ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final;
147};
148
149}
150}
151}
Definition Configuration.hpp:17
Configs that affect how software-limit switches behave.
Definition SoftwareLimitSwitchConfigs.hpp:24
units::angle::turn_t ReverseSoftLimitThreshold
Position threshold for reverse soft limit features.
Definition SoftwareLimitSwitchConfigs.hpp:61
constexpr SoftwareLimitSwitchConfigs & WithForwardSoftLimitThreshold(units::angle::turn_t newForwardSoftLimitThreshold)
Modifies this configuration's ForwardSoftLimitThreshold parameter and returns itself for method-chain...
Definition SoftwareLimitSwitchConfigs.hpp:114
units::angle::turn_t ForwardSoftLimitThreshold
Position threshold for forward soft limit features.
Definition SoftwareLimitSwitchConfigs.hpp:51
constexpr SoftwareLimitSwitchConfigs & WithReverseSoftLimitThreshold(units::angle::turn_t newReverseSoftLimitThreshold)
Modifies this configuration's ReverseSoftLimitThreshold parameter and returns itself for method-chain...
Definition SoftwareLimitSwitchConfigs.hpp:135
constexpr SoftwareLimitSwitchConfigs & WithReverseSoftLimitEnable(bool newReverseSoftLimitEnable)
Modifies this configuration's ReverseSoftLimitEnable parameter and returns itself for method-chaining...
Definition SoftwareLimitSwitchConfigs.hpp:93
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
bool ReverseSoftLimitEnable
If enabled, the motor output is set to neutral if position exceeds ReverseSoftLimitThreshold and reve...
Definition SoftwareLimitSwitchConfigs.hpp:41
constexpr SoftwareLimitSwitchConfigs & WithForwardSoftLimitEnable(bool newForwardSoftLimitEnable)
Modifies this configuration's ForwardSoftLimitEnable parameter and returns itself for method-chaining...
Definition SoftwareLimitSwitchConfigs.hpp:75
bool ForwardSoftLimitEnable
If enabled, the motor output is set to neutral if position exceeds ForwardSoftLimitThreshold and forw...
Definition SoftwareLimitSwitchConfigs.hpp:34
Definition motor_constants.h:14