Skip to content

Commit 94363b8

Browse files
committed
Fixed normal estaimtion
1 parent f8c08dd commit 94363b8

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

cuboid_detection/launch/bbox_filter.launch

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
<!-- Launch ground plane segmentation -->
55
<include file="$(find cuboid_detection)/launch/ground_plane_segmentation.launch"/>
6+
<include file="$(find cuboid_detection)/launch/surface_normal_estimation.launch"/>
67

78
<!-- Detect 2D bbox -->
89
<node

cuboid_detection/src/surface_normal_estimation.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void convert_icp_eigen_to_tf(Eigen::Matrix4f Tm)
8080

8181
// Broadcast the transforms
8282
tf::TransformBroadcaster br;
83-
std::cerr<<"Publishing TF"<<std::endl;
83+
8484
br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "camera_depth_frame", "cuboid_frame"));
8585
}
8686

@@ -139,9 +139,6 @@ pcl::SacModel model, Eigen::Vector3f plane_normal, bool invert_local)
139139
pcl::PointCloud<pcl::PointXYZ>::Ptr plane_xyz_cloud_ptr(new pcl::PointCloud<pcl::PointXYZ>);
140140
pcl::fromPCLPointCloud2(*plane_cloud_ptr, *plane_xyz_cloud_ptr);
141141

142-
std::pair<pcl_msgs::ModelCoefficients, pcl::PCLPointCloud2::Ptr> plane_info;
143-
plane_info = make_pair(ros_coefficients, plane_cloud_ptr);
144-
145142
Eigen::Vector4f centroid;
146143
pcl::compute3DCentroid(*plane_xyz_cloud_ptr, centroid);
147144

@@ -185,9 +182,12 @@ void callback(const sensor_msgs::PointCloud2ConstPtr& input)
185182
{
186183
if(planes[i].num_of_points < planes[j].num_of_points)
187184
{
185+
Eigen::Vector3f temp_normals = normals[i];
188186
planeSegementationOutput temp_plane = planes[i];
189187
planes[i] = planes[j];
188+
normals[i] = normals[j];
190189
planes[j] = temp_plane;
190+
normals[j] = temp_normals;
191191
}
192192
}
193193
}
@@ -209,6 +209,8 @@ void callback(const sensor_msgs::PointCloud2ConstPtr& input)
209209

210210
convert_icp_eigen_to_tf(Rt);
211211

212+
std::cerr<<Rt<<std::endl;
213+
212214
// Convert to ROS data type
213215
sensor_msgs::PointCloud2 output;
214216
pcl_conversions::fromPCL(*cloud_ptr, output);
@@ -253,10 +255,7 @@ int main(int argc, char** argv)
253255
ros::Subscriber sub = nh.subscribe(input_topic, 1, callback);
254256
ros::Subscriber sub_coeff = nh.subscribe("/ground_plane_segmentation/coefficients", 1, coefficients_callback);
255257

256-
// Create a ROS publisher for the output segmented point cloud and coefficients
257-
pcl_pub = nh.advertise<sensor_msgs::PointCloud2>(output_topic, 1);
258-
pcl_pub_top = nh.advertise<sensor_msgs::PointCloud2>(output_topic, 1);
259-
coef_pub = nh.advertise<pcl_msgs::ModelCoefficients>(coefficients_topic, 1);
258+
// Create a ROS publisher for the normal coefficients
260259
normal_x_pub = nh.advertise<pcl_msgs::ModelCoefficients>("/surface_segmentation/normal_x_coefficients", 1);
261260
normal_y_pub = nh.advertise<pcl_msgs::ModelCoefficients>("/surface_segmentation/normal_y_coefficients", 1);
262261
normal_z_pub = nh.advertise<pcl_msgs::ModelCoefficients>("/surface_segmentation/normal_z_coefficients", 1);

0 commit comments

Comments
 (0)