Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
laser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
wolf_projects
wolf_lib
plugins
laser
Commits
19362bd8
Commit
19362bd8
authored
2 years ago
by
Joan Solà Ortega
Browse files
Options
Downloads
Patches
Plain Diff
Remove typedefs and using aliases for PointCloud
parent
d2daa45c
No related branches found
No related tags found
1 merge request
!41
Draft: Resolve "New branch laser 3d"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/laser/sensor/sensor_laser_3d.h
+1
-1
1 addition, 1 deletion
include/laser/sensor/sensor_laser_3d.h
include/laser/utils/laser3d_tools.h
+10
-10
10 additions, 10 deletions
include/laser/utils/laser3d_tools.h
test/gtest_laser3d_tools.cpp
+55
-45
55 additions, 45 deletions
test/gtest_laser3d_tools.cpp
with
66 additions
and
56 deletions
include/laser/sensor/sensor_laser_3d.h
+
1
−
1
View file @
19362bd8
...
@@ -50,10 +50,10 @@ class SensorLaser3d : public SensorBase
...
@@ -50,10 +50,10 @@ class SensorLaser3d : public SensorBase
SensorLaser3d
(
StateBlockPtr
_p_ptr
,
StateBlockPtr
_o_ptr
);
SensorLaser3d
(
StateBlockPtr
_p_ptr
,
StateBlockPtr
_o_ptr
);
SensorLaser3d
(
const
Eigen
::
VectorXd
&
_extrinsics
,
const
std
::
shared_ptr
<
ParamsSensorLaser3d
>
_params
);
SensorLaser3d
(
const
Eigen
::
VectorXd
&
_extrinsics
,
const
std
::
shared_ptr
<
ParamsSensorLaser3d
>
_params
);
~
SensorLaser3d
();
~
SensorLaser3d
();
WOLF_SENSOR_CREATE
(
SensorLaser3d
,
ParamsSensorLaser3d
,
7
);
ParamsSensorLaser3dPtr
params_laser3d_
;
ParamsSensorLaser3dPtr
params_laser3d_
;
};
};
WOLF_SENSOR_CREATE
(
SensorLaser3d
,
ParamsSensorLaser3d
,
7
);
}
// namespace laser
}
// namespace laser
}
// namespace wolf
}
// namespace wolf
...
...
This diff is collapsed.
Click to expand it.
include/laser/utils/laser3d_tools.h
+
10
−
10
View file @
19362bd8
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
//
//
//--------LICENSE_END--------
//--------LICENSE_END--------
#include
<pcl/point_types.h>
#include
<pcl/point_types.h>
#include
<pcl/point_cloud.h>
#include
<pcl/point_cloud.h>
#include
<pcl/common/transforms.h>
#include
<pcl/common/transforms.h>
...
@@ -32,27 +31,28 @@
...
@@ -32,27 +31,28 @@
#include
<pcl/registration/icp_nl.h>
#include
<pcl/registration/icp_nl.h>
#include
<pcl/registration/transforms.h>
#include
<pcl/registration/transforms.h>
using
PointCloud
=
pcl
::
PointCloud
<
pcl
::
PointXYZ
>
;
//
using PointCloud = pcl::PointCloud<pcl::PointXYZ>;
typedef
boost
::
shared_ptr
<
PointCloud
>
PointCloudBoostPtr
;
//
typedef boost::shared_ptr<PointCloud> PointCloudBoostPtr;
typedef
boost
::
shared_ptr
<
const
PointCloud
>
PointCloudBoostConstPtr
;
//
typedef boost::shared_ptr<const PointCloud> PointCloudBoostConstPtr;
namespace
wolf
namespace
wolf
{
{
namespace
laser
namespace
laser
{
{
// _cloud_ref: first PointCloud
// _cloud_ref: first PointCloud
// _cloud_other
ref: first
PointCloud
// _cloud_other
: second
PointCloud
inline
void
pairAlign
(
const
PointCloud
BoostConstPtr
_cloud_ref
,
inline
void
pairAlign
(
const
pcl
::
PointCloud
<
pcl
::
PointXYZ
>::
Ptr
_cloud_ref
,
const
PointCloud
BoostConstPtr
_cloud_other
,
const
pcl
::
PointCloud
<
pcl
::
PointXYZ
>::
Ptr
_cloud_other
,
const
Eigen
::
Isometry3d
&
_transform_guess
,
const
Eigen
::
Isometry3d
&
_transform_guess
,
Eigen
::
Isometry3d
&
_transform_final
,
Eigen
::
Isometry3d
&
_transform_final
,
pcl
::
IterativeClosestPointNonLinear
<
pcl
::
PointXYZ
,
pcl
::
PointXYZ
>
&
_registration_solver
,
pcl
::
IterativeClosestPointNonLinear
<
pcl
::
PointXYZ
,
pcl
::
PointXYZ
>
&
_registration_solver
,
bool
_downsample
=
false
)
bool
_downsample
=
false
)
{
{
// Internal PointCloud pointers (boost::shared_ptr)
// Internal PointCloud pointers (boost::shared_ptr)
PointCloudBoostPtr
cloud_ref
=
boost
::
make_shared
<
PointCloud
>
();
// std::make_shared<PoinCloud> cloud_ref;
pcl
::
PointCloud
<
pcl
::
PointXYZ
>::
Ptr
cloud_ref
=
PointCloudBoostPtr
cloud_other
=
pcl
::
make_shared
<
pcl
::
PointCloud
<
pcl
::
PointXYZ
>>
();
boost
::
make_shared
<
PointCloud
>
();
// std::make_shared<PoinCloud> cloud_other(new PointCloud);
pcl
::
PointCloud
<
pcl
::
PointXYZ
>::
Ptr
cloud_other
=
pcl
::
make_shared
<
pcl
::
PointCloud
<
pcl
::
PointXYZ
>>
();
// Downsample for consistency and speed
// Downsample for consistency and speed
// \note enable this for large datasets
// \note enable this for large datasets
...
...
This diff is collapsed.
Click to expand it.
test/gtest_laser3d_tools.cpp
+
55
−
45
View file @
19362bd8
...
@@ -26,34 +26,32 @@
...
@@ -26,34 +26,32 @@
// //Wolf
// //Wolf
#include
"core/common/wolf.h"
#include
"core/common/wolf.h"
// #include "core/math/rotations.h"
#include
"core/utils/utils_gtest.h"
#include
"core/utils/utils_gtest.h"
#include
<core/math/rotations.h>
// pcl
#include
<pcl/registration/gicp.h>
#include
<pcl/registration/gicp6d.h>
// Eigen
// Eigen
#include
<Eigen/Geometry>
#include
<Eigen/Geometry>
//
//
std
// std
#include
<iostream>
#include
<iostream>
#include
<string>
#include
<string>
#include
<filesystem>
#include
<filesystem>
#include
<unistd.h>
#include
<unistd.h>
// #include <iostream>
// #include <fstream>
// #include <iomanip>
//#define write_results
//#define write_results
////// vsainz: i have to write a test
////// vsainz: i have to write a test
// using namespace wolf
using
namespace
wolf
;
using
namespace
Eigen
;
// using namespace Eigenç
std
::
string
laser_root_dir
=
_WOLF_LASER_ROOT_DIR
;
std
::
string
laser_root_dir
=
_WOLF_LASER_ROOT_DIR
;
void
loadData
(
std
::
string
fname
,
pcl
::
PointCloud
<
pcl
::
PointXYZ
>&
cloud
)
void
loadData
(
std
::
string
fname
,
PointCloud
&
cloud
)
{
{
pcl
::
io
::
loadPCDFile
(
fname
,
cloud
);
pcl
::
io
::
loadPCDFile
(
fname
,
cloud
);
// remove NAN points from the cloud
// remove NAN points from the cloud
...
@@ -61,24 +59,21 @@ void loadData(std::string fname, PointCloud& cloud)
...
@@ -61,24 +59,21 @@ void loadData(std::string fname, PointCloud& cloud)
pcl
::
removeNaNFromPointCloud
(
cloud
,
cloud
,
indices
);
pcl
::
removeNaNFromPointCloud
(
cloud
,
cloud
,
indices
);
};
};
TEST
(
laser3d_tools
,
pairAlign
_
identity
)
TEST
(
pairAlign
,
identity
)
{
{
// typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;
using
PointCloud
=
pcl
::
PointCloud
<
pcl
::
PointXYZ
>
;
// Load data
// Load data
PointCloud
Boost
Ptr
pcl_ref
=
boost
::
make_shared
<
PointCloud
>
();
pcl
::
PointCloud
<
pcl
::
PointXYZ
>::
Ptr
pcl_ref
=
pcl
::
make_shared
<
pcl
::
PointCloud
<
pcl
::
PointXYZ
>
>
();
loadData
(
laser_root_dir
+
"/test/data/1.pcd"
,
*
pcl_ref
);
loadData
(
laser_root_dir
+
"/test/data/1.pcd"
,
*
pcl_ref
);
PointCloud
Boost
Ptr
pcl_other
=
pcl_ref
;
pcl
::
PointCloud
<
pcl
::
PointXYZ
>::
Ptr
pcl_other
=
pcl_ref
;
// same PCld --> ground truth transform is identity
// loadData("data/2.pcd", pcl_other
);
WOLF_INFO
(
"Ground truth transform :
\n
"
,
Matrix4d
::
Identity
()
);
// Guess
// Guess
Eigen
::
Isometry3d
transformation_guess
=
Eigen
::
Translation3d
(
1
,
1
,
1
)
*
Eigen
::
AngleAxisd
(
0.
1
,
Eigen
::
Vector3d
(
1
,
2
,
3
).
normalized
());
Isometry3d
transformation_guess
=
Translation3d
(
1
,
1
,
1
)
*
AngleAxisd
(
0.
2
,
Vector3d
(
1
,
2
,
3
).
normalized
());
WOLF_INFO
(
"Initial guess transform:
\n
"
,
transformation_guess
.
matrix
());
WOLF_INFO
(
"Initial guess transform:
\n
"
,
transformation_guess
.
matrix
());
// final transform
// final transform
Eigen
::
Isometry3d
transformation_final
;
Isometry3d
transformation_final
;
// Solver configuration
// Solver configuration
pcl
::
IterativeClosestPointNonLinear
<
pcl
::
PointXYZ
,
pcl
::
PointXYZ
>
registration_solver
;
pcl
::
IterativeClosestPointNonLinear
<
pcl
::
PointXYZ
,
pcl
::
PointXYZ
>
registration_solver
;
...
@@ -91,60 +86,75 @@ TEST(laser3d_tools, pairAlign_identity)
...
@@ -91,60 +86,75 @@ TEST(laser3d_tools, pairAlign_identity)
registration_solver
.
setMaximumIterations
(
200
);
registration_solver
.
setMaximumIterations
(
200
);
// Alignment
// Alignment
wolf
::
laser
::
pairAlign
(
pcl_ref
,
pcl_other
,
transformation_guess
,
transformation_final
,
registration_solver
,
true
);
//false);
wolf
::
laser
::
pairAlign
(
pcl_ref
,
pcl_other
,
transformation_guess
,
transformation_final
,
registration_solver
,
true
);
// false);
WOLF_INFO
(
"Final transform:
\n
"
,
transformation_final
.
matrix
());
WOLF_INFO
(
"Final transform:
\n
"
,
transformation_final
.
matrix
());
ASSERT_MATRIX_APPROX
(
transformation_final
.
matrix
(),
Eigen
::
Matrix4d
::
Identity
(),
1e-2
);
ASSERT_MATRIX_APPROX
(
transformation_final
.
matrix
(),
Matrix4d
::
Identity
(),
1e-2
);
}
}
TEST
(
laser3d_tools
,
pairAlign
_
known_transformation
)
TEST
(
pairAlign
,
known_transformation
)
{
{
// typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;
using
PointCloud
=
pcl
::
PointCloud
<
pcl
::
PointXYZ
>
;
// Load data
// Load data
PointCloud
Boost
Ptr
pcl_ref
=
boost
::
make_shared
<
PointCloud
>
();
pcl
::
PointCloud
<
pcl
::
PointXYZ
>::
Ptr
pcl_ref
=
pcl
::
make_shared
<
pcl
::
PointCloud
<
pcl
::
PointXYZ
>
>
();
loadData
(
laser_root_dir
+
"/test/data/1.pcd"
,
*
pcl_ref
);
loadData
(
laser_root_dir
+
"/test/data/1.pcd"
,
*
pcl_ref
);
// known transform
// known transform
Eigen
::
Affine3d
transformation_known
=
Eigen
::
Affine3d
::
Identity
();
Affine3d
transformation_known
=
Affine3d
::
Identity
();
transformation_known
.
translation
()
<<
1.0
,
0.5
,
0.2
;
transformation_known
.
translation
()
<<
1.0
,
0.5
,
0.2
;
transformation_known
.
rotate
(
Eigen
::
AngleAxisd
(
0.3
,
Eigen
::
Vector3d
::
UnitZ
()));
transformation_known
.
rotate
(
AngleAxisd
(
0.3
,
Vector3d
::
UnitZ
()));
// Move point cloud
// Move point cloud
PointCloud
Boost
Ptr
pcl_other
=
boost
::
make_shared
<
PointCloud
>
();
pcl
::
PointCloud
<
pcl
::
PointXYZ
>::
Ptr
pcl_other
=
pcl
::
make_shared
<
pcl
::
PointCloud
<
pcl
::
PointXYZ
>
>
();
pcl
::
transformPointCloud
(
*
pcl_ref
,
*
pcl_other
,
transformation_known
);
pcl
::
transformPointCloud
(
*
pcl_ref
,
*
pcl_other
,
transformation_known
);
// Guess
// Guess
Eigen
::
Isometry3d
transformation_guess
=
Eigen
::
Isometry3d
::
Identity
();
Isometry3d
transformation_guess
=
Isometry3d
::
Identity
();
// final transform
// final transform
Eigen
::
Isometry3d
transformation_final
;
Isometry3d
transformation_final
;
WOLF_INFO
(
"Applied transformation:
\n
"
,
transformation_known
.
matrix
());
WOLF_INFO
(
"Applied transformation:
\n
"
,
transformation_known
.
matrix
());
// Solver configuration
// Solver configuration
pcl
::
IterativeClosestPointNonLinear
<
pcl
::
PointXYZ
,
pcl
::
PointXYZ
>
registration_solver
;
pcl
::
IterativeClosestPointNonLinear
<
pcl
::
PointXYZ
,
pcl
::
PointXYZ
>
registration_solver
;
registration_solver
.
setTransformationEpsilon
(
1e-6
);
// pcl::GeneralizedIterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> registration_solver;
double
max_trans_epsilon_meters
=
0.001
;
double
max_rot_epsilon_degrees
=
0.1
;
double
trf_rotation_epsilon
=
cos
(
toRad
(
max_rot_epsilon_degrees
));
registration_solver
.
setTransformationEpsilon
(
max_trans_epsilon_meters
*
max_trans_epsilon_meters
);
registration_solver
.
setTransformationRotationEpsilon
(
trf_rotation_epsilon
);
// Set the maximum distance between two correspondences (src<->tgt) to 10cm
// Set the maximum distance between two correspondences (src<->tgt) to 10cm
// Note: adjust this based on the size of your datasets
// Note: adjust this based on the size of your datasets
registration_solver
.
setMaxCorrespondenceDistance
(
0.5
);
// visaub: changed to 100 cm
registration_solver
.
setMaxCorrespondenceDistance
(
0.5
);
// visaub: changed to 100 cm
// Set the point representation
registration_solver
.
setMaximumIterations
(
100
);
// reg.setPointRepresentation(pcl::make_shared<const MyPointRepresentation>(point_representation));
registration_solver
.
setMaximumIterations
(
200
);
// Alignment
// Alignment
wolf
::
laser
::
pairAlign
(
pcl_ref
,
pcl_other
,
transformation_guess
,
transformation_final
,
registration_solver
,
true
);
//false);
wolf
::
laser
::
pairAlign
(
pcl_ref
,
pcl_other
,
transformation_guess
,
transformation_final
,
registration_solver
,
true
);
// false);
WOLF_INFO
(
"Final transform:
\n
"
,
transformation_final
.
matrix
());
WOLF_INFO
(
"Final transform:
\n
"
,
transformation_final
.
matrix
());
ASSERT_MATRIX_APPROX
(
transformation_final
.
matrix
(),
transformation_known
.
matrix
(),
1e-2
);
auto
convcrit
=
registration_solver
.
getConvergeCriteria
();
}
WOLF_INFO
(
"convergence criteria: "
,
registration_solver
.
getConvergeCriteria
()
->
getConvergenceState
());
ASSERT_MATRIX_APPROX
(
transformation_final
.
matrix
(),
transformation_known
.
matrix
(),
1e-2
);
}
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
testing
::
InitGoogleTest
(
&
argc
,
argv
);
testing
::
InitGoogleTest
(
&
argc
,
argv
);
//
::testing::GTEST_FLAG(filter) = "
Conversions.R2q_norm_of_q
";
::
testing
::
GTEST_FLAG
(
filter
)
=
"
pairAlign.known_transformation
"
;
return
RUN_ALL_TESTS
();
return
RUN_ALL_TESTS
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment