gazebo_noisydepth_plugin.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2018 Michael Pantic, ASL, ETH Zurich, Switzerland
00003  *
00004  * Forked from Openni/Kinect Depth Plugin, retaining original copyright header:
00005  *
00006  * Copyright (C) 2012-2014 Open Source Robotics Foundation
00007  *
00008  * Licensed under the Apache License, Version 2.0 (the "License");
00009  * you may not use this file except in compliance with the License.
00010  * You may obtain a copy of the License at
00011  *
00012  *     http://www.apache.org/licenses/LICENSE-2.0
00013  *
00014  * Unless required by applicable law or agreed to in writing, software
00015  * distributed under the License is distributed on an "AS IS" BASIS,
00016  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00017  * See the License for the specific language governing permissions and
00018  * limitations under the License.
00019  *
00020 */
00021 /*
00022  * Desc: A dynamic controller plugin that publishes ROS image_raw camera_info
00023  * topic for generic camera sensor.
00024  * Author: John Hsu
00025  * Date: 24 Sept 2008
00026  */
00027 
00028 #ifndef ROTORS_GAZEBO_PLUGINS_GAZEBO_NOISYDEPTH_PLUGIN_H
00029 #define ROTORS_GAZEBO_PLUGINS_GAZEBO_NOISYDEPTH_PLUGIN_H
00030 
00031 #include <dynamic_reconfigure/server.h>
00032 #include <boost/thread/mutex.hpp>
00033 
00034 #include <gazebo_plugins/GazeboRosOpenniKinectConfig.h>
00035 #include <gazebo_plugins/gazebo_ros_camera_utils.h>
00036 #include <gazebo/common/Time.hh>
00037 #include <gazebo/msgs/MessageTypes.hh>
00038 #include <gazebo/physics/physics.hh>
00039 #include <gazebo/plugins/DepthCameraPlugin.hh>
00040 #include <gazebo/sensors/SensorTypes.hh>
00041 #include <gazebo/transport/TransportTypes.hh>
00042 
00043 #include <image_transport/image_transport.h>
00044 #include <ros/advertise_options.h>
00045 #include <ros/callback_queue.h>
00046 #include <ros/ros.h>
00047 
00048 #include <sdf/Param.hh>
00049 
00050 #include <sensor_msgs/CameraInfo.h>
00051 #include <sensor_msgs/Image.h>
00052 #include <sensor_msgs/PointCloud2.h>
00053 #include <sensor_msgs/fill_image.h>
00054 #include <std_msgs/Float64.h>
00055 
00056 #include <rotors_gazebo_plugins/depth_noise_model.hpp>
00057 
00058 namespace gazebo {
00059 class GazeboNoisyDepth : public DepthCameraPlugin, GazeboRosCameraUtils {
00060  public:
00061   GazeboNoisyDepth();
00062 
00063   ~GazeboNoisyDepth();
00064 
00067   virtual void Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf);
00068 
00070   virtual void Advertise();
00071 
00072   virtual void OnNewDepthFrame(const float *_image, unsigned int _width,
00073                                unsigned int _height, unsigned int _depth,
00074                                const std::string &_format);
00075 
00076  protected:
00077   virtual void OnNewImageFrame(const unsigned char *_image, unsigned int _width,
00078                                unsigned int _height, unsigned int _depth,
00079                                const std::string &_format);
00080 
00081  private:
00082   void DepthImageConnect();
00083   void DepthImageDisconnect();
00084   void DepthInfoConnect();
00085   void DepthInfoDisconnect();
00086   void FillDepthImage(const float *_src);
00087   bool FillDepthImageHelper(const uint32_t rows_arg,
00088                             const uint32_t cols_arg,
00089                             const uint32_t step_arg,
00090                             const float *data_arg,
00091                             sensor_msgs::Image *image_msg);
00092 
00093   virtual void PublishCameraInfo();
00094 
00095   event::ConnectionPtr load_connection_;
00096   std::unique_ptr<DepthNoiseModel> noise_model;
00097 
00098   ros::Publisher depth_image_pub_;
00099   ros::Publisher depth_image_camera_info_pub_;
00100 
00101   int depth_image_connect_count_;
00102   int depth_info_connect_count_;
00103 
00104   std::string depth_image_topic_name_;
00105   std::string depth_image_camera_info_topic_name_;
00106 
00107   common::Time depth_sensor_update_time_;
00108   common::Time last_depth_image_camera_info_update_time_;
00109   sensor_msgs::Image depth_image_msg_;
00110 };
00111 }
00112 #endif  // ROTORS_GAZEBO_PLUGINS_GAZEBO_NOISYDEPTH_PLUGIN_H


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