EstimationNode.h
Go to the documentation of this file.
00001 #pragma once
00002 
00022 #ifndef __ESTIMATIONNODE_H
00023 #define __ESTIMATIONNODE_H
00024 
00025 
00026 #include "ros/ros.h"
00027 #include "geometry_msgs/Twist.h"
00028 #include "sensor_msgs/Image.h"
00029 #include "tf/tfMessage.h"
00030 #include "tf/transform_listener.h"
00031 #include "tf/transform_broadcaster.h"
00032 #include "std_msgs/Empty.h"
00033 #include "std_srvs/Empty.h"
00034 #include "ardrone_autonomy/Navdata.h"
00035 #include "uga_tum_ardrone/filter_state.h"
00036 #include "std_msgs/String.h"
00037 #include <dynamic_reconfigure/server.h>
00038 #include "uga_tum_ardrone/StateestimationParamsConfig.h"
00039 #include "TooN/se3.h"
00040 
00041 
00042 class DroneKalmanFilter;
00043 class MapView;
00044 class PTAMWrapper;
00045 
00046 struct EstimationNode
00047 {
00048 private:
00049         // comm with drone
00050         ros::Subscriber navdata_sub; // drone navdata
00051         ros::Subscriber vel_sub; // to co-read contro commands sent from other thread
00052         ros::Subscriber vid_sub;
00053         ros::Time lastNavStamp;
00054 
00055 
00056         // comm with ptam
00057         //ros::Subscriber slam_info_sub; // ptam info (tracking quality) etc.
00058         //tf::TransformListener tf_sub;
00059         ros::Subscriber uga_tum_ardrone_sub;
00060         ros::Publisher uga_tum_ardrone_pub;
00061         static pthread_mutex_t uga_tum_ardrone_CS;
00062 
00063         // output
00064         ros::Publisher dronepose_pub;
00065 
00066         ros::NodeHandle nh_;
00067 
00068         tf::TransformBroadcaster tf_broadcaster;
00069 
00070         // parameters
00071         // every [publishFreq]ms, the node publishes the drones predicted position [predTime]ms into the future.
00072         // this pose can then be used to steer the drone. obviously, the larger [predTime], the worse the estimate.
00073         // this pose is published on /tf, and simultaneously further info is published on /ardrone/predictedPose
00074         ros::Duration predTime;
00075         int publishFreq;
00076 
00077         std::string navdata_channel;
00078         std::string control_channel;
00079         std::string output_channel;
00080         std::string video_channel;
00081         std::string command_channel;
00082 
00083 
00084 
00085         // for navdata time-smoothing
00086         long lastDroneTS;
00087         long lastRosTS;
00088         long droneRosTSOffset;
00089 
00090 
00091         // save last navinfo received for forwarding...
00092         ardrone_autonomy::Navdata lastNavdataReceived;
00093 
00094 public:
00095         // filter
00096         DroneKalmanFilter* filter;
00097         PTAMWrapper* ptamWrapper;
00098         MapView* mapView;
00099         std::string packagePath;
00100 
00101         EstimationNode();
00102         ~EstimationNode();
00103 
00104 
00105         // ROS message callbacks
00106         void navdataCb(const ardrone_autonomy::NavdataConstPtr navdataPtr);
00107         void velCb(const geometry_msgs::TwistConstPtr velPtr);
00108         void vidCb(const sensor_msgs::ImageConstPtr img);
00109         void comCb(const std_msgs::StringConstPtr str);
00110         void dynConfCb(uga_tum_ardrone::StateestimationParamsConfig &config, uint32_t level);
00111 
00112         // main pose-estimation loop
00113         void Loop();
00114 
00115         // writes a string message to "/uga_tum_ardrone/com".
00116         // is thread-safe (can be called by any thread, but may block till other calling thread finishes)
00117         void publishCommand(std::string c);
00118         void reSendInfo();
00119 
00120         void publishTf(TooN::SE3<>, ros::Time stamp, int seq, std::string system);
00121 
00122         // logging stuff
00123         // logging stuff
00124         std::ofstream* logfileIMU;
00125         std::ofstream* logfilePTAM;
00126         std::ofstream* logfileFilter;
00127         std::ofstream* logfilePTAMRaw;
00128         static pthread_mutex_t logIMU_CS;
00129         static pthread_mutex_t logPTAM_CS;
00130         static pthread_mutex_t logFilter_CS;
00131         static pthread_mutex_t logPTAMRaw_CS;
00132         long currentLogID;
00133         long startedLogClock;
00134 
00135         void toogleLogging();   // switches logging on or off.
00136         std::string calibFile;
00137         int arDroneVersion;
00138     float initialYaw;
00139 
00140 };
00141 #endif /* __ESTIMATIONNODE_H */


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