DroneController.h
Go to the documentation of this file.
00001 #pragma once
00002 
00021 #ifndef __DRONECONTROLLER_H
00022 #define __DRONECONTROLLER_H
00023  
00024  
00025  
00026 
00027 #include "TooN/se3.h"
00028 #include <queue>
00029 #include "geometry_msgs/Twist.h"
00030 #include "tum_ardrone/filter_state.h"
00031 
00032 class ControlNode;
00033 
00034 struct ControlCommand
00035 {
00036         inline ControlCommand() {roll = pitch = yaw = gaz = 0;}
00037         inline ControlCommand(double roll, double pitch, double yaw, double gaz)
00038         {
00039                 this->roll = roll;
00040                 this->pitch = pitch;
00041                 this->yaw = yaw;
00042                 this->gaz = gaz;
00043         }
00044         double yaw, roll, pitch, gaz;
00045 };
00046 
00047 
00048 struct DronePosition
00049 {
00050 public:
00051         double yaw;
00052         TooN::Vector<3> pos;
00053         inline DronePosition(TooN::Vector<3> pos, double yaw)
00054                 : yaw(yaw), pos(pos) {}
00055         inline DronePosition(){ yaw=0; pos=TooN::makeVector(0,0,0);}
00056 };
00057 
00058 class DroneController
00059 {
00060 private:
00061         ControlCommand lastSentControl;
00062         
00063         // currentTarget.
00064         DronePosition target;
00065         bool targetValid;
00066 
00067         // used for integral term
00068         TooN::Vector<4> targetNew;      // 0=target has been reached before
00069                                                                 // 1=target is new
00070 
00071         // need to keep track of integral terms
00072         TooN::Vector<4> i_term;
00073         TooN::Vector<4> last_err;
00074         TooN::Vector<4> speedAverages;
00075 
00076         double lastTimeStamp;
00077         double targetSetAtClock;
00078         ControlCommand hoverCommand;
00079 
00080 
00081 
00082         // filled with info (on update)
00083         bool  ptamIsGood;
00084         double scaleAccuracy;
00085         void calcControl(TooN::Vector<4> new_err, TooN::Vector<4> d_error, double yaw);
00086 
00087 public:
00088 
00089         // generates and sends a new control command to the drone, based on the currently active command ant the drone's position.
00090         ControlCommand update(tum_ardrone::filter_stateConstPtr);
00091 
00092         ControlNode* node;
00093 
00094         // for logging, gets filled with recent infos on control.
00095         TooN::Vector<28> logInfo;
00096 
00097         // adds a waypoint
00098         void setTarget(DronePosition newTarget);
00099         void clearTarget();
00100         DronePosition getCurrentTarget();
00101         ControlCommand getLastControl();
00102 
00103         // gets last error
00104         TooN::Vector<4> getLastErr();
00105 
00106         DroneController(void);
00107         ~DroneController(void);
00108 
00109 
00110 
00111 
00112 
00113         // PID control parameters. settable via dynamic_reconfigure
00114         // target is where i want to get to.
00115         // pose and yaw are where i am.
00116         double max_yaw;
00117         double max_rp;
00118         double max_gaz_rise;
00119         double max_gaz_drop;
00120 
00121         double rise_fac;
00122         double agressiveness;
00123 
00124         double Ki_yaw;
00125         double Kd_yaw;
00126         double Kp_yaw;
00127 
00128         double Ki_gaz;
00129         double Kd_gaz;
00130         double Kp_gaz;
00131 
00132         double Ki_rp;
00133         double Kd_rp;
00134         double Kp_rp;
00135 
00136 };
00137 #endif /* __DRONECONTROLLER_H */
00138 


tum_ardrone
Author(s):
autogenerated on Sat Jun 8 2019 20:27:22