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
Commits
c022189f
Commit
c022189f
authored
2 years ago
by
Timo Weberruß
Browse files
Options
Downloads
Patches
Plain Diff
Fix bugs in OrientationDistance
parent
5f84402e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!109
Social layers
,
!55
Draft: Implement human grouping
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
source/armarx/navigation/human/OrientationDistance.cpp
+6
-7
6 additions, 7 deletions
source/armarx/navigation/human/OrientationDistance.cpp
source/armarx/navigation/human/test/human_test.cpp
+24
-19
24 additions, 19 deletions
source/armarx/navigation/human/test/human_test.cpp
with
30 additions
and
26 deletions
source/armarx/navigation/human/OrientationDistance.cpp
+
6
−
7
View file @
c022189f
...
...
@@ -24,8 +24,8 @@ namespace armarx::navigation::human
OrientationDistance
::
getOrientationFactor
(
const
Human
&
h1
,
const
Human
&
h2
)
{
const
double
lineOrientation
=
getLineOrientation
(
h2
,
h1
);
const
double
angleH1
=
Eigen
::
Rotation2Dd
(
h1
.
pose
.
linear
()).
angle
();
const
double
angleH2
=
Eigen
::
Rotation2Dd
(
h2
.
pose
.
linear
()).
angle
();
const
double
angleH1
=
normOrientation
(
Eigen
::
Rotation2Dd
(
h1
.
pose
.
linear
()).
angle
()
/
M_PI
)
;
const
double
angleH2
=
normOrientation
(
Eigen
::
Rotation2Dd
(
h2
.
pose
.
linear
()).
angle
()
/
M_PI
)
;
printf
(
"line orientation = %.2f
\n
"
,
lineOrientation
);
printf
(
"angle h1 = %.2f, angle h2 = %.2f
\n
"
,
angleH1
,
angleH2
);
...
...
@@ -41,22 +41,21 @@ namespace armarx::navigation::human
}
double
OrientationDistance
::
getLineOrientation
(
const
Human
&
h
2
,
const
Human
&
h
1
)
OrientationDistance
::
getLineOrientation
(
const
Human
&
h
1
,
const
Human
&
h
2
)
{
const
double
dx
=
(
h1
.
pose
.
translation
()
-
h2
.
pose
.
translation
()).
x
();
const
double
dy
=
(
h1
.
pose
.
translation
()
-
h2
.
pose
.
translation
()).
y
();
const
double
lineOrientation
=
atan2
(
dy
,
dx
);
const
double
lineOrientation
=
atan2
(
dy
,
dx
)
/
M_PI
;
return
lineOrientation
;
}
//
scale
s orientation to (-1, 1]
//
bring
s orientation to (-1, 1]
double
OrientationDistance
::
normOrientation
(
const
double
orientation
)
{
double
convertedOrientation
=
orientation
/
M_PI
;
// brings orientation to [0, 2)
convertedOrientation
=
std
::
fmod
(((
std
::
fmod
(
convertedO
rientation
,
2
))
+
2
),
2
);
double
convertedOrientation
=
std
::
fmod
(((
std
::
fmod
(
o
rientation
,
2
))
+
2
),
2
);
// brings orientation to [-1, 1)
convertedOrientation
-=
static_cast
<
int
>
(
convertedOrientation
>
1
)
*
2
;
return
convertedOrientation
;
...
...
This diff is collapsed.
Click to expand it.
source/armarx/navigation/human/test/human_test.cpp
+
24
−
19
View file @
c022189f
...
...
@@ -30,7 +30,9 @@
#include
<SemanticObjectRelations/Shapes/Shape.h>
#include
<armarx/navigation/core/Trajectory.h>
#include
<armarx/navigation/human/EuclideanDistance.h>
#include
<armarx/navigation/human/OrientationDistance.h>
#include
<range/v3/view/zip.hpp>
#include
<math.h>
// test includes and other stuff
#define BOOST_TEST_MODULE Navigation::ArmarXLibraries::core
...
...
@@ -38,11 +40,11 @@
#include
<armarx/navigation/Test.h>
#include
<armarx/navigation/core/basic_types.h>
#include
<armarx/navigation/human/OrientationDistance.h>
#include
<armarx/navigation/human/types.h>
using
armarx
::
navigation
::
core
::
Pose2D
;
using
armarx
::
navigation
::
human
::
EuclideanDistance
;
using
armarx
::
navigation
::
human
::
OrientationDistance
;
using
armarx
::
navigation
::
human
::
Human
;
BOOST_AUTO_TEST_CASE
(
testEuclideanDistance1_standardDistance
)
...
...
@@ -63,28 +65,31 @@ BOOST_AUTO_TEST_CASE(testEuclideanDistance1_standardDistance)
.
detectionTime
=
armarx
::
DateTime
::
Now
()};
double
d
=
distance
.
computeDistance
(
h1
,
h2
);
ARMARX_INFO
<<
"Distance is"
+
std
::
to_string
(
d
);
printf
(
"Distance is %.2f
\n
"
,
d
);
BOOST_CHECK_CLOSE
(
d
,
5
,
0.001
);
}
//BOOST_AUTO_TEST_CASE(testOrientationDistance1_faceToFace)
//{
// const OrientationDistance distance = OrientationDistance();
// Pose2D pose1 = Pose2D::Identity();
// pose1.translation() = Eigen::Vector2f(0, 0);
// pose1.linear() = Eigen::Rotation2Df(0).toRotationMatrix();
// const Human h1 = {.pose = pose1,
// .linearVelocity = Eigen::Vector2f(0.2, 0.1),
// .detectionTime = armarx::DateTime::Now()};
// Pose2D pose2 = Pose2D::Identity();
// pose2.translation() = Eigen::Vector2f(1, 0);
// pose2.linear() = Eigen::Rotation2Df(2.3).toRotationMatrix();
// const Human h2 = {.pose = pose2,
// .linearVelocity = Eigen::Vector2f(0.5, 0.8),
// .detectionTime = armarx::DateTime::Now()};
BOOST_AUTO_TEST_CASE
(
testOrientationDistance1_faceToFace
)
{
const
OrientationDistance
distance
=
OrientationDistance
(
1
,
0
);
Pose2D
pose1
=
Pose2D
::
Identity
();
pose1
.
translation
()
=
Eigen
::
Vector2f
(
0
,
0
);
pose1
.
linear
()
=
Eigen
::
Rotation2Df
(
0
).
toRotationMatrix
();
const
Human
h1
=
{.
pose
=
pose1
,
.
linearVelocity
=
Eigen
::
Vector2f
(
0.2
,
0.1
),
.
detectionTime
=
armarx
::
DateTime
::
Now
()};
//}
Pose2D
pose2
=
Pose2D
::
Identity
();
pose2
.
translation
()
=
Eigen
::
Vector2f
(
1
,
0
);
pose2
.
linear
()
=
Eigen
::
Rotation2Df
(
M_PI
).
toRotationMatrix
();
const
Human
h2
=
{.
pose
=
pose2
,
.
linearVelocity
=
Eigen
::
Vector2f
(
0.5
,
0.8
),
.
detectionTime
=
armarx
::
DateTime
::
Now
()};
double
d
=
distance
.
computeDistance
(
h1
,
h2
);
printf
(
"Distance is %.2f
\n
"
,
d
);
BOOST_CHECK
(
d
<
0.001
);
}
//BOOST_AUTO_TEST_CASE(testPathLength)
//{
...
...
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