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
6103a554
Commit
6103a554
authored
Oct 11, 2015
by
Lorenz Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UAS: Fix battery status lowpass and only publish values when battery measurements are valid
parent
9b75d0dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
+14
-9
UAS.cc
src/uas/UAS.cc
+14
-9
No files found.
src/uas/UAS.cc
View file @
6103a554
...
@@ -73,7 +73,7 @@ UAS::UAS(MAVLinkProtocol* protocol, Vehicle* vehicle) : UASInterface(),
...
@@ -73,7 +73,7 @@ UAS::UAS(MAVLinkProtocol* protocol, Vehicle* vehicle) : UASInterface(),
tickLowpassVoltage
(
12.0
f
),
tickLowpassVoltage
(
12.0
f
),
warnLevelPercent
(
UAS_DEFAULT_BATTERY_WARNLEVEL
),
warnLevelPercent
(
UAS_DEFAULT_BATTERY_WARNLEVEL
),
currentVoltage
(
12.6
f
),
currentVoltage
(
12.6
f
),
lpVoltage
(
12
.0
f
),
lpVoltage
(
-
1
.0
f
),
currentCurrent
(
0.4
f
),
currentCurrent
(
0.4
f
),
chargeLevel
(
-
1
),
chargeLevel
(
-
1
),
lowBattAlarm
(
false
),
lowBattAlarm
(
false
),
...
@@ -495,11 +495,11 @@ void UAS::receiveMessage(mavlink_message_t message)
...
@@ -495,11 +495,11 @@ void UAS::receiveMessage(mavlink_message_t message)
emit
loadChanged
(
this
,
state
.
load
/
10.0
f
);
emit
loadChanged
(
this
,
state
.
load
/
10.0
f
);
emit
valueChanged
(
uasId
,
name
.
arg
(
"load"
),
"%"
,
state
.
load
/
10.0
f
,
time
);
emit
valueChanged
(
uasId
,
name
.
arg
(
"load"
),
"%"
,
state
.
load
/
10.0
f
,
time
);
if
(
state
.
voltage_battery
!=
UINT16_MAX
)
{
if
(
state
.
voltage_battery
>
0.0
f
&&
state
.
voltage_battery
!=
UINT16_MAX
)
{
// Battery charge/time remaining/voltage calculations
// Battery charge/time remaining/voltage calculations
currentVoltage
=
state
.
voltage_battery
/
1000.0
f
;
currentVoltage
=
state
.
voltage_battery
/
1000.0
f
;
lpVoltage
=
filterVoltage
(
currentVoltage
);
filterVoltage
(
currentVoltage
);
tickLowpassVoltage
=
tickLowpassVoltage
*
0.8
f
+
0.2
f
*
currentVoltage
;
tickLowpassVoltage
=
tickLowpassVoltage
*
0.8
f
+
0.2
f
*
currentVoltage
;
// We don't want to tick above the threshold
// We don't want to tick above the threshold
if
(
tickLowpassVoltage
>
tickVoltage
)
if
(
tickLowpassVoltage
>
tickVoltage
)
...
@@ -514,10 +514,10 @@ void UAS::receiveMessage(mavlink_message_t message)
...
@@ -514,10 +514,10 @@ void UAS::receiveMessage(mavlink_message_t message)
&&
(
currentVoltage
>
3.3
f
)
&&
(
currentVoltage
>
3.3
f
)
/* warn only if current voltage is really still lower by a reasonable amount */
/* warn only if current voltage is really still lower by a reasonable amount */
&&
((
currentVoltage
-
0.2
f
)
<
tickVoltage
)
&&
((
currentVoltage
-
0.2
f
)
<
tickVoltage
)
/* warn only every
12
seconds */
/* warn only every
20
seconds */
&&
(
QGC
::
groundTimeUsecs
()
-
lastVoltageWarning
)
>
12
000000
)
&&
(
QGC
::
groundTimeUsecs
()
-
lastVoltageWarning
)
>
20
000000
)
{
{
_say
(
QString
(
"
Voltage warning for
system %1: %2 volts"
).
arg
(
getUASID
()).
arg
(
lpVoltage
,
0
,
'f'
,
1
,
QChar
(
' '
)));
_say
(
QString
(
"
Low battery
system %1: %2 volts"
).
arg
(
getUASID
()).
arg
(
lpVoltage
,
0
,
'f'
,
1
,
QChar
(
' '
)));
lastVoltageWarning
=
QGC
::
groundTimeUsecs
();
lastVoltageWarning
=
QGC
::
groundTimeUsecs
();
lastTickVoltageValue
=
tickLowpassVoltage
;
lastTickVoltageValue
=
tickLowpassVoltage
;
}
}
...
@@ -1557,9 +1557,14 @@ quint64 UAS::getUnixTime(quint64 time)
...
@@ -1557,9 +1557,14 @@ quint64 UAS::getUnixTime(quint64 time)
/**
/**
* @param value battery voltage
* @param value battery voltage
*/
*/
float
UAS
::
filterVoltage
(
float
value
)
const
float
UAS
::
filterVoltage
(
float
value
)
{
{
return
lpVoltage
*
0.6
f
+
value
*
0.4
f
;
if
(
lpVoltage
<
0.0
f
)
{
lpVoltage
=
value
;
}
lpVoltage
=
lpVoltage
*
0.6
f
+
value
*
0.4
f
;
return
lpVoltage
;
}
}
/**
/**
...
...
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