##

PID.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _GAZEBO_PID_HH_
#define _GAZEBO_PID_HH_
#include "gazebo/common/Time.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace common
{
class GZ_COMMON_VISIBLE PID
{
public: PID(double _p = 0.0, double _i = 0.0, double _d = 0.0,
double _imax = 0.0, double _imin = 0.0,
double _cmdMax = -1.0, double _cmdMin = 0.0);
public: virtual ~PID();
public: void Init(double _p = 0.0, double _i = 0.0, double _d = 0.0,
double _imax = 0.0, double _imin = 0.0,
double _cmdMax = -1.0, double _cmdMin = 0.0);
public: void SetPGain(double _p);
public: void SetIGain(double _i);
public: void SetDGain(double _d);
public: void SetIMax(double _i);
public: void SetIMin(double _i);
public: void SetCmdMax(double _c);
public: void SetCmdMin(double _c);
public: double GetPGain() const;
public: double GetIGain() const;
public: double GetDGain() const;
public: double GetIMax() const;
public: double GetIMin() const;
public: double GetCmdMax() const;
public: double GetCmdMin() const;
public: double Update(double _error, common::Time _dt);
public: void SetCmd(double _cmd);
public: double GetCmd();
public: void GetErrors(double &_pe, double &_ie, double &_de);
public: PID &operator=(const PID &_p)
{
if (this == &_p)
return *this;
this->pGain = _p.pGain;
this->iGain = _p.iGain;
this->dGain = _p.dGain;
this->iMax = _p.iMax;
this->iMin = _p.iMin;
this->cmdMax = _p.cmdMax;
this->cmdMin = _p.cmdMin;
this->pErrLast = _p.pErrLast;
this->pErr = _p.pErr;
this->iErr = _p.iErr;
this->dErr = _p.dErr;
this->cmd = _p.cmd;
this->Reset();
return *this;
}
public: void Reset();
private: double pErrLast;
private: double pErr;
private: double iErr;
private: double dErr;
private: double pGain;
private: double iGain;
private: double dGain;
private: double iMax;
private: double iMin;
private: double cmd;
private: double cmdMax = -1.0;
private: double cmdMin = 0.0;
};
}
}
#endif
gazebo::common::PID::GetDGain
double GetDGain() const
Get the derivative Gain.
gazebo::common::PID::GetErrors
void GetErrors(double &_pe, double &_ie, double &_de)
Return PID error terms for the controller.
Time.hh
gazebo::common::PID::SetCmdMax
void SetCmdMax(double _c)
Set the maximum value for the command.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::common::Time
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: Time.hh:47
common
common
Definition: FuelModelDatabase.hh:37
gazebo::common::PID::Init
void Init(double _p=0.0, double _i=0.0, double _d=0.0, double _imax=0.0, double _imin=0.0, double _cmdMax=-1.0, double _cmdMin=0.0)
Initialize PID-gains and integral term limits:[iMax:iMin]-[I1:I2].
gazebo::common::PID::GetIMin
double GetIMin() const
Get the integral lower limit.
system.hh
gazebo::common::PID::SetCmd
void SetCmd(double _cmd)
Set current target command for this PID controller.
gazebo::common::PID::GetCmd
double GetCmd()
Return current command for this PID controller.
gazebo::common::PID::operator=
PID & operator=(const PID &_p)
Assignment operator.
Definition: PID.hh:157
gazebo::common::PID::SetDGain
void SetDGain(double _d)
Set the derivtive Gain.
gazebo::common::PID::SetIMax
void SetIMax(double _i)
Set the integral upper limit.
gazebo::common::PID::GetIMax
double GetIMax() const
Get the integral upper limit.
gazebo::common::PID::Reset
void Reset()
Reset the errors and command.
gazebo::common::PID::GetPGain
double GetPGain() const
Get the proportional Gain.
gazebo::common::PID::SetPGain
void SetPGain(double _p)
Set the proportional Gain.
gazebo::common::PID::~PID
virtual ~PID()
Destructor.
gazebo::common::PID
Generic PID controller class. Generic proportiolnal-integral-derivative controller class that keeps t...
Definition: PID.hh:36
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gazebo::common::PID::SetIMin
void SetIMin(double _i)
Set the integral lower limit.
gazebo::common::PID::Update
double Update(double _error, common::Time _dt)
Update the Pid loop with nonuniform time step size.
gazebo::common::PID::PID
PID(double _p=0.0, double _i=0.0, double _d=0.0, double _imax=0.0, double _imin=0.0, double _cmdMax=-1.0, double _cmdMin=0.0)
Constructor, zeros out Pid values when created and initialize Pid-gains and integral term limits:[iMa...
gazebo::common::PID::SetCmdMin
void SetCmdMin(double _c)
Set the maximum value for the command.
gazebo::common::PID::GetIGain
double GetIGain() const
Get the integral Gain.
gazebo::common::PID::GetCmdMin
double GetCmdMin() const
Get the maximum value for the command.
gazebo::common::PID::SetIGain
void SetIGain(double _i)
Set the integral Gain.
gazebo::common::PID::GetCmdMax
double GetCmdMax() const
Get the maximum value for the command.