From 6d67e37c3d9368e495e4deef600c18a4a737ac63 Mon Sep 17 00:00:00 2001 From: sdekhterman Date: Thu, 24 Oct 2024 20:55:28 -0500 Subject: [PATCH] controller now compiles without errors --- cpp_pid/include/cpp_pid/pid.h | 2 +- cpp_pid/src/main.cpp | 4 ++-- cpp_pid/src/pid.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cpp_pid/include/cpp_pid/pid.h b/cpp_pid/include/cpp_pid/pid.h index b4fd424..2c6ea9a 100644 --- a/cpp_pid/include/cpp_pid/pid.h +++ b/cpp_pid/include/cpp_pid/pid.h @@ -8,7 +8,7 @@ namespace auvsl { public: // Contructor and destructor - PID(double dt, double max, double min, double Kp, double Kd, double Ki); + PID(double dt, double max, double min, double Kp, double Ki, double Kd); ~PID(); // Returns the manipulated variable given a setpoint and current process value diff --git a/cpp_pid/src/main.cpp b/cpp_pid/src/main.cpp index 3956bf2..35c32f1 100644 --- a/cpp_pid/src/main.cpp +++ b/cpp_pid/src/main.cpp @@ -49,12 +49,12 @@ void writeToCSVfile(std::string name, Eigen::MatrixXd matrix) int main(int argc, char **argv) { - double T = 50, dt = 1/T, max = 70, min = -70, Kp = 10, Kd = 5, Ki = 2; + double T = 50, dt = 1/T, max = 70, min = -70, Kp = 10, Ki = 2, Kd = 5; //make a server object that callsback odomentry information, an object to analysis the relevant waypoints, if the vehcile should stop, path errors fed into the controller, and a controller object auvsl::Server* srvrObj = new auvsl::Server; auvsl::Environment* envObj = new auvsl::Environment; - auvsl::PID* pidObj = new auvsl::PID(dt, max, min, Kp, Kd, Ki); + auvsl::PID* pidObj = new auvsl::PID(dt, max, min, Kp, Ki, Kd); rclcpp::init(argc, argv); auto node = rclcpp::Node::make_shared("fuzzyControl"); diff --git a/cpp_pid/src/pid.cpp b/cpp_pid/src/pid.cpp index 6845dd5..24a833c 100644 --- a/cpp_pid/src/pid.cpp +++ b/cpp_pid/src/pid.cpp @@ -10,14 +10,14 @@ namespace auvsl { // Constructor - PID::PID(double dt, double max, double min, double Kp, double Kd, double Ki) : + PID::PID(double dt, double max, double min, double Kp, double Ki, double Kd) : _dt(dt), _max(max), _min(min), _Kp(Kp), - _Kd(Kd), _Ki(Ki), - _pre_error(0), + _Kd(Kd), + _prev_error(0), _integral(0) { }