Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to be committed: #64

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
# Make sure our local CMake Modules path comes first
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
# Find gnuradio to get access to the cmake modules
find_package(Gnuradio REQUIRED)
find_package(Gnuradio "3.10" REQUIRED)

# Set the version information here
set(VERSION_MAJOR 1)
Expand Down Expand Up @@ -74,7 +74,7 @@ if(NOT CMAKE_MODULES_DIR)
set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake)
endif(NOT CMAKE_MODULES_DIR)

set(GR_INCLUDE_DIR include/radar)
set(GR_INCLUDE_DIR include/gnuradio/radar)
set(GR_CMAKE_DIR ${CMAKE_MODULES_DIR}/gnuradio-radar)
set(GR_PKG_DATA_DIR ${GR_DATA_DIR}/${CMAKE_PROJECT_NAME})
set(GR_PKG_DOC_DIR ${GR_DOC_DIR}/${CMAKE_PROJECT_NAME})
Expand Down Expand Up @@ -132,7 +132,7 @@ add_custom_target(uninstall
########################################################################
# Add subdirectories
########################################################################
add_subdirectory(include/radar)
add_subdirectory(include/gnuradio/radar)
add_subdirectory(lib)
add_subdirectory(apps)
add_subdirectory(docs)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ For full documentation build the toolbox and open `build/docs/doxygen/html/index


**Development platform**
GNU Radio maint-3.8
GNU Radio maint-3.10
UHD 3.15
Ubuntu 18.04
Ubuntu 22.04

**Dependencies**
Qt 5.10.1
Expand Down
17 changes: 9 additions & 8 deletions cmake/Modules/gnuradio-radarConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
INCLUDE(FindPkgConfig)
PKG_CHECK_MODULES(PC_RADAR radar)
find_package(PkgConfig)

PKG_CHECK_MODULES(PC_GR_RADAR gnuradio-radar)

FIND_PATH(
RADAR_INCLUDE_DIRS
NAMES radar/api.h
GR_RADAR_INCLUDE_DIRS
NAMES gnuradio/radar/api.h
HINTS $ENV{RADAR_DIR}/include
${PC_RADAR_INCLUDEDIR}
PATHS ${CMAKE_INSTALL_PREFIX}/include
Expand All @@ -12,7 +13,7 @@ FIND_PATH(
)

FIND_LIBRARY(
RADAR_LIBRARIES
GR_RADAR_LIBRARIES
NAMES gnuradio-radar
HINTS $ENV{RADAR_DIR}/lib
${PC_RADAR_LIBDIR}
Expand All @@ -24,8 +25,8 @@ FIND_LIBRARY(
/usr/lib64
)

include("${CMAKE_CURRENT_LIST_DIR}/radarTarget.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/gnuradio-radarTarget.cmake")

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(RADAR DEFAULT_MSG RADAR_LIBRARIES RADAR_INCLUDE_DIRS)
MARK_AS_ADVANCED(RADAR_LIBRARIES RADAR_INCLUDE_DIRS)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GR_RADAR DEFAULT_MSG GR_RADAR_LIBRARIES GR_RADAR_INCLUDE_DIRS)
MARK_AS_ADVANCED(GR_RADAR_LIBRARIES GR_RADAR_INCLUDE_DIRS)
193 changes: 193 additions & 0 deletions examples/tests/test_find_max_peak_c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

#
# SPDX-License-Identifier: GPL-3.0
#
# GNU Radio Python Flow Graph
# Title: Test Find Max Peak C
# GNU Radio version: 3.10.1.1

from packaging.version import Version as StrictVersion

if __name__ == '__main__':
import ctypes
import sys
if sys.platform.startswith('linux'):
try:
x11 = ctypes.cdll.LoadLibrary('libX11.so')
x11.XInitThreads()
except:
print("Warning: failed to XInitThreads()")

from PyQt5 import Qt
from gnuradio import qtgui
from gnuradio.filter import firdes
import sip
from gnuradio import analog
from gnuradio import blocks
from gnuradio import gr
from gnuradio.fft import window
import sys
import signal
from argparse import ArgumentParser
from gnuradio.eng_arg import eng_float, intx
from gnuradio import eng_notation
from gnuradio import radar
from gnuradio.qtgui import Range, RangeWidget
from PyQt5 import QtCore



from gnuradio import qtgui

class test_find_max_peak_c(gr.top_block, Qt.QWidget):

def __init__(self):
gr.top_block.__init__(self, "Test Find Max Peak C", catch_exceptions=True)
Qt.QWidget.__init__(self)
self.setWindowTitle("Test Find Max Peak C")
qtgui.util.check_set_qss()
try:
self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
except:
pass
self.top_scroll_layout = Qt.QVBoxLayout()
self.setLayout(self.top_scroll_layout)
self.top_scroll = Qt.QScrollArea()
self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
self.top_scroll_layout.addWidget(self.top_scroll)
self.top_scroll.setWidgetResizable(True)
self.top_widget = Qt.QWidget()
self.top_scroll.setWidget(self.top_widget)
self.top_layout = Qt.QVBoxLayout(self.top_widget)
self.top_grid_layout = Qt.QGridLayout()
self.top_layout.addLayout(self.top_grid_layout)

self.settings = Qt.QSettings("GNU Radio", "test_find_max_peak_c")

try:
if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
self.restoreGeometry(self.settings.value("geometry").toByteArray())
else:
self.restoreGeometry(self.settings.value("geometry"))
except:
pass

##################################################
# Variables
##################################################
self.threshold = threshold = -120
self.samp_rate = samp_rate = 32000
self.packet_len = packet_len = 2048

##################################################
# Blocks
##################################################
self._threshold_range = Range(-200, 100, 1, -120, 200)
self._threshold_win = RangeWidget(self._threshold_range, self.set_threshold, "'threshold'", "counter_slider", float, QtCore.Qt.Horizontal)
self.top_layout.addWidget(self._threshold_win)
self.radar_ts_fft_cc_0 = radar.ts_fft_cc(packet_len, "packet_len")
self.radar_ts_fft_cc_0.set_min_output_buffer(4096)
self.radar_print_results_0 = radar.print_results(False, "")
self.radar_find_max_peak_c_0 = radar.find_max_peak_c(samp_rate, threshold, 0, [], False, "packet_len")
self.qtgui_sink_x_0 = qtgui.sink_c(
packet_len, #fftsize
window.WIN_BLACKMAN_hARRIS, #wintype
0, #fc
samp_rate, #bw
'QT GUI Plot', #name
True, #plotfreq
True, #plotwaterfall
True, #plottime
True, #plotconst
None # parent
)
self.qtgui_sink_x_0.set_update_time(1.0/10)
self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.qwidget(), Qt.QWidget)

self.qtgui_sink_x_0.enable_rf_freq(False)

self.top_layout.addWidget(self._qtgui_sink_x_0_win)
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
self.blocks_throttle_0.set_min_output_buffer(4096)
self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, packet_len, "packet_len")
self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 5000, 1, 0, 0)


##################################################
# Connections
##################################################
self.msg_connect((self.radar_find_max_peak_c_0, 'Msg out'), (self.radar_print_results_0, 'Msg in'))
self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0))
self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.qtgui_sink_x_0, 0))
self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.radar_ts_fft_cc_0, 0))
self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))
self.connect((self.radar_ts_fft_cc_0, 0), (self.radar_find_max_peak_c_0, 0))


def closeEvent(self, event):
self.settings = Qt.QSettings("GNU Radio", "test_find_max_peak_c")
self.settings.setValue("geometry", self.saveGeometry())
self.stop()
self.wait()

event.accept()

def get_threshold(self):
return self.threshold

def set_threshold(self, threshold):
self.threshold = threshold
self.radar_find_max_peak_c_0.set_threshold(self.threshold)

def get_samp_rate(self):
return self.samp_rate

def set_samp_rate(self, samp_rate):
self.samp_rate = samp_rate
self.analog_sig_source_x_0.set_sampling_freq(self.samp_rate)
self.blocks_throttle_0.set_sample_rate(self.samp_rate)
self.qtgui_sink_x_0.set_frequency_range(0, self.samp_rate)

def get_packet_len(self):
return self.packet_len

def set_packet_len(self, packet_len):
self.packet_len = packet_len
self.blocks_stream_to_tagged_stream_0.set_packet_len(self.packet_len)
self.blocks_stream_to_tagged_stream_0.set_packet_len_pmt(self.packet_len)




def main(top_block_cls=test_find_max_peak_c, options=None):

if StrictVersion("4.5.0") <= StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
style = gr.prefs().get_string('qtgui', 'style', 'raster')
Qt.QApplication.setGraphicsSystem(style)
qapp = Qt.QApplication(sys.argv)

tb = top_block_cls()

tb.start()

tb.show()

def sig_handler(sig=None, frame=None):
tb.stop()
tb.wait()

Qt.QApplication.quit()

signal.signal(signal.SIGINT, sig_handler)
signal.signal(signal.SIGTERM, sig_handler)

timer = Qt.QTimer()
timer.start(500)
timer.timeout.connect(lambda: None)

qapp.exec_()

if __name__ == '__main__':
main()
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@ install(FILES
os_cfar_2d_vc.h
estimator_ofdm.h
estimator_rcs.h
trigger_command.h
DESTINATION include/radar
trigger_command.h DESTINATION include/gnuradio/radar
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ set(QTGUI_MOC_HEADERS
scatter_plot.h
time_plot.h
spectrogram_plot.h)
QT5_WRAP_CPP(QTGUI_MOC_OUTFILES ${QTGUI_MOC_HEADERS})

qt5_wrap_cpp(QTGUI_MOC_OUTFILES ${QTGUI_MOC_HEADERS})

########################################################################
# Setup library
Expand Down Expand Up @@ -77,7 +78,7 @@ endif(NOT radar_sources)

add_library(gnuradio-radar SHARED ${radar_sources})
target_link_libraries(gnuradio-radar PUBLIC
gnuradio::gnuradio-runtime ${QT_LIBRARIES} fftw3f::fftw3f UHD::UHD qwt::qwt
gnuradio::gnuradio-runtime ${QT_LIBRARIES} fftw3f::fftw3f UHD::UHD qwt::qwt Qt5::Widgets
)
target_include_directories(gnuradio-radar
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
Expand All @@ -95,7 +96,7 @@ endif(APPLE)
# Install built library files
########################################################################
include(GrMiscUtils)
GR_LIBRARY_FOO(gnuradio-radar)
GR_LIBRARY_FOO(gnuradio-radar Qwt Qt5Widgets)

########################################################################
# Print summary
Expand Down
1 change: 1 addition & 0 deletions lib/scatter_plot.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <qwt_plot_marker.h>
#include <qwt_symbol.h>
#include <qwt_text.h>
#include <qwt_matrix_raster_data.h>

namespace gr {
namespace radar {
Expand Down
2 changes: 1 addition & 1 deletion python/radar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ GR_PYTHON_INSTALL(
include(GrTest)

set(GR_TEST_TARGET_DEPS gnuradio-radar)
set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR})
#set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR})

# Create a package directory that tests can import. It includes everything
# from `python/`.
Expand Down
3 changes: 1 addition & 2 deletions python/radar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@
# import pybind11 generated symbols into the radar namespace
try:
# this might fail if the module is python-only
from .bindings.radar_python import *
except ModuleNotFoundError:
from .radar_python import *
except ModuleNotFoundError:
pass

# import any pure python here
Expand Down
8 changes: 8 additions & 0 deletions python/radar/bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
########################################################################
# Check if there is C++ code at all
########################################################################
if(NOT radar_sources)
MESSAGE(STATUS "No C++ sources... skipping python bindings")
return()
endif(NOT radar_sources)

########################################################################
# Check for pygccxml
########################################################################
Expand Down
Loading