43 #if PERIODIC_TELEMETRY
45 #include "pprzlink/messages.h"
47 #ifdef SENSOR_SYNC_SEND_SONAR
50 #include "generated/airframe.h"
55 #ifdef SONAR_USE_PWM_FILTER
62 #ifndef SONAR_PWM_CHANNEL
63 #error "No SONAR_PWM_CHANNEL defined to use sonar_pwm module, add a line like define=SONAR_PWM_CHANNEL value=PWM_INPUT1"
68 #define SONAR_OFFSET 0
72 #ifndef SONAR_PWM_PERIOD
73 #define SONAR_PWM_PERIOD 4096
78 #define SONAR_SCALE SONAR_PWM_PERIOD
82 #ifndef SONAR_MEDIAN_SIZE
83 #define SONAR_MEDIAN_SIZE 7
87 #ifndef SONAR_MIN_RANGE
88 #define SONAR_MIN_RANGE 0.15f
92 #ifndef SONAR_MAX_RANGE
93 #define SONAR_MAX_RANGE 7.0f
97 #ifndef SONAR_PWM_OFFSET
98 #define SONAR_PWM_OFFSET 820
102 #ifndef SENSOR_SYNC_SEND_SONAR
103 #define SENSOR_SYNC_SEND_SONAR TRUE
114 #ifdef SONAR_USE_PWM_FILTER
129 #ifdef SONAR_USE_PWM_FILTER
137 #if SONAR_COMPENSATE_ROTATION
140 float gain = (float)fabs( (
double) (cosf(phi) * cosf(theta)));
153 #ifdef SENSOR_SYNC_SEND_SONAR
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.
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).
struct SonarAdc sonar_adc
float distance
Distance measured in meters.
struct MedianFilterFloat sonar_filt
void sonar_pwm_init(void)
#define SONAR_SCALE
Ranger scale or sensitivity as you wish.
#define SONAR_PWM_OFFSET
Some sensor may need an initial PWM offset (823 usec in the case of an EZ1 sensor)
void sonar_pwm_read(void)
#define SONAR_MAX_RANGE
The maximum range for the device to be able to measure.
#define SONAR_MIN_RANGE
The minimum range for the device to be able to measure.
struct SonarPwm sonar_pwm
#define SONAR_OFFSET
The input channel of the PWM based sensor.
#define SONAR_MEDIAN_SIZE
The Median Filter strength.
float scale
scale to convert raw to a real distance
uint16_t raw
raw PWM value
float distance
Distance measured.
API to get/set the generic vehicle states.
Periodic telemetry system header (includes downlink utility and generated code).
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.