Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
52dc821e
Commit
52dc821e
authored
Jul 02, 2013
by
Lorenz Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added rotation of mag vector into body frame in HIL
parent
f9318458
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
9 deletions
+50
-9
QGCXPlaneLink.cc
src/comm/QGCXPlaneLink.cc
+50
-9
No files found.
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
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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