Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
52dc821e
Commit
52dc821e
authored
Jul 02, 2013
by
Lorenz Meier
Browse files
Added rotation of mag vector into body frame in HIL
parent
f9318458
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/comm/QGCXPlaneLink.cc
View file @
52dc821e
...
...
@@ -524,8 +524,6 @@ void QGCXPlaneLink::readBytes()
roll
=
p
.
f
[
1
]
/
180.0
f
*
M_PI
;
yaw
=
p
.
f
[
2
]
/
180.0
f
*
M_PI
;
yaw
=
yaw
;
// X-Plane expresses yaw as 0..2 PI
if
(
yaw
>
M_PI
)
{
yaw
-=
2.0
*
M_PI
;
...
...
@@ -552,6 +550,43 @@ void QGCXPlaneLink::readBytes()
zmag
=
0.45
f
;
fields_changed
|=
(
1
<<
6
)
|
(
1
<<
7
)
|
(
1
<<
8
);
double
cosPhi
=
cos
(
roll
);
double
sinPhi
=
sin
(
roll
);
double
cosThe
=
cos
(
pitch
);
double
sinThe
=
sin
(
pitch
);
double
cosPsi
=
cos
(
0
);
double
sinPsi
=
sin
(
0
);
float
dcm
[
3
][
3
];
dcm
[
0
][
0
]
=
cosThe
*
cosPsi
;
dcm
[
0
][
1
]
=
-
cosPhi
*
sinPsi
+
sinPhi
*
sinThe
*
cosPsi
;
dcm
[
0
][
2
]
=
sinPhi
*
sinPsi
+
cosPhi
*
sinThe
*
cosPsi
;
dcm
[
1
][
0
]
=
cosThe
*
sinPsi
;
dcm
[
1
][
1
]
=
cosPhi
*
cosPsi
+
sinPhi
*
sinThe
*
sinPsi
;
dcm
[
1
][
2
]
=
-
sinPhi
*
cosPsi
+
cosPhi
*
sinThe
*
sinPsi
;
dcm
[
2
][
0
]
=
-
sinThe
;
dcm
[
2
][
1
]
=
sinPhi
*
cosThe
;
dcm
[
2
][
2
]
=
cosPhi
*
cosThe
;
Eigen
::
Matrix3f
m
=
Eigen
::
Map
<
Eigen
::
Matrix3f
>
((
float
*
)
dcm
).
eval
();
Eigen
::
Vector3f
mag
(
xmag
,
ymag
,
zmag
);
Eigen
::
Vector3f
magbody
=
m
*
mag
;
qDebug
()
<<
"yaw mag:"
<<
p
.
f
[
2
]
<<
"x"
<<
xmag
<<
"y"
<<
ymag
;
qDebug
()
<<
"yaw mag in body:"
<<
magbody
(
0
)
<<
magbody
(
1
)
<<
magbody
(
2
);
xmag
=
magbody
(
0
);
ymag
=
magbody
(
1
);
zmag
=
magbody
(
2
);
// Rotate the measurement vector into the body frame using roll and pitch
emitUpdate
=
true
;
}
...
...
@@ -570,7 +605,9 @@ void QGCXPlaneLink::readBytes()
{
vy
=
p
.
f
[
3
];
vx
=
-
p
.
f
[
5
];
vz
=
p
.
f
[
4
];
// moving 'up' in XPlane is positive, but its negative in NED
// for us.
vz
=
-
p
.
f
[
4
];
}
else
if
(
p
.
index
==
12
)
{
...
...
@@ -624,7 +661,6 @@ void QGCXPlaneLink::readBytes()
// Set state
simUpdateLastText
=
QGC
::
groundTimeMilliseconds
();
}
simUpdateLast
=
QGC
::
groundTimeMilliseconds
();
if
(
_sensorHilEnabled
)
{
...
...
@@ -647,13 +683,18 @@ void QGCXPlaneLink::readBytes()
emit
sensorHilGpsChanged
(
QGC
::
groundTimeUsecs
(),
lat
,
lon
,
alt
,
gps_fix_type
,
eph
,
epv
,
vel
,
vx
,
vy
,
vz
,
cog
,
satellites
);
}
else
{
emit
hilStateChanged
(
QGC
::
groundTimeUsecs
(),
roll
,
pitch
,
yaw
,
rollspeed
,
pitchspeed
,
yawspeed
,
lat
,
lon
,
alt
,
vx
,
vy
,
vz
,
ind_airspeed
,
true_airspeed
,
xacc
,
yacc
,
zacc
);
pitchspeed
,
yawspeed
,
lat
,
lon
,
alt
,
vx
,
vy
,
vz
,
ind_airspeed
,
true_airspeed
,
xacc
,
yacc
,
zacc
);
}
// Limit ground truth to 25 Hz
if
(
QGC
::
groundTimeMilliseconds
()
-
simUpdateLast
>
40
)
{
emit
hilGroundTruthChanged
(
QGC
::
groundTimeUsecs
(),
roll
,
pitch
,
yaw
,
rollspeed
,
pitchspeed
,
yawspeed
,
lat
,
lon
,
alt
,
vx
,
vy
,
vz
,
ind_airspeed
,
true_airspeed
,
xacc
,
yacc
,
zacc
);
}
emit
hilGroundTruthChanged
(
QGC
::
groundTimeUsecs
(),
roll
,
pitch
,
yaw
,
rollspeed
,
pitchspeed
,
yawspeed
,
lat
,
lon
,
alt
,
vx
,
vy
,
vz
,
ind_airspeed
,
true_airspeed
,
xacc
,
yacc
,
zacc
);
simUpdateLast
=
QGC
::
groundTimeMilliseconds
();
}
if
(
!
oldConnectionState
&&
xPlaneConnected
)
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment