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
adba6059
Commit
adba6059
authored
Apr 24, 2010
by
pixhawk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed finally HUD offset! Now working on antialiasing / flickering.
parent
0bdc6c34
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
28 deletions
+38
-28
UAS.cc
src/uas/UAS.cc
+1
-1
HUD.cc
src/ui/HUD.cc
+37
-27
No files found.
src/uas/UAS.cc
View file @
adba6059
...
...
@@ -430,7 +430,7 @@ void UAS::sendMessage(LinkInterface* link, mavlink_message_t message)
*/
const
float
UAS
::
filterVoltage
(
float
value
)
{
return
lpVoltage
*
0.
8
f
+
value
*
0.2
f
;
return
lpVoltage
*
0.
7
f
+
value
*
0.3
f
;
/*
currentVoltage = value;
static QList<float> voltages<float>(20);
...
...
src/ui/HUD.cc
View file @
adba6059
...
...
@@ -388,12 +388,17 @@ void HUD::paintCenterBackground(float roll, float pitch, float yaw)
// Move to the center of the window
glTranslatef
(
referenceWidth
/
2.0
f
,
referenceHeight
/
2.0
f
,
0
);
// Move based on the yaw difference
glTranslatef
(
yaw
,
0.0
f
,
0.0
f
);
// Rotate based on the bank
glRotatef
((
roll
/
M_PI
)
*
180.0
f
,
0
,
0
,
1
);
glRotatef
((
roll
/
M_PI
)
*
180.0
f
,
0
.0
f
,
0.0
f
,
1.0
f
);
// Translate in the direction of the rotation based
// on the pitch. On the 777, a pitch of 1 degree = 2 mm
glTranslatef
(
0
,
((
-
pitch
/
M_PI
)
*
180.0
f
*
vPitchPerDeg
),
0
);
//glTranslatef(0, ((-pitch/M_PI)*180.0f * vPitchPerDeg), 0);
glTranslatef
(
0.0
f
,
(
pitch
*
vPitchPerDeg
*
16.5
f
),
0.0
f
);
// Ground
glColor3ub
(
179
,
102
,
0
);
...
...
@@ -528,6 +533,29 @@ void HUD::paintEvent(QPaintEvent *event)
pitch
=
pitch
*
0.3
+
0.7
*
values
.
value
(
"pitch"
,
0.0
f
);
yaw
=
yaw
*
0.3
+
0.7
*
values
.
value
(
"yaw"
,
0.0
f
);
// Translate for yaw
const
float
maxYawTrans
=
60.0
f
;
static
float
yawDiff
=
0.0
f
;
float
newYawDiff
=
valuesDot
.
value
(
"yaw"
,
0.0
f
);
if
(
isinf
(
newYawDiff
))
newYawDiff
=
yawDiff
;
if
(
newYawDiff
>
M_PI
)
newYawDiff
=
newYawDiff
-
M_PI
;
if
(
newYawDiff
<
-
M_PI
)
newYawDiff
=
newYawDiff
+
M_PI
;
newYawDiff
=
yawDiff
*
0.8
+
newYawDiff
*
0.2
;
yawDiff
=
newYawDiff
;
yawInt
+=
newYawDiff
;
if
(
yawInt
>
M_PI
)
yawInt
=
M_PI
;
if
(
yawInt
<
-
M_PI
)
yawInt
=
-
M_PI
;
float
yawTrans
=
yawInt
*
(
double
)
maxYawTrans
;
yawInt
*=
0.6
f
;
//qDebug() << "yaw translation" << yawTrans << "integral" << yawInt << "difference" << yawDiff << "yaw" << yaw << "asin(yawInt)" << asinYaw;
// Update scaling factor
// adjust scaling to fit both horizontally and vertically
...
...
@@ -545,7 +573,7 @@ void HUD::paintEvent(QPaintEvent *event)
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
// Blue / Brown background
if
(
noCamera
)
paintCenterBackground
(
roll
,
pitch
,
yaw
);
if
(
noCamera
)
paintCenterBackground
(
roll
,
pitch
,
yaw
Trans
);
glMatrixMode
(
GL_MODELVIEW
);
glPopMatrix
();
...
...
@@ -556,11 +584,11 @@ void HUD::paintEvent(QPaintEvent *event)
//glEnable(GL_MULTISAMPLE);
// QT PAINTING
makeCurrent
();
//
makeCurrent();
QPainter
painter
;
painter
.
begin
(
this
);
painter
.
setRenderHint
(
QPainter
::
Antialiasing
,
true
);
//
painter.setRenderHint(QPainter::HighQualityAntialiasing, true);
painter
.
setRenderHint
(
QPainter
::
HighQualityAntialiasing
,
true
);
painter
.
translate
((
this
->
vwidth
/
2.0
+
xCenterOffset
)
*
scalingFactor
,
(
this
->
vheight
/
2.0
+
yCenterOffset
)
*
scalingFactor
);
...
...
@@ -665,37 +693,19 @@ void HUD::paintEvent(QPaintEvent *event)
// MOVING PARTS
// Translate for yaw
const
float
maxYawTrans
=
60.0
f
;
float
yawDiff
=
valuesDot
.
value
(
"yaw"
,
0.0
f
);
if
(
isinf
(
yawDiff
))
yawDiff
=
0.0
f
;
if
(
yawDiff
>
M_PI
)
yawDiff
=
yawDiff
-
M_PI
;
if
(
yawDiff
<
-
M_PI
)
yawDiff
=
yawDiff
+
M_PI
;
yawInt
+=
yawDiff
;
if
(
yawInt
>
M_PI
)
yawInt
=
M_PI
;
if
(
yawInt
<
-
M_PI
)
yawInt
=
-
M_PI
;
float
yawTrans
=
yawInt
*
(
double
)
maxYawTrans
;
yawInt
*=
0.6
f
;
//qDebug() << "yaw translation" << yawTrans << "integral" << yawInt << "difference" << yawDiff << "yaw" << yaw << "asin(yawInt)" << asinYaw;
painter
.
translate
(
0
,
(
pitch
/
M_PI
)
*
-
180.0
f
*
refToScreenY
(
1.8
));
//painter.translate(refToScreenX(yawTrans), 0);
painter
.
translate
(
refToScreenX
(
yawTrans
),
0
);
// Rotate view and draw all roll-dependent indicators
painter
.
rotate
((
roll
/
M_PI
)
*
-
180.0
f
);
painter
.
translate
(
0
,
(
pitch
/
M_PI
)
*
-
180.0
f
*
refToScreenY
(
1.8
));
//qDebug() << "ROLL" << roll << "PITCH" << pitch << "YAW DIFF" << valuesDot.value("roll", 0.0f);
// PITCH
paintPitchLines
(
(
pitch
/
M_PI
)
*
180.0
f
,
&
painter
);
paintPitchLines
(
pitch
,
&
painter
);
painter
.
end
();
//glDisable(GL_MULTISAMPLE);
...
...
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