Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
d3e9ee88
Commit
d3e9ee88
authored
7 years ago
by
nanthony21
Committed by
Matthias Grob
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Use filtered throttle for battery estimation instead of raw.
parent
036d9200
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/modules/systemlib/battery.cpp
+15
-3
15 additions, 3 deletions
src/modules/systemlib/battery.cpp
src/modules/systemlib/battery.h
+3
-1
3 additions, 1 deletion
src/modules/systemlib/battery.h
with
18 additions
and
4 deletions
src/modules/systemlib/battery.cpp
+
15
−
3
View file @
d3e9ee88
...
...
@@ -71,9 +71,10 @@ Battery::updateBatteryStatus(hrt_abstime timestamp, float voltage_v, float curre
reset
(
battery_status
);
battery_status
->
timestamp
=
timestamp
;
filterVoltage
(
voltage_v
);
filterThrottle
(
throttle_normalized
);
filterCurrent
(
current_a
);
sumDischarged
(
timestamp
,
current_a
);
estimateRemaining
(
_voltage_filtered_v
,
_current_filtered_a
,
throttle_
normaliz
ed
,
armed
);
estimateRemaining
(
_voltage_filtered_v
,
_current_filtered_a
,
_
throttle_
filter
ed
,
armed
);
computeScale
();
if
(
_battery_initialized
)
{
...
...
@@ -126,6 +127,17 @@ Battery::filterCurrent(float current_a)
}
}
void
Battery
::
filterThrottle
(
float
throttle
){
if
(
!
_battery_initialized
)
{
_throttle_filtered
=
throttle
;
}
const
float
filtered_next
=
_throttle_filtered
*
0.99
f
+
throttle
*
0.01
f
;
if
(
PX4_ISFINITE
(
filtered_next
)){
_throttle_filtered
=
filtered_next
;
}
}
void
Battery
::
sumDischarged
(
hrt_abstime
timestamp
,
float
current_a
)
...
...
@@ -150,7 +162,7 @@ Battery::sumDischarged(hrt_abstime timestamp, float current_a)
}
void
Battery
::
estimateRemaining
(
float
voltage_v
,
float
current_a
,
float
throttle
_normalized
,
bool
armed
)
Battery
::
estimateRemaining
(
float
voltage_v
,
float
current_a
,
float
throttle
,
bool
armed
)
{
// remaining battery capacity based on voltage
float
cell_voltage
=
voltage_v
/
_n_cells
.
get
();
...
...
@@ -161,7 +173,7 @@ Battery::estimateRemaining(float voltage_v, float current_a, float throttle_norm
}
else
{
// assume linear relation between throttle and voltage drop
cell_voltage
+=
throttle
_normalized
*
_v_load_drop
.
get
();
cell_voltage
+=
throttle
*
_v_load_drop
.
get
();
}
_remaining_voltage
=
math
::
gradual
(
cell_voltage
,
_v_empty
.
get
(),
_v_charged
.
get
(),
0.
f
,
1.
f
);
...
...
This diff is collapsed.
Click to expand it.
src/modules/systemlib/battery.h
+
3
−
1
View file @
d3e9ee88
...
...
@@ -88,9 +88,10 @@ public:
private
:
void
filterVoltage
(
float
voltage_v
);
void
filterThrottle
(
float
throttle
);
void
filterCurrent
(
float
current_a
);
void
sumDischarged
(
hrt_abstime
timestamp
,
float
current_a
);
void
estimateRemaining
(
float
voltage_v
,
float
current_a
,
float
throttle
_normalized
,
bool
armed
);
void
estimateRemaining
(
float
voltage_v
,
float
current_a
,
float
throttle
,
bool
armed
);
void
determineWarning
(
bool
connected
);
void
computeScale
();
...
...
@@ -108,6 +109,7 @@ private:
bool
_battery_initialized
=
false
;
float
_voltage_filtered_v
=
-
1.
f
;
float
_throttle_filtered
=
-
1.
f
;
float
_current_filtered_a
=
-
1.
f
;
float
_discharged_mah
=
0.
f
;
float
_discharged_mah_loop
=
0.
f
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment