REVLib - C++
ClosedLoopConfig.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 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
37
38namespace rev::spark {
39
41public:
42 enum FeedbackSensor : uint32_t {
48 };
49
50 ClosedLoopConfig() = default;
51 ~ClosedLoopConfig() override = default;
52
55 ClosedLoopConfig(ClosedLoopConfig&&) noexcept = delete;
56 ClosedLoopConfig& operator=(ClosedLoopConfig&&) noexcept = delete;
57
69
80
92
103 ClosedLoopConfig& Pidf(double p, double i, double d, double ff,
104 ClosedLoopSlot slot = kSlot0);
105
115 ClosedLoopConfig& Pid(double p, double i, double d,
116 ClosedLoopSlot slot = kSlot0);
117
126 ClosedLoopConfig& P(double p, ClosedLoopSlot slot = kSlot0);
127
135 ClosedLoopConfig& I(double i, ClosedLoopSlot slot = kSlot0);
136
145 ClosedLoopConfig& D(double d, ClosedLoopSlot slot = kSlot0);
146
156
165 ClosedLoopConfig& DFilter(double dFilter, ClosedLoopSlot slot = kSlot0);
166
174 ClosedLoopConfig& IZone(double iZone, ClosedLoopSlot slot = kSlot0);
175
183 ClosedLoopConfig& MinOutput(double minOutput, ClosedLoopSlot slot = kSlot0);
184
192 ClosedLoopConfig& MaxOutput(double maxOutput, ClosedLoopSlot slot = kSlot0);
193
202 ClosedLoopConfig& OutputRange(double minOutput, double maxOutput,
203 ClosedLoopSlot slot = kSlot0);
204
214 ClosedLoopConfig& IMaxAccum(double iMaxAccum, ClosedLoopSlot slot = kSlot0);
215
223
232
241
250 double maxInput);
251
265
266 std::string Flatten() override;
267
270}; // ClosedLoopConfig
271
272} // namespace rev::spark
Definition: BaseConfig.h:40
Definition: ClosedLoopConfig.h:40
ClosedLoopConfig & PositionWrappingMaxInput(double maxInput)
Definition: ClosedLoopConfig.cpp:164
ClosedLoopConfig & VelocityFF(double ff, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:103
ClosedLoopConfig & IMaxAccum(double iMaxAccum, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:146
ClosedLoopConfig & Pid(double p, double i, double d, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:74
ClosedLoopConfig & P(double p, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:85
ClosedLoopConfig & DFilter(double dFilter, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:109
ClosedLoopConfig(const ClosedLoopConfig &)=delete
FeedbackSensor
Definition: ClosedLoopConfig.h:42
@ kPrimaryEncoder
Definition: ClosedLoopConfig.h:44
@ kAbsoluteEncoder
Definition: ClosedLoopConfig.h:47
@ kAlternateOrExternalEncoder
Definition: ClosedLoopConfig.h:46
@ kNoSensor
Definition: ClosedLoopConfig.h:43
@ kAnalogSensor
Definition: ClosedLoopConfig.h:45
ClosedLoopConfig(ClosedLoopConfig &&) noexcept=delete
ClosedLoopConfig & MinOutput(double minOutput, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:122
ClosedLoopConfig & PositionWrappingMinInput(double minInput)
Definition: ClosedLoopConfig.cpp:158
SmartMotionConfig smartMotion
Definition: ClosedLoopConfig.h:269
ClosedLoopConfig & SetFeedbackSensor(FeedbackSensor sensor)
Definition: ClosedLoopConfig.cpp:179
ClosedLoopConfig & PositionWrappingInputRange(double minInput, double maxInput)
Definition: ClosedLoopConfig.cpp:170
ClosedLoopConfig & PositionWrappingEnabled(bool enabled)
Definition: ClosedLoopConfig.cpp:153
~ClosedLoopConfig() override=default
ClosedLoopConfig & D(double d, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:97
ClosedLoopConfig & MaxOutput(double maxOutput, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:129
ClosedLoopConfig & I(double i, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:91
std::string Flatten() override
Definition: ClosedLoopConfig.cpp:184
ClosedLoopConfig & OutputRange(double minOutput, double maxOutput, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:136
ClosedLoopConfig & Apply(ClosedLoopConfig &config)
Definition: ClosedLoopConfig.cpp:44
ClosedLoopConfig & IZone(double iZone, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:116
ClosedLoopConfig & operator=(const ClosedLoopConfig &)=delete
MAXMotionConfig maxMotion
Definition: ClosedLoopConfig.h:268
ClosedLoopConfig & Pidf(double p, double i, double d, double ff, ClosedLoopSlot slot=kSlot0)
Definition: ClosedLoopConfig.cpp:61
Definition: MAXMotionConfig.h:36
Definition: SmartMotionConfig.h:36
Definition: SparkLowLevel.cpp:40
ClosedLoopSlot
Definition: ClosedLoopSlot.h:33
@ kSlot0
Definition: ClosedLoopSlot.h:33