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
d9a1e221
Commit
d9a1e221
authored
Oct 29, 2014
by
philipoe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added workaround/bugfix for the acceleration calculation in X-Plane-HIL-link
parent
ab2e4d8b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
21 deletions
+37
-21
QGCXPlaneLink.cc
src/comm/QGCXPlaneLink.cc
+36
-20
QGCXPlaneLink.h
src/comm/QGCXPlaneLink.h
+1
-1
No files found.
src/comm/QGCXPlaneLink.cc
View file @
d9a1e221
...
...
@@ -594,20 +594,35 @@ void QGCXPlaneLink::readBytes()
}
if
(
p
.
index
==
4
)
{
// Do not actually use the XPlane value, but calculate our own
Eigen
::
Vector3f
g
(
0
,
0
,
-
9.81
f
);
Eigen
::
Matrix3f
R
=
euler_to_wRo
(
yaw
,
pitch
,
roll
);
Eigen
::
Vector3f
gr
=
R
.
transpose
().
eval
()
*
g
;
// TODO Add centrip. accel
xacc
=
gr
[
0
];
yacc
=
gr
[
1
];
zacc
=
gr
[
2
];
fields_changed
|=
(
1
<<
0
)
|
(
1
<<
1
)
|
(
1
<<
2
);
// WORKAROUND: IF ground speed <<1m/s and altitude-above-ground <1m, do NOT use the X-Plane data, because X-Plane (tested
// with v10.3 and earlier) delivers yacc=0 and zacc=0 when the ground speed is very low, which gives e.g. wrong readings
// before launch when waiting on the runway. This might pose a problem for initial state estimation/calibration.
// Instead, we calculate our own accelerations.
if
(
fabsf
(
groundspeed
)
<
0.1
f
&&
alt_agl
<
1.0
)
{
// TODO: Add centrip. acceleration to the current static acceleration implementation.
Eigen
::
Vector3f
g
(
0
,
0
,
-
9.81
f
);
Eigen
::
Matrix3f
R
=
euler_to_wRo
(
yaw
,
pitch
,
roll
);
Eigen
::
Vector3f
gr
=
R
.
transpose
().
eval
()
*
g
;
xacc
=
gr
[
0
];
yacc
=
gr
[
1
];
zacc
=
gr
[
2
];
//qDebug() << "Calculated values" << gr[0] << gr[1] << gr[2];
}
else
{
// Accelerometer readings, directly from X-Plane and including centripetal forces.
const
float
one_g
=
9.80665
f
;
xacc
=
p
.
f
[
5
]
*
one_g
;
yacc
=
p
.
f
[
6
]
*
one_g
;
zacc
=
-
p
.
f
[
4
]
*
one_g
;
//qDebug() << "X-Plane values" << xacc << yacc << zacc;
}
fields_changed
|=
(
1
<<
0
)
|
(
1
<<
1
)
|
(
1
<<
2
);
}
else
if
(
p
.
index
==
6
&&
xPlaneVersion
==
10
)
{
...
...
@@ -712,12 +727,13 @@ void QGCXPlaneLink::readBytes()
// {
// qDebug() << "ATT:" << p.f[0] << p.f[1] << p.f[2];
// }
else
if
(
p
.
index
==
20
)
{
//qDebug() << "LAT/LON/ALT:" << p.f[0] << p.f[1] << p.f[2];
lat
=
p
.
f
[
0
];
lon
=
p
.
f
[
1
];
alt
=
p
.
f
[
2
]
*
0.3048
f
;
// convert feet (MSL) to meters
else
if
(
p
.
index
==
20
)
{
//qDebug() << "LAT/LON/ALT:" << p.f[0] << p.f[1] << p.f[2];
lat
=
p
.
f
[
0
];
lon
=
p
.
f
[
1
];
alt
=
p
.
f
[
2
]
*
0.3048
f
;
// convert feet (MSL) to meters
alt_agl
=
p
.
f
[
3
]
*
0.3048
f
;
//convert feet (AGL) to meters
}
else
if
(
p
.
index
==
21
&&
xPlaneVersion
==
10
)
{
...
...
src/comm/QGCXPlaneLink.h
View file @
d9a1e221
...
...
@@ -191,7 +191,7 @@ protected:
bool
attitudeReceived
;
float
roll
,
pitch
,
yaw
,
rollspeed
,
pitchspeed
,
yawspeed
;
double
lat
,
lon
,
alt
;
double
lat
,
lon
,
alt
,
alt_agl
;
float
vx
,
vy
,
vz
,
xacc
,
yacc
,
zacc
;
float
ind_airspeed
;
float
true_airspeed
;
...
...
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