kopia lustrzana https://github.com/proto17/dji_droneid
Added hierarchical block for DroneID detection
rodzic
5c11419e2a
commit
f4e03c5816
|
@ -7,5 +7,6 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
install(FILES
|
install(FILES
|
||||||
dji_droneid_burst_extractor.block.yml DESTINATION share/gnuradio/grc/blocks
|
dji_droneid_burst_extractor.block.yml
|
||||||
|
dji_droneid_detector.block.yml DESTINATION share/gnuradio/grc/blocks
|
||||||
)
|
)
|
||||||
|
|
|
@ -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
|
|
@ -12,5 +12,6 @@
|
||||||
install(FILES
|
install(FILES
|
||||||
api.h
|
api.h
|
||||||
utils.h
|
utils.h
|
||||||
burst_extractor.h DESTINATION include/gnuradio/dji_droneid
|
burst_extractor.h
|
||||||
|
detector.h DESTINATION include/gnuradio/dji_droneid
|
||||||
)
|
)
|
||||||
|
|
|
@ -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 */
|
|
@ -14,6 +14,7 @@ include(GrPlatform) #define LIB_SUFFIX
|
||||||
list(APPEND dji_droneid_sources
|
list(APPEND dji_droneid_sources
|
||||||
utils.cc
|
utils.cc
|
||||||
burst_extractor_impl.cc
|
burst_extractor_impl.cc
|
||||||
|
detector_impl.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
set(dji_droneid_sources "${dji_droneid_sources}" PARENT_SCOPE)
|
set(dji_droneid_sources "${dji_droneid_sources}" PARENT_SCOPE)
|
||||||
|
|
|
@ -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 */
|
|
@ -31,7 +31,7 @@ include(GrPybind)
|
||||||
list(APPEND dji_droneid_python_files
|
list(APPEND dji_droneid_python_files
|
||||||
utils_python.cc
|
utils_python.cc
|
||||||
burst_extractor_python.cc
|
burst_extractor_python.cc
|
||||||
python_bindings.cc)
|
detector_python.cc python_bindings.cc)
|
||||||
|
|
||||||
GR_PYBIND_MAKE_OOT(dji_droneid
|
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(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,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";
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace py = pybind11;
|
||||||
// BINDING_FUNCTION_PROTOTYPES(
|
// BINDING_FUNCTION_PROTOTYPES(
|
||||||
void bind_utils(py::module& m);
|
void bind_utils(py::module& m);
|
||||||
void bind_burst_extractor(py::module& m);
|
void bind_burst_extractor(py::module& m);
|
||||||
|
void bind_detector(py::module& m);
|
||||||
// ) END BINDING_FUNCTION_PROTOTYPES
|
// ) END BINDING_FUNCTION_PROTOTYPES
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,5 +54,6 @@ PYBIND11_MODULE(dji_droneid_python, m)
|
||||||
// BINDING_FUNCTION_CALLS(
|
// BINDING_FUNCTION_CALLS(
|
||||||
bind_utils(m);
|
bind_utils(m);
|
||||||
bind_burst_extractor(m);
|
bind_burst_extractor(m);
|
||||||
|
bind_detector(m);
|
||||||
// ) END BINDING_FUNCTION_CALLS
|
// ) END BINDING_FUNCTION_CALLS
|
||||||
}
|
}
|
Ładowanie…
Reference in New Issue