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
a114aebe
Commit
a114aebe
authored
10 months ago
by
Joan Vallvé Navarro
Browse files
Options
Downloads
Patches
Plain Diff
little work on gtest icp
parent
fec12f87
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#18412
passed
10 months ago
Stage: license
Stage: none
Stage: csm
Stage: falko
Stage: csm_falko
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/gtest/CMakeLists.txt
+3
-1
3 additions, 1 deletion
test/gtest/CMakeLists.txt
test/gtest_icp.cpp
+5
-87
5 additions, 87 deletions
test/gtest_icp.cpp
test/matplotlibcpp.h
+0
-3007
0 additions, 3007 deletions
test/matplotlibcpp.h
with
8 additions
and
3095 deletions
test/gtest/CMakeLists.txt
+
3
−
1
View file @
a114aebe
include
(
FetchContent
)
SET
(
BUILD_GMOCK OFF
)
# Disable gmock
SET
(
INSTALL_GTEST OFF
)
# Disable installation of googletest
FetchContent_Declare
(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG main
)
SET
(
INSTALL_GTEST OFF
)
# Disable installation of googletest
FetchContent_MakeAvailable
(
googletest
)
function
(
add_gtest target
)
...
...
This diff is collapsed.
Click to expand it.
test/gtest_icp.cpp
+
5
−
87
View file @
a114aebe
...
...
@@ -23,12 +23,6 @@
#include
"laser_scan_utils/laser_scan.h"
#include
"laser_scan_utils/icp.h"
#define TEST_PLOTS false
#if TEST_PLOTS
#include
"matplotlibcpp.h"
namespace
plt
=
matplotlibcpp
;
#endif
using
namespace
laserscanutils
;
const
Eigen
::
Vector2d
A
=
Eigen
::
Vector2d
::
Zero
();
...
...
@@ -37,10 +31,8 @@ const Eigen::Vector2d C = (Eigen::Vector2d() << 30, 0).finished();
const
Eigen
::
Vector2d
CB
=
B
-
C
;
double
AB_ang
=
atan2
((
A
-
B
).
norm
(),(
A
-
C
).
norm
());
double
dist_min
=
2
;
int
color_id
=
0
;
const
std
::
vector
<
std
::
string
>
colors
({
"b"
,
"r"
,
"g"
,
"c"
,
"m"
,
"y"
});
/* Synthetic scans are created from this simple scenario with three
orthogon
al walls:
/* Synthetic scans are created from this simple scenario with three
vertic
al walls:
*
* B
* +
...
...
@@ -151,15 +143,6 @@ LaserScan simulateScan(const Eigen::Vector3d& laser_pose, const LaserScanParams&
}
}
// // print ranges
// std::cout << "Scan:" << std::endl;
// std::cout << " angle_min: " << params.angle_min_ << std::endl;
// std::cout << " angle_step_: " << params.angle_step_ << std::endl;
// std::cout << " ranges: ";
// for (auto range : scan.ranges_raw_)
// std::cout << range << ", ";
// std::cout << std::endl;
return
scan
;
};
...
...
@@ -172,19 +155,14 @@ void generateRandomProblem(Eigen::Vector3d& pose_ref,
double
perturbation
=
1
)
{
pose_ref
=
generateRandomPoseInsideTriangle
();
pose_d
=
Eigen
::
Vector3d
::
Random
()
*
perturbation
;
while
(
pose_d
(
2
)
>
M_PI
)
pose_d
(
2
)
-=
2
*
M_PI
;
while
(
pose_d
(
2
)
<=
-
M_PI
)
pose_d
(
2
)
+=
2
*
M_PI
;
pose_tar
.
head
<
2
>
()
=
pose_ref
.
head
<
2
>
()
+
Eigen
::
Rotation2Dd
(
pose_ref
(
2
))
*
pose_d
.
head
<
2
>
();
pose_tar
(
2
)
=
pose_ref
(
2
)
+
pose_d
(
2
);
while
(
not
insideTriangle
(
pose_tar
))
do
{
pose_d
=
Eigen
::
Vector3d
::
Random
();
pose_d
=
Eigen
::
Vector3d
::
Random
()
*
perturbation
;
pose_d
(
2
)
=
pi2pi
(
pose_d
(
2
));
pose_tar
.
head
<
2
>
()
=
pose_ref
.
head
<
2
>
()
+
Eigen
::
Rotation2Dd
(
pose_ref
(
2
))
*
pose_d
.
head
<
2
>
();
pose_tar
(
2
)
=
pose_ref
(
2
)
+
pose_d
(
2
);
}
while
(
not
insideTriangle
(
pose_tar
));
scan_ref
=
simulateScan
(
pose_ref
,
scan_params
);
scan_tar
=
simulateScan
(
pose_tar
,
scan_params
);
...
...
@@ -204,53 +182,9 @@ LaserScanParams generateLaserScanParams(double angle_min_deg, double angle_step_
scan_params
.
range_std_dev_
=
0
;
scan_params
.
angle_std_dev_
=
0
;
//scan_params.print();
return
scan_params
;
}
void
initPlot
()
{
#if TEST_PLOTS
plt
::
figure
();
#endif
}
void
showPlot
()
{
#if TEST_PLOTS
plt
::
show
();
#endif
}
void
plotScan
(
const
LaserScan
&
scan
,
const
LaserScanParams
&
scan_params
,
const
Eigen
::
Vector3d
pose
,
bool
fig_created
=
false
)
{
#if TEST_PLOTS
// Create figure
if
(
not
fig_created
)
plt
::
figure
();
plt
::
axis
(
"scaled"
);
std
::
vector
<
double
>
x
(
scan
.
ranges_raw_
.
size
());
std
::
vector
<
double
>
y
(
scan
.
ranges_raw_
.
size
());
for
(
auto
i
=
0
;
i
<
scan
.
ranges_raw_
.
size
();
i
++
)
{
x
.
at
(
i
)
=
pose
(
0
)
+
cos
(
scan_params
.
angle_min_
+
i
*
scan_params
.
angle_step_
+
pose
(
2
))
*
scan
.
ranges_raw_
.
at
(
i
);
y
.
at
(
i
)
=
pose
(
1
)
+
sin
(
scan_params
.
angle_min_
+
i
*
scan_params
.
angle_step_
+
pose
(
2
))
*
scan
.
ranges_raw_
.
at
(
i
);
}
plt
::
plot
(
x
,
y
,
"."
+
colors
.
at
(
color_id
));
std
::
vector
<
double
>
pose_x
{
pose
(
0
)
-
sin
(
pose
(
2
)),
pose
(
0
),
pose
(
0
)
+
cos
(
pose
(
2
))};
std
::
vector
<
double
>
pose_y
{
pose
(
1
)
+
cos
(
pose
(
2
)),
pose
(
1
),
pose
(
1
)
+
sin
(
pose
(
2
))};
plt
::
plot
(
pose_x
,
pose_y
,
colors
.
at
(
color_id
)
+
"-"
);
if
(
not
fig_created
)
plt
::
show
();
color_id
++
;
if
(
color_id
>=
colors
.
size
())
color_id
=
0
;
#endif
}
///////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////// TESTS ////////////////////////////////////////////
...
...
@@ -310,8 +244,6 @@ TEST(TestIcp, TestGenerateRandomPose)
// 0-2M_PI (5 degrees step)
LaserScanParams
scan_params
=
generateLaserScanParams
(
-
180
,
1
);
initPlot
();
// 100 random poses and scans
for
(
auto
i
=
0
;
i
<
100
;
i
++
)
{
...
...
@@ -319,11 +251,7 @@ TEST(TestIcp, TestGenerateRandomPose)
ASSERT_TRUE
(
insideTriangle
(
laser_pose
));
auto
scan
=
simulateScan
(
laser_pose
,
scan_params
);
plotScan
(
scan
,
scan_params
,
laser_pose
,
true
);
}
showPlot
();
}
TEST
(
TestIcp
,
TestIcpSame1
)
...
...
@@ -445,11 +373,6 @@ TEST(TestIcp, TestIcp1)
ASSERT_TRUE
(
icp_output
.
valid
);
EXPECT_MATRIX_APPROX
(
icp_output
.
res_transf
,
pose_d
,
1e-1
);
initPlot
();
plotScan
(
scan_ref
,
scan_params
,
pose_ref
,
true
);
plotScan
(
scan_tar
,
scan_params
,
pose_tar
,
true
);
showPlot
();
}
}
...
...
@@ -482,11 +405,6 @@ TEST(TestIcp, TestIcp10)
ASSERT_TRUE
(
icp_output
.
valid
);
EXPECT_MATRIX_APPROX
(
icp_output
.
res_transf
,
pose_d
,
1e-1
);
initPlot
();
plotScan
(
scan_ref
,
scan_params
,
pose_ref
,
true
);
plotScan
(
scan_tar
,
scan_params
,
pose_tar
,
true
);
showPlot
();
}
}
//*/
...
...
This diff is collapsed.
Click to expand it.
test/matplotlibcpp.h
deleted
100644 → 0
+
0
−
3007
View file @
fec12f87
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