Servers by jDrones

New sensor Backend & Frontend driver development


(René) #1

I was checking out sensor drivers in ArduPilot library as I need to wire some I2C sensors to a PixHawk 2.1, temperature sensors, ambient light detectors and current probes.
As also stated in the documentation, most drivers consist of a frontend, a backend and some specific extra classes to deal with certain devices (example AP_Baro_BMP280, AP_Baro_BME280, …).
Now, confronting frontends and backends of different I2C sensors, Compass and Barometer in this case, I gathered all functions which appear in the code and seem to recur in all other drivers.

I am wondering which of these functions need to be implemented in a new sensor driver.


calibrate(bool save);
update_calibration(uint8_t i, T raw_val);
read(uint8_t i);
update(bool log);
all_healthy(void) const;
_add_backend(AP_XXX_Backend *backend);
_have_i2c_driver(uint8_t bus, uint8_t address) const;


update_healthy_flag(uint8_t instance);
backend_update(uint8_t instance);
register_sensor(void) const;
set_dev_id(uint8_t instance, uint32_t dev_id);
_copy_to_frontend(uint8_t instance, T data);

I believe this post can be helpful for those willing to further develop ArduPilot hardware compatibility, as in the documentation little is said about sensor handling. It would be good to add a small description for each of those functions as a reference for new developers/contributors.