mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 22:48:29 -04:00
c59bdc12df
the previous approach assumed a 1:1 mapping between compass backends and compass instances, which isn't true on PX4. It also only setup milligauss offsets on a set_and_save call, which is not the only way offsets change this adds a milligauss_ratio per instance, which is considerably simpler
32 lines
759 B
C++
32 lines
759 B
C++
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
#ifndef AP_Compass_PX4_H
|
|
#define AP_Compass_PX4_H
|
|
|
|
#include "Compass.h"
|
|
#include "AP_Compass_Backend.h"
|
|
|
|
class AP_Compass_PX4 : public AP_Compass_Backend
|
|
{
|
|
public:
|
|
bool init(void);
|
|
void read(void);
|
|
void accumulate(void);
|
|
|
|
AP_Compass_PX4(Compass &compass);
|
|
// detect the sensor
|
|
static AP_Compass_Backend *detect(Compass &compass);
|
|
|
|
private:
|
|
uint8_t _num_sensors;
|
|
|
|
uint8_t _instance[COMPASS_MAX_INSTANCES];
|
|
int _mag_fd[COMPASS_MAX_INSTANCES];
|
|
Vector3f _sum[COMPASS_MAX_INSTANCES];
|
|
uint32_t _count[COMPASS_MAX_INSTANCES];
|
|
uint64_t _last_timestamp[COMPASS_MAX_INSTANCES];
|
|
};
|
|
|
|
#endif // AP_Compass_PX4_H
|
|
|