Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
x
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
f
g
i
j
l
m
n
p
q
r
s
t
u
v
x
y
z
Enumerations
Enumerator
a
b
c
e
f
g
j
l
m
o
p
r
s
u
v
w
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
p
q
r
s
t
u
v
z
Enumerations
Enumerator
a
b
c
d
f
i
l
m
n
o
r
s
u
v
Related Functions
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Functions
a
b
c
d
e
f
g
i
j
l
m
n
o
p
q
r
s
t
u
w
Variables
a
b
c
d
e
f
g
h
i
k
l
m
o
p
r
s
t
u
v
Typedefs
a
c
d
g
j
m
p
r
s
t
v
Enumerator
Macros
_
a
b
d
e
f
h
i
j
k
m
o
p
q
r
s
v
Examples
unittest
quaternion.cpp
Go to the documentation of this file.
1
//
2
// Copyright (c) 2019-2020 INRIA CNRS
3
//
4
5
#include <
pinocchio/math/quaternion.hpp
>
6
#include <
pinocchio/spatial/se3.hpp
>
7
8
#include <boost/variant.hpp>
// to avoid C99 warnings
9
10
#include <boost/test/unit_test.hpp>
11
#include <boost/utility/binary.hpp>
12
13
BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
14
15
BOOST_AUTO_TEST_CASE
(test_assignQuaternion)
16
{
17
using namespace
pinocchio
;
18
const
int
max_tests = 1e5;
19
for
(
int
k = 0; k < max_tests; ++k)
20
{
21
const
SE3
M
(SE3::Random());
22
SE3::Quaternion
quat_ref(
M
.rotation());
23
24
SE3::Quaternion
quat
;
25
quaternion::assignQuaternion
(
quat
,
M
.rotation());
26
27
BOOST_CHECK(
quat
.coeffs().isApprox(quat_ref.coeffs()));
28
}
29
}
30
31
BOOST_AUTO_TEST_CASE
(test_uniformRandom)
32
{
33
srand(0);
34
35
using namespace
pinocchio
;
36
Eigen::Quaternion<double>
q
;
37
38
for
(
int
i
= 0;
i
< (1 << 10); ++
i
)
39
{
40
quaternion::uniformRandom
(
q
);
41
BOOST_CHECK_MESSAGE(
42
(
q
.coeffs().array().abs() <= 1).all(),
43
"Quaternion coeffs out of bounds: "
<<
i
<<
' '
<<
q
.coeffs().transpose());
44
}
45
}
46
47
BOOST_AUTO_TEST_CASE
(test_isNormalized)
48
{
49
srand(0);
50
51
using namespace
pinocchio
;
52
typedef
Eigen::Quaternion<double>
Quaternion
;
53
typedef
Quaternion::Coefficients Vector4;
54
55
#ifdef NDEBUG
56
const
int
max_test = 1e6;
57
#else
58
const
int
max_test = 1e2;
59
#endif
60
for
(
int
i
= 0;
i
< max_test; ++
i
)
61
{
62
Quaternion
q
;
63
q
.coeffs() = Vector4::Random() + Vector4::Constant(2);
64
BOOST_CHECK(!
quaternion::isNormalized
(
q
));
65
66
q
.normalize();
67
BOOST_CHECK(
quaternion::isNormalized
(
q
));
68
}
69
70
// Specific check for the Zero vector
71
BOOST_CHECK(!
quaternion::isNormalized
(
Quaternion
(Vector4::Zero())));
72
}
73
74
BOOST_AUTO_TEST_SUITE_END()
quaternion.hpp
pinocchio::quaternion::uniformRandom
void uniformRandom(Eigen::QuaternionBase< Derived > &q)
Uniformly random quaternion sphere.
Definition:
math/quaternion.hpp:115
quat
quat
pinocchio::SE3
context::SE3 SE3
Definition:
spatial/fwd.hpp:59
inverse-kinematics.i
int i
Definition:
inverse-kinematics.py:17
pinocchio::quaternion::assignQuaternion
void assignQuaternion(Eigen::QuaternionBase< D > &quat, const Eigen::MatrixBase< Matrix3 > &R)
Definition:
math/quaternion.hpp:215
pinocchio::quaternion::isNormalized
bool isNormalized(const Eigen::QuaternionBase< Quaternion > &quat, const typename Quaternion::Coefficients::RealScalar &prec)
Check whether the input quaternion is Normalized within the given precision.
Definition:
math/quaternion.hpp:230
pinocchio::python::context::Quaternion
Eigen::Quaternion< Scalar, Options > Quaternion
Definition:
bindings/python/context/generic.hpp:49
se3.hpp
M
M
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(test_assignQuaternion)
Definition:
quaternion.cpp:15
pinocchio::q
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
Definition:
joint-configuration.hpp:1083
pinocchio
Main pinocchio namespace.
Definition:
timings.cpp:33
pinocchio
Author(s):
autogenerated on Thu Apr 10 2025 02:42:21