Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qgroundcontrol
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
Model registry
Operate
Environments
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
Valentin Platzgummer
qgroundcontrol
Commits
52dc821e
Commit
52dc821e
authored
11 years ago
by
Lorenz Meier
Browse files
Options
Downloads
Patches
Plain Diff
Added rotation of mag vector into body frame in HIL
parent
f9318458
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/comm/QGCXPlaneLink.cc
+50
-9
50 additions, 9 deletions
src/comm/QGCXPlaneLink.cc
with
50 additions
and
9 deletions
src/comm/QGCXPlaneLink.cc
+
50
−
9
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
)
{
...
...
@@ -651,11 +687,16 @@ void QGCXPlaneLink::readBytes()
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
);
}
simUpdateLast
=
QGC
::
groundTimeMilliseconds
();
}
if
(
!
oldConnectionState
&&
xPlaneConnected
)
{
emit
statusMessage
(
tr
(
"Receiving from XPlane."
));
...
...
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