Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Ale
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
aflab
astrogeology
Ale
Commits
9344dd42
Commit
9344dd42
authored
4 years ago
by
Jesse Mapel
Committed by
Jesse Mapel
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fixed no av seg fault
parent
62455a7f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Orientations.cpp
+10
-5
10 additions, 5 deletions
src/Orientations.cpp
tests/ctests/OrientationsTests.cpp
+43
-0
43 additions, 0 deletions
tests/ctests/OrientationsTests.cpp
with
53 additions
and
5 deletions
src/Orientations.cpp
+
10
−
5
View file @
9344dd42
...
...
@@ -84,7 +84,10 @@ namespace ale {
Vec3d
Orientations
::
interpolateAV
(
double
time
)
const
{
Vec3d
interpAv
;
if
(
m_times
.
size
()
>
1
)
{
if
(
m_avs
.
empty
())
{
throw
std
::
invalid_argument
(
"Cannot interpolate angular velocities for an orientation without them."
);
}
else
if
(
m_avs
.
size
()
>
1
)
{
int
interpIndex
=
interpolationIndex
(
m_times
,
time
);
double
t
=
(
time
-
m_times
[
interpIndex
])
/
(
m_times
[
interpIndex
+
1
]
-
m_times
[
interpIndex
]);
interpAv
=
Vec3d
(
linearInterpolate
(
m_avs
[
interpIndex
],
m_avs
[
interpIndex
+
1
],
t
));
...
...
@@ -144,11 +147,13 @@ namespace ale {
Rotation
inverseConst
=
m_constRotation
.
inverse
();
Rotation
rhsRot
=
rhs
.
interpolate
(
time
);
mergedRotations
.
push_back
(
inverseConst
*
interpolate
(
time
)
*
rhsRot
);
if
(
!
getAngularVelocities
().
empty
()
&&
!
rhs
.
getAngularVelocities
().
empty
())
{
Vec3d
combinedAv
=
rhsRot
.
inverse
()(
interpolateAV
(
time
));
Vec3d
rhsAv
=
rhs
.
interpolateAV
(
time
);
combinedAv
+=
rhsAv
;
mergedAvs
.
push_back
(
combinedAv
);
}
}
m_times
=
mergedTimes
;
m_rotations
=
mergedRotations
;
...
...
This diff is collapsed.
Click to expand it.
tests/ctests/OrientationsTests.cpp
+
43
−
0
View file @
9344dd42
...
...
@@ -30,6 +30,16 @@ class OrientationTest : public ::testing::Test {
Orientations
orientations
;
};
class
NoAVOrientationTest
:
public
OrientationTest
{
protected:
void
SetUp
()
override
{
OrientationTest
::
SetUp
();
noAvOrientations
=
Orientations
(
rotations
,
times
);
}
Orientations
noAvOrientations
;
};
class
ConstOrientationTest
:
public
OrientationTest
{
protected:
void
SetUp
()
override
{
...
...
@@ -151,6 +161,10 @@ TEST_F(OrientationTest, InterpolateAv) {
EXPECT_NEAR
(
interpAv
.
z
,
M_PI
/
(
3.0
*
sqrt
(
3.0
)),
1e-10
);
}
TEST_F
(
NoAVOrientationTest
,
InterpolateAv
)
{
EXPECT_ANY_THROW
(
noAvOrientations
.
interpolateAV
(
0.25
));
}
TEST_F
(
OrientationTest
,
RotateAt
)
{
Vec3d
rotatedX
=
orientations
.
rotateVectorAt
(
0.0
,
Vec3d
(
1.0
,
0.0
,
0.0
));
EXPECT_NEAR
(
rotatedX
.
x
,
0.0
,
1e-10
);
...
...
@@ -266,6 +280,35 @@ TEST_F(ConstOrientationTest, OrientationMultiplication) {
EXPECT_EQ
(
constQuats
[
1
],
1
);
EXPECT_EQ
(
constQuats
[
2
],
0
);
EXPECT_EQ
(
constQuats
[
3
],
0
);
const
vector
<
Vec3d
>
&
originalAVs
=
orientations
.
getAngularVelocities
();
const
vector
<
Vec3d
>
&
avs
=
multOrientation
.
getAngularVelocities
();
ASSERT_EQ
(
originalAVs
.
size
(),
avs
.
size
());
for
(
size_t
i
=
0
;
i
<
avs
.
size
();
i
++
)
{
// We are chaining the same rotation with itself so the angular velocities
// should just double
EXPECT_EQ
(
2
*
originalAVs
[
i
].
x
,
avs
[
i
].
x
);
EXPECT_EQ
(
2
*
originalAVs
[
i
].
y
,
avs
[
i
].
y
);
EXPECT_EQ
(
2
*
originalAVs
[
i
].
z
,
avs
[
i
].
z
);
}
}
TEST_F
(
NoAVOrientationTest
,
MultiplicationNoAV
)
{
Orientations
multOrientation
=
noAvOrientations
*
orientations
;
Orientations
multAVOrientation
=
orientations
*
orientations
;
vector
<
Rotation
>
outputRotations
=
multOrientation
.
getRotations
();
vector
<
Rotation
>
outputAVRotations
=
multAVOrientation
.
getRotations
();
ASSERT_EQ
(
outputRotations
.
size
(),
outputAVRotations
.
size
());
for
(
size_t
i
=
0
;
i
<
outputRotations
.
size
();
i
++
)
{
vector
<
double
>
quats
=
outputRotations
[
i
].
toQuaternion
();
vector
<
double
>
aVQuats
=
outputAVRotations
[
i
].
toQuaternion
();
EXPECT_EQ
(
aVQuats
[
0
],
quats
[
0
]);
EXPECT_EQ
(
aVQuats
[
1
],
quats
[
1
]);
EXPECT_EQ
(
aVQuats
[
2
],
quats
[
2
]);
EXPECT_EQ
(
aVQuats
[
3
],
quats
[
3
]);
}
EXPECT_TRUE
(
multOrientation
.
getAngularVelocities
().
empty
());
}
TEST_F
(
ConstOrientationTest
,
OrientationInverse
)
{
...
...
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