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
27408130
Commit
27408130
authored
5 years ago
by
Joaquim Casals Buñuel
Browse files
Options
Downloads
Patches
Plain Diff
Minor fixes
parent
bae806a9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
cmake_modules/Findcsm.cmake
+1
-1
1 addition, 1 deletion
cmake_modules/Findcsm.cmake
src/icp.cpp
+10
-10
10 additions, 10 deletions
src/icp.cpp
src/icp.h
+1
-1
1 addition, 1 deletion
src/icp.h
src/laser_scan.cpp
+33
-24
33 additions, 24 deletions
src/laser_scan.cpp
with
46 additions
and
36 deletions
.gitignore
+
1
−
0
View file @
27408130
...
@@ -5,3 +5,4 @@ lib/
...
@@ -5,3 +5,4 @@ lib/
.settings/language.settings.xml
.settings/language.settings.xml
.project
.project
.cproject
.cproject
.clangd
This diff is collapsed.
Click to expand it.
cmake_modules/Findcsm.cmake
+
1
−
1
View file @
27408130
...
@@ -46,7 +46,7 @@ macro(csm_report_not_found REASON_MSG)
...
@@ -46,7 +46,7 @@ macro(csm_report_not_found REASON_MSG)
# Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by
# Note <package>_FIND_[REQUIRED/QUIETLY] variables defined by
# FindPackage() use the camelcase library name, not uppercase.
# FindPackage() use the camelcase library name, not uppercase.
if
(
csm_FIND_QUIETLY
)
if
(
csm_FIND_QUIETLY
)
message
(
STATUS
"
Failed to f
in
d
csm- "
${
REASON_MSG
}
${
ARGN
}
)
message
(
STATUS
"
Ignor
in
g
csm
dependency
- "
${
REASON_MSG
}
${
ARGN
}
)
else
(
csm_FIND_REQUIRED
)
else
(
csm_FIND_REQUIRED
)
message
(
FATAL_ERROR
"Failed to find csm - "
${
REASON_MSG
}
${
ARGN
}
)
message
(
FATAL_ERROR
"Failed to find csm - "
${
REASON_MSG
}
${
ARGN
}
)
else
()
else
()
...
...
This diff is collapsed.
Click to expand it.
src/icp.cpp
+
10
−
10
View file @
27408130
...
@@ -126,15 +126,15 @@ icpOutput ICP::align(const LaserScan &_current_ls, const LaserScan &_ref_ls, con
...
@@ -126,15 +126,15 @@ icpOutput ICP::align(const LaserScan &_current_ls, const LaserScan &_ref_ls, con
}
}
//Legacy code
//Legacy code
icpOutput
ICP
::
align
(
const
LaserScan
&
_
las
t_ls
,
const
LaserScan
&
_
origin
_ls
,
const
LaserScanParams
&
scan_params
,
const
icpParams
&
icp_params
,
Eigen
::
Vector3s
&
_
last_
transf
)
icpOutput
ICP
::
align
(
const
LaserScan
&
_
curren
t_ls
,
const
LaserScan
&
_
ref
_ls
,
const
LaserScanParams
&
scan_params
,
const
icpParams
&
icp_params
,
Eigen
::
Vector3s
&
_transf
_guess
)
{
{
// Uncomment to enable debug messages from the CSM library
// Uncomment to enable debug messages from the CSM library
// sm_debug_write(true);
// sm_debug_write(true);
LDWrapper
last
=
LDWrapper
(
_
las
t_ls
,
scan_params
);
LDWrapper
current
=
LDWrapper
(
_
curren
t_ls
,
scan_params
);
LDWrapper
origin
=
LDWrapper
(
_
origin
_ls
,
scan_params
);
LDWrapper
ref
=
LDWrapper
(
_
ref
_ls
,
scan_params
);
int
num_rays
=
_
las
t_ls
.
ranges_raw_
.
size
();
int
num_rays
=
_
curren
t_ls
.
ranges_raw_
.
size
();
sm_params
csm_input
{};
sm_params
csm_input
{};
sm_result
csm_output
{};
sm_result
csm_output
{};
...
@@ -143,12 +143,12 @@ icpOutput ICP::align(const LaserScan &_last_ls, const LaserScan &_origin_ls, con
...
@@ -143,12 +143,12 @@ icpOutput ICP::align(const LaserScan &_last_ls, const LaserScan &_origin_ls, con
csm_input
.
max_reading
=
scan_params
.
range_max_
;
csm_input
.
max_reading
=
scan_params
.
range_max_
;
csm_input
.
sigma
=
scan_params
.
range_std_dev_
;
csm_input
.
sigma
=
scan_params
.
range_std_dev_
;
csm_input
.
laser_ref
=
origin
.
laser_data
;
csm_input
.
laser_ref
=
ref
.
laser_data
;
csm_input
.
laser_sens
=
las
t
.
laser_data
;
csm_input
.
laser_sens
=
curren
t
.
laser_data
;
csm_input
.
first_guess
[
0
]
=
_last
_transf
(
0
);
csm_input
.
first_guess
[
0
]
=
_transf
_guess
(
0
);
csm_input
.
first_guess
[
1
]
=
_last
_transf
(
1
);
csm_input
.
first_guess
[
1
]
=
_transf
_guess
(
1
);
csm_input
.
first_guess
[
2
]
=
_last
_transf
(
2
);
csm_input
.
first_guess
[
2
]
=
_transf
_guess
(
2
);
csm_input
.
use_point_to_line_distance
=
icp_params
.
use_point_to_line_distance
;
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_correspondence_dist
=
icp_params
.
max_correspondence_dist
;
...
@@ -183,7 +183,7 @@ icpOutput ICP::align(const LaserScan &_last_ls, const LaserScan &_origin_ls, con
...
@@ -183,7 +183,7 @@ icpOutput ICP::align(const LaserScan &_last_ls, const LaserScan &_origin_ls, con
else
else
{
{
std
::
cout
<<
"ICP valid != 1, providing first guess transformation and identity covariance
\n
"
;
std
::
cout
<<
"ICP valid != 1, providing first guess transformation and identity covariance
\n
"
;
result
.
res_transf
=
_last
_transf
;
result
.
res_transf
=
_transf
_guess
;
result
.
res_covar
=
Eigen
::
Matrix3s
::
Identity
();
result
.
res_covar
=
Eigen
::
Matrix3s
::
Identity
();
}
}
...
...
This diff is collapsed.
Click to expand it.
src/icp.h
+
1
−
1
View file @
27408130
...
@@ -19,7 +19,7 @@ struct icpOutput{
...
@@ -19,7 +19,7 @@ struct icpOutput{
struct
icpParams
{
struct
icpParams
{
int
use_point_to_line_distance
;
int
use_point_to_line_distance
;
int
max_correspondence_dist
;
double
max_correspondence_dist
;
int
max_iterations
;
int
max_iterations
;
int
use_corr_tricks
;
int
use_corr_tricks
;
double
outliers_maxPerc
;
double
outliers_maxPerc
;
...
...
This diff is collapsed.
Click to expand it.
src/laser_scan.cpp
+
33
−
24
View file @
27408130
...
@@ -2,7 +2,17 @@
...
@@ -2,7 +2,17 @@
namespace
laserscanutils
namespace
laserscanutils
{
{
void
LaserScanParams
::
print
()
const
{
std
::
cout
<<
"PRINTING LASERSCANPARAMS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
<<
std
::
endl
;
std
::
cout
<<
"angle_min_: "
<<
angle_min_
<<
std
::
endl
;
std
::
cout
<<
"angle_max_: "
<<
angle_max_
<<
std
::
endl
;
std
::
cout
<<
"angle_step_: "
<<
angle_step_
<<
std
::
endl
;
std
::
cout
<<
"scan_time_: "
<<
scan_time_
<<
std
::
endl
;
std
::
cout
<<
"range_min_: "
<<
range_min_
<<
std
::
endl
;
std
::
cout
<<
"range_max_: "
<<
range_max_
<<
std
::
endl
;
std
::
cout
<<
"range_std_dev_: "
<<
range_std_dev_
<<
std
::
endl
;
std
::
cout
<<
"angle_std_dev_: "
<<
angle_std_dev_
<<
std
::
endl
;
}
LaserScan
::
LaserScan
()
:
LaserScan
::
LaserScan
()
:
is_raw_processed_
(
false
)
is_raw_processed_
(
false
)
{
{
...
@@ -28,7 +38,7 @@ LaserScan::~LaserScan()
...
@@ -28,7 +38,7 @@ LaserScan::~LaserScan()
bool
LaserScan
::
isRawProcessed
()
const
bool
LaserScan
::
isRawProcessed
()
const
{
{
return
is_raw_processed_
;
return
is_raw_processed_
;
}
}
bool
LaserScan
::
checkScanCorrectness
(
unsigned
int
_idx
,
unsigned
int
_idx_range
)
const
bool
LaserScan
::
checkScanCorrectness
(
unsigned
int
_idx
,
unsigned
int
_idx_range
)
const
...
@@ -40,12 +50,12 @@ bool LaserScan::checkScanCorrectness(unsigned int _idx, unsigned int _idx_range)
...
@@ -40,12 +50,12 @@ bool LaserScan::checkScanCorrectness(unsigned int _idx, unsigned int _idx_range)
//set loop bounds
//set loop bounds
unsigned
int
ii_init
=
std
::
max
(
(
unsigned
int
)
0
,
(
_idx
-
_idx_range
)
);
unsigned
int
ii_init
=
std
::
max
(
(
unsigned
int
)
0
,
(
_idx
-
_idx_range
)
);
unsigned
int
ii_end
=
std
::
min
(
(
unsigned
int
)(
ranges_
.
size
()
-
1
)
,
(
_idx
+
_idx_range
)
);
unsigned
int
ii_end
=
std
::
min
(
(
unsigned
int
)(
ranges_
.
size
()
-
1
)
,
(
_idx
+
_idx_range
)
);
//proceed
//proceed
for
(
unsigned
int
ii
=
ii_init
;
ii
<=
ii_end
;
ii
++
)
for
(
unsigned
int
ii
=
ii_init
;
ii
<=
ii_end
;
ii
++
)
if
(
ranges_
[
ii
]
<
0
)
if
(
ranges_
[
ii
]
<
0
)
return
false
;
return
false
;
//return
//return
return
true
;
return
true
;
}
}
...
@@ -55,16 +65,16 @@ bool LaserScan::checkScanJumps(unsigned int _idx, unsigned int _idx_range) const
...
@@ -55,16 +65,16 @@ bool LaserScan::checkScanJumps(unsigned int _idx, unsigned int _idx_range) const
//first of all check if scan has been raw processed
//first of all check if scan has been raw processed
if
(
!
is_raw_processed_
)
if
(
!
is_raw_processed_
)
return
true
;
return
true
;
//set loop bounds
//set loop bounds
unsigned
int
ii_init
=
std
::
max
(
(
unsigned
int
)
0
,
(
_idx
-
_idx_range
)
);
unsigned
int
ii_init
=
std
::
max
(
(
unsigned
int
)
0
,
(
_idx
-
_idx_range
)
);
unsigned
int
ii_end
=
std
::
min
(
(
unsigned
int
)(
ranges_
.
size
()
-
1
)
,
(
_idx
+
_idx_range
)
);
unsigned
int
ii_end
=
std
::
min
(
(
unsigned
int
)(
ranges_
.
size
()
-
1
)
,
(
_idx
+
_idx_range
)
);
//proceed
//proceed
for
(
unsigned
int
ii
=
ii_init
;
ii
<=
ii_end
;
ii
++
)
for
(
unsigned
int
ii
=
ii_init
;
ii
<=
ii_end
;
ii
++
)
if
(
jumps_mask_
[
ii
]
)
if
(
jumps_mask_
[
ii
]
)
return
true
;
return
true
;
//return
//return
return
false
;
return
false
;
}
}
...
@@ -95,20 +105,20 @@ void LaserScan::ranges2xy(const LaserScanParams& _scan_params, Eigen::Matrix4s _
...
@@ -95,20 +105,20 @@ void LaserScan::ranges2xy(const LaserScanParams& _scan_params, Eigen::Matrix4s _
{
{
//set as valid range
//set as valid range
ranges_
[
ii
]
=
ranges_raw_
[
ii
];
ranges_
[
ii
]
=
ranges_raw_
[
ii
];
//transform the laser hit from polar to 3D euclidean homogeneous
//transform the laser hit from polar to 3D euclidean homogeneous
point_laser
<<
ranges_
[
ii
]
*
cos
(
azimuth
),
ranges_
[
ii
]
*
sin
(
azimuth
),
0
,
1
;
point_laser
<<
ranges_
[
ii
]
*
cos
(
azimuth
),
ranges_
[
ii
]
*
sin
(
azimuth
),
0
,
1
;
//apply device mounting point calibration (p_r = T * p_l)
//apply device mounting point calibration (p_r = T * p_l)
point_ref
=
_device_T
*
point_laser
;
point_ref
=
_device_T
*
point_laser
;
//set to points_all_ as a 2D homogeneous
//set to points_all_ as a 2D homogeneous
points_all_
.
col
(
ii
)
<<
point_ref
(
0
),
point_ref
(
1
),
1
;
points_all_
.
col
(
ii
)
<<
point_ref
(
0
),
point_ref
(
1
),
1
;
//set to points_ as a 2D homogeneous
//set to points_ as a 2D homogeneous
points_
.
col
(
ii_ok
)
<<
point_ref
(
0
),
point_ref
(
1
),
1
;
points_
.
col
(
ii_ok
)
<<
point_ref
(
0
),
point_ref
(
1
),
1
;
//check jump.
//check jump.
//Min dist between consecutive points is r*sin(angle_step_). A jump occurs when this min dist is overpassed by kr times
//Min dist between consecutive points is r*sin(angle_step_). A jump occurs when this min dist is overpassed by kr times
if
(
fabs
(
ranges_
[
ii
]
-
prev_range
)
>
_jump_th
)
//jump condition
if
(
fabs
(
ranges_
[
ii
]
-
prev_range
)
>
_jump_th
)
//jump condition
{
{
...
@@ -117,10 +127,10 @@ void LaserScan::ranges2xy(const LaserScanParams& _scan_params, Eigen::Matrix4s _
...
@@ -117,10 +127,10 @@ void LaserScan::ranges2xy(const LaserScanParams& _scan_params, Eigen::Matrix4s _
}
}
else
else
jumps_mask_
[
ii
]
=
false
;
jumps_mask_
[
ii
]
=
false
;
//increment ok counter
//increment ok counter
ii_ok
++
;
ii_ok
++
;
//keep current range as previous for the next iteration
//keep current range as previous for the next iteration
prev_range
=
ranges_raw_
[
ii
];
prev_range
=
ranges_raw_
[
ii
];
}
}
...
@@ -131,17 +141,17 @@ void LaserScan::ranges2xy(const LaserScanParams& _scan_params, Eigen::Matrix4s _
...
@@ -131,17 +141,17 @@ void LaserScan::ranges2xy(const LaserScanParams& _scan_params, Eigen::Matrix4s _
points_all_
.
col
(
ii
)
<<
0
,
0
,
0
;
points_all_
.
col
(
ii
)
<<
0
,
0
,
0
;
//prev_range = 0;
//prev_range = 0;
}
}
//increment azimuth with angle step
//increment azimuth with angle step
azimuth
+=
_scan_params
.
angle_step_
;
azimuth
+=
_scan_params
.
angle_step_
;
}
}
//push back the last index to jumps_indexes_, to properly close the list. This will be used by findSegments()
//push back the last index to jumps_indexes_, to properly close the list. This will be used by findSegments()
jumps_indexes_
.
push_back
(
ii_ok
);
jumps_indexes_
.
push_back
(
ii_ok
);
//resize the output matrix to the number of correct points, while keeping values
//resize the output matrix to the number of correct points, while keeping values
points_
.
conservativeResize
(
3
,
ii_ok
);
points_
.
conservativeResize
(
3
,
ii_ok
);
//raise the flag
//raise the flag
is_raw_processed_
=
true
;
is_raw_processed_
=
true
;
}
}
...
@@ -323,21 +333,21 @@ void LaserScan::findSegments(const LaserScanParams& _scan_params, std::list<lase
...
@@ -323,21 +333,21 @@ void LaserScan::findSegments(const LaserScanParams& _scan_params, std::list<lase
//in case ths input scan is not yet raw processed, do it
//in case ths input scan is not yet raw processed, do it
if
(
!
is_raw_processed_
)
if
(
!
is_raw_processed_
)
ranges2xy
(
_scan_params
,
Eigen
::
Matrix4s
::
Identity
(),
_jump_th_segment
);
ranges2xy
(
_scan_params
,
Eigen
::
Matrix4s
::
Identity
(),
_jump_th_segment
);
//run over all jumps (except the last, which indicates the closing index)
//run over all jumps (except the last, which indicates the closing index)
for
(
auto
jumps_it
=
jumps_indexes_
.
begin
();
jumps_it
!=
std
::
prev
(
jumps_indexes_
.
end
());
jumps_it
++
)
for
(
auto
jumps_it
=
jumps_indexes_
.
begin
();
jumps_it
!=
std
::
prev
(
jumps_indexes_
.
end
());
jumps_it
++
)
{
{
//new segment in the list
//new segment in the list
_segment_list
.
push_back
(
ScanSegment
());
_segment_list
.
push_back
(
ScanSegment
());
//check how many points
//check how many points
num_points
=
(
*
std
::
next
(
jumps_it
))
-
(
*
jumps_it
);
num_points
=
(
*
std
::
next
(
jumps_it
))
-
(
*
jumps_it
);
//fill points
//fill points
_segment_list
.
back
().
points_
.
resize
(
3
,
num_points
);
_segment_list
.
back
().
points_
.
resize
(
3
,
num_points
);
for
(
unsigned
int
ii
=
0
;
ii
<
num_points
;
ii
++
)
for
(
unsigned
int
ii
=
0
;
ii
<
num_points
;
ii
++
)
_segment_list
.
back
().
points_
.
col
(
ii
)
<<
this
->
points_
.
col
((
*
jumps_it
)
+
ii
);
_segment_list
.
back
().
points_
.
col
(
ii
)
<<
this
->
points_
.
col
((
*
jumps_it
)
+
ii
);
//set segment attributes
//set segment attributes
_segment_list
.
back
().
idx_first_
=
(
*
jumps_it
);
_segment_list
.
back
().
idx_first_
=
(
*
jumps_it
);
_segment_list
.
back
().
idx_last_
=
(
*
jumps_it
+
num_points
-
1
);
_segment_list
.
back
().
idx_last_
=
(
*
jumps_it
+
num_points
-
1
);
...
@@ -361,4 +371,3 @@ void LaserScan::findSegments(const LaserScanParams& _scan_params, std::list<lase
...
@@ -361,4 +371,3 @@ void LaserScan::findSegments(const LaserScanParams& _scan_params, std::list<lase
}
}
}
//namespace
}
//namespace
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