kopia lustrzana https://github.com/proto17/dji_droneid
Porównaj commity
3 Commity
8cf47662f7
...
f15ebdf508
Autor | SHA1 | Data |
---|---|---|
David Protzman | f15ebdf508 | |
David Protzman | f4e03c5816 | |
David Protzman | 5c11419e2a |
|
@ -56,6 +56,29 @@ blocks:
|
|||
coordinate: [552, 8.0]
|
||||
rotation: 0
|
||||
state: true
|
||||
- name: burst_threshold
|
||||
id: variable_qtgui_range
|
||||
parameters:
|
||||
comment: ''
|
||||
gui_hint: ''
|
||||
label: Burst Detection Threshold
|
||||
min_len: '200'
|
||||
orient: QtCore.Qt.Horizontal
|
||||
outputmsgname: value
|
||||
rangeType: float
|
||||
showports: 'False'
|
||||
start: '0'
|
||||
step: '0.05'
|
||||
stop: '1'
|
||||
value: '.7'
|
||||
widget: counter_slider
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [2312, 8.0]
|
||||
rotation: 0
|
||||
state: true
|
||||
- name: channels_2ghz
|
||||
id: variable
|
||||
parameters:
|
||||
|
@ -211,6 +234,18 @@ blocks:
|
|||
coordinate: [400, 8.0]
|
||||
rotation: 0
|
||||
state: true
|
||||
- name: long_cp_len
|
||||
id: variable
|
||||
parameters:
|
||||
comment: ''
|
||||
value: dji_droneid.utils.get_cyclic_prefix_lengths(samp_rate)[0]
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [2176, 92.0]
|
||||
rotation: 0
|
||||
state: enabled
|
||||
- name: samp_rate
|
||||
id: variable
|
||||
parameters:
|
||||
|
@ -223,6 +258,18 @@ blocks:
|
|||
coordinate: [248, 4.0]
|
||||
rotation: 0
|
||||
state: enabled
|
||||
- name: short_cp_len
|
||||
id: variable
|
||||
parameters:
|
||||
comment: ''
|
||||
value: dji_droneid.utils.get_cyclic_prefix_lengths(samp_rate)[1]
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [2176, 180.0]
|
||||
rotation: 0
|
||||
state: enabled
|
||||
- name: zc_seq
|
||||
id: variable
|
||||
parameters:
|
||||
|
@ -235,177 +282,23 @@ blocks:
|
|||
coordinate: [1960, 12.0]
|
||||
rotation: 0
|
||||
state: enabled
|
||||
- name: analog_const_source_x_0
|
||||
id: analog_const_source_x
|
||||
- name: blocks_delay_0
|
||||
id: blocks_delay
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
const: '0'
|
||||
delay: (fft_size * 4) + (short_cp_len * 3) + long_cp_len + fft_size
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
type: float
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [1056, 1012.0]
|
||||
rotation: 180
|
||||
state: true
|
||||
- name: blocks_complex_to_mag_1
|
||||
id: blocks_complex_to_mag
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
vlen: '1'
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [1992, 932.0]
|
||||
rotation: 0
|
||||
state: true
|
||||
- name: blocks_complex_to_mag_squared_0
|
||||
id: blocks_complex_to_mag_squared
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
vlen: '1'
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [1048, 580.0]
|
||||
rotation: 0
|
||||
state: true
|
||||
- name: blocks_complex_to_mag_squared_1
|
||||
id: blocks_complex_to_mag_squared
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
vlen: '1'
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [1048, 1140.0]
|
||||
rotation: 0
|
||||
state: true
|
||||
- name: blocks_divide_xx_0
|
||||
id: blocks_divide_xx
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
num_inputs: '2'
|
||||
num_ports: '1'
|
||||
type: complex
|
||||
vlen: '1'
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [1712, 932.0]
|
||||
rotation: 0
|
||||
state: true
|
||||
- name: blocks_float_to_complex_0
|
||||
id: blocks_float_to_complex
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
vlen: '1'
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [1056, 948.0]
|
||||
rotation: 0
|
||||
state: true
|
||||
- name: blocks_moving_average_xx_0
|
||||
id: blocks_moving_average_xx
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
length: fft_size
|
||||
max_iter: '4000'
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
scale: 1 / (fft_size - 1)
|
||||
type: float
|
||||
vlen: '1'
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [1048, 644.0]
|
||||
rotation: 180
|
||||
state: true
|
||||
- name: blocks_multiply_const_xx_0
|
||||
id: blocks_multiply_const_xx
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
const: 1 / fft_size
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
type: complex
|
||||
vlen: '1'
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [1376, 476.0]
|
||||
rotation: 0
|
||||
state: true
|
||||
- name: blocks_multiply_const_xx_0_0
|
||||
id: blocks_multiply_const_xx
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
const: dji_droneid.utils.variance_vector(zc_seq)
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
type: float
|
||||
vlen: '1'
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [1056, 788.0]
|
||||
rotation: 0
|
||||
state: true
|
||||
- name: blocks_nlog10_ff_0
|
||||
id: blocks_nlog10_ff
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
k: '0'
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
n: '10'
|
||||
vlen: '1'
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [2040, 1132.0]
|
||||
coordinate: [1008, 436.0]
|
||||
rotation: 0
|
||||
state: true
|
||||
- name: blocks_selector_0
|
||||
|
@ -431,41 +324,37 @@ blocks:
|
|||
coordinate: [880, 208.0]
|
||||
rotation: 0
|
||||
state: disabled
|
||||
- name: blocks_transcendental_0
|
||||
id: blocks_transcendental
|
||||
- name: dji_droneid_burst_extractor_0
|
||||
id: dji_droneid_burst_extractor
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
name: sqrt
|
||||
type: float
|
||||
sample_rate: samp_rate
|
||||
threshold: burst_threshold
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [1056, 868.0]
|
||||
rotation: 180
|
||||
coordinate: [1400, 456.0]
|
||||
rotation: 0
|
||||
state: true
|
||||
- name: fft_filter_xxx_0
|
||||
id: fft_filter_xxx
|
||||
- name: dji_droneid_detector_0
|
||||
id: dji_droneid_detector
|
||||
parameters:
|
||||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
decim: '1'
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
nthreads: '1'
|
||||
samp_delay: '0'
|
||||
taps: dji_droneid.utils.conj_vector(zc_seq)
|
||||
type: ccc
|
||||
sample_rate: samp_rate
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [1056, 452.0]
|
||||
coordinate: [968, 532.0]
|
||||
rotation: 0
|
||||
state: true
|
||||
- name: filter_fft_low_pass_filter_0
|
||||
|
@ -880,7 +769,7 @@ blocks:
|
|||
coordinate: [136, 360.0]
|
||||
rotation: 0
|
||||
state: enabled
|
||||
- name: qtgui_time_sink_x_0
|
||||
- name: qtgui_time_sink_x_1
|
||||
id: qtgui_time_sink_x
|
||||
parameters:
|
||||
affinity: ''
|
||||
|
@ -908,11 +797,11 @@ blocks:
|
|||
color8: dark red
|
||||
color9: dark green
|
||||
comment: ''
|
||||
ctrlpanel: 'True'
|
||||
ctrlpanel: 'False'
|
||||
entags: 'True'
|
||||
grid: 'False'
|
||||
gui_hint: ''
|
||||
label1: Correlator Output
|
||||
label1: Signal 1
|
||||
label10: Signal 10
|
||||
label2: Signal 2
|
||||
label3: Signal 3
|
||||
|
@ -934,7 +823,7 @@ blocks:
|
|||
marker8: '-1'
|
||||
marker9: '-1'
|
||||
name: '""'
|
||||
nconnections: '2'
|
||||
nconnections: '1'
|
||||
size: '1024'
|
||||
srate: samp_rate
|
||||
stemplot: 'False'
|
||||
|
@ -954,7 +843,7 @@ blocks:
|
|||
tr_mode: qtgui.TRIG_MODE_FREE
|
||||
tr_slope: qtgui.TRIG_SLOPE_POS
|
||||
tr_tag: '""'
|
||||
type: float
|
||||
type: msg_complex
|
||||
update_time: '0.10'
|
||||
width1: '1'
|
||||
width10: '1'
|
||||
|
@ -974,28 +863,18 @@ blocks:
|
|||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [2352, 996.0]
|
||||
coordinate: [1856, 456.0]
|
||||
rotation: 0
|
||||
state: true
|
||||
state: enabled
|
||||
|
||||
connections:
|
||||
- [analog_const_source_x_0, '0', blocks_float_to_complex_0, '1']
|
||||
- [blocks_complex_to_mag_1, '0', qtgui_time_sink_x_0, '0']
|
||||
- [blocks_complex_to_mag_squared_0, '0', blocks_moving_average_xx_0, '0']
|
||||
- [blocks_complex_to_mag_squared_1, '0', blocks_nlog10_ff_0, '0']
|
||||
- [blocks_divide_xx_0, '0', blocks_complex_to_mag_1, '0']
|
||||
- [blocks_float_to_complex_0, '0', blocks_divide_xx_0, '1']
|
||||
- [blocks_moving_average_xx_0, '0', blocks_multiply_const_xx_0_0, '0']
|
||||
- [blocks_multiply_const_xx_0, '0', blocks_divide_xx_0, '0']
|
||||
- [blocks_multiply_const_xx_0_0, '0', blocks_transcendental_0, '0']
|
||||
- [blocks_nlog10_ff_0, '0', qtgui_time_sink_x_0, '1']
|
||||
- [blocks_delay_0, '0', dji_droneid_burst_extractor_0, '0']
|
||||
- [blocks_selector_0, '0', fosphor_glfw_sink_c_0, '0']
|
||||
- [blocks_transcendental_0, '0', blocks_float_to_complex_0, '0']
|
||||
- [fft_filter_xxx_0, '0', blocks_multiply_const_xx_0, '0']
|
||||
- [filter_fft_low_pass_filter_0, '0', blocks_complex_to_mag_squared_0, '0']
|
||||
- [filter_fft_low_pass_filter_0, '0', blocks_complex_to_mag_squared_1, '0']
|
||||
- [dji_droneid_burst_extractor_0, bursts, qtgui_time_sink_x_1, in]
|
||||
- [dji_droneid_detector_0, '0', dji_droneid_burst_extractor_0, '1']
|
||||
- [filter_fft_low_pass_filter_0, '0', blocks_delay_0, '0']
|
||||
- [filter_fft_low_pass_filter_0, '0', blocks_selector_0, '1']
|
||||
- [filter_fft_low_pass_filter_0, '0', fft_filter_xxx_0, '0']
|
||||
- [filter_fft_low_pass_filter_0, '0', dji_droneid_detector_0, '0']
|
||||
- [osmosdr_source_0, '0', blocks_selector_0, '0']
|
||||
- [osmosdr_source_0, '0', filter_fft_low_pass_filter_0, '0']
|
||||
|
||||
|
|
|
@ -7,5 +7,6 @@
|
|||
#
|
||||
|
||||
install(FILES
|
||||
DESTINATION share/gnuradio/grc/blocks
|
||||
dji_droneid_burst_extractor.block.yml
|
||||
dji_droneid_detector.block.yml DESTINATION share/gnuradio/grc/blocks
|
||||
)
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
id: dji_droneid_burst_extractor
|
||||
label: Burst Extractor
|
||||
category: '[dji_droneid]'
|
||||
|
||||
templates:
|
||||
imports: from gnuradio import dji_droneid
|
||||
make: dji_droneid.burst_extractor(${sample_rate}, ${threshold})
|
||||
callbacks:
|
||||
- set_threshold(${threshold})
|
||||
|
||||
# Make one 'parameters' list entry for every parameter you want settable from the GUI.
|
||||
# Keys include:
|
||||
# * id (makes the value accessible as keyname, e.g. in the make entry)
|
||||
# * label (label shown in the GUI)
|
||||
# * dtype (e.g. int, float, complex, byte, short, xxx_vector, ...)
|
||||
# * default
|
||||
parameters:
|
||||
- id: sample_rate
|
||||
label: Sample Rate (Hz)
|
||||
dtype: float
|
||||
- id: threshold
|
||||
label: Threshold
|
||||
dtype: float
|
||||
default: 0.7
|
||||
|
||||
# Make one 'inputs' list entry per input and one 'outputs' list entry per output.
|
||||
# Keys include:
|
||||
# * label (an identifier for the GUI)
|
||||
# * domain (optional - stream or message. Default is stream)
|
||||
# * dtype (e.g. int, float, complex, byte, short, xxx_vector, ...)
|
||||
# * vlen (optional - data stream vector length. Default is 1)
|
||||
# * optional (optional - set to 1 for optional inputs. Default is 0)
|
||||
inputs:
|
||||
- label: samples
|
||||
domain: stream
|
||||
dtype: complex
|
||||
vlen: 1
|
||||
optional: 0
|
||||
- label: scores
|
||||
domain: stream
|
||||
dtype: float
|
||||
vlen: 1
|
||||
optional: 0
|
||||
|
||||
outputs:
|
||||
- label: bursts
|
||||
domain: message
|
||||
optional: 1
|
||||
|
||||
# 'file_format' specifies the version of the GRC yml format used in the file
|
||||
# and should usually not be changed.
|
||||
file_format: 1
|
|
@ -0,0 +1,43 @@
|
|||
id: dji_droneid_detector
|
||||
label: DJI DroneID Detector
|
||||
category: '[dji_droneid]'
|
||||
|
||||
templates:
|
||||
imports: from gnuradio import dji_droneid
|
||||
make: dji_droneid.detector(${sample_rate})
|
||||
|
||||
# Make one 'parameters' list entry for every parameter you want settable from the GUI.
|
||||
# Keys include:
|
||||
# * id (makes the value accessible as keyname, e.g. in the make entry)
|
||||
# * label (label shown in the GUI)
|
||||
# * dtype (e.g. int, float, complex, byte, short, xxx_vector, ...)
|
||||
# * default
|
||||
parameters:
|
||||
- id: sample_rate
|
||||
label: Sample Rate (Hz)
|
||||
dtype: float
|
||||
|
||||
# Make one 'inputs' list entry per input and one 'outputs' list entry per output.
|
||||
# Keys include:
|
||||
# * label (an identifier for the GUI)
|
||||
# * domain (optional - stream or message. Default is stream)
|
||||
# * dtype (e.g. int, float, complex, byte, short, xxx_vector, ...)
|
||||
# * vlen (optional - data stream vector length. Default is 1)
|
||||
# * optional (optional - set to 1 for optional inputs. Default is 0)
|
||||
inputs:
|
||||
- label: in
|
||||
domain: stream
|
||||
dtype: complex
|
||||
vlen: 1
|
||||
optional: 0
|
||||
|
||||
outputs:
|
||||
- label: out
|
||||
domain: stream
|
||||
dtype: float
|
||||
vlen: 1
|
||||
optional: 0
|
||||
|
||||
# 'file_format' specifies the version of the GRC yml format used in the file
|
||||
# and should usually not be changed.
|
||||
file_format: 1
|
|
@ -11,5 +11,7 @@
|
|||
########################################################################
|
||||
install(FILES
|
||||
api.h
|
||||
utils.h DESTINATION include/gnuradio/dji_droneid
|
||||
utils.h
|
||||
burst_extractor.h
|
||||
detector.h DESTINATION include/gnuradio/dji_droneid
|
||||
)
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2022 gr-dji_droneid author.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_DJI_DRONEID_BURST_EXTRACTOR_H
|
||||
#define INCLUDED_DJI_DRONEID_BURST_EXTRACTOR_H
|
||||
|
||||
#include <gnuradio/dji_droneid/api.h>
|
||||
#include <gnuradio/sync_block.h>
|
||||
|
||||
namespace gr {
|
||||
namespace dji_droneid {
|
||||
|
||||
/*!
|
||||
* \brief <+description of block+>
|
||||
* \ingroup dji_droneid
|
||||
*
|
||||
*/
|
||||
class DJI_DRONEID_API burst_extractor : virtual public gr::sync_block
|
||||
{
|
||||
public:
|
||||
typedef std::shared_ptr<burst_extractor> sptr;
|
||||
|
||||
/*!
|
||||
* \brief Return a shared_ptr to a new instance of dji_droneid::burst_extractor.
|
||||
*
|
||||
* To avoid accidental use of raw pointers, dji_droneid::burst_extractor's
|
||||
* constructor is in a private implementation
|
||||
* class. dji_droneid::burst_extractor::make is the public interface for
|
||||
* creating new instances.
|
||||
*/
|
||||
static sptr make(float sample_rate, float threshold);
|
||||
|
||||
virtual void set_threshold(float threshold) = 0;
|
||||
|
||||
virtual pmt::pmt_t get_output_port_name() const = 0;
|
||||
};
|
||||
|
||||
} // namespace dji_droneid
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_DJI_DRONEID_BURST_EXTRACTOR_H */
|
|
@ -0,0 +1,41 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2022 gr-dji_droneid author.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_DJI_DRONEID_DETECTOR_H
|
||||
#define INCLUDED_DJI_DRONEID_DETECTOR_H
|
||||
|
||||
#include <gnuradio/dji_droneid/api.h>
|
||||
#include <gnuradio/hier_block2.h>
|
||||
|
||||
namespace gr {
|
||||
namespace dji_droneid {
|
||||
|
||||
/*!
|
||||
* \brief <+description of block+>
|
||||
* \ingroup dji_droneid
|
||||
*
|
||||
*/
|
||||
class DJI_DRONEID_API detector : virtual public gr::hier_block2
|
||||
{
|
||||
public:
|
||||
typedef std::shared_ptr<detector> sptr;
|
||||
|
||||
/*!
|
||||
* \brief Return a shared_ptr to a new instance of dji_droneid::detector.
|
||||
*
|
||||
* To avoid accidental use of raw pointers, dji_droneid::detector's
|
||||
* constructor is in a private implementation
|
||||
* class. dji_droneid::detector::make is the public interface for
|
||||
* creating new instances.
|
||||
*/
|
||||
static sptr make(float sample_rate);
|
||||
};
|
||||
|
||||
} // namespace dji_droneid
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_DJI_DRONEID_DETECTOR_H */
|
|
@ -13,6 +13,8 @@ include(GrPlatform) #define LIB_SUFFIX
|
|||
|
||||
list(APPEND dji_droneid_sources
|
||||
utils.cc
|
||||
burst_extractor_impl.cc
|
||||
detector_impl.cc
|
||||
)
|
||||
|
||||
set(dji_droneid_sources "${dji_droneid_sources}" PARENT_SCOPE)
|
||||
|
@ -22,7 +24,8 @@ if(NOT dji_droneid_sources)
|
|||
endif(NOT dji_droneid_sources)
|
||||
|
||||
add_library(gnuradio-dji_droneid SHARED ${dji_droneid_sources})
|
||||
target_link_libraries(gnuradio-dji_droneid gnuradio::gnuradio-runtime gnuradio-fft fftw3 gnuradio-blocks gnuradio-filter)
|
||||
target_link_libraries(gnuradio-dji_droneid gnuradio::gnuradio-runtime gnuradio-fft
|
||||
fftw3 gnuradio-blocks gnuradio-filter gnuradio-analog)
|
||||
target_include_directories(gnuradio-dji_droneid
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
|
||||
PUBLIC $<INSTALL_INTERFACE:include>
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2022 gr-dji_droneid author.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "burst_extractor_impl.h"
|
||||
#include <gnuradio/io_signature.h>
|
||||
|
||||
#include <gnuradio/dji_droneid/utils.h>
|
||||
|
||||
namespace gr {
|
||||
namespace dji_droneid {
|
||||
|
||||
burst_extractor::sptr burst_extractor::make(const float sample_rate, const float threshold)
|
||||
{
|
||||
return gnuradio::make_block_sptr<burst_extractor_impl>(sample_rate, threshold);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The private constructor
|
||||
*/
|
||||
burst_extractor_impl::burst_extractor_impl(const float sample_rate, const float threshold)
|
||||
: gr::sync_block("burst_extractor",
|
||||
gr::io_signature::make2(
|
||||
2, 2, sizeof(std::complex<float>), sizeof(float)),
|
||||
gr::io_signature::make(
|
||||
0, 0, 0)),
|
||||
output_port_name_(pmt::mp("bursts")), threshold_(threshold), sample_tag_(pmt::mp("start_index"))
|
||||
{
|
||||
message_port_register_out(output_port_name_);
|
||||
|
||||
const auto fft_size = utils::get_fft_size(sample_rate);
|
||||
const auto [long_cp_len, short_cp_len] = utils::get_cyclic_prefix_lengths(sample_rate);
|
||||
|
||||
const auto full_frame_length = long_cp_len + (short_cp_len * 8) + (fft_size * 9);
|
||||
const auto extract_size = full_frame_length + (fft_size * 2);
|
||||
|
||||
buffer_.resize(extract_size);
|
||||
remaining_samples_ = -1;
|
||||
buffer_ptr_ = nullptr;
|
||||
|
||||
metadata_ = pmt::make_dict();
|
||||
}
|
||||
|
||||
/*
|
||||
* Our virtual destructor.
|
||||
*/
|
||||
burst_extractor_impl::~burst_extractor_impl() {}
|
||||
|
||||
int burst_extractor_impl::work(int noutput_items,
|
||||
gr_vector_const_void_star& input_items,
|
||||
gr_vector_void_star& output_items)
|
||||
{
|
||||
std::lock_guard<decltype(settings_lock_)> l(settings_lock_);
|
||||
|
||||
auto in_samples = static_cast<const std::complex<float> *>(input_items[0]);
|
||||
auto in_scores = static_cast<const float *>(input_items[1]);
|
||||
|
||||
// This is HORRIBLY inefficient, but works for now. A much better way would be to copy out chunks of
|
||||
// samples at a time after the threshold has been passed, but that requires effort.
|
||||
|
||||
// Walk through each sample of the input either looking for the threshold to be passed, or accumulating
|
||||
// samples in the buffer until all samples have been read
|
||||
for (auto idx = decltype(noutput_items){0}; idx < noutput_items; idx++) {
|
||||
// First step is for when no burst has yet been detected. Check if the threshold has been met, and
|
||||
// if so then start buffering up samples
|
||||
if (remaining_samples_ == -1) {
|
||||
if (in_scores[idx] >= threshold_) {
|
||||
remaining_samples_ = static_cast<int32_t>(buffer_.size());
|
||||
buffer_[0] = in_samples[idx];
|
||||
buffer_ptr_ = &buffer_[1];
|
||||
start_index_ = nitems_read(0) + idx;
|
||||
}
|
||||
// This state is for the last sample that's read for a burst
|
||||
} else if (remaining_samples_ == 1) {
|
||||
*buffer_ptr_++ = in_samples[idx];
|
||||
publish_message();
|
||||
remaining_samples_ = -1;
|
||||
buffer_ptr_ = nullptr;
|
||||
// Finally, this state is for when there are still more samples to read for a burst
|
||||
} else {
|
||||
*buffer_ptr_++ = in_samples[idx];
|
||||
remaining_samples_--;
|
||||
}
|
||||
}
|
||||
|
||||
// Tell runtime system how many output items we produced.
|
||||
return noutput_items;
|
||||
}
|
||||
|
||||
void burst_extractor_impl::publish_message() {
|
||||
// Update the metadata with the current burst's start index
|
||||
metadata_ = pmt::dict_add(metadata_, sample_tag_, pmt::from_uint64(start_index_));
|
||||
|
||||
// Build a PDU pair and send it
|
||||
const auto pdu = pmt::cons(
|
||||
metadata_, pmt::init_c32vector(buffer_.size(), buffer_));
|
||||
message_port_pub(output_port_name_, pdu);
|
||||
}
|
||||
|
||||
void burst_extractor_impl::set_threshold(const float threshold) {
|
||||
std::lock_guard<decltype(settings_lock_)> l(settings_lock_);
|
||||
threshold_ = threshold;
|
||||
}
|
||||
|
||||
} /* namespace dji_droneid */
|
||||
} /* namespace gr */
|
|
@ -0,0 +1,52 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2022 gr-dji_droneid author.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_DJI_DRONEID_BURST_EXTRACTOR_IMPL_H
|
||||
#define INCLUDED_DJI_DRONEID_BURST_EXTRACTOR_IMPL_H
|
||||
|
||||
#include <gnuradio/dji_droneid/burst_extractor.h>
|
||||
|
||||
namespace gr {
|
||||
namespace dji_droneid {
|
||||
|
||||
class burst_extractor_impl : public burst_extractor
|
||||
{
|
||||
private:
|
||||
const pmt::pmt_t output_port_name_;
|
||||
float threshold_;
|
||||
const pmt::pmt_t sample_tag_;
|
||||
|
||||
pmt::pmt_t metadata_;
|
||||
uint64_t start_index_;
|
||||
std::vector<std::complex<float>> buffer_;
|
||||
std::complex<float> * buffer_ptr_;
|
||||
int32_t remaining_samples_;
|
||||
|
||||
std::mutex settings_lock_;
|
||||
|
||||
void publish_message();
|
||||
|
||||
public:
|
||||
burst_extractor_impl(float sample_rate, float threshold);
|
||||
~burst_extractor_impl();
|
||||
|
||||
void set_threshold(float threshold) override;
|
||||
|
||||
pmt::pmt_t get_output_port_name() const override {
|
||||
return output_port_name_;
|
||||
}
|
||||
|
||||
// Where all the action really happens
|
||||
int work(int noutput_items,
|
||||
gr_vector_const_void_star& input_items,
|
||||
gr_vector_void_star& output_items);
|
||||
};
|
||||
|
||||
} // namespace dji_droneid
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_DJI_DRONEID_BURST_EXTRACTOR_IMPL_H */
|
|
@ -0,0 +1,71 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2022 gr-dji_droneid author.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "detector_impl.h"
|
||||
#include <gnuradio/io_signature.h>
|
||||
|
||||
#include <gnuradio/dji_droneid/utils.h>
|
||||
|
||||
|
||||
namespace gr {
|
||||
namespace dji_droneid {
|
||||
|
||||
detector::sptr detector::make(float sample_rate)
|
||||
{
|
||||
return gnuradio::make_block_sptr<detector_impl>(sample_rate);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The private constructor
|
||||
*/
|
||||
detector_impl::detector_impl(const float sample_rate)
|
||||
: gr::hier_block2("detector",
|
||||
gr::io_signature::make(
|
||||
1 /* min inputs */, 1 /* max inputs */, sizeof(gr_complex)),
|
||||
gr::io_signature::make(
|
||||
1 /* min outputs */, 1 /*max outputs */, sizeof(float)))
|
||||
{
|
||||
const auto fft_size = utils::get_fft_size(sample_rate);
|
||||
const auto zc = utils::create_zc(fft_size, 4);
|
||||
const auto zc_variance = utils::variance_vector(zc);
|
||||
|
||||
corr_filter_ = gr::filter::fft_filter_ccc::make(1, utils::conj_vector(zc));
|
||||
|
||||
c2mag_sq_ = gr::blocks::complex_to_mag_squared::make();
|
||||
moving_avg_ = gr::blocks::moving_average_ff::make(static_cast<int32_t>(fft_size), 1.0f / static_cast<float>(fft_size - 1));
|
||||
mult_const_ff_ = gr::blocks::multiply_const_ff::make(zc_variance);
|
||||
transcendental_ = gr::blocks::transcendental::make("sqrt");
|
||||
float_to_complex_ = gr::blocks::float_to_complex::make();
|
||||
const_source_ = gr::analog::sig_source_f::make(0, gr::analog::GR_CONST_WAVE, 0, 0, 0);
|
||||
|
||||
mult_const_cc_ = gr::blocks::multiply_const_cc::make({1.0f / static_cast<float>(fft_size), 0});
|
||||
divide_ = gr::blocks::divide_cc::make();
|
||||
c2mag_ = gr::blocks::complex_to_mag::make();
|
||||
|
||||
connect(self(), 0, corr_filter_, 0);
|
||||
connect(self(), 0, c2mag_sq_, 0);
|
||||
connect(corr_filter_, 0, mult_const_cc_, 0);
|
||||
connect(c2mag_sq_, 0, moving_avg_, 0);
|
||||
connect(moving_avg_, 0, mult_const_ff_, 0);
|
||||
connect(mult_const_ff_, 0, transcendental_, 0);
|
||||
connect(transcendental_, 0, float_to_complex_, 0);
|
||||
connect(const_source_, 0, float_to_complex_, 1);
|
||||
connect(mult_const_cc_, 0, divide_, 0);
|
||||
connect(float_to_complex_, 0, divide_, 1);
|
||||
connect(divide_, 0, c2mag_, 0);
|
||||
connect(c2mag_, 0, self(), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Our virtual destructor.
|
||||
*/
|
||||
detector_impl::~detector_impl() {}
|
||||
|
||||
|
||||
} /* namespace dji_droneid */
|
||||
} /* namespace gr */
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2022 gr-dji_droneid author.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_DJI_DRONEID_DETECTOR_IMPL_H
|
||||
#define INCLUDED_DJI_DRONEID_DETECTOR_IMPL_H
|
||||
|
||||
#include <gnuradio/dji_droneid/detector.h>
|
||||
|
||||
#include <gnuradio/blocks/complex_to_mag_squared.h>
|
||||
#include <gnuradio/blocks/moving_average.h>
|
||||
#include <gnuradio/blocks/multiply_const.h>
|
||||
#include <gnuradio/blocks/transcendental.h>
|
||||
#include <gnuradio/blocks/float_to_complex.h>
|
||||
#include <gnuradio/analog/sig_source.h>
|
||||
#include <gnuradio/blocks/divide.h>
|
||||
#include <gnuradio/blocks/complex_to_mag.h>
|
||||
#include <gnuradio/filter/fft_filter_ccc.h>
|
||||
|
||||
namespace gr {
|
||||
namespace dji_droneid {
|
||||
|
||||
class detector_impl : public detector
|
||||
{
|
||||
private:
|
||||
gr::blocks::complex_to_mag_squared::sptr c2mag_sq_;
|
||||
gr::blocks::moving_average_ff::sptr moving_avg_;
|
||||
gr::blocks::multiply_const_ff::sptr mult_const_ff_;
|
||||
gr::blocks::transcendental::sptr transcendental_;
|
||||
gr::blocks::float_to_complex::sptr float_to_complex_;
|
||||
gr::analog::sig_source_f::sptr const_source_;
|
||||
gr::blocks::divide_cc::sptr divide_;
|
||||
gr::blocks::complex_to_mag::sptr c2mag_;
|
||||
gr::blocks::multiply_const_cc::sptr mult_const_cc_;
|
||||
gr::filter::fft_filter_ccc::sptr corr_filter_;
|
||||
|
||||
public:
|
||||
detector_impl(float sample_rate);
|
||||
~detector_impl();
|
||||
|
||||
// Where all the action really happens
|
||||
};
|
||||
|
||||
} // namespace dji_droneid
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_DJI_DRONEID_DETECTOR_IMPL_H */
|
|
@ -0,0 +1,21 @@
|
|||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2022 gr-dji_droneid author.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include <gnuradio/attributes.h>
|
||||
#include <gnuradio/dji_droneid/detector.h>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
namespace gr {
|
||||
namespace dji_droneid {
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_detector_replace_with_specific_test_name)
|
||||
{
|
||||
// Put test here
|
||||
}
|
||||
|
||||
} /* namespace dji_droneid */
|
||||
} /* namespace gr */
|
|
@ -29,7 +29,9 @@ include(GrPybind)
|
|||
########################################################################
|
||||
|
||||
list(APPEND dji_droneid_python_files
|
||||
utils_python.cc python_bindings.cc)
|
||||
utils_python.cc
|
||||
burst_extractor_python.cc
|
||||
detector_python.cc python_bindings.cc)
|
||||
|
||||
GR_PYBIND_MAKE_OOT(dji_droneid
|
||||
../../..
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright 2022 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU Radio
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
/***********************************************************************************/
|
||||
/* This file is automatically generated using bindtool and can be manually edited */
|
||||
/* The following lines can be configured to regenerate this file during cmake */
|
||||
/* If manual edits are made, the following tags should be modified accordingly. */
|
||||
/* BINDTOOL_GEN_AUTOMATIC(0) */
|
||||
/* BINDTOOL_USE_PYGCCXML(0) */
|
||||
/* BINDTOOL_HEADER_FILE(burst_extractor.h) */
|
||||
/* BINDTOOL_HEADER_FILE_HASH(7bf7a5ce653e37c004b46a6f723a4319) */
|
||||
/***********************************************************************************/
|
||||
|
||||
#include <pybind11/complex.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
#include <gnuradio/dji_droneid/burst_extractor.h>
|
||||
// pydoc.h is automatically generated in the build directory
|
||||
#include <burst_extractor_pydoc.h>
|
||||
|
||||
void bind_burst_extractor(py::module& m)
|
||||
{
|
||||
|
||||
using burst_extractor = ::gr::dji_droneid::burst_extractor;
|
||||
|
||||
|
||||
py::class_<burst_extractor,
|
||||
gr::sync_block,
|
||||
gr::block,
|
||||
gr::basic_block,
|
||||
std::shared_ptr<burst_extractor>>(m, "burst_extractor", D(burst_extractor))
|
||||
|
||||
.def(py::init(&burst_extractor::make),
|
||||
py::arg("sample_rate"),
|
||||
py::arg("threshold"),
|
||||
D(burst_extractor, make))
|
||||
|
||||
|
||||
.def("set_threshold",
|
||||
&burst_extractor::set_threshold,
|
||||
py::arg("threshold"),
|
||||
D(burst_extractor, set_threshold))
|
||||
|
||||
|
||||
.def("get_output_port_name",
|
||||
&burst_extractor::get_output_port_name,
|
||||
D(burst_extractor, get_output_port_name))
|
||||
|
||||
;
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright 2022 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU Radio
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
/***********************************************************************************/
|
||||
/* This file is automatically generated using bindtool and can be manually edited */
|
||||
/* The following lines can be configured to regenerate this file during cmake */
|
||||
/* If manual edits are made, the following tags should be modified accordingly. */
|
||||
/* BINDTOOL_GEN_AUTOMATIC(0) */
|
||||
/* BINDTOOL_USE_PYGCCXML(0) */
|
||||
/* BINDTOOL_HEADER_FILE(detector.h) */
|
||||
/* BINDTOOL_HEADER_FILE_HASH(17867f37e707405fecba12ebe8de8db3) */
|
||||
/***********************************************************************************/
|
||||
|
||||
#include <pybind11/complex.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
#include <gnuradio/dji_droneid/detector.h>
|
||||
// pydoc.h is automatically generated in the build directory
|
||||
#include <detector_pydoc.h>
|
||||
|
||||
void bind_detector(py::module& m)
|
||||
{
|
||||
|
||||
using detector = gr::dji_droneid::detector;
|
||||
|
||||
|
||||
py::class_<detector, gr::hier_block2,
|
||||
std::shared_ptr<detector>>(m, "detector", D(detector))
|
||||
|
||||
.def(py::init(&detector::make),
|
||||
D(detector,make)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright 2022 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU Radio
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
#include "pydoc_macros.h"
|
||||
#define D(...) DOC(gr, dji_droneid, __VA_ARGS__)
|
||||
/*
|
||||
This file contains placeholders for docstrings for the Python bindings.
|
||||
Do not edit! These were automatically extracted during the binding process
|
||||
and will be overwritten during the build process
|
||||
*/
|
||||
|
||||
|
||||
static const char* __doc_gr_dji_droneid_burst_extractor = R"doc()doc";
|
||||
|
||||
|
||||
static const char* __doc_gr_dji_droneid_burst_extractor_burst_extractor_0 = R"doc()doc";
|
||||
|
||||
|
||||
static const char* __doc_gr_dji_droneid_burst_extractor_burst_extractor_1 = R"doc()doc";
|
||||
|
||||
|
||||
static const char* __doc_gr_dji_droneid_burst_extractor_make = R"doc()doc";
|
||||
|
||||
|
||||
static const char* __doc_gr_dji_droneid_burst_extractor_set_threshold = R"doc()doc";
|
||||
|
||||
|
||||
static const char* __doc_gr_dji_droneid_burst_extractor_get_output_port_name =
|
||||
R"doc()doc";
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Copyright 2022 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU Radio
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
#include "pydoc_macros.h"
|
||||
#define D(...) DOC(gr, dji_droneid, __VA_ARGS__)
|
||||
/*
|
||||
This file contains placeholders for docstrings for the Python bindings.
|
||||
Do not edit! These were automatically extracted during the binding process
|
||||
and will be overwritten during the build process
|
||||
*/
|
||||
|
||||
|
||||
|
||||
static const char *__doc_gr_dji_droneid_detector = R"doc()doc";
|
||||
|
||||
|
||||
static const char *__doc_gr_dji_droneid_detector_detector = R"doc()doc";
|
||||
|
||||
|
||||
static const char *__doc_gr_dji_droneid_detector_make = R"doc()doc";
|
||||
|
||||
|
|
@ -22,6 +22,8 @@ namespace py = pybind11;
|
|||
/**************************************/
|
||||
// BINDING_FUNCTION_PROTOTYPES(
|
||||
void bind_utils(py::module& m);
|
||||
void bind_burst_extractor(py::module& m);
|
||||
void bind_detector(py::module& m);
|
||||
// ) END BINDING_FUNCTION_PROTOTYPES
|
||||
|
||||
|
||||
|
@ -51,5 +53,7 @@ PYBIND11_MODULE(dji_droneid_python, m)
|
|||
/**************************************/
|
||||
// BINDING_FUNCTION_CALLS(
|
||||
bind_utils(m);
|
||||
bind_burst_extractor(m);
|
||||
bind_detector(m);
|
||||
// ) END BINDING_FUNCTION_CALLS
|
||||
}
|
Ładowanie…
Reference in New Issue