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
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "../include/DTL_ROS.h"
00038
00039 using namespace iav_depthimage_to_laserscan;
00040
00041 DTL_ROS::DTL_ROS(ros::NodeHandle& n, CParam& Param_1, CParam& Param_2, LSParam& laser_param): it_(n){
00042 boost::mutex::scoped_lock lock(connect_mutex_);
00043
00044
00045 Param1 = Param_1;
00046 Param2 = Param_2;
00047 lsparam = laser_param;
00048 sensor_msgs::LaserScanPtr scan_msg(new sensor_msgs::LaserScan());
00049 scan_msg_united = scan_msg;
00050
00051
00052 uint32_t ranges_size = lsparam.laser_rays - 1;
00053 scan_msg_united->ranges.assign(ranges_size, std::numeric_limits<float>::quiet_NaN());
00054
00055 scan_msg_united->angle_min = lsparam.laser_min_angle;
00056 scan_msg_united->angle_max = lsparam.laser_max_angle;
00057 scan_msg_united->angle_increment = (scan_msg_united->angle_max - scan_msg_united->angle_min) / (scan_msg_united->ranges.size() - 1);;
00058 scan_msg_united->time_increment = 0.0;
00059 scan_msg_united->scan_time = 0;
00060 scan_msg_united->range_min = lsparam.laser_min_range;
00061 scan_msg_united->range_max = lsparam.laser_max_range;
00062
00063 pub_ = n.advertise<sensor_msgs::LaserScan>("Laser_Scan", 10);
00064
00065 image_transport::TransportHints hints("raw", ros::TransportHints(), n);
00066 sub_ = it_.subscribeCamera("image", 10, &DTL_ROS::image_callback, this, hints);
00067 sub_2 = it_.subscribeCamera("image2", 10, &DTL_ROS::image_callback_2, this, hints);
00068
00069 }
00070
00071 DTL_ROS::~DTL_ROS() {
00072 sub_.shutdown();
00073 sub_2.shutdown();
00074 }
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 void DTL_ROS::image_callback(const sensor_msgs::ImageConstPtr& depth_msg, const sensor_msgs::CameraInfoConstPtr& info_msg) {
00086
00087 sensor_msgs::LaserScanPtr scan_msg = itl.convert_msg(depth_msg, Param1, lsparam);
00088
00089 scan_msg_united->header = depth_msg->header;
00090 scan_msg_united->header.frame_id = lsparam.laser_output_frame_id;
00091
00092 int index;
00093
00094
00095 for(int i=0; i < Param1.cam_image_width; i++) {
00096 index = Param1.cam_index[i];
00097 scan_msg_united->ranges[index] = scan_msg->ranges[index];
00098 }
00099
00100
00101 ros::Time time = ros::Time::now();
00102 Param1.m_tf->header.stamp = time;
00103 m_TB.sendTransform(*Param1.m_tf);
00104
00105
00106 pub_.publish(scan_msg_united);
00107 }
00108
00109 void DTL_ROS::image_callback_2(const sensor_msgs::ImageConstPtr& depth_msg2, const sensor_msgs::CameraInfoConstPtr& info_msg2) {
00110
00111 sensor_msgs::LaserScanPtr scan_msg_2 = itl.convert_msg(depth_msg2, Param2, lsparam);
00112
00113 int index;
00114
00115
00116 for(int i=0; i < Param2.cam_image_width; i++) {
00117 index = Param2.cam_index[i];
00118 scan_msg_united->ranges[index] = scan_msg_2->ranges[index];
00119 }
00120
00121
00122 ros::Time time = ros::Time::now();
00123 Param2.m_tf->header.stamp = time;
00124 m_TB.sendTransform(*Param2.m_tf);
00125
00126 }