gazebo_optical_flow_plugin.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2012-2015 Open Source Robotics Foundation
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  *
00016 */
00017 #ifndef _GAZEBO_OPTICAL_FLOW_PLUGIN_HH_
00018 #define _GAZEBO_OPTICAL_FLOW_PLUGIN_HH_
00019 
00020 #include <string>
00021 
00022 #include "gazebo/common/Plugin.hh"
00023 #include "gazebo/sensors/CameraSensor.hh"
00024 #include "gazebo/gazebo.hh"
00025 #include "gazebo/common/common.hh"
00026 #include "gazebo/rendering/Camera.hh"
00027 #include "gazebo/util/system.hh"
00028 #include "gazebo/transport/transport.hh"
00029 #include "gazebo/msgs/msgs.hh"
00030 
00031 #include "OpticalFlow.pb.h"
00032 
00033 #include <opencv2/opencv.hpp>
00034 #include <iostream>
00035 #include <boost/timer/timer.hpp>
00036 
00037 #include "flow_opencv.hpp"
00038 #include "flow_px4.hpp"
00039 
00040 using namespace cv;
00041 using namespace std;
00042 
00043 namespace gazebo
00044 {
00045   class GAZEBO_VISIBLE OpticalFlowPlugin : public SensorPlugin
00046   {
00047     public:
00048       OpticalFlowPlugin();
00049       virtual ~OpticalFlowPlugin();
00050       virtual void Load(sensors::SensorPtr _sensor, sdf::ElementPtr _sdf);
00051       virtual void OnNewFrame(const unsigned char *_image,
00052                               unsigned int _width, unsigned int _height,
00053                               unsigned int _depth, const std::string &_format);
00054 
00055     protected:
00056       unsigned int width, height, depth;
00057       std::string format;
00058       sensors::CameraSensorPtr parentSensor;
00059       rendering::CameraPtr camera;
00060 
00061     private:
00062       event::ConnectionPtr newFrameConnection;
00063       Mat old_gray;
00064       Mat frame_gray;
00065       transport::PublisherPtr opticalFlow_pub_;
00066       transport::NodePtr node_handle_;
00067       opticalFlow_msgs::msgs::opticalFlow opticalFlow_message;
00068       std::string namespace_;
00069       boost::timer::cpu_timer timer_;
00070       OpticalFlowOpenCV *_optical_flow;
00071       // OpticalFlowPX4 *_optical_flow;
00072 
00073       float hfov;
00074       float rate;
00075       int dt_us;
00076       float focal_length;
00077       double first_frame_time;
00078       double frame_time;
00079       double old_frame_time;
00080       uint32_t frame_time_us;
00081   };
00082 }
00083 #endif


rotors_gazebo_plugins
Author(s): Fadri Furrer, Michael Burri, Mina Kamel, Janosch Nikolic, Markus Achtelik
autogenerated on Thu Apr 18 2019 02:43:43