REVLib - C++
CANPIDController.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2022 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#ifdef _MSC_VER
32// Disable deprecation warnings for this file when using VS compiler
33#pragma warning(disable : 4996)
34#endif
35
36#ifdef __GNUC__
37#pragma GCC diagnostic push
38#pragma GCC diagnostic ignored "-Wdeprecated"
39#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
40#endif
41
42#include <wpi/deprecated.h>
43
44#include "rev/CANSensor.h"
45#include "rev/ControlType.h"
46#include "rev/REVLibError.h"
47
48namespace rev {
49
50class CANSparkMax;
51class SparkMaxPIDController;
52
56class WPI_DEPRECATED("Use SparkMaxPIDController instead") CANPIDController {
58
59public:
63 enum class WPI_DEPRECATED(
65 kTrapezoidal = 0,
66 kSCurve = 1
67 };
68
72 enum class WPI_DEPRECATED("Use SparkMaxPIDController::ArbFFUnits instead")
74 kVoltage = 0,
75 kPercentOut = 1
76 };
77
78 virtual ~CANPIDController() {}
79
103 double value, ControlType ctrl, int pidSlot = 0,
104 double arbFeedforward = 0,
105 ArbFFUnits arbFFUnits = ArbFFUnits::kVoltage) = 0;
106
123 virtual REVLibError SetP(double gain, int slotID = 0) = 0;
124
141 virtual REVLibError SetI(double gain, int slotID = 0) = 0;
142
159 virtual REVLibError SetD(double gain, int slotID = 0) = 0;
160
176 virtual REVLibError SetDFilter(double gain, int slotID = 0) = 0;
177
194 virtual REVLibError SetFF(double gain, int slotID = 0) = 0;
195
215 virtual REVLibError SetIZone(double IZone, int slotID = 0) = 0;
216
236 virtual REVLibError SetOutputRange(double min, double max,
237 int slotID = 0) = 0;
238
255 virtual double GetP(int slotID = 0) const = 0;
256
272 virtual double GetI(int slotID = 0) const = 0;
273
289 virtual double GetD(int slotID = 0) const = 0;
290
307 virtual double GetDFilter(int slotID = 0) const = 0;
308
325 virtual double GetFF(int slotID = 0) const = 0;
326
342 virtual double GetIZone(int slotID = 0) const = 0;
343
359 virtual double GetOutputMin(int slotID = 0) const = 0;
360
376 virtual double GetOutputMax(int slotID = 0) const = 0;
377
392 int slotID = 0) = 0;
393
408 virtual REVLibError SetSmartMotionMaxAccel(double maxAccel,
409 int slotID = 0) = 0;
410
424 int slotID = 0) = 0;
425
441 double allowedErr, int slotID = 0) = 0;
442
458 int slotID = 0) = 0;
459
471 virtual double GetSmartMotionMaxVelocity(int slotID = 0) const = 0;
472
485 virtual double GetSmartMotionMaxAccel(int slotID = 0) const = 0;
486
497 virtual double GetSmartMotionMinOutputVelocity(int slotID = 0) const = 0;
498
512 int slotID = 0) const = 0;
513
526 virtual REVLibError SetIMaxAccum(double iMaxAccum, int slotID = 0) = 0;
527
538 virtual double GetIMaxAccum(int slotID = 0) const = 0;
539
552 virtual REVLibError SetIAccum(double iAccum) = 0;
553
560 virtual double GetIAccum() const = 0;
561
577 virtual REVLibError SetFeedbackDevice(const CANSensor& sensor) = 0;
578
587
597
607
614 virtual bool GetPositionPIDWrappingEnabled() const = 0;
615
622 virtual double GetPositionPIDWrappingMaxInput() const = 0;
623
630 virtual double GetPositionPIDWrappingMinInput() const = 0;
631
632private:
634};
635
636} // namespace rev
637
638#ifdef __GNUC__
639#pragma GCC diagnostic pop
640#endif
Definition: CANPIDController.h:56
virtual double GetSmartMotionMaxAccel(int slotID=0) const =0
virtual double GetI(int slotID=0) const =0
virtual double GetOutputMax(int slotID=0) const =0
virtual REVLibError SetP(double gain, int slotID=0)=0
virtual REVLibError SetSmartMotionMinOutputVelocity(double minVel, int slotID=0)=0
virtual double GetIAccum() const =0
ArbFFUnits
Definition: CANPIDController.h:73
virtual REVLibError SetSmartMotionMaxVelocity(double maxVel, int slotID=0)=0
virtual ~CANPIDController()
Definition: CANPIDController.h:78
virtual double GetSmartMotionAllowedClosedLoopError(int slotID=0) const =0
virtual double GetD(int slotID=0) const =0
virtual REVLibError SetSmartMotionMaxAccel(double maxAccel, int slotID=0)=0
virtual REVLibError SetOutputRange(double min, double max, int slotID=0)=0
virtual double GetOutputMin(int slotID=0) const =0
virtual double GetSmartMotionMinOutputVelocity(int slotID=0) const =0
virtual REVLibError SetIZone(double IZone, int slotID=0)=0
virtual REVLibError SetSmartMotionAllowedClosedLoopError(double allowedErr, int slotID=0)=0
virtual REVLibError SetIMaxAccum(double iMaxAccum, int slotID=0)=0
virtual REVLibError SetPositionPIDWrappingMinInput(double value)=0
virtual double GetPositionPIDWrappingMinInput() const =0
virtual double GetPositionPIDWrappingMaxInput() const =0
virtual REVLibError SetSmartMotionAccelStrategy(AccelStrategy accelStrategy, int slotID=0)=0
virtual REVLibError SetPositionPIDWrappingMaxInput(double value)=0
virtual REVLibError SetReference(double value, ControlType ctrl, int pidSlot=0, double arbFeedforward=0, ArbFFUnits arbFFUnits=ArbFFUnits::kVoltage)=0
virtual double GetDFilter(int slotID=0) const =0
virtual REVLibError SetIAccum(double iAccum)=0
virtual REVLibError SetD(double gain, int slotID=0)=0
virtual double GetP(int slotID=0) const =0
virtual REVLibError SetDFilter(double gain, int slotID=0)=0
virtual double GetIZone(int slotID=0) const =0
virtual double GetIMaxAccum(int slotID=0) const =0
virtual double GetSmartMotionMaxVelocity(int slotID=0) const =0
virtual REVLibError SetI(double gain, int slotID=0)=0
virtual REVLibError SetPositionPIDWrappingEnabled(bool enable)=0
virtual bool GetPositionPIDWrappingEnabled() const =0
virtual REVLibError SetFF(double gain, int slotID=0)=0
virtual REVLibError SetFeedbackDevice(const CANSensor &sensor)=0
virtual double GetFF(int slotID=0) const =0
AccelStrategy
Definition: CANPIDController.h:64
Definition: CANSensor.h:42
Definition: SparkMaxPIDController.h:59
Definition: CANSparkLowLevel.cpp:39
REVLibError
Definition: REVLibError.h:33
ControlType
Definition: ControlType.h:36