gazebo_ros_openni_kinect.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 /*
18  * Desc: A dynamic controller plugin that publishes ROS image_raw camera_info topic for generic camera sensor.
19  * Author: John Hsu
20  * Date: 24 Sept 2008
21  */
22 
23 #ifndef GAZEBO_ROS_OPENNI_KINECT_HH
24 #define GAZEBO_ROS_OPENNI_KINECT_HH
25 
26 // ros stuff
27 #include <ros/ros.h>
28 #include <ros/callback_queue.h>
29 #include <ros/advertise_options.h>
30 
31 // ros messages stuff
32 #include <sensor_msgs/PointCloud2.h>
33 #include <sensor_msgs/Image.h>
34 #include <sensor_msgs/CameraInfo.h>
35 #include <sensor_msgs/fill_image.h>
36 #include <std_msgs/Float64.h>
38 
39 // gazebo stuff
40 #include <sdf/Param.hh>
41 #include <gazebo/physics/physics.hh>
42 #include <gazebo/transport/TransportTypes.hh>
43 #include <gazebo/msgs/MessageTypes.hh>
44 #include <gazebo/common/Time.hh>
45 #include <gazebo/sensors/SensorTypes.hh>
46 #include <gazebo/plugins/DepthCameraPlugin.hh>
47 
48 // dynamic reconfigure stuff
49 #include <gazebo_plugins/GazeboRosOpenniKinectConfig.h>
50 #include <dynamic_reconfigure/server.h>
51 
52 // boost stuff
53 #include <boost/thread/mutex.hpp>
54 
55 // camera stuff
57 
58 namespace gazebo
59 {
60  class GazeboRosOpenniKinect : public DepthCameraPlugin, GazeboRosCameraUtils
61  {
64  public: GazeboRosOpenniKinect();
65 
67  public: ~GazeboRosOpenniKinect();
68 
71  public: virtual void Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf);
72 
74  public: virtual void Advertise();
75 
77  protected: virtual void OnNewDepthFrame(const float *_image,
78  unsigned int _width, unsigned int _height,
79  unsigned int _depth, const std::string &_format);
80 
82  protected: virtual void OnNewImageFrame(const unsigned char *_image,
83  unsigned int _width, unsigned int _height,
84  unsigned int _depth, const std::string &_format);
85 
87  private: void FillPointdCloud(const float *_src);
88 
90  private: void FillDepthImage(const float *_src);
91 
94  private: void PointCloudConnect();
95  private: void PointCloudDisconnect();
96 
99  private: void DepthImageConnect();
100  private: void DepthImageDisconnect();
101 
102  private: bool FillPointCloudHelper(sensor_msgs::PointCloud2 &point_cloud_msg,
103  uint32_t rows_arg, uint32_t cols_arg,
104  uint32_t step_arg, void* data_arg);
105 
106  private: bool FillDepthImageHelper( sensor_msgs::Image& image_msg,
107  uint32_t height, uint32_t width,
108  uint32_t step, void* data_arg);
109 
113 
115  private: sensor_msgs::PointCloud2 point_cloud_msg_;
116  private: sensor_msgs::Image depth_image_msg_;
117 
119  private: double point_cloud_cutoff_;
121  private: double point_cloud_cutoff_max_;
122 
124  private: std::string point_cloud_topic_name_;
125 
126 
128  private: std::string depth_image_topic_name_;
129  private: common::Time depth_sensor_update_time_;
130 
131  // overload with our own
134  private: void DepthInfoConnect();
135  private: void DepthInfoDisconnect();
138 
140  protected: virtual void PublishCameraInfo();
141 
142  private: event::ConnectionPtr load_connection_;
143  };
144 
145 }
146 #endif
147 
double point_cloud_cutoff_
Minimum range of the point cloud.
int depth_image_connect_count_
Keep track of number of connctions for point clouds.
virtual void Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf)
Load the plugin.
ros::Publisher point_cloud_pub_
A pointer to the ROS node. A node will be instantiated if it does not exist.
bool FillPointCloudHelper(sensor_msgs::PointCloud2 &point_cloud_msg, uint32_t rows_arg, uint32_t cols_arg, uint32_t step_arg, void *data_arg)
virtual void Advertise()
Advertise point cloud and depth image.
bool FillDepthImageHelper(sensor_msgs::Image &image_msg, uint32_t height, uint32_t width, uint32_t step, void *data_arg)
int point_cloud_connect_count_
Keep track of number of connctions for point clouds.
virtual void OnNewImageFrame(const unsigned char *_image, unsigned int _width, unsigned int _height, unsigned int _depth, const std::string &_format)
Update the controller.
void FillPointdCloud(const float *_src)
push point cloud data into ros topic
std::string depth_image_topic_name_
image where each pixel contains the depth data
virtual void OnNewDepthFrame(const float *_image, unsigned int _width, unsigned int _height, unsigned int _depth, const std::string &_format)
Update the controller.
double point_cloud_cutoff_max_
Maximum range of the point cloud.
sensor_msgs::PointCloud2 point_cloud_msg_
PointCloud2 point cloud message.
std::string point_cloud_topic_name_
ROS image topic name.
void FillDepthImage(const float *_src)
push depth image data into ros topic


gazebo_plugins
Author(s): John Hsu
autogenerated on Tue Mar 26 2019 02:31:27