Go to the documentation of this file.00001
00013 #ifndef UCL_DRONE_CONTROLLER_H
00014 #define UCL_DRONE_CONTROLLER_H
00015
00016
00017 #include <ros/ros.h>
00018 #include <signal.h>
00019
00020
00021 #include <ucl_drone/ucl_drone.h>
00022
00023
00024 #include <ucl_drone/profiling.h>
00025
00026
00027
00028 #include <geometry_msgs/Twist.h>
00029 #include <std_msgs/Empty.h>
00030 #include <ucl_drone/Pose3D.h>
00031 #include <ucl_drone/PoseRef.h>
00032
00033
00034 #include <std_srvs/Empty.h>
00035
00036
00039 class BasicController
00040 {
00041 private:
00042 ros::NodeHandle nh;
00043
00044 ros::Subscriber pose_sub;
00045 ros::Subscriber poseref_sub;
00046 ros::Publisher land_pub;
00047 ros::Publisher takeoff_pub;
00048 ros::Publisher vel_pub;
00049 ros::Publisher toggleState_pub;
00050 ros::Publisher reset_pub;
00051
00052 std::string pose_channel;
00053 std::string poseref_channel;
00054 std::string control_channel;
00055 std::string takeoff_channel;
00056 std::string land_channel;
00057 std::string toggleState_channel;
00058 std::string reset_channel;
00059
00061 bool isControlling;
00062
00064 float alt_ref;
00065 double x_ref;
00066 double y_ref;
00067 double yaw_ref;
00068
00069 double Kp_alt;
00070 double Ki_alt;
00071 double Kd_alt;
00072 double Kp_yaw;
00073 double Kp_plan;
00074 double Ki_plan;
00075
00076 double Kd_plan;
00077
00078 double Ki_yaw;
00079 double Kd_yaw;
00080 double integral_alt_error;
00081 double integral_yaw_error;
00082 double integral_xy_error;
00083 double integral_f_error;
00084 double integral_l_error;
00085 double anti_windup_yaw;
00086
00087 double regu_old_time_z;
00088 double regu_old_time_yaw;
00089 double regu_old_time_xy;
00090 double old_delta_alt;
00091 double old_delta_yaw;
00092 double dist_old;
00093 double p_term_f_old;
00094 double p_term_l_old;
00095 double alt_desired_old;
00096 double yaw_desired_old;
00097 double x_desired_old;
00098 double y_desired_old;
00099 double last_vel_z_command;
00100 double last_vel_yaw_command;
00101 double last_vel_x_command;
00102 double last_vel_y_command;
00103 double old_yaw_desired;
00104
00106 ucl_drone::Pose3D lastPoseReceived;
00107
00109 ucl_drone::PoseRef lastPoseRefReceived;
00110
00112
00113
00115 ros::ServiceServer startControl_;
00116
00118 ros::ServiceServer stopControl_;
00119
00120 void reguXY(double *xvel_cmd, double *yvel_cmd, double x_mes, double y_mes, double x_desired,
00121 double y_desired, double yaw, double regu_new_time_xy);
00122 void reguAltitude(double *zvel_cmd, double alt_mes, double alt_desired, double regu_new_time_z);
00123 void reguYaw(double *yawvel_cmd, double yaw_mes, double yaw_desired, double regu_new_time);
00124
00125 void sendVelToDrone(double pitch, double roll, double yaw_vel, double zvel_cmd,
00126 bool force = false);
00127
00129 void poseCb(const ucl_drone::Pose3D::ConstPtr posePtr);
00130
00132 void poseRefCb(const ucl_drone::PoseRef::ConstPtr poseRefPtr);
00133
00135
00136
00137 public:
00139 BasicController();
00140
00142 ~BasicController();
00143
00144 void init();
00145
00146 void controlLoop();
00147
00149 bool startControl(std_srvs::Empty::Request &, std_srvs::Empty::Response &);
00150
00152 bool stopControl(std_srvs::Empty::Request &, std_srvs::Empty::Response &);
00153 };
00154
00155 #endif