WPILibC++  2020.3.2-60-g3011ebe
PIDController.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2020 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 
39 class PIDController : public PIDBase, public Controller {
40  public:
53  WPI_DEPRECATED("Use frc2::PIDController class instead.")
54  PIDController(double p, double i, double d, PIDSource* source,
55  PIDOutput* output, double period = 0.05);
56 
69  WPI_DEPRECATED("Use frc2::PIDController class instead.")
70  PIDController(double p, double i, double d, double f, PIDSource* source,
71  PIDOutput* output, double period = 0.05);
72 
85  WPI_DEPRECATED("Use frc2::PIDController class instead.")
86  PIDController(double p, double i, double d, PIDSource& source,
87  PIDOutput& output, double period = 0.05);
88 
101  WPI_DEPRECATED("Use frc2::PIDController class instead.")
102  PIDController(double p, double i, double d, double f, PIDSource& source,
103  PIDOutput& output, double period = 0.05);
104 
105  ~PIDController() override;
106 
110  void Enable() override;
111 
116  void Disable() override;
117 
121  void SetEnabled(bool enable);
122 
126  bool IsEnabled() const;
127 
131  void Reset() override;
132 
133  void InitSendable(SendableBuilder& builder) override;
134 
135  private:
136  std::unique_ptr<Notifier> m_controlLoop;
137 };
138 
139 } // 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:41
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:23
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: PDPSim.h:16
frc::PIDController
Class implements a PID Control Loop.
Definition: PIDController.h:39
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