Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Navigation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Software
ArmarX
Skills
Navigation
Merge requests
!109
Social layers
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Social layers
feature/store-proxemics-in-memory
into
master
Overview
0
Commits
69
Pipelines
0
Changes
1
Open
Fabian Reister
requested to merge
feature/store-proxemics-in-memory
into
master
6 months ago
Overview
0
Commits
69
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Viewing commit
2979fef6
Prev
Next
Show latest version
1 file
+
137
−
113
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
2979fef6
Start implementing tests
· 2979fef6
Timo Weberruß
authored
2 years ago
source/armarx/navigation/human/test/human_test.cpp
+
137
−
113
Options
@@ -28,9 +28,8 @@
#include
<ArmarXCore/core/logging/Logging.h>
#include
<SemanticObjectRelations/Shapes/Shape.h>
#include
<armarx/navigation/core/Graph.h>
#include
<armarx/navigation/core/Trajectory.h>
#include
<armarx/navigation/
core/types
.h>
#include
<armarx/navigation/
human/EuclideanDistance
.h>
#include
<range/v3/view/zip.hpp>
// test includes and other stuff
@@ -38,119 +37,144 @@
#define ARMARX_BOOST_TEST
#include
<armarx/navigation/Test.h>
#include
<armarx/navigation/core/basic_types.h>
#include
<armarx/navigation/human/types.h>
BOOST_AUTO_TEST_CASE
(
testPathLength
)
{
armarx
::
navigation
::
core
::
Path
path
{
armarx
::
navigation
::
core
::
Pose
(
Eigen
::
Translation3f
(
0
,
0
,
0
)),
armarx
::
navigation
::
core
::
Pose
(
Eigen
::
Translation3f
(
0
,
2000
,
0
)),
armarx
::
navigation
::
core
::
Pose
(
Eigen
::
Translation3f
(
0
,
4000
,
0
))};
const
auto
traj
=
armarx
::
navigation
::
core
::
GlobalTrajectory
::
FromPath
(
path
,
100
);
BOOST_CHECK_CLOSE
(
traj
.
length
(),
4000
,
0.01
);
}
using
armarx
::
navigation
::
core
::
Pose2D
;
using
armarx
::
navigation
::
human
::
EuclideanDistance
;
using
armarx
::
navigation
::
human
::
Human
;
BOOST_AUTO_TEST_CASE
(
test
ResampleAlongLin
e
)
BOOST_AUTO_TEST_CASE
(
test
EuclideanDistanc
e
)
{
armarx
::
navigation
::
core
::
Path
path
{
armarx
::
navigation
::
core
::
Pose
(
Eigen
::
Translation3f
(
0
,
0
,
0
)),
armarx
::
navigation
::
core
::
Pose
(
Eigen
::
Translation3f
(
0
,
2000
,
0
))}
;
const
auto
traj
=
armarx
::
navigation
::
core
::
GlobalTrajectory
::
FromPath
(
path
,
100
);
BOOST_CHECK_EQUAL
(
traj
.
points
().
size
(),
2
);
const
auto
resampledTraj
=
traj
.
resample
(
500
)
;
for
(
const
auto
&
pt
:
resampledTraj
.
positions
()
)
{
ARMARX_DEBUG
<<
VAROUT
(
pt
);
}
BOOST_CHECK_EQUAL
(
resampledTraj
.
points
().
size
(),
4
)
;
EuclideanDistance
distance
=
EuclideanDistance
();
Pose2D
pose1
=
Pose2D
::
Identity
()
;
// pose1.translation() = Eigen::Vector2f(3, 4);
// pose1.linear() = Eigen::Rotation2Df(1.1).toRotationMatrix(
);
// Human h1 = {.pose = pose1,
// .linearVelocity = Eigen::Vector2f(0.2, 0.1),
// .detectionTime = armarx::DateTime::Now()}
;
// Pose2D pose2 = Pose2D::Identity
()
;
// pose2.translation() = Eigen::Vector2f(6, 8);
//
pose2.linear() = Eigen::Rotation2Df(2.3).toRotationMatrix(
);
// Human h2 = {.pose = pose2,
// .linearVelocity = Eigen::Vector2f(0.5, 0.8),
// .detectionTime = armarx::DateTime::Now()}
;
}
BOOST_AUTO_TEST_CASE
(
testResampleAlongLineWithWaypoint
)
{
armarx
::
navigation
::
core
::
Path
path
{
armarx
::
navigation
::
core
::
Pose
(
Eigen
::
Translation3f
(
0
,
0
,
0
)),
armarx
::
navigation
::
core
::
Pose
(
Eigen
::
Translation3f
(
0
,
1050
,
0
)),
armarx
::
navigation
::
core
::
Pose
(
Eigen
::
Translation3f
(
0
,
2100
,
0
))};
const
auto
traj
=
armarx
::
navigation
::
core
::
GlobalTrajectory
::
FromPath
(
path
,
100
);
BOOST_CHECK_EQUAL
(
traj
.
points
().
size
(),
3
);
const
auto
resampledTraj
=
traj
.
resample
(
500
);
for
(
const
auto
&
pt
:
resampledTraj
.
positions
())
{
ARMARX_DEBUG
<<
VAROUT
(
pt
);
}
BOOST_CHECK_EQUAL
(
resampledTraj
.
points
().
size
(),
5
);
}
BOOST_AUTO_TEST_CASE
(
testGraphRoutes
)
{
using
namespace
armarx
::
navigation
;
/*
*
* (0) -> (2) -> (3)
* ^
* |
* (1)
*/
core
::
Graph
graph
;
graph
.
addVertex
(
semrel
::
ShapeID
(
0
));
graph
.
addVertex
(
semrel
::
ShapeID
(
1
));
graph
.
addVertex
(
semrel
::
ShapeID
(
2
));
graph
.
addVertex
(
semrel
::
ShapeID
(
3
));
graph
.
addEdge
(
semrel
::
ShapeID
(
0
),
semrel
::
ShapeID
(
2
));
graph
.
addEdge
(
semrel
::
ShapeID
(
1
),
semrel
::
ShapeID
(
2
));
graph
.
addEdge
(
semrel
::
ShapeID
(
2
),
semrel
::
ShapeID
(
3
));
const
auto
paths
=
armarx
::
navigation
::
core
::
findPathsTo
(
graph
.
vertex
(
semrel
::
ShapeID
(
3
)),
graph
);
// GT: paths
// - {3}
// - {2,3}
// - {0,2,3}
// - {1,2,3}
BOOST_CHECK_EQUAL
(
paths
.
size
(),
4
);
std
::
vector
<
std
::
vector
<
int
>>
gtPaths
{{
3
},
{
2
,
3
},
{
0
,
2
,
3
},
{
1
,
2
,
3
}};
const
auto
isMatchingPath
=
[](
const
auto
&
path
,
const
auto
&
gtPath
)
{
if
(
path
.
size
()
!=
gtPath
.
size
())
{
return
false
;
}
// check that sequences match
for
(
const
auto
&
[
v
,
gtId
]
:
ranges
::
views
::
zip
(
path
,
gtPath
))
{
if
(
v
.
objectID
().
t
!=
gtId
)
{
return
false
;
}
}
ARMARX_INFO
<<
"Found matching path: "
<<
VAROUT
(
path
)
<<
", "
<<
VAROUT
(
gtPath
);
return
true
;
};
// check that all required paths are available
for
(
const
auto
&
gtPath
:
gtPaths
)
{
BOOST_CHECK
(
std
::
any_of
(
paths
.
begin
(),
paths
.
end
(),
[
&
gtPath
,
&
isMatchingPath
](
const
auto
&
path
)
{
return
isMatchingPath
(
path
,
gtPath
);
}));
}
}
//BOOST_AUTO_TEST_CASE(testPathLength)
//{
// armarx::navigation::core::Path path{
// armarx::navigation::core::Pose(Eigen::Translation3f(0, 0, 0)),
// armarx::navigation::core::Pose(Eigen::Translation3f(0, 2000, 0)),
// armarx::navigation::core::Pose(Eigen::Translation3f(0, 4000, 0))};
// const auto traj = armarx::navigation::core::GlobalTrajectory::FromPath(path, 100);
// BOOST_CHECK_CLOSE(traj.length(), 4000, 0.01);
//}
//BOOST_AUTO_TEST_CASE(testResampleAlongLine)
//{
// armarx::navigation::core::Path path{
// armarx::navigation::core::Pose(Eigen::Translation3f(0, 0, 0)),
// armarx::navigation::core::Pose(Eigen::Translation3f(0, 2000, 0))};
// const auto traj = armarx::navigation::core::GlobalTrajectory::FromPath(path, 100);
// BOOST_CHECK_EQUAL(traj.points().size(), 2);
// const auto resampledTraj = traj.resample(500);
// for (const auto& pt : resampledTraj.positions())
// {
// ARMARX_DEBUG << VAROUT(pt);
// }
// BOOST_CHECK_EQUAL(resampledTraj.points().size(), 4);
//}
//BOOST_AUTO_TEST_CASE(testResampleAlongLineWithWaypoint)
//{
// armarx::navigation::core::Path path{
// armarx::navigation::core::Pose(Eigen::Translation3f(0, 0, 0)),
// armarx::navigation::core::Pose(Eigen::Translation3f(0, 1050, 0)),
// armarx::navigation::core::Pose(Eigen::Translation3f(0, 2100, 0))};
// const auto traj = armarx::navigation::core::GlobalTrajectory::FromPath(path, 100);
// BOOST_CHECK_EQUAL(traj.points().size(), 3);
// const auto resampledTraj = traj.resample(500);
// for (const auto& pt : resampledTraj.positions())
// {
// ARMARX_DEBUG << VAROUT(pt);
// }
// BOOST_CHECK_EQUAL(resampledTraj.points().size(), 5);
//}
//BOOST_AUTO_TEST_CASE(testGraphRoutes)
//{
// using namespace armarx::navigation;
// /*
// *
// * (0) -> (2) -> (3)
// * ^
// * |
// * (1)
// */
// core::Graph graph;
// graph.addVertex(semrel::ShapeID(0));
// graph.addVertex(semrel::ShapeID(1));
// graph.addVertex(semrel::ShapeID(2));
// graph.addVertex(semrel::ShapeID(3));
// graph.addEdge(semrel::ShapeID(0), semrel::ShapeID(2));
// graph.addEdge(semrel::ShapeID(1), semrel::ShapeID(2));
// graph.addEdge(semrel::ShapeID(2), semrel::ShapeID(3));
// const auto paths =
// armarx::navigation::core::findPathsTo(graph.vertex(semrel::ShapeID(3)), graph);
// // GT: paths
// // - {3}
// // - {2,3}
// // - {0,2,3}
// // - {1,2,3}
// BOOST_CHECK_EQUAL(paths.size(), 4);
// std::vector<std::vector<int>> gtPaths{{3}, {2, 3}, {0, 2, 3}, {1, 2, 3}};
// const auto isMatchingPath = [](const auto& path, const auto& gtPath)
// {
// if (path.size() != gtPath.size())
// {
// return false;
// }
// // check that sequences match
// for (const auto& [v, gtId] : ranges::views::zip(path, gtPath))
// {
// if (v.objectID().t != gtId)
// {
// return false;
// }
// }
// ARMARX_INFO << "Found matching path: " << VAROUT(path) << ", " << VAROUT(gtPath);
// return true;
// };
// // check that all required paths are available
// for (const auto& gtPath : gtPaths)
// {
// BOOST_CHECK(std::any_of(paths.begin(),
// paths.end(),
// [>Path, &isMatchingPath](const auto& path)
// { return isMatchingPath(path, gtPath); }));
// }
//}
Loading