46 #include <std_msgs/Float64.h> 50 #include <dynamic_reconfigure/Config.h> 51 #include <dynamic_reconfigure/DoubleParameter.h> 52 #include <dynamic_reconfigure/Reconfigure.h> 55 void setKp(
double Kp);
66 std::string
ns =
"/left_wheel_pid/";
77 int main(
int argc,
char** argv)
94 for (
double Kp = Kp_min; Kp <= Kp_max; Kp += Kp_step)
100 ros::topic::waitForMessage<std_msgs::Float64>(
"setpoint");
101 ros::topic::waitForMessage<std_msgs::Float64>(
"state");
122 ros::topic::waitForMessage<std_msgs::Float64>(
"state");
170 ROS_INFO_STREAM(
"Did not see any oscillations for this range of Kp. Adjust " 171 "Kp_max and Kp_min to broaden the search.");
180 dynamic_reconfigure::ReconfigureRequest srv_req;
181 dynamic_reconfigure::ReconfigureResponse srv_resp;
182 dynamic_reconfigure::DoubleParameter double_param;
183 dynamic_reconfigure::Config config;
184 double_param.name =
"Ki";
185 double_param.value = 0.0;
186 config.doubles.push_back(double_param);
187 double_param.name =
"Kd";
188 double_param.value = 0.0;
189 config.doubles.push_back(double_param);
190 srv_req.config = config;
197 dynamic_reconfigure::ReconfigureRequest srv_req;
198 dynamic_reconfigure::ReconfigureResponse srv_resp;
199 dynamic_reconfigure::DoubleParameter double_param;
200 dynamic_reconfigure::Config config;
205 double_param.name =
"Kp";
206 double_param.value = Kp / srv_resp.config.doubles.at(0).value;
207 config.doubles.push_back(double_param);
208 srv_req.config = config;
232 dynamic_reconfigure::ReconfigureRequest srv_req;
233 dynamic_reconfigure::ReconfigureResponse srv_resp;
234 dynamic_reconfigure::DoubleParameter double_param;
235 dynamic_reconfigure::Config config;
240 double_param.name =
"Kp";
241 double_param.value =
autotune::Kp_ZN / srv_resp.config.doubles.at(0).value;
242 config.doubles.push_back(double_param);
244 double_param.name =
"Ki";
245 double_param.value =
autotune::Ki_ZN / srv_resp.config.doubles.at(0).value;
246 config.doubles.push_back(double_param);
248 double_param.name =
"Kd";
249 double_param.value =
autotune::Kd_ZN / srv_resp.config.doubles.at(0).value;
250 config.doubles.push_back(double_param);
252 srv_req.config = config;
void setpointCallback(const std_msgs::Float64 &setpoint_msg)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
bool call(const std::string &service_name, MReq &req, MRes &res)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
Duration expectedCycleTime() const
std::vector< double > oscillation_times(3)
#define ROS_INFO_STREAM(args)
ROSCPP_DECL void shutdown()
int main(int argc, char **argv)
ROSCPP_DECL void spinOnce()
void stateCallback(const std_msgs::Float64 &state_msg)