Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
laser_scan_utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
labrobotica
algorithms
laser_scan_utils
Commits
7b35cbe4
Commit
7b35cbe4
authored
5 years ago
by
Joaquim Casals Buñuel
Browse files
Options
Downloads
Patches
Plain Diff
Added align functionality for two arbitrary laser scans from different sensors
parent
1b566f72
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/icp.cpp
+70
-0
70 additions, 0 deletions
src/icp.cpp
src/icp.h
+15
-8
15 additions, 8 deletions
src/icp.h
with
85 additions
and
8 deletions
src/icp.cpp
+
70
−
0
View file @
7b35cbe4
#include
"icp.h"
#include
"icp.h"
#include
<algorithm>
using
namespace
laserscanutils
;
using
namespace
laserscanutils
;
unsigned
seed
=
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
().
count
();
unsigned
seed
=
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
().
count
();
std
::
mt19937
generator
(
seed
);
std
::
mt19937
generator
(
seed
);
...
@@ -56,6 +58,74 @@ ICP::~ICP()
...
@@ -56,6 +58,74 @@ ICP::~ICP()
}
}
icpOutput
ICP
::
align
(
const
LaserScan
&
_current_ls
,
const
LaserScan
&
_ref_ls
,
const
LaserScanParams
&
_current_scan_params
,
const
LaserScanParams
&
_ref_scan_params
,
const
icpParams
&
_icp_params
,
Eigen
::
Vector3s
&
_transf_ref_current
)
{
// Uncomment to enable debug messages from the CSM library
// sm_debug_write(true);
LDWrapper
laser_scan_current
=
LDWrapper
(
_current_ls
,
_current_scan_params
);
LDWrapper
laser_scan_ref
=
LDWrapper
(
_ref_ls
,
_ref_scan_params
);
int
num_rays
=
_current_ls
.
ranges_raw_
.
size
();
sm_params
csm_input
{};
sm_result
csm_output
{};
csm_input
.
min_reading
=
max
(
_current_scan_params
.
range_min_
,
_ref_scan_params
.
range_min_
);
csm_input
.
max_reading
=
min
(
_current_scan_params
.
range_max_
,
_ref_scan_params
.
range_max_
);
csm_input
.
sigma
=
_ref_scan_params
.
range_std_dev_
;
csm_input
.
laser_ref
=
laser_scan_ref
.
laser_data
;
csm_input
.
laser_sens
=
laser_scan_current
.
laser_data
;
csm_input
.
first_guess
[
0
]
=
_transf_ref_current
(
0
);
csm_input
.
first_guess
[
1
]
=
_transf_ref_current
(
1
);
csm_input
.
first_guess
[
2
]
=
_transf_ref_current
(
2
);
csm_input
.
use_point_to_line_distance
=
_icp_params
.
use_point_to_line_distance
;
csm_input
.
max_correspondence_dist
=
_icp_params
.
max_correspondence_dist
;
csm_input
.
max_iterations
=
_icp_params
.
max_iterations
;
csm_input
.
use_corr_tricks
=
_icp_params
.
use_corr_tricks
;
csm_input
.
outliers_maxPerc
=
_icp_params
.
outliers_maxPerc
;
csm_input
.
outliers_adaptive_order
=
_icp_params
.
outliers_adaptive_order
;
csm_input
.
outliers_adaptive_mult
=
_icp_params
.
outliers_adaptive_mult
;
csm_input
.
do_compute_covariance
=
1
;
sm_icp
(
&
csm_input
,
&
csm_output
);
icpOutput
result
{};
result
.
nvalid
=
csm_output
.
nvalid
;
result
.
valid
=
csm_output
.
valid
;
result
.
error
=
csm_output
.
error
;
if
(
result
.
valid
==
1
)
{
result
.
res_transf
(
0
)
=
csm_output
.
x
[
0
];
result
.
res_transf
(
1
)
=
csm_output
.
x
[
1
];
result
.
res_transf
(
2
)
=
csm_output
.
x
[
2
];
for
(
int
i
=
0
;
i
<
3
;
++
i
)
for
(
int
j
=
0
;
j
<
3
;
++
j
)
result
.
res_covar
(
i
,
j
)
=
// gsl_matrix_get(csm_output.cov_x_m, i, j); // NOT
// COMPILING
csm_output
.
cov_x_m
->
data
[
i
*
csm_output
.
cov_x_m
->
tda
+
j
];
// This does the same
}
else
{
std
::
cout
<<
"ICP valid != 1, providing first guess transformation and "
"identity covariance
\n
"
;
result
.
res_transf
=
_transf_ref_current
;
result
.
res_covar
=
Eigen
::
Matrix3s
::
Identity
();
}
// std::cout << "Number of valid correspondences: " << csm_output.nvalid <<
// '\n'; std::cout << "Number of iterations: " << csm_output.iterations <<
// '\n'; std::cout << "Error: " << csm_output.error << '\n';
return
result
;
}
//Legacy code
icpOutput
ICP
::
align
(
const
LaserScan
&
_last_ls
,
const
LaserScan
&
_origin_ls
,
const
LaserScanParams
&
scan_params
,
const
icpParams
&
icp_params
,
Eigen
::
Vector3s
&
_last_transf
)
icpOutput
ICP
::
align
(
const
LaserScan
&
_last_ls
,
const
LaserScan
&
_origin_ls
,
const
LaserScanParams
&
scan_params
,
const
icpParams
&
icp_params
,
Eigen
::
Vector3s
&
_last_transf
)
{
{
// Uncomment to enable debug messages from the CSM library
// Uncomment to enable debug messages from the CSM library
...
...
This diff is collapsed.
Click to expand it.
src/icp.h
+
15
−
8
View file @
7b35cbe4
#ifndef ICP_H_
#ifndef ICP_H_
#define ICP_H_
#define ICP_H_
#include
<chrono>
#include
<random>
#include
"laser_scan.h"
#include
"laser_scan.h"
#include
<chrono>
#include
<csm/csm_all.h>
#include
<csm/csm_all.h>
#include
<random>
// using namespace CSM;
// using namespace CSM;
namespace
laserscanutils
{
namespace
laserscanutils
{
...
@@ -33,12 +33,19 @@ class ICP
...
@@ -33,12 +33,19 @@ class ICP
ICP
();
ICP
();
~
ICP
();
~
ICP
();
static
icpOutput
align
(
const
LaserScan
&
_last_ls
,
const
LaserScan
&
_reference_ls
,
const
LaserScanParams
&
scan_params
,
const
icpParams
&
icp_params
,
Eigen
::
Vector3s
&
_last_transf
);
static
icpOutput
align
(
const
LaserScan
&
_current_ls
,
const
LaserScan
&
_ref_ls
,
static
void
printTwoLaserData
(
sm_params
&
params
);
const
LaserScanParams
&
_current_scan_params
,
static
void
printLaserData
(
LDP
&
laser_data
);
const
LaserScanParams
&
_ref_scan_params
,
};
const
icpParams
&
_icp_params
,
Eigen
::
Vector3s
&
_transf_ref_current
);
static
icpOutput
align
(
const
LaserScan
&
_last_ls
,
const
LaserScan
&
_reference_ls
,
const
LaserScanParams
&
scan_params
,
const
icpParams
&
icp_params
,
Eigen
::
Vector3s
&
_last_transf
);
static
void
printTwoLaserData
(
sm_params
&
params
);
static
void
printLaserData
(
LDP
&
laser_data
);
};
}
}
#endif
#endif
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