REVLib - C++
SparkBaseConfig.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
33#include "rev/SparkBase.h"
43
44namespace rev::spark {
45
47public:
48 enum IdleMode : uint32_t { kCoast = 0, kBrake = 1 };
49
50 SparkBaseConfig() = default;
51 ~SparkBaseConfig() override = default;
52
55 SparkBaseConfig(SparkBaseConfig&&) noexcept = delete;
56 SparkBaseConfig& operator=(SparkBaseConfig&&) noexcept = delete;
57
68 virtual SparkBaseConfig& Apply(SparkBaseConfig& config);
69
81
93
104 virtual SparkBaseConfig& Apply(EncoderConfig& config);
105
116 virtual SparkBaseConfig& Apply(LimitSwitchConfig& config);
117
128 virtual SparkBaseConfig& Apply(SoftLimitConfig& config);
129
140 virtual SparkBaseConfig& Apply(ClosedLoopConfig& config);
141
152 virtual SparkBaseConfig& Apply(SignalsConfig& config);
153
160 virtual SparkBaseConfig& SetIdleMode(IdleMode idleMode);
161
171 virtual SparkBaseConfig& Inverted(bool inverted);
172
198 virtual SparkBaseConfig& SmartCurrentLimit(int stallLimit,
199 int freeLimit = 0,
200 int limitRpm = 20000);
201
228 virtual SparkBaseConfig& SecondaryCurrentLimit(double limit,
229 int chopCycles = 0);
230
240 virtual SparkBaseConfig& OpenLoopRampRate(double rate);
241
251 virtual SparkBaseConfig& ClosedLoopRampRate(double rate);
252
260 virtual SparkBaseConfig& VoltageCompensation(double nominalVoltage);
261
268
282 virtual SparkBaseConfig& Follow(int leaderCanId, bool invert = false);
283
297 virtual SparkBaseConfig& Follow(SparkBase& leader, bool invert = false);
298
305
306 std::string Flatten() override;
307
315}; // class SparkBaseConfig
316
317} // namespace rev::spark
Definition: AbsoluteEncoderConfig.h:35
Definition: AnalogSensorConfig.h:35
Definition: BaseConfig.h:40
Definition: ClosedLoopConfig.h:40
Definition: EncoderConfig.h:35
Definition: LimitSwitchConfig.h:35
Definition: SignalsConfig.h:35
Definition: SoftLimitConfig.h:35
Definition: SparkBaseConfig.h:46
virtual SparkBaseConfig & VoltageCompensation(double nominalVoltage)
Definition: SparkBaseConfig.cpp:132
EncoderConfig encoder
Definition: SparkBaseConfig.h:311
virtual SparkBaseConfig & DisableVoltageCompensation()
Definition: SparkBaseConfig.cpp:139
~SparkBaseConfig() override=default
IdleMode
Definition: SparkBaseConfig.h:48
@ kCoast
Definition: SparkBaseConfig.h:48
@ kBrake
Definition: SparkBaseConfig.h:48
SoftLimitConfig softLimit
Definition: SparkBaseConfig.h:314
virtual SparkBaseConfig & OpenLoopRampRate(double rate)
Definition: SparkBaseConfig.cpp:114
virtual SparkBaseConfig & Inverted(bool inverted)
Definition: SparkBaseConfig.cpp:89
virtual SparkBaseConfig & Apply(SparkBaseConfig &config)
Definition: SparkBaseConfig.cpp:37
SparkBaseConfig(SparkBaseConfig &&) noexcept=delete
ClosedLoopConfig closedLoop
Definition: SparkBaseConfig.h:310
virtual SparkBaseConfig & DisableFollowerMode()
Definition: SparkBaseConfig.cpp:155
std::string Flatten() override
Definition: SparkBaseConfig.cpp:161
SparkBaseConfig & operator=(const SparkBaseConfig &)=delete
SignalsConfig signals
Definition: SparkBaseConfig.h:313
virtual SparkBaseConfig & Follow(int leaderCanId, bool invert=false)
Definition: SparkBaseConfig.cpp:144
virtual SparkBaseConfig & ClosedLoopRampRate(double rate)
Definition: SparkBaseConfig.cpp:123
AbsoluteEncoderConfig absoluteEncoder
Definition: SparkBaseConfig.h:308
AnalogSensorConfig analogSensor
Definition: SparkBaseConfig.h:309
SparkBaseConfig(const SparkBaseConfig &)=delete
virtual SparkBaseConfig & SmartCurrentLimit(int stallLimit, int freeLimit=0, int limitRpm=20000)
Definition: SparkBaseConfig.cpp:94
LimitSwitchConfig limitSwitch
Definition: SparkBaseConfig.h:312
virtual SparkBaseConfig & SecondaryCurrentLimit(double limit, int chopCycles=0)
Definition: SparkBaseConfig.cpp:106
virtual SparkBaseConfig & SetIdleMode(IdleMode idleMode)
Definition: SparkBaseConfig.cpp:84
Definition: SparkBase.h:57
Definition: SparkLowLevel.cpp:40