mirror of https://github.com/ArduPilot/ardupilot
AP_RPM: added AP_Generator support
useful for notch filtering of generator vibration
This commit is contained in:
parent
86ed18716e
commit
13453f705e
|
@ -17,6 +17,7 @@
|
|||
#include "RPM_Pin.h"
|
||||
#include "RPM_SITL.h"
|
||||
#include "RPM_EFI.h"
|
||||
#include "RPM_Generator.h"
|
||||
#include "RPM_HarmonicNotch.h"
|
||||
#include "RPM_ESC_Telem.h"
|
||||
|
||||
|
@ -79,6 +80,11 @@ void AP_RPM::init(void)
|
|||
case RPM_TYPE_EFI:
|
||||
drivers[i] = new AP_RPM_EFI(*this, i, state[i]);
|
||||
break;
|
||||
#endif
|
||||
#if HAL_GENERATOR_ENABLED
|
||||
case RPM_TYPE_GENERATOR:
|
||||
drivers[i] = new AP_RPM_Generator(*this, i, state[i]);
|
||||
break;
|
||||
#endif
|
||||
// include harmonic notch last
|
||||
// this makes whatever process is driving the dynamic notch appear as an RPM value
|
||||
|
|
|
@ -42,6 +42,7 @@ public:
|
|||
RPM_TYPE_EFI = 3,
|
||||
RPM_TYPE_HNTCH = 4,
|
||||
RPM_TYPE_ESC_TELEM = 5,
|
||||
RPM_TYPE_GENERATOR = 6,
|
||||
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
||||
RPM_TYPE_SITL = 10,
|
||||
#endif
|
||||
|
|
|
@ -20,7 +20,7 @@ const AP_Param::GroupInfo AP_RPM_Params::var_info[] = {
|
|||
// @Param: TYPE
|
||||
// @DisplayName: RPM type
|
||||
// @Description: What type of RPM sensor is connected
|
||||
// @Values: 0:None,1:Not Used,2:GPIO,3:EFI,4:Harmonic Notch,5:ESC Telemetry Motors Bitmask
|
||||
// @Values: 0:None,1:Not Used,2:GPIO,3:EFI,4:Harmonic Notch,5:ESC Telemetry Motors Bitmask,6:Generator
|
||||
// @User: Standard
|
||||
AP_GROUPINFO_FLAGS("TYPE", 1, AP_RPM_Params, type, 0, AP_PARAM_FLAG_ENABLE),
|
||||
// Note, 1 was previously for type = PWM. This has been removed from docs to make setup less confusing for users.
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <AP_HAL/AP_HAL.h>
|
||||
|
||||
#include "RPM_Generator.h"
|
||||
|
||||
#if HAL_GENERATOR_ENABLED
|
||||
extern const AP_HAL::HAL& hal;
|
||||
|
||||
void AP_RPM_Generator::update(void)
|
||||
{
|
||||
const auto *generator = AP::generator();
|
||||
if (generator == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (generator->healthy()) {
|
||||
state.rate_rpm = generator->get_rpm();
|
||||
state.rate_rpm *= ap_rpm._params[state.instance].scaling;
|
||||
state.signal_quality = 0.5;
|
||||
} else {
|
||||
state.signal_quality = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // HAL_GENERATOR_ENABLED
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "AP_RPM.h"
|
||||
#include "RPM_Backend.h"
|
||||
#include <AP_Generator/AP_Generator.h>
|
||||
|
||||
#if HAL_GENERATOR_ENABLED
|
||||
|
||||
class AP_RPM_Generator : public AP_RPM_Backend
|
||||
{
|
||||
public:
|
||||
// constructor
|
||||
using AP_RPM_Backend::AP_RPM_Backend;
|
||||
|
||||
// update state
|
||||
void update(void) override;
|
||||
};
|
||||
|
||||
#endif // HAL_GENERATOR_ENABLED
|
||||
|
Loading…
Reference in New Issue