gazebo_ros_openni_kinect.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2012-2014 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 /*
00018  * Desc: A dynamic controller plugin that publishes ROS image_raw camera_info topic for generic camera sensor.
00019  * Author: John Hsu
00020  * Date: 24 Sept 2008
00021  */
00022 
00023 #ifndef GAZEBO_ROS_OPENNI_KINECT_HH
00024 #define GAZEBO_ROS_OPENNI_KINECT_HH
00025 
00026 // ros stuff
00027 #include <ros/ros.h>
00028 #include <ros/callback_queue.h>
00029 #include <ros/advertise_options.h>
00030 
00031 #include <pcl/point_types.h>
00032 
00033 // ros messages stuff
00034 #include <sensor_msgs/PointCloud2.h>
00035 #include <sensor_msgs/Image.h>
00036 #include <sensor_msgs/CameraInfo.h>
00037 #include <sensor_msgs/fill_image.h>
00038 #include <std_msgs/Float64.h>
00039 #include <image_transport/image_transport.h>
00040 
00041 // gazebo stuff
00042 #include <sdf/Param.hh>
00043 #include <gazebo/physics/physics.hh>
00044 #include <gazebo/transport/TransportTypes.hh>
00045 #include <gazebo/msgs/MessageTypes.hh>
00046 #include <gazebo/common/Time.hh>
00047 #include <gazebo/sensors/SensorTypes.hh>
00048 #include <gazebo/plugins/DepthCameraPlugin.hh>
00049 
00050 // dynamic reconfigure stuff
00051 #include <gazebo_plugins/GazeboRosOpenniKinectConfig.h>
00052 #include <dynamic_reconfigure/server.h>
00053 
00054 // boost stuff
00055 #include <boost/thread/mutex.hpp>
00056 
00057 // camera stuff
00058 #include <gazebo_plugins/gazebo_ros_camera_utils.h>
00059 
00060 namespace gazebo
00061 {
00062   class GazeboRosOpenniKinect : public DepthCameraPlugin, GazeboRosCameraUtils
00063   {
00066     public: GazeboRosOpenniKinect();
00067 
00069     public: ~GazeboRosOpenniKinect();
00070 
00073     public: virtual void Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf);
00074 
00076     public: virtual void Advertise();
00077 
00079     protected: virtual void OnNewDepthFrame(const float *_image, 
00080                    unsigned int _width, unsigned int _height, 
00081                    unsigned int _depth, const std::string &_format);
00082 
00084     protected: virtual void OnNewImageFrame(const unsigned char *_image, 
00085                    unsigned int _width, unsigned int _height, 
00086                    unsigned int _depth, const std::string &_format);
00087 
00089     private: void FillPointdCloud(const float *_src);
00090 
00092     private: void FillDepthImage(const float *_src);
00093 
00095     private: int point_cloud_connect_count_;
00096     private: void PointCloudConnect();
00097     private: void PointCloudDisconnect();
00098 
00100     private: int depth_image_connect_count_;
00101     private: void DepthImageConnect();
00102     private: void DepthImageDisconnect();
00103 
00104     private: bool FillPointCloudHelper(sensor_msgs::PointCloud2 &point_cloud_msg,
00105                                   uint32_t rows_arg, uint32_t cols_arg,
00106                                   uint32_t step_arg, void* data_arg);
00107 
00108     private: bool FillDepthImageHelper( sensor_msgs::Image& image_msg,
00109                                   uint32_t height, uint32_t width,
00110                                   uint32_t step, void* data_arg);
00111 
00113     private: ros::Publisher point_cloud_pub_;
00114     private: ros::Publisher depth_image_pub_;
00115 
00117     private: sensor_msgs::PointCloud2 point_cloud_msg_;
00118     private: sensor_msgs::Image depth_image_msg_;
00119 
00120     private: double point_cloud_cutoff_;
00121 
00123     private: std::string point_cloud_topic_name_;
00124 
00125 
00127     private: std::string depth_image_topic_name_;
00128     private: common::Time depth_sensor_update_time_;
00129 
00130     // overload with our own
00131     private: std::string depth_image_camera_info_topic_name_;
00132     private: int depth_info_connect_count_;
00133     private: void DepthInfoConnect();
00134     private: void DepthInfoDisconnect();
00135     private: common::Time last_depth_image_camera_info_update_time_;
00136     protected: ros::Publisher depth_image_camera_info_pub_;
00137 
00138     using GazeboRosCameraUtils::PublishCameraInfo;
00139     protected: virtual void PublishCameraInfo();
00140 
00141     private: event::ConnectionPtr load_connection_;
00142   };
00143 
00144 }
00145 #endif
00146 


gazebo_plugins
Author(s): John Hsu
autogenerated on Fri Aug 28 2015 10:47:25