mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 10:03:35 +08:00
support mag power compensation with battery_status instance 1
This commit is contained in:
@@ -48,13 +48,6 @@ MagCompensator::MagCompensator(ModuleParams *parent):
|
||||
void MagCompensator::calculate_mag_corrected(matrix::Vector3f &mag, const matrix::Vector3f ¶m_vect)
|
||||
{
|
||||
if (_armed) {
|
||||
int type = _param_mag_compensation_type.get();
|
||||
|
||||
if (type == CompensationType::THROTTLE) {
|
||||
mag = mag + param_vect * _throttle; //for param [gauss]
|
||||
|
||||
} else if (type == CompensationType::CURRENT) {
|
||||
mag = mag + param_vect * _battery_current * 0.001; //for param [gauss/kA]
|
||||
}
|
||||
mag = mag + param_vect * _power;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,26 +53,11 @@ public:
|
||||
|
||||
void update_armed_flag(bool armed) { _armed = armed; }
|
||||
|
||||
void update_throttle(float throttle) { _throttle = throttle; }
|
||||
|
||||
void update_current(float battery_current) { _battery_current = battery_current; }
|
||||
void update_power(float power) { _power = power; }
|
||||
|
||||
void calculate_mag_corrected(matrix::Vector3f &mag, const matrix::Vector3f ¶m_vect);
|
||||
|
||||
private:
|
||||
|
||||
enum CompensationType {
|
||||
DISABLED = 0,
|
||||
THROTTLE,
|
||||
CURRENT
|
||||
};
|
||||
|
||||
float _throttle{0};
|
||||
float _battery_current{0};
|
||||
float _power{0};
|
||||
bool _armed{false};
|
||||
|
||||
DEFINE_PARAMETERS(
|
||||
(ParamInt<px4::params::CAL_MAG_COMP_TYP>) _param_mag_compensation_type
|
||||
)
|
||||
|
||||
};
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
*
|
||||
* @value 0 Disabled
|
||||
* @value 1 Throttle-based compensation
|
||||
* @value 2 Current-based compensation
|
||||
* @value 2 Current-based compensation (battery_status instance 0)
|
||||
* @value 3 Current-based compensation (battery_status instance 1)
|
||||
*
|
||||
* @category system
|
||||
* @group Sensor Calibration
|
||||
|
||||
Reference in New Issue
Block a user