ardrone_driver.h
Go to the documentation of this file.
00001 #ifndef _ARDRONE_DRIVER_H_
00002 #define _ARDRONE_DRIVER_H_
00003 
00004 class ARDroneDriver;
00005 
00006 #include <ros/ros.h>
00007 #include <image_transport/image_transport.h>
00008 #include <tf/transform_broadcaster.h>
00009 #include <camera_info_manager/camera_info_manager.h>
00010 #include <sensor_msgs/Image.h>
00011 #include <sensor_msgs/Imu.h>
00012 #include <geometry_msgs/Vector3Stamped.h>
00013 #include <std_srvs/Empty.h>
00014 #include <ardrone_autonomy/Navdata.h>
00015 #include <ardrone_autonomy/ardrone_sdk.h>
00016 #include <vector>
00017 #include <utils/ardrone_gen_ids.h>
00018 #include <ardrone_tool/ardrone_version.h>
00019 #include <ardrone_tool/ardrone_tool.h>
00020 
00021 // Load auto-generated include files for full navdata
00022 #define NAVDATA_STRUCTS_INCLUDES
00023 #include <ardrone_autonomy/NavdataMessageDefinitions.h>
00024 #undef NAVDATA_STRUCTS_INCLUDES
00025 
00026 
00027 #define _DEG2RAD 0.01745331111
00028 #define _RAD2DEG 57.2957184819
00029 
00030 #define DRIVER_USERNAME "ardrone_driver"
00031 #define DRIVER_APPNAME "ardrone_driver"
00032 #define CAMERA_QUEUE_SIZE (10)
00033 #define NAVDATA_QUEUE_SIZE (25)
00034 
00035 enum ROOT_FRAME
00036 {
00037     ROOT_FRAME_BASE = 0,
00038     ROOT_FRAME_FRONT = 1,
00039     ROOT_FRAME_BOTTOM = 2,
00040     ROOT_FRAME_NUM
00041 };
00042 
00043 class ARDroneDriver
00044 {    
00045 public:
00046         ARDroneDriver();
00047         ~ARDroneDriver();
00048 
00049         void run();
00050     double getRosParam(char* param, double defaultVal);
00051     bool imuReCalibCallback(std_srvs::Empty::Request& request, std_srvs::Empty::Response &response);
00052 
00053     #define NAVDATA_STRUCTS_HEADER_PUBLIC
00054     #include <ardrone_autonomy/NavdataMessageDefinitions.h>
00055     #undef NAVDATA_STRUCTS_HEADER_PUBLIC
00056 
00057     void publish_video();
00058     void publish_navdata(navdata_unpacked_t &navdata_raw, const ros::Time &navdata_receive_time);
00059 
00060 private:
00061     void publish_tf();
00062     bool readCovParams(std::string param_name, boost::array<double, 9> &cov_array);
00063     double calcAverage(std::vector<double> &vec);
00064     void resetCaliberation();   
00065     void configureDrone();
00066 
00067     ros::NodeHandle node_handle;
00068         ros::Subscriber cmd_vel_sub;
00069         ros::Subscriber takeoff_sub;
00070         ros::Subscriber reset_sub;
00071         ros::Subscriber land_sub;
00072         image_transport::ImageTransport image_transport;
00073         image_transport::CameraPublisher image_pub;
00074     image_transport::CameraPublisher hori_pub;
00075         image_transport::CameraPublisher vert_pub;
00076 
00077     camera_info_manager::CameraInfoManager *cinfo_hori_;
00078     camera_info_manager::CameraInfoManager *cinfo_vert_;
00079 
00080     ros::Publisher navdata_pub;
00081     ros::Publisher imu_pub;
00082     ros::Publisher mag_pub;
00083 
00084     tf::TransformBroadcaster tf_broad;
00085 
00086         //ros::Subscriber toggleCam_sub;
00087         ros::ServiceServer toggleCam_service;
00088         ros::ServiceServer setCamChannel_service;
00089         ros::ServiceServer setLedAnimation_service;
00090     ros::ServiceServer imuReCalib_service;
00091     ros::ServiceServer flatTrim_service;
00092     ros::ServiceServer setFlightAnimation_service;
00093     ros::ServiceServer setRecord_service;
00094         
00095         /*
00096          * Orange Green : 1
00097          * Orange Yellow: 2
00098          * Orange Blue: 3
00099          */
00100         //ros::ServiceServer setEnemyColor_service; 
00101         
00102         /*
00103          * Indoor: 1
00104          * Oudoor: 0
00105          */
00106         //ros::ServiceServer setHullType_service;
00107 
00108     long int last_frame_id;
00109     long int last_navdata_id;
00110     long int copy_current_frame_id;
00111     long int copy_current_navdata_id;
00112 
00113         int flying_state;
00114 
00115     bool inited;
00116     std::string droneFrameId;
00117 
00118     // Load auto-generated declarations for full navdata
00119     #define NAVDATA_STRUCTS_HEADER_PRIVATE
00120     #include <ardrone_autonomy/NavdataMessageDefinitions.h>
00121     #undef NAVDATA_STRUCTS_HEADER_PRIVATE
00122 
00123     /*
00124      * TF Frames
00125      * Base: Should be COM
00126      */
00127     std::string droneFrameBase, droneFrameIMU, droneFrameFrontCam, droneFrameBottomCam;
00128     int drone_root_frame;
00129     tf::StampedTransform tf_base_front, tf_base_bottom;
00130 
00131     // Huge part of IMU message is constant, let's fill'em once.
00132     sensor_msgs::Imu imu_msg;
00133     geometry_msgs::Vector3Stamped mag_msg;
00134     ardrone_autonomy::Navdata legacynavdata_msg;
00135 
00136     // Manual IMU caliberation
00137     bool do_caliberation;
00138     int max_num_samples;
00139     bool caliberated;
00140     double acc_bias[3];
00141     double gyro_bias[3];
00142     double vel_bias[3];
00143     std::vector< std::vector<double> > acc_samples;
00144     std::vector< std::vector<double> > gyro_samples;
00145     std::vector< std::vector<double> > vel_samples;
00146 
00147 };
00148 
00149 #endif


ardrone_autonomy
Author(s): Mani Monajjemi, Mani Monajjemi
autogenerated on Sun Oct 5 2014 22:17:06