Paparazzi UAS
v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
|
Parrot Bebop Sonar driver. More...
#include "sonar_bebop.h"
#include "generated/airframe.h"
#include "mcu_periph/adc.h"
#include "mcu_periph/spi.h"
#include "mcu_periph/sys_time.h"
#include "subsystems/abi.h"
#include <pthread.h>
#include <unistd.h>
#include "subsystems/datalink/downlink.h"
#include "filters/median_filter.h"
Go to the source code of this file.
Macros | |
#define | SONAR_BEBOP_INX_DIFF_TO_DIST 340./(2.*160000.) |
SONAR_BEBOP_INX_DIFF_TO_DIST conversion from index difference to distance based on time of flight ADC speed = 160kHz speed of sound = 340m/s. More... | |
#define | SONAR_BEBOP_ADC_MAX_VALUE 4095 |
SONAR_BEBOP_ADC_MAX_VALUE maximum ADC output (12 bit ADC) More... | |
#define | SONAR_BEBOP_ADC_BUFFER_SIZE 8192 |
SONAR_BEBOP_ADC_BUFFER_SIZE ADC buffer size. More... | |
#define | SONAR_BEBOP_TRANSITION_HIGH_TO_LOW 0.8 |
SONAR_BEBOP_TRANSITION_HIGH_TO_LOW below this altitude we should use mode 0. More... | |
#define | SONAR_BEBOP_TRANSITION_LOW_TO_HIGH 1.2 |
SONAR_BEBOP_TRANSITION_LOW_TO_HIGH above this altitude we should use mode 1. More... | |
#define | SONAR_BEBOP_TRANSITION_COUNT 7 |
SONAR_BEBOP_TRANSITION_COUNT number of samples before switching mode. More... | |
#define | SONAR_BEBOP_PEAK_THRESHOLD 50 |
SONAR_BEBOP_PEAK_THRESHOLD minimum samples from broadcast stop. More... | |
#define | SONAR_BEBOP_MIN_PEAK_VAL 512 |
SONAR_BEBOP_MIN_PEAK_VAL minimum adc value of reflected peak that will be cosidered. More... | |
#define | SONAR_BEBOP_MAX_TRANS_TIME 370 |
SONAR_BEBOP_MAX_TRANS_TIME maximum time for a reflection to travel and return in the adc measurement window. More... | |
Functions | |
void * | sonar_bebop_read (void *data) |
sonar_bebop_read Read ADC value to update sonar measurement More... | |
void | sonar_bebop_init (void) |
Variables | |
struct MedianFilterFloat | sonar_filt |
uint32_t | sonar_bebop_spike_timer |
static uint8_t | mode |
mode holds the current sonar mode mode = 0 used at high altitude, uses 16 wave patterns mode = 1 used at low altitude, uses 4 wave patterns More... | |
static uint8_t | pulse_transition_counter |
static uint8_t | sonar_bebop_spi_d [2][16] |
sonar_bebop_spi_d the waveforms emitted by the sonar waveform 0 is long pulse used at high altitude waveform 1 is shorter pulse used at low altitude More... | |
struct SonarBebop | sonar_bebop |
static struct spi_transaction | sonar_bebop_spi_t |
uint16_t | adc_buffer [SONAR_BEBOP_ADC_BUFFER_SIZE] |
Parrot Bebop Sonar driver.
This file contains the ADC driver for the sonar on the Parrot Bebop and Bebop 2 quadrotors. The sonar is both transmitter and receiver. An SPI interface is used to communicate with the 12 bit ADC which operates at 160kHz. The required waveform of the sonar is sent during the SPI transaction, with the returned data the recorded signal from the sonar. Two waveforms have been implemented dependent on the operating altitude of the Bebop.
Definition in file sonar_bebop.c.
#define SONAR_BEBOP_ADC_BUFFER_SIZE 8192 |
SONAR_BEBOP_ADC_BUFFER_SIZE ADC buffer size.
Definition at line 63 of file sonar_bebop.c.
Referenced by sonar_bebop_read().
#define SONAR_BEBOP_ADC_MAX_VALUE 4095 |
SONAR_BEBOP_ADC_MAX_VALUE maximum ADC output (12 bit ADC)
Definition at line 60 of file sonar_bebop.c.
Referenced by sonar_bebop_read().
#define SONAR_BEBOP_INX_DIFF_TO_DIST 340./(2.*160000.) |
SONAR_BEBOP_INX_DIFF_TO_DIST conversion from index difference to distance based on time of flight ADC speed = 160kHz speed of sound = 340m/s.
Definition at line 57 of file sonar_bebop.c.
Referenced by sonar_bebop_read().
#define SONAR_BEBOP_MAX_TRANS_TIME 370 |
SONAR_BEBOP_MAX_TRANS_TIME maximum time for a reflection to travel and return in the adc measurement window.
Definition at line 99 of file sonar_bebop.c.
Referenced by sonar_bebop_read().
#define SONAR_BEBOP_MIN_PEAK_VAL 512 |
SONAR_BEBOP_MIN_PEAK_VAL minimum adc value of reflected peak that will be cosidered.
Definition at line 95 of file sonar_bebop.c.
Referenced by sonar_bebop_read().
#define SONAR_BEBOP_PEAK_THRESHOLD 50 |
SONAR_BEBOP_PEAK_THRESHOLD minimum samples from broadcast stop.
Definition at line 90 of file sonar_bebop.c.
Referenced by sonar_bebop_read().
#define SONAR_BEBOP_TRANSITION_COUNT 7 |
SONAR_BEBOP_TRANSITION_COUNT number of samples before switching mode.
Definition at line 83 of file sonar_bebop.c.
Referenced by sonar_bebop_read().
#define SONAR_BEBOP_TRANSITION_HIGH_TO_LOW 0.8 |
SONAR_BEBOP_TRANSITION_HIGH_TO_LOW below this altitude we should use mode 0.
Definition at line 73 of file sonar_bebop.c.
Referenced by sonar_bebop_read().
#define SONAR_BEBOP_TRANSITION_LOW_TO_HIGH 1.2 |
SONAR_BEBOP_TRANSITION_LOW_TO_HIGH above this altitude we should use mode 1.
Definition at line 78 of file sonar_bebop.c.
Referenced by sonar_bebop_read().
void sonar_bebop_init | ( | void | ) |
Definition at line 115 of file sonar_bebop.c.
References spi_transaction::dss, init_median_filter_f(), spi_transaction::input_buf, spi_transaction::input_length, SonarBebop::meas, mode, SonarBebop::offset, spi_transaction::output_buf, spi_transaction::output_length, pulse_transition_counter, spi_transaction::select, sonar_bebop, sonar_bebop_read(), sonar_bebop_spi_d, sonar_bebop_spi_t, sonar_bebop_spike_timer, sonar_filt, SPIDss8bit, SPISelectUnselect, SPITransDone, spi_transaction::status, and SysTimeTimerStart.
void * sonar_bebop_read | ( | void * | data | ) |
sonar_bebop_read Read ADC value to update sonar measurement
Definition at line 150 of file sonar_bebop.c.
References adc_buffer, adc_enable(), adc_read(), AGL_SONAR_ADC_ID, DefaultChannel, DefaultDevice, SonarBebop::distance, get_sys_time_usec(), SonarBebop::meas, mode, spi_transaction::output_buf, FloatEulers::phi, pulse_transition_counter, sonar_bebop, SONAR_BEBOP_ADC_BUFFER_SIZE, SONAR_BEBOP_ADC_MAX_VALUE, SONAR_BEBOP_INX_DIFF_TO_DIST, SONAR_BEBOP_MAX_TRANS_TIME, SONAR_BEBOP_MIN_PEAK_VAL, SONAR_BEBOP_PEAK_THRESHOLD, sonar_bebop_spi_d, sonar_bebop_spi_t, SONAR_BEBOP_TRANSITION_COUNT, SONAR_BEBOP_TRANSITION_HIGH_TO_LOW, SONAR_BEBOP_TRANSITION_LOW_TO_HIGH, sonar_filt, spi0, spi_submit(), SPITransDone, SPITransSuccess, stateGetNedToBodyEulers_f(), stateGetPositionEnu_f(), spi_transaction::status, FloatEulers::theta, update_median_filter_f(), and EnuCoor_f::z.
Referenced by sonar_bebop_init().
uint16_t adc_buffer[SONAR_BEBOP_ADC_BUFFER_SIZE] |
Definition at line 146 of file sonar_bebop.c.
Referenced by sonar_bebop_read().
|
static |
mode holds the current sonar mode mode = 0 used at high altitude, uses 16 wave patterns mode = 1 used at low altitude, uses 4 wave patterns
Definition at line 69 of file sonar_bebop.c.
Referenced by atmega_i2c_cam_ctrl_send(), dc_info(), lis3mdl_init(), mavlink_common_message_handler(), nav_throttle_curve_set(), parse_rc_3ch_datalink(), parseFormationSlot(), periodic_telemetry_err_report(), rotorcraft_cam_set_mode(), sdio_connect(), sonar_bebop_init(), sonar_bebop_read(), throttle_curve_run(), and uart_periph_set_mode().
|
static |
Definition at line 86 of file sonar_bebop.c.
Referenced by sonar_bebop_init(), and sonar_bebop_read().
struct SonarBebop sonar_bebop |
Definition at line 107 of file sonar_bebop.c.
Referenced by sonar_bebop_init(), and sonar_bebop_read().
|
static |
sonar_bebop_spi_d the waveforms emitted by the sonar waveform 0 is long pulse used at high altitude waveform 1 is shorter pulse used at low altitude
Definition at line 105 of file sonar_bebop.c.
Referenced by sonar_bebop_init(), and sonar_bebop_read().
|
static |
Definition at line 109 of file sonar_bebop.c.
Referenced by sonar_bebop_init(), and sonar_bebop_read().
uint32_t sonar_bebop_spike_timer |
Definition at line 48 of file sonar_bebop.c.
Referenced by sonar_bebop_init().
struct MedianFilterFloat sonar_filt |
Definition at line 47 of file sonar_bebop.c.
Referenced by sonar_bebop_init(), and sonar_bebop_read().