CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_BattMonitor/AP_BattMonitor_Bebop.h
Views: 1798
1
/*
2
This program is free software: you can redistribute it and/or modify
3
it under the terms of the GNU General Public License as published by
4
the Free Software Foundation, either version 3 of the License, or
5
(at your option) any later version.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
11
12
You should have received a copy of the GNU General Public License
13
along with this program. If not, see <http://www.gnu.org/licenses/>.
14
*/
15
#pragma once
16
17
#include <AP_Common/AP_Common.h>
18
#include <AP_HAL/AP_HAL.h>
19
#include "AP_BattMonitor_Backend.h"
20
21
class AP_BattMonitor_Bebop :public AP_BattMonitor_Backend
22
{
23
public:
24
// constructor. This incorporates initialisation as well.
25
AP_BattMonitor_Bebop(AP_BattMonitor &mon, AP_BattMonitor::BattMonitor_State &mon_state, AP_BattMonitor_Params &params):
26
AP_BattMonitor_Backend(mon, mon_state, params),
27
_prev_vbat_raw(0.0f),
28
_prev_vbat(0.0f),
29
_battery_voltage_max(0.0f)
30
{};
31
32
virtual ~AP_BattMonitor_Bebop(void) {};
33
34
// initialise
35
void init() override;
36
37
// read the latest battery voltage
38
void read() override;
39
40
// bebop provides current info
41
bool has_current() const override { return true; };
42
43
// don't allow reset of remaining capacity for bebop battery
44
bool reset_remaining(float percentage) override { return false; }
45
46
private:
47
float _prev_vbat_raw;
48
float _prev_vbat;
49
float _battery_voltage_max;
50
float _compute_compensation(const uint16_t *rpm, float vbat_raw);
51
float _filter_voltage(float vbat_raw);
52
float _compute_battery_percentage(float vbat);
53
};
54
55