support mag power compensation with battery_status instance 1

This commit is contained in:
baumanta
2020-04-28 08:36:44 +02:00
committed by Beat Küng
parent 503bd15b82
commit 48cf38d623
8 changed files with 51 additions and 48 deletions
+1 -8
View File
@@ -48,13 +48,6 @@ MagCompensator::MagCompensator(ModuleParams *parent):
void MagCompensator::calculate_mag_corrected(matrix::Vector3f &mag, const matrix::Vector3f &param_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;
}
}
+2 -17
View File
@@ -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 &param_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