28#include "generated/airframe.h"
31#if defined(SITL) || (defined(SONAR_I2C_COMPENSATE_ROTATION) && (SONAR_I2C_COMPENSATE_ROTATION == 1))
36#include "pprzlink/messages.h"
39#ifdef MODULE_SONAR_I2C_SYNC_SEND
45#error SONAR_I2C_DEV needs to be defined
51#define SONAR_I2C_ADDR 0xE0
54#define READ_MODE_SINGLE 0x51
59#ifndef SONAR_I2C_MIN_RANGE
60#define SONAR_I2C_MIN_RANGE 0.24f
64#ifndef SONAR_I2C_MAX_RANGE
65#define SONAR_I2C_MAX_RANGE 4.0f
69#ifndef SONAR_I2C_OFFSET
70#define SONAR_I2C_OFFSET 0.0f
74#ifndef USE_SONAR_I2C_AGL
75#define USE_SONAR_I2C_AGL 0
79#ifndef SONAR_I2C_USE_FILTER
80#define SONAR_I2C_USE_FILTER 1
83#ifdef SONAR_I2C_USE_FILTER
86#ifndef SONAR_I2C_MEDIAN_SIZE
87#define SONAR_I2C_MEDIAN_SIZE 7
92#ifndef SONAR_I2C_COMPENSATE_ROTATION
93#define SONAR_I2C_COMPENSATE_ROTATION 0
97#ifndef SONAR_I2C_SCALE
98#define SONAR_I2C_SCALE 0.000044f
126#ifdef SONAR_I2C_USE_FILTER
130#if PERIODIC_TELEMETRY
160#if MODULE_SONAR_I2C_SYNC_SEND
199#ifdef SONAR_I2C_USE_FILTER
207 #if SONAR_I2C_COMPENSATE_ROTATION
210 float gain =
cosf(phi) *
cosf(theta);
Main include for ABI (AirBorneInterface).
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Common code for AP and FBW telemetry.
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
enum I2CTransactionStatus status
Transaction status.
bool i2c_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction.
bool i2c_receive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint16_t len)
Submit a read only transaction.
@ I2CTransRunning
transaction is currently ongoing
@ I2CTransSuccess
transaction successfully finished by I2C driver
@ I2CTransFailed
transaction failed
@ I2CTransDone
transaction set to done by user level
@ I2CTransPending
transaction is pending in queue
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
#define SONAR_I2C_OFFSET
Rangefinder distance offset value for what should be considered zero distance, e.g....
void sonar_i2c_event(void)
Rangefinder event function Basically just check the progress of the transation to prevent overruns du...
#define SONAR_I2C_MAX_RANGE
The maximum chosen distance for the device to be give readings.
#define USE_SONAR_I2C_AGL
Send AGL data over ABI.
void sonar_i2c_report(void)
Option to send debug informative values over telemetry if you do not want sonar message in telemetry.
#define SONAR_I2C_MEDIAN_SIZE
The amount of sensor samples to keep in the median filter buffer.
static void sonar_i2c_send_sonar(struct transport_tx *trans, struct link_device *dev)
Send measured value and status information so it can be read back in e.g.
void sonar_i2c_init(void)
Set the default values at initialization.
struct SonarI2C sonar_i2c
struct MedianFilterFloat sonar_i2c_filter
#define SONAR_I2C_MIN_RANGE
The minimum chosen distance for the device to be give readings.
void sonar_i2c_periodic(void)
Get the ranger current distance value.
Driver for an sonar rangfinder sensor when used via I2C bus.
uint16_t raw
raw measuread non scaled range value from sensor
float distance
Distance scaled to [m].
enum SonarI2CStatus status
bool update_agl
Do or don't update AGL ABI message.
struct i2c_transaction trans
API to get/set the generic vehicle states.
static const struct usb_device_descriptor dev
int16_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint16_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.