Paparazzi UAS
v7.0_unstable
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 "modules/core/abi.h"
#include <pthread.h>
#include <unistd.h>
#include "modules/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) |
void | sonar_bebop_event (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 |
static pthread_mutex_t | sonar_mutex = PTHREAD_MUTEX_INITIALIZER |
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 59 of file sonar_bebop.c.
#define SONAR_BEBOP_ADC_MAX_VALUE 4095 |
SONAR_BEBOP_ADC_MAX_VALUE maximum ADC output (12 bit ADC)
Definition at line 56 of file sonar_bebop.c.
#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 53 of file sonar_bebop.c.
#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 95 of file sonar_bebop.c.
#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 91 of file sonar_bebop.c.
#define SONAR_BEBOP_PEAK_THRESHOLD 50 |
SONAR_BEBOP_PEAK_THRESHOLD minimum samples from broadcast stop.
Definition at line 86 of file sonar_bebop.c.
#define SONAR_BEBOP_TRANSITION_COUNT 7 |
SONAR_BEBOP_TRANSITION_COUNT number of samples before switching mode.
Definition at line 79 of file sonar_bebop.c.
#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 69 of file sonar_bebop.c.
#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 74 of file sonar_bebop.c.
void sonar_bebop_event | ( | void | ) |
Definition at line 146 of file sonar_bebop.c.
References AGL_SONAR_ADC_ID, SonarBebop::available, DefaultChannel, DefaultDevice, SonarBebop::distance, get_sys_time_usec(), SonarBebop::meas, FloatEulers::phi, sonar_bebop, sonar_mutex, stateGetNedToBodyEulers_f(), and FloatEulers::theta.
void sonar_bebop_init | ( | void | ) |
Definition at line 113 of file sonar_bebop.c.
References SonarBebop::available, 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, sonar_mutex, 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 179 of file sonar_bebop.c.
References adc_buffer, adc_enable(), adc_read(), SonarBebop::available, SonarBebop::distance, SonarBebop::meas, mode, spi_transaction::output_buf, 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, sonar_mutex, spi0, spi_submit(), SPITransDone, SPITransSuccess, spi_transaction::status, and update_median_filter_f().
Referenced by sonar_bebop_init().
uint16_t adc_buffer[SONAR_BEBOP_ADC_BUFFER_SIZE] |
Definition at line 175 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 65 of file sonar_bebop.c.
Referenced by actuators_faulhaber_SetMode(), atmega_i2c_cam_ctrl_send(), autopilot_generated_SetModeHandler(), autopilot_set_mode(), autopilot_SetModeHandler(), autopilot_static_SetModeHandler(), dc_info(), ins_ekf2_remove_gps(), lis3mdl_init(), mavlink_common_message_handler(), modeAlternate(), nav_throttle_curve_set(), parseFormationSlot(), periodic_telemetry_err_report(), rotorcraft_cam_set_mode(), s_measure(), s_start_measure(), sonar_bebop_init(), sonar_bebop_read(), sys_id_doublet_mod_handler(), throttle_curve_run(), and uart_periph_set_mode().
|
static |
Definition at line 82 of file sonar_bebop.c.
Referenced by sonar_bebop_init(), and sonar_bebop_read().
struct SonarBebop sonar_bebop |
Definition at line 101 of file sonar_bebop.c.
Referenced by sonar_bebop_event(), 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 101 of file sonar_bebop.c.
Referenced by sonar_bebop_init(), and sonar_bebop_read().
|
static |
Definition at line 101 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 1 of file sonar_bebop.c.
Referenced by sonar_bebop_init(), sonar_bebop_read(), sonar_pwm_init(), and sonar_pwm_read().
|
static |
Definition at line 111 of file sonar_bebop.c.
Referenced by sonar_bebop_event(), sonar_bebop_init(), and sonar_bebop_read().