Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef GAZEBO_ROS_DEPTH_CAMERA_HH
00024 #define GAZEBO_ROS_DEPTH_CAMERA_HH
00025
00026
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
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
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
00051 #include <gazebo_plugins/GazeboRosCameraConfig.h>
00052 #include <dynamic_reconfigure/server.h>
00053
00054
00055 #include <boost/thread/mutex.hpp>
00056
00057
00058 #include <gazebo_plugins/gazebo_ros_camera_utils.h>
00059
00060 namespace gazebo
00061 {
00062 class GazeboRosDepthCamera : public DepthCameraPlugin, GazeboRosCameraUtils
00063 {
00066 public: GazeboRosDepthCamera();
00067
00069 public: ~GazeboRosDepthCamera();
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 OnNewRGBPointCloud(const float *_pcd,
00085 unsigned int _width, unsigned int _height,
00086 unsigned int _depth, const std::string &_format);
00087
00089 protected: virtual void OnNewImageFrame(const unsigned char *_image,
00090 unsigned int _width, unsigned int _height,
00091 unsigned int _depth, const std::string &_format);
00092
00094 private: void FillPointdCloud(const float *_src);
00095
00097 private: void FillDepthImage(const float *_src);
00098
00100 private: int point_cloud_connect_count_;
00101 private: void PointCloudConnect();
00102 private: void PointCloudDisconnect();
00103
00105 private: int depth_image_connect_count_;
00106 private: void DepthImageConnect();
00107 private: void DepthImageDisconnect();
00108 private: common::Time last_depth_image_camera_info_update_time_;
00109
00110 private: bool FillPointCloudHelper(sensor_msgs::PointCloud2 &point_cloud_msg,
00111 uint32_t rows_arg, uint32_t cols_arg,
00112 uint32_t step_arg, void* data_arg);
00113
00114 private: bool FillDepthImageHelper( sensor_msgs::Image& image_msg,
00115 uint32_t rows_arg, uint32_t cols_arg,
00116 uint32_t step_arg, void* data_arg);
00117
00119 private: ros::Publisher point_cloud_pub_;
00120 private: ros::Publisher depth_image_pub_;
00121
00123 private: sensor_msgs::PointCloud2 point_cloud_msg_;
00124 private: sensor_msgs::Image depth_image_msg_;
00125
00126 private: double point_cloud_cutoff_;
00127
00129 private: std::string point_cloud_topic_name_;
00130
00131 private: void InfoConnect();
00132 private: void InfoDisconnect();
00133
00134 using GazeboRosCameraUtils::PublishCameraInfo;
00135 protected: virtual void PublishCameraInfo();
00136
00138 private: std::string depth_image_topic_name_;
00139 private: std::string depth_image_camera_info_topic_name_;
00140 private: int depth_info_connect_count_;
00141 private: void DepthInfoConnect();
00142 private: void DepthInfoDisconnect();
00143
00144
00145 private: common::Time depth_sensor_update_time_;
00146 protected: ros::Publisher depth_image_camera_info_pub_;
00147
00148 private: event::ConnectionPtr load_connection_;
00149 };
00150
00151 }
00152 #endif
00153