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


uga_tum_ardrone
Author(s):
autogenerated on Sat Jun 8 2019 20:30:11