Skip to content

Commit 012dba2

Browse files
Pepijn-HundepoolMatthijsBurgh
authored andcommitted
horiontal plane attempt
1 parent 5b80acc commit 012dba2

File tree

2 files changed

+34
-16
lines changed

2 files changed

+34
-16
lines changed

ed_sensor_integration/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ cmake_minimum_required(VERSION 3.0.2)
22
project(ed_sensor_integration)
33

44
find_package(catkin REQUIRED COMPONENTS
5+
# cv_bridge
6+
# dynamic_reconfigure
7+
# geometry_msgs
8+
# actionlib_msgs
9+
# image_transport
10+
11+
# rospy
12+
# roscpp
13+
# std_msgs
514
ed
615
ed_sensor_integration_msgs
716
geolib2

ed_sensor_integration/src/kinect/code_v1.cpp

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
#include <iostream>
22
#include <pcl/ModelCoefficients.h>
33
#include <pcl/io/pcd_io.h>
4+
45
#include <pcl/point_types.h>
6+
#include <pcl/point_cloud.h>
7+
#include <pcl/point_representation.h>
8+
59
#include <pcl/sample_consensus/method_types.h>
610
#include <pcl/sample_consensus/model_types.h>
11+
#include <pcl/sample_consensus/sac_model_parallel_plane.h>
12+
713
#include <pcl/segmentation/sac_segmentation.h>
14+
815
#include <pcl/filters/voxel_grid.h>
916
#include <pcl/filters/extract_indices.h>
17+
1018
#include <ed/io/json_reader.h>
1119

12-
Eigen::Matrix4f ReadJson(std::string 2022-04-05-13-28-28, float *xout, float *yout, float *zout) {
20+
Eigen::Matrix4f ReadJson(std::string pcd_filename, float *xout, float *yout, float *zout) {
1321

14-
std::string json_filename = boost::filesystem::change_extension(2022-04-05-13-28-28, ".json").string();
22+
std::string json_filename = boost::filesystem::change_extension(pcd_filename, ".json").string();
1523
// read json metadata
1624
tue::config::DataPointer meta_data;
1725

@@ -62,24 +70,22 @@ Eigen::Matrix4f ReadJson(std::string 2022-04-05-13-28-28, float *xout, float *yo
6270
{n*qx*qz - n*qy*qw, n*qy*qz + n*qx*qw, 1.0f - n*qx*qx - n*qy*qy, z},
6371
{0.0f, 0.0f, 0.0f, 1.0f}}; */
6472

65-
Transform(0,0) = xx; //1.0f - n*qy*qy - n*qz*qz;
66-
Transform(0,1) = xy; //n*qx*qy - n*qz*qw;
67-
Transform(0,2) = xz; //n*qx*qz + n*qy*qw;
73+
Transform(0,0) = xx;//1.0f - n*qy*qy - n*qz*qz;
74+
Transform(0,1) = xy;//n*qx*qy - n*qz*qw;
75+
Transform(0,2) = xz;//n*qx*qz + n*qy*qw;
6876
Transform(0,3) = x;
69-
Transform(1,0) = yx; //n*qx*qy + n*qz*qw;
70-
Transform(1,1) = yy; //1.0f - n*qx*qx - n*qz*qz;
71-
Transform(1,2) = yz; //n*qy*qz - n*qx*qw;
77+
Transform(1,0) = yx;//n*qx*qy + n*qz*qw;
78+
Transform(1,1) = yy;//1.0f - n*qx*qx - n*qz*qz;
79+
Transform(1,2) = yz;//n*qy*qz - n*qx*qw;
7280
Transform(1,3) = y;
73-
Transform(2,0) = zx; //n*qx*qz - n*qy*qw;
74-
Transform(2,1) = zy; //n*qy*qz + n*qx*qw;
75-
Transform(2,2) = zz; //1.0f - n*qx*qx - n*qy*qy;
81+
Transform(2,0) = zx;//n*qx*qz - n*qy*qw;
82+
Transform(2,1) = zy;//n*qy*qz + n*qx*qw;
83+
Transform(2,2) = zz;//1.0f - n*qx*qx - n*qy*qy;
7684
Transform(2,3) = z;
7785

7886
std::cout << Transform << std::endl;
7987
return Transform;
8088
}
81-
}
82-
8389

8490
int
8591
main ()
@@ -112,13 +118,16 @@ main ()
112118
pcl::PointIndices::Ptr inliers (new pcl::PointIndices ());
113119
// Create the segmentation object
114120
pcl::SACSegmentation<pcl::PointXYZ> seg;
121+
pcl::SampleConsensusModelParallelPlane<pcl::PointXYZ> model (cloud_filtered);
115122
// Optional
116123
seg.setOptimizeCoefficients (true);
117124
// Mandatory
118-
seg.setModelType (pcl::SACMODEL_PLANE);
125+
seg.setModelType (pcl::SACMODEL_PARALLEL_PLANE);
119126
seg.setMethodType (pcl::SAC_RANSAC);
120127
seg.setMaxIterations (1000);
121128
seg.setDistanceThreshold (0.01);
129+
model.setAxis(Eigen::Vector3f(1,0,0));
130+
model.setEpsAngle(30*0.0174532925); //*0.0174532925 to radians
122131

123132
// Create the filtering object
124133
pcl::ExtractIndices<pcl::PointXYZ> extract;
@@ -130,6 +139,7 @@ main ()
130139
// Segment the largest planar component from the remaining cloud
131140
seg.setInputCloud (cloud_filtered);
132141
seg.segment (*inliers, *coefficients);
142+
133143
if (inliers->indices.size () == 0)
134144
{
135145
std::cerr << "Could not estimate a planar model for the given dataset." << std::endl;
@@ -155,5 +165,4 @@ main ()
155165
}
156166

157167
return (0);
158-
159-
168+
}

0 commit comments

Comments
 (0)