REVLib - C++
ClosedLoopConfig.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024-2026 REV Robotics
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. Neither the name of REV Robotics nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#pragma once
30
31#include <string>
32
33#include "rev/ClosedLoopTypes.h"
37
38namespace rev::detached {
39class DetachedEncoder;
40}
41
42namespace rev::spark {
43
45public:
46 ClosedLoopConfig() = default;
47 ~ClosedLoopConfig() override = default;
48
51 ClosedLoopConfig(ClosedLoopConfig&&) noexcept = delete;
52 ClosedLoopConfig& operator=(ClosedLoopConfig&&) noexcept = delete;
53
65
77
89
102 [[deprecated(
103 "Use FeedForwardConfig::V(double v, ClosedLoopSlot slot) to set a "
104 "Velocity Feedforward")]] ClosedLoopConfig&
105 Pidf(double p, double i, double d, double ff, ClosedLoopSlot slot = kSlot0);
106
116 ClosedLoopConfig& Pid(double p, double i, double d,
117 ClosedLoopSlot slot = kSlot0);
118
127 ClosedLoopConfig& P(double p, ClosedLoopSlot slot = kSlot0);
128
136 ClosedLoopConfig& I(double i, ClosedLoopSlot slot = kSlot0);
137
146 ClosedLoopConfig& D(double d, ClosedLoopSlot slot = kSlot0);
147
158 [[deprecated(
159 "Use FeedForwardConfig::V(double v, ClosedLoopSlot slot) to set this "
160 "gain")]] ClosedLoopConfig&
161 VelocityFF(double ff, ClosedLoopSlot slot = kSlot0);
162
171 ClosedLoopConfig& DFilter(double dFilter, ClosedLoopSlot slot = kSlot0);
172
180 ClosedLoopConfig& IZone(double iZone, ClosedLoopSlot slot = kSlot0);
181
189 ClosedLoopConfig& MinOutput(double minOutput, ClosedLoopSlot slot = kSlot0);
190
198 ClosedLoopConfig& MaxOutput(double maxOutput, ClosedLoopSlot slot = kSlot0);
199
208 ClosedLoopConfig& OutputRange(double minOutput, double maxOutput,
209 ClosedLoopSlot slot = kSlot0);
210
220 ClosedLoopConfig& IMaxAccum(double iMaxAccum, ClosedLoopSlot slot = kSlot0);
221
234 ClosedLoopConfig& AllowedClosedLoopError(double allowedError,
235 ClosedLoopSlot slot = kSlot0);
236
244
253
262
271 double maxInput);
272
291
306 int detachedEncoderDeviceId);
307
322 FeedbackSensor sensor,
323 const rev::detached::DetachedEncoder& detachedEncoder);
324
325 std::string Flatten() override;
326
329}; // ClosedLoopConfig
330
331} // namespace rev::spark
Definition: BaseConfig.h:40
Definition: DetachedEncoder.h:43
Definition: ClosedLoopConfig.h:44
ClosedLoopConfig & PositionWrappingMaxInput(double maxInput)
Definition: ClosedLoopConfig.cpp:173
ClosedLoopConfig & VelocityFF(double ff, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:104
ClosedLoopConfig & IMaxAccum(double iMaxAccum, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:147
ClosedLoopConfig & Pid(double p, double i, double d, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:75
ClosedLoopConfig & P(double p, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:86
ClosedLoopConfig & DFilter(double dFilter, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:110
FeedForwardConfig feedForward
Definition: ClosedLoopConfig.h:328
ClosedLoopConfig(ClosedLoopConfig &&) noexcept=delete
ClosedLoopConfig & MinOutput(double minOutput, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:123
ClosedLoopConfig(const ClosedLoopConfig &)=default
ClosedLoopConfig & PositionWrappingMinInput(double minInput)
Definition: ClosedLoopConfig.cpp:167
ClosedLoopConfig & SetFeedbackSensor(FeedbackSensor sensor)
Definition: ClosedLoopConfig.cpp:188
ClosedLoopConfig & AllowedClosedLoopError(double allowedError, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:154
ClosedLoopConfig & PositionWrappingInputRange(double minInput, double maxInput)
Definition: ClosedLoopConfig.cpp:179
ClosedLoopConfig & PositionWrappingEnabled(bool enabled)
Definition: ClosedLoopConfig.cpp:162
~ClosedLoopConfig() override=default
ClosedLoopConfig & D(double d, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:98
ClosedLoopConfig & MaxOutput(double maxOutput, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:130
ClosedLoopConfig & I(double i, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:92
std::string Flatten() override
Definition: ClosedLoopConfig.cpp:233
ClosedLoopConfig & OutputRange(double minOutput, double maxOutput, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:137
ClosedLoopConfig & Apply(ClosedLoopConfig &config)
Definition: ClosedLoopConfig.cpp:45
ClosedLoopConfig & IZone(double iZone, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:117
ClosedLoopConfig & operator=(const ClosedLoopConfig &)=delete
MAXMotionConfig maxMotion
Definition: ClosedLoopConfig.h:327
ClosedLoopConfig & Pidf(double p, double i, double d, double ff, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:62
Definition: FeedForwardConfig.h:36
Definition: MAXMotionConfig.h:36
Definition: ClosedLoopConfig.h:38
Definition: SparkLowLevel.cpp:40
FeedbackSensor
Definition: ClosedLoopTypes.h:37
ClosedLoopSlot
Definition: ClosedLoopTypes.h:35
@ kSlot0
Definition: ClosedLoopTypes.h:35
Definition: SparkLowLevel.cpp:40