Skip to content

A simple C++ PID package for other ROS repos

Notifications You must be signed in to change notification settings

NTU-Mecatron/pid_package

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A simple C++ PID controller package

Class constructor and method

    PID ( double Kp, double Ki, double Kd, double dt, double max, double min );
    double calculate ( double setpoint, double current );

Installation

cd ~/catkin_ws/src
git clone -b ros1 https://github.com/NTU-Mecatron/pid_package

Example usage

For .hpp/.h file:

#include <pid_package/pid.h>

class YourClass {
public:
    YourClass();

private:
    PID your_pid_ = PID(0,0,0,0,0,0);
};

For .cpp file:

#include "your_package/your_class.hpp"
YourClass::YourClass() {
    your_pid_ = PID(1, 0.1, 0.01, 0.01, 100, -100);
}

void YourClass::yourCallback() {
    double setpoint = 10;
    double current = 5;
    double output = your_pid_.calculate(setpoint, current);
}

You can use float type for the PID controller as well.

CMakelists.txt

Modify your CMakeLists.txt file to include the following:

find_package(pid_package REQUIRED)

package.xml

Modify your package.xml file to include the following:

<build_depend>pid_package</build_depend>
<exec_depend>pid_package</exec_depend>

About

A simple C++ PID package for other ROS repos

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 66.9%
  • CMake 33.1%