@@ -9,37 +9,29 @@ DepthImageProjectorNode::DepthImageProjectorNode(const ros::NodeHandle& nh, cons
99 : nh_(nh_private), it_(nh)
1010{
1111 mapPublisher_ = nh_.advertise <nav_msgs::OccupancyGrid>(" map" , 1 );
12-
13- // TODO synchronize two image topics
14- colorSubscriber_ = it_.subscribeCamera (" color_in" , 1 , &DepthImageProjectorNode::colorCallback, this );
1512 depthSubscriber_ = it_.subscribeCamera (" depth_in" , 1 , &DepthImageProjectorNode::depthCallback, this );
1613
17- // frame ids for tf which associates color frame with depth frame
18- nh_.param <std::string>(" color_frame_id" , color_frame_id_, " d435_color_optical" );
1914 nh_.param <std::string>(" depth_frame_id" , depth_frame_id_, " d435_depth_optical" );
20- nh_.param <std::string>(" map_frame_id" , map_frame_id_, " d435_depth_link " );
15+ nh_.param <std::string>(" map_frame_id" , map_frame_id_, " base_link_hor " );
2116 nh_.param <double >(" tf_wait_duration" , tf_wait_duration_, 0.1 );
2217
23- int colorWidth, colorHeight;
24- nh_.param <int >(" colorWidth" , colorWidth , 640 );
25- nh_.param <int >(" colorHeight" , colorHeight, 360 );
2618 int depthWidth, depthHeight;
27- nh_.param <int >(" depthWidth " , depthWidth , 640 );
28- nh_.param <int >(" depthHeight " , depthHeight, 360 );
19+ nh_.param <int >(" depth_width " , depthWidth , 640 );
20+ nh_.param <int >(" depth_height " , depthHeight, 360 );
2921
3022 double gridMapLayerHeight, gridMapAccumulationWeight;
31- nh_.param <int >(" gridMapWidth " , gridMapWidth_ , 1000 );
32- nh_.param <int >(" gridMapHeight " , gridMapHeight_, 1000 );
33- nh_.param <double >(" gridMapResolution " , gridMapResolution_, 0.01 );
34- nh_.param <double >(" gridMapLayerHeight " , gridMapLayerHeight, 1 );
35- nh_.param <double >(" gridMapAccumulationWeight " , gridMapAccumulationWeight, 1 );
23+ nh_.param <int >(" grid_map_width " , gridMapWidth_ , 1000 );
24+ nh_.param <int >(" grid_map_height " , gridMapHeight_, 1000 );
25+ nh_.param <double >(" grid_map_resolution " , gridMapResolution_, 0.01 );
26+ nh_.param <double >(" grid_map_layer_height " , gridMapLayerHeight, 1 );
27+ nh_.param <double >(" grid_map_accumulation_weight " , gridMapAccumulationWeight, 1 );
3628
3729 double minDepth, maxDepth, depthHitThreshold;
3830 int unknownDepthColor;
39- nh_.param <double >(" minDepth " , minDepth, 0.105 );
40- nh_.param <double >(" maxDepth " , maxDepth, 10 );
41- nh_.param <double >(" depthHitThreshold " , depthHitThreshold, 0.95 );
42- nh_.param <int >(" unknownDepthColor " , unknownDepthColor, 255 );
31+ nh_.param <double >(" min_depth " , minDepth, 0.105 );
32+ nh_.param <double >(" max_depth " , maxDepth, 10 );
33+ nh_.param <double >(" depth_hit_threshold " , depthHitThreshold, 0.95 );
34+ nh_.param <int >(" unknown_depth_color " , unknownDepthColor, 255 );
4335
4436 std::string vertexShader, geometryShader, fragmentShader, vertexShaderScaling, fragmentShaderScaling;
4537 nh_.param <std::string>(" vertex_shader" , vertexShader , " " );
@@ -49,7 +41,6 @@ DepthImageProjectorNode::DepthImageProjectorNode(const ros::NodeHandle& nh, cons
4941 nh_.param <std::string>(" fragment_shader_scaling" , fragmentShaderScaling, " " );
5042
5143 projector_ = std::make_unique<cgs::DepthImageProjector>(
52- colorWidth, colorHeight,
5344 depthWidth, depthHeight,
5445 gridMapWidth_, gridMapHeight_, gridMapResolution_,
5546 gridMapLayerHeight, gridMapAccumulationWeight,
@@ -58,36 +49,9 @@ DepthImageProjectorNode::DepthImageProjectorNode(const ros::NodeHandle& nh, cons
5849 vertexShaderScaling, fragmentShaderScaling
5950 );
6051
61- float threshold_l, svm_coef_a, svm_coef_b, svm_intercept;
62- nh_.param <float >(" threshold_l" , threshold_l , 0 );
63- nh_.param <float >(" svm_coef_a" , svm_coef_a , 0 );
64- nh_.param <float >(" svm_coef_b" , svm_coef_b , 0 );
65- nh_.param <float >(" svm_intercept" , svm_intercept, 0 );
66-
67- // TODO Remove entire color image process as color image is not used anymore
68- // projector_->uniform("threshold_l" , threshold_l);
69- // projector_->uniform("svm_coef_a" , svm_coef_a);
70- // projector_->uniform("svm_coef_b" , svm_coef_b);
71- // projector_->uniform("svm_intercept", svm_intercept);
72-
7352 output_.create (gridMapHeight_, gridMapWidth_, CV_8UC1);
7453}
7554
76- void DepthImageProjectorNode::colorCallback (const sensor_msgs::Image::ConstPtr& imageMsg, const sensor_msgs::CameraInfoConstPtr & cameraInfoMsg)
77- {
78- try
79- {
80- latestColorImagePtr = cv_bridge::toCvShare (imageMsg, sensor_msgs::image_encodings::TYPE_8UC3);
81- }
82- catch (cv_bridge::Exception& e)
83- {
84- ROS_ERROR_STREAM (" cv_bridge exception: " << e.what ());
85- return ;
86- }
87-
88- latestColorCameraInfo = *(cameraInfoMsg.get ());
89- }
90-
9155void DepthImageProjectorNode::depthCallback (const sensor_msgs::Image::ConstPtr& imageMsg, const sensor_msgs::CameraInfoConstPtr & cameraInfoMsg)
9256{
9357 cv_bridge::CvImageConstPtr cv_ptr;
@@ -100,21 +64,6 @@ void DepthImageProjectorNode::depthCallback(const sensor_msgs::Image::ConstPtr&
10064 ROS_ERROR_STREAM (" cv_bridge exception: " << e.what ());
10165 return ;
10266 }
103-
104- if (!latestColorImagePtr)
105- {
106- ROS_WARN_STREAM (" color stream not ready" );
107- return ;
108- }
109-
110- // TODO Remove entire color image process as color image is not used anymore
111- // // Update & check whether depthToColor is valid.
112- // bool is_conversion_valid = updateDepthToColor();
113- // if (!is_conversion_valid)
114- // {
115- // ROS_WARN_STREAM("extrinsics parameter not arrivied yet");
116- // return;
117- // }
11867
11968 std::array<float , 16 > depthToMap;
12069 try
@@ -136,18 +85,13 @@ void DepthImageProjectorNode::depthCallback(const sensor_msgs::Image::ConstPtr&
13685
13786 // Update projector parameters with camera info
13887 projector_->updateProjectionMatrix (
139- {static_cast <float >(latestColorCameraInfo.K [0 ]), static_cast <float >(latestColorCameraInfo.K [4 ])},
140- {static_cast <float >(latestColorCameraInfo.K [2 ]), static_cast <float >(latestColorCameraInfo.K [5 ])},
14188 {static_cast <float >(cameraInfoMsg->K [0 ]) , static_cast <float >(cameraInfoMsg->K [4 ])},
14289 {static_cast <float >(cameraInfoMsg->K [2 ]) , static_cast <float >(cameraInfoMsg->K [5 ])},
143- latestDepthToColor_,
14490 depthToMap
14591 );
14692
14793 // Perform projection
148- const auto & color = latestColorImagePtr->image ;
149- const auto & depth = cv_ptr->image ;
150- projector_->project (output_, color, depth);
94+ projector_->project (output_, cv_ptr->image );
15195
15296 // Publish
15397 nav_msgs::MapMetaData mapInfo;
@@ -187,34 +131,6 @@ void DepthImageProjectorNode::getTransformMatrixArray(const tf::Transform& trans
187131 }; // column major order
188132}
189133
190- bool DepthImageProjectorNode::updateDepthToColor ()
191- {
192- // Calculation is performed only once since depthToColor does not change.
193- if (depthToColorArrived_)
194- {
195- return true ;
196- }
197-
198- try
199- {
200- if (tfListener_.waitForTransform (color_frame_id_, depth_frame_id_, ros::Time (0 ), ros::Duration (tf_wait_duration_)))
201- {
202- tf::StampedTransform transform;
203- tfListener_.lookupTransform (color_frame_id_, depth_frame_id_, ros::Time (0 ), transform);
204-
205- getTransformMatrixArray (transform, latestDepthToColor_);
206-
207- depthToColorArrived_ = true ;
208- }
209- }
210- catch (tf::TransformException& ex)
211- {
212- ROS_WARN (" Transform Exception in updateDepthToColor(). %s" , ex.what ());
213- }
214-
215- return depthToColorArrived_;
216- }
217-
218134void DepthImageProjectorNode::run ()
219135{
220136 ros::spin ();
0 commit comments