CTRE Phoenix 6 C++ 26.0.0-beta-1
Loading...
Searching...
No Matches
ProximityParamsConfigs.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/dimensionless.h>
11#include <units/length.h>
12
13namespace ctre {
14namespace phoenix6 {
15
16
17namespace configs {
18
19/**
20 * \brief Configs that affect the ToF Proximity detection
21 *
22 * \details Includes proximity mode and the threshold for simple
23 * detection
24 */
26public:
27 constexpr ProximityParamsConfigs() = default;
28
29 /**
30 * \brief Threshold for object detection.
31 *
32 * - Minimum Value: 0
33 * - Maximum Value: 4
34 * - Default Value: 0.4
35 * - Units: m
36 */
37 units::length::meter_t ProximityThreshold = 0.4_m;
38 /**
39 * \brief How far above and below the threshold the distance needs to
40 * be to trigger undetected and detected, respectively. This is used
41 * to prevent bouncing between the detected and undetected states for
42 * objects on the threshold.
43 *
44 * If the threshold is set to 0.1 meters, and the hysteresis is 0.01
45 * meters, then an object needs to be within 0.09 meters to be
46 * detected. After the object is first detected, the distance then
47 * needs to exceed 0.11 meters to become undetected again.
48 *
49 * - Minimum Value: 0
50 * - Maximum Value: 1
51 * - Default Value: 0.01
52 * - Units: m
53 */
54 units::length::meter_t ProximityHysteresis = 0.01_m;
55 /**
56 * \brief The minimum allowable signal strength before determining the
57 * measurement is valid.
58 *
59 * If the signal strength is particularly low, this typically means
60 * the object is far away and there's fewer total samples to derive
61 * the distance from. Set this value to be below the lowest strength
62 * you see when you're detecting an object with the CANrange; the
63 * default of 2500 is typically acceptable in most cases.
64 *
65 * - Minimum Value: 1
66 * - Maximum Value: 15000
67 * - Default Value: 2500
68 * - Units:
69 */
70 units::dimensionless::scalar_t MinSignalStrengthForValidMeasurement = 2500;
71
72 /**
73 * \brief Modifies this configuration's ProximityThreshold parameter and returns itself for
74 * method-chaining and easier to use config API.
75 *
76 * Threshold for object detection.
77 *
78 * - Minimum Value: 0
79 * - Maximum Value: 4
80 * - Default Value: 0.4
81 * - Units: m
82 *
83 * \param newProximityThreshold Parameter to modify
84 * \returns Itself
85 */
86 constexpr ProximityParamsConfigs &WithProximityThreshold(units::length::meter_t newProximityThreshold)
87 {
88 ProximityThreshold = std::move(newProximityThreshold);
89 return *this;
90 }
91
92 /**
93 * \brief Modifies this configuration's ProximityHysteresis parameter and returns itself for
94 * method-chaining and easier to use config API.
95 *
96 * How far above and below the threshold the distance needs to be to
97 * trigger undetected and detected, respectively. This is used to
98 * prevent bouncing between the detected and undetected states for
99 * objects on the threshold.
100 *
101 * If the threshold is set to 0.1 meters, and the hysteresis is 0.01
102 * meters, then an object needs to be within 0.09 meters to be
103 * detected. After the object is first detected, the distance then
104 * needs to exceed 0.11 meters to become undetected again.
105 *
106 * - Minimum Value: 0
107 * - Maximum Value: 1
108 * - Default Value: 0.01
109 * - Units: m
110 *
111 * \param newProximityHysteresis Parameter to modify
112 * \returns Itself
113 */
114 constexpr ProximityParamsConfigs &WithProximityHysteresis(units::length::meter_t newProximityHysteresis)
115 {
116 ProximityHysteresis = std::move(newProximityHysteresis);
117 return *this;
118 }
119
120 /**
121 * \brief Modifies this configuration's MinSignalStrengthForValidMeasurement parameter and returns itself for
122 * method-chaining and easier to use config API.
123 *
124 * The minimum allowable signal strength before determining the
125 * measurement is valid.
126 *
127 * If the signal strength is particularly low, this typically means
128 * the object is far away and there's fewer total samples to derive
129 * the distance from. Set this value to be below the lowest strength
130 * you see when you're detecting an object with the CANrange; the
131 * default of 2500 is typically acceptable in most cases.
132 *
133 * - Minimum Value: 1
134 * - Maximum Value: 15000
135 * - Default Value: 2500
136 * - Units:
137 *
138 * \param newMinSignalStrengthForValidMeasurement Parameter to modify
139 * \returns Itself
140 */
141 constexpr ProximityParamsConfigs &WithMinSignalStrengthForValidMeasurement(units::dimensionless::scalar_t newMinSignalStrengthForValidMeasurement)
142 {
143 MinSignalStrengthForValidMeasurement = std::move(newMinSignalStrengthForValidMeasurement);
144 return *this;
145 }
146
147
148
149 std::string ToString() const override;
150
151 std::string Serialize() const final;
152 ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final;
153};
154
155}
156}
157}
Definition Configuration.hpp:17
Configs that affect the ToF Proximity detection.
Definition ProximityParamsConfigs.hpp:25
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
units::dimensionless::scalar_t MinSignalStrengthForValidMeasurement
The minimum allowable signal strength before determining the measurement is valid.
Definition ProximityParamsConfigs.hpp:70
constexpr ProximityParamsConfigs & WithProximityThreshold(units::length::meter_t newProximityThreshold)
Modifies this configuration's ProximityThreshold parameter and returns itself for method-chaining and...
Definition ProximityParamsConfigs.hpp:86
constexpr ProximityParamsConfigs & WithMinSignalStrengthForValidMeasurement(units::dimensionless::scalar_t newMinSignalStrengthForValidMeasurement)
Modifies this configuration's MinSignalStrengthForValidMeasurement parameter and returns itself for m...
Definition ProximityParamsConfigs.hpp:141
units::length::meter_t ProximityThreshold
Threshold for object detection.
Definition ProximityParamsConfigs.hpp:37
constexpr ProximityParamsConfigs & WithProximityHysteresis(units::length::meter_t newProximityHysteresis)
Modifies this configuration's ProximityHysteresis parameter and returns itself for method-chaining an...
Definition ProximityParamsConfigs.hpp:114
units::length::meter_t ProximityHysteresis
How far above and below the threshold the distance needs to be to trigger undetected and detected,...
Definition ProximityParamsConfigs.hpp:54
Definition motor_constants.h:14