Go to the documentation of this file.00001
00036 #ifndef CONTROLLER_H
00037 #define CONTROLLER_H
00038
00039 #include <dynamic_reconfigure/server.h>
00040 #include <iostream>
00041 #include "math.h"
00042 #include <pid/PidConfig.h>
00043 #include "ros/ros.h"
00044 #include <ros/time.h>
00045 #include <std_msgs/Float64.h>
00046 #include <std_msgs/Bool.h>
00047 #include <stdio.h>
00048 #include <string>
00049
00050 namespace pid
00051 {
00052
00053 double plant_state;
00054 double control_effort;
00055 double setpoint = 0;
00056 bool pid_enabled = true;
00057
00058 ros::Time prev_time;
00059 ros::Duration delta_t;
00060 bool first_reconfig = true;
00061
00062 double error_integral = 0;
00063 double proportional = 0;
00064 double integral = 0;
00065 double derivative = 0;
00066
00067
00068 double Kp = 0, Ki = 0, Kd = 0;
00069
00070
00071 bool angle_error = false;
00072 double angle_wrap = 2.0*3.14159;
00073
00074
00075
00076 double cutoff_frequency = -1;
00077
00078
00079
00080 double c=1.;
00081
00082
00083 double tan_filt = 1.;
00084
00085
00086 double upper_limit = 1000, lower_limit = -1000;
00087
00088
00089 double windup_limit = 1000;
00090
00091
00092 std::vector<double> error(3, 0), filtered_error(3, 0), error_deriv(3, 0), filtered_error_deriv(3, 0);
00093
00094
00095 ros::Publisher control_effort_pub;
00096
00097 std::string topic_from_controller, topic_from_plant, setpoint_topic, pid_enable_topic, node_name = "pid_node";
00098
00099 std_msgs::Float64 control_msg, state_msg;
00100
00101
00102 double min_loop_frequency = 1, max_loop_frequency = 1000;
00103 int measurements_received = 0;
00104
00105 }
00106
00107 #endif