WPILibC++  2020.3.2
PIDController.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <memory>
11 #include <string>
12 
13 #include <wpi/deprecated.h>
14 #include <wpi/mutex.h>
15 
16 #include "frc/Base.h"
17 #include "frc/Controller.h"
18 #include "frc/Notifier.h"
19 #include "frc/PIDBase.h"
20 #include "frc/PIDSource.h"
21 #include "frc/Timer.h"
22 
23 namespace frc {
24 
25 class PIDOutput;
26 
37 class PIDController : public PIDBase, public Controller {
38  public:
51  WPI_DEPRECATED("Use frc2::PIDController class instead.")
52  PIDController(double p, double i, double d, PIDSource* source,
53  PIDOutput* output, double period = 0.05);
54 
67  WPI_DEPRECATED("Use frc2::PIDController class instead.")
68  PIDController(double p, double i, double d, double f, PIDSource* source,
69  PIDOutput* output, double period = 0.05);
70 
83  WPI_DEPRECATED("Use frc2::PIDController class instead.")
84  PIDController(double p, double i, double d, PIDSource& source,
85  PIDOutput& output, double period = 0.05);
86 
99  WPI_DEPRECATED("Use frc2::PIDController class instead.")
100  PIDController(double p, double i, double d, double f, PIDSource& source,
101  PIDOutput& output, double period = 0.05);
102 
103  ~PIDController() override;
104 
108  void Enable() override;
109 
114  void Disable() override;
115 
119  void SetEnabled(bool enable);
120 
124  bool IsEnabled() const;
125 
129  void Reset() override;
130 
131  void InitSendable(SendableBuilder& builder) override;
132 
133  private:
134  std::unique_ptr<Notifier> m_controlLoop;
135 };
136 
137 } // namespace frc
frc::PIDSource
PIDSource interface is a generic sensor source for the PID class.
Definition: PIDSource.h:20
frc::PIDController::Enable
void Enable() override
Begin running the PIDController.
frc::PIDController::IsEnabled
bool IsEnabled() const
Return true if PIDController is enabled.
frc::PIDController::InitSendable
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
frc::PIDBase
Class implements a PID Control Loop.
Definition: PIDBase.h:39
frc::PIDController::Reset
void Reset() override
Reset the previous error, the integral term, and disable the controller.
frc::PIDController::PIDController
PIDController(double p, double i, double d, PIDSource *source, PIDOutput *output, double period=0.05)
Allocate a PID object with the given constants for P, I, D.
frc::Controller
Interface for Controllers.
Definition: Controller.h:21
frc::PIDController::Disable
void Disable() override
Stop running the PIDController, this sets the output to zero before stopping.
frc
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
frc::PIDController
Class implements a PID Control Loop.
Definition: PIDController.h:37
frc::PIDOutput
PIDOutput interface is a generic output for the PID class.
Definition: PIDOutput.h:20
frc::PIDController::SetEnabled
void SetEnabled(bool enable)
Set the enabled state of the PIDController.
frc::SendableBuilder
Definition: SendableBuilder.h:23