Main Page
Related Pages
+
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
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
+
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
+
Enumerations
a
b
c
d
e
g
i
l
m
o
p
r
s
t
v
+
Enumerator
a
b
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
v
x
y
+
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
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
_
a
b
c
d
e
f
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
+
Enumerations
a
b
c
d
e
f
g
h
i
k
l
m
o
p
r
s
t
u
w
+
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
+
Properties
a
b
c
d
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
+
Related Functions
:
a
b
c
d
e
f
g
i
m
o
q
r
s
v
w
+
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
x
y
z
+
Functions
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
+
Variables
_
a
b
c
d
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
p
q
r
s
t
u
v
w
x
z
+
Enumerations
a
b
c
d
e
f
h
i
k
l
n
o
r
t
u
v
x
+
Enumerator
b
c
d
e
f
h
i
k
l
m
n
o
p
r
t
u
v
w
x
+
Macros
_
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
plotjuggler_base
src
special_messages.cpp
Go to the documentation of this file.
1
#include "
PlotJuggler/special_messages.h
"
2
#include <cmath>
3
4
PJ::Msg::RPY
PJ::Msg::QuaternionToRPY
(
PJ::Msg::Quaternion
q)
5
{
6
RPY
rpy;
7
8
double
quat_norm2 = (q.
w
* q.
w
) + (q.
x
* q.
x
) + (q.
y
* q.
y
) + (q.
z
* q.
z
);
9
if
(std::abs(quat_norm2 - 1.0) > std::numeric_limits<double>::epsilon())
10
{
11
double
mult = 1.0 / std::sqrt(quat_norm2);
12
q.
x
*= mult;
13
q.
y
*= mult;
14
q.
z
*= mult;
15
q.
w
*= mult;
16
}
17
18
// roll (x-axis rotation)
19
double
sinr_cosp = 2 * (q.
w
* q.
x
+ q.
y
* q.
z
);
20
double
cosr_cosp = 1 - 2 * (q.
x
* q.
x
+ q.
y
* q.
y
);
21
rpy.
roll
= std::atan2(sinr_cosp, cosr_cosp);
22
23
// pitch (y-axis rotation)
24
double
sinp = 2 * (q.
w
* q.
y
- q.
z
* q.
x
);
25
if
(std::abs(sinp) >= 1)
26
{
27
rpy.
pitch
= std::copysign(
M_PI_2
, sinp);
// use 90 degrees if out of range
28
}
29
else
30
{
31
rpy.
pitch
= std::asin(sinp);
32
}
33
34
// yaw (z-axis rotation)
35
double
siny_cosp = 2 * (q.
w
* q.
z
+ q.
x
* q.
y
);
36
double
cosy_cosp = 1 - 2 * (q.
y
* q.
y
+ q.
z
* q.
z
);
37
rpy.
yaw
= std::atan2(siny_cosp, cosy_cosp);
38
39
return
rpy;
40
}
PJ::Msg::QuaternionToRPY
RPY QuaternionToRPY(Quaternion q)
Definition:
special_messages.cpp:4
PJ::Msg::Quaternion::x
double x
Definition:
special_messages.h:63
M_PI_2
#define M_PI_2
Definition:
qwt_math.h:60
PJ::Msg::Quaternion::y
double y
Definition:
special_messages.h:64
PJ::Msg::RPY::roll
double roll
Definition:
special_messages.h:73
PJ::Msg::RPY::pitch
double pitch
Definition:
special_messages.h:74
PJ::Msg::Quaternion::z
double z
Definition:
special_messages.h:65
PJ::Msg::RPY::yaw
double yaw
Definition:
special_messages.h:75
PJ::Msg::RPY
Definition:
special_messages.h:71
special_messages.h
PJ::Msg::Quaternion::w
double w
Definition:
special_messages.h:66
PJ::Msg::Quaternion
Definition:
special_messages.h:61
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Jun 19 2023 03:12:53