gazebo_optical_flow_plugin.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef _GAZEBO_OPTICAL_FLOW_PLUGIN_HH_
18 #define _GAZEBO_OPTICAL_FLOW_PLUGIN_HH_
19 
20 #include <string>
21 
22 #include "gazebo/common/Plugin.hh"
23 #include "gazebo/sensors/CameraSensor.hh"
24 #include "gazebo/gazebo.hh"
25 #include "gazebo/common/common.hh"
26 #include "gazebo/rendering/Camera.hh"
27 #include "gazebo/util/system.hh"
28 #include "gazebo/transport/transport.hh"
29 #include "gazebo/msgs/msgs.hh"
30 
31 #include "OpticalFlow.pb.h"
32 
33 #include <opencv2/opencv.hpp>
34 #include <iostream>
35 #include <boost/timer/timer.hpp>
36 
37 #include "flow_opencv.hpp"
38 #include "flow_px4.hpp"
39 
40 using namespace cv;
41 using namespace std;
42 
43 namespace gazebo
44 {
45  class GAZEBO_VISIBLE OpticalFlowPlugin : public SensorPlugin
46  {
47  public:
49  virtual ~OpticalFlowPlugin();
50  virtual void Load(sensors::SensorPtr _sensor, sdf::ElementPtr _sdf);
51  virtual void OnNewFrame(const unsigned char *_image,
52  unsigned int _width, unsigned int _height,
53  unsigned int _depth, const std::string &_format);
54 
55  protected:
56  unsigned int width, height, depth;
57  std::string format;
58  sensors::CameraSensorPtr parentSensor;
59  rendering::CameraPtr camera;
60 
61  private:
62  event::ConnectionPtr newFrameConnection;
63  Mat old_gray;
65  transport::PublisherPtr opticalFlow_pub_;
66  transport::NodePtr node_handle_;
67  opticalFlow_msgs::msgs::opticalFlow opticalFlow_message;
68  std::string namespace_;
69  boost::timer::cpu_timer timer_;
70  OpticalFlowOpenCV *_optical_flow;
71  // OpticalFlowPX4 *_optical_flow;
72 
73  float hfov;
74  float rate;
75  int dt_us;
76  float focal_length;
78  double frame_time;
80  uint32_t frame_time_us;
81  };
82 }
83 #endif
sensors::CameraSensorPtr parentSensor
event::ConnectionPtr newFrameConnection
transport::PublisherPtr opticalFlow_pub_
opticalFlow_msgs::msgs::opticalFlow opticalFlow_message


rotors_gazebo_plugins
Author(s): Fadri Furrer, Michael Burri, Mina Kamel, Janosch Nikolic, Markus Achtelik
autogenerated on Mon Feb 28 2022 23:39:04