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
0f6fee56
Commit
0f6fee56
authored
Oct 11, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1949 from mavlink/battery_fix
Battery indication fixes
parents
7797d824
ea61dbd4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
34 deletions
+42
-34
Vehicle.cc
src/Vehicle/Vehicle.cc
+1
-1
UAS.cc
src/uas/UAS.cc
+37
-29
UAS.h
src/uas/UAS.h
+1
-1
MainToolBar.qml
src/ui/toolbar/MainToolBar.qml
+3
-3
No files found.
src/Vehicle/Vehicle.cc
View file @
0f6fee56
...
@@ -77,7 +77,7 @@ Vehicle::Vehicle(LinkInterface* link, int vehicleId, MAV_AUTOPILOT firmwareType,
...
@@ -77,7 +77,7 @@ Vehicle::Vehicle(LinkInterface* link, int vehicleId, MAV_AUTOPILOT firmwareType,
,
_latitude
(
DEFAULT_LAT
)
,
_latitude
(
DEFAULT_LAT
)
,
_longitude
(
DEFAULT_LON
)
,
_longitude
(
DEFAULT_LON
)
,
_refreshTimer
(
new
QTimer
(
this
))
,
_refreshTimer
(
new
QTimer
(
this
))
,
_batteryVoltage
(
0.0
)
,
_batteryVoltage
(
-
1.0
f
)
,
_batteryPercent
(
0.0
)
,
_batteryPercent
(
0.0
)
,
_batteryConsumed
(
-
1.0
)
,
_batteryConsumed
(
-
1.0
)
,
_currentHeartbeatTimeout
(
0
)
,
_currentHeartbeatTimeout
(
0
)
...
...
src/uas/UAS.cc
View file @
0f6fee56
...
@@ -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,36 +495,39 @@ void UAS::receiveMessage(mavlink_message_t message)
...
@@ -495,36 +495,39 @@ 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
);
// Battery charge/time remaining/voltage calculations
if
(
state
.
voltage_battery
>
0.0
f
&&
state
.
voltage_battery
!=
UINT16_MAX
)
{
currentVoltage
=
state
.
voltage_battery
/
1000.0
f
;
// Battery charge/time remaining/voltage calculations
lpVoltage
=
filterVoltage
(
currentVoltage
);
currentVoltage
=
state
.
voltage_battery
/
1000.0
f
;
tickLowpassVoltage
=
tickLowpassVoltage
*
0.8
f
+
0.2
f
*
currentVoltage
;
filterVoltage
(
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
)
{
{
lastTickVoltageValue
=
tickLowpassVoltage
;
lastTickVoltageValue
=
tickLowpassVoltage
;
}
}
if
((
startVoltage
>
0.0
f
)
&&
(
tickLowpassVoltage
<
tickVoltage
)
&&
(
fabs
(
lastTickVoltageValue
-
tickLowpassVoltage
)
>
0.1
f
)
if
((
startVoltage
>
0.0
f
)
&&
(
tickLowpassVoltage
<
tickVoltage
)
&&
(
fabs
(
lastTickVoltageValue
-
tickLowpassVoltage
)
>
0.1
f
)
/* warn if lower than treshold */
/* warn if lower than treshold */
&&
(
lpVoltage
<
tickVoltage
)
&&
(
lpVoltage
<
tickVoltage
)
/* warn only if we have at least the voltage of an empty LiPo cell, else we're sampling something wrong */
/* warn only if we have at least the voltage of an empty LiPo cell, else we're sampling something wrong */
&&
(
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
)
>
12000000
)
&&
(
QGC
::
groundTimeUsecs
()
-
lastVoltageWarning
)
>
20000000
)
{
{
_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
;
}
}
if
(
startVoltage
==
-
1.0
f
&&
currentVoltage
>
0.1
f
)
startVoltage
=
currentVoltage
;
chargeLevel
=
state
.
battery_remaining
;
if
(
startVoltage
==
-
1.0
f
&&
currentVoltage
>
0.1
f
)
startVoltage
=
currentVoltage
;
emit
batteryChanged
(
this
,
lpVoltage
,
currentCurrent
,
getChargeLevel
(),
0
)
;
chargeLevel
=
state
.
battery_remaining
;
}
emit
batteryChanged
(
this
,
lpVoltage
,
currentCurrent
,
getChargeLevel
(),
0
);
emit
valueChanged
(
uasId
,
name
.
arg
(
"battery_remaining"
),
"%"
,
getChargeLevel
(),
time
);
emit
valueChanged
(
uasId
,
name
.
arg
(
"battery_remaining"
),
"%"
,
getChargeLevel
(),
time
);
emit
valueChanged
(
uasId
,
name
.
arg
(
"battery_voltage"
),
"V"
,
currentVoltage
,
time
);
emit
valueChanged
(
uasId
,
name
.
arg
(
"battery_voltage"
),
"V"
,
currentVoltage
,
time
);
...
@@ -1554,9 +1557,14 @@ quint64 UAS::getUnixTime(quint64 time)
...
@@ -1554,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
;
}
}
/**
/**
...
...
src/uas/UAS.h
View file @
0f6fee56
...
@@ -85,7 +85,7 @@ public:
...
@@ -85,7 +85,7 @@ public:
/** @brief The time interval the robot is switched on */
/** @brief The time interval the robot is switched on */
quint64
getUptime
()
const
;
quint64
getUptime
()
const
;
/** @brief Add one measurement and get low-passed voltage */
/** @brief Add one measurement and get low-passed voltage */
float
filterVoltage
(
float
value
)
const
;
float
filterVoltage
(
float
value
);
Q_PROPERTY
(
double
localX
READ
getLocalX
WRITE
setLocalX
NOTIFY
localXChanged
)
Q_PROPERTY
(
double
localX
READ
getLocalX
WRITE
setLocalX
NOTIFY
localXChanged
)
Q_PROPERTY
(
double
localY
READ
getLocalY
WRITE
setLocalY
NOTIFY
localYChanged
)
Q_PROPERTY
(
double
localY
READ
getLocalY
WRITE
setLocalY
NOTIFY
localYChanged
)
...
...
src/ui/toolbar/MainToolBar.qml
View file @
0f6fee56
...
@@ -479,7 +479,7 @@ Rectangle {
...
@@ -479,7 +479,7 @@ Rectangle {
QGCLabel
{
QGCLabel
{
visible
:
batteryStatus
.
visible
&&
activeVehicle
.
batteryConsumed
<
0.0
visible
:
batteryStatus
.
visible
&&
activeVehicle
.
batteryConsumed
<
0.0
text
:
activeVehicle
.
batteryVoltage
.
toFixed
(
1
)
+
'
V
'
;
text
:
(
activeVehicle
.
batteryVoltage
>
0
)
?
activeVehicle
.
batteryVoltage
.
toFixed
(
1
)
+
'
V
'
:
'
---
'
;
font.pixelSize
:
ScreenTools
.
smallFontPixelSize
font.pixelSize
:
ScreenTools
.
smallFontPixelSize
font.weight
:
Font
.
DemiBold
font.weight
:
Font
.
DemiBold
anchors.right
:
parent
.
right
anchors.right
:
parent
.
right
...
@@ -495,7 +495,7 @@ Rectangle {
...
@@ -495,7 +495,7 @@ Rectangle {
anchors.rightMargin
:
getProportionalDimmension
(
6
)
anchors.rightMargin
:
getProportionalDimmension
(
6
)
visible
:
batteryStatus
.
visible
&&
activeVehicle
.
batteryConsumed
>=
0.0
visible
:
batteryStatus
.
visible
&&
activeVehicle
.
batteryConsumed
>=
0.0
QGCLabel
{
QGCLabel
{
text
:
activeVehicle
.
batteryVoltage
.
toFixed
(
1
)
+
'
V
'
;
text
:
(
activeVehicle
.
batteryVoltage
>
0
)
?
activeVehicle
.
batteryVoltage
.
toFixed
(
1
)
+
'
V
'
:
'
---
'
;
width
:
getProportionalDimmension
(
30
)
width
:
getProportionalDimmension
(
30
)
horizontalAlignment
:
Text
.
AlignRight
horizontalAlignment
:
Text
.
AlignRight
font.pixelSize
:
ScreenTools
.
smallFontPixelSize
font.pixelSize
:
ScreenTools
.
smallFontPixelSize
...
@@ -503,7 +503,7 @@ Rectangle {
...
@@ -503,7 +503,7 @@ Rectangle {
color
:
colorWhite
color
:
colorWhite
}
}
QGCLabel
{
QGCLabel
{
text
:
activeVehicle
.
batteryConsumed
.
toFixed
(
0
)
+
'
mAh
'
;
text
:
(
activeVehicle
.
batteryConsumed
>
0
)
?
activeVehicle
.
batteryConsumed
.
toFixed
(
0
)
+
'
mAh
'
:
'
---
'
;
width
:
getProportionalDimmension
(
30
)
width
:
getProportionalDimmension
(
30
)
horizontalAlignment
:
Text
.
AlignRight
horizontalAlignment
:
Text
.
AlignRight
font.pixelSize
:
ScreenTools
.
smallFontPixelSize
font.pixelSize
:
ScreenTools
.
smallFontPixelSize
...
...
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