Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AP-S 2020 - PyRaTk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DELTA
DELTA Low-Cost 5.8GHz FMCW Radar PCB
AP-S 2020 Software
AP-S 2020 - PyRaTk
Commits
e97f9d62
Commit
e97f9d62
authored
4 years ago
by
Merlo, Jason
Browse files
Options
Downloads
Patches
Plain Diff
Updated to be more general
parent
9ce2c5e6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pyratk/acquisition/nidaq.py
+16
-19
16 additions, 19 deletions
pyratk/acquisition/nidaq.py
pyratk/radars/radar.py
+7
-7
7 additions, 7 deletions
pyratk/radars/radar.py
pyratk/widgets/fft_widget.py
+9
-6
9 additions, 6 deletions
pyratk/widgets/fft_widget.py
with
32 additions
and
32 deletions
pyratk/acquisition/nidaq.py
+
16
−
19
View file @
e97f9d62
...
...
@@ -121,24 +121,21 @@ class nidaq(DAQ):
time
.
sleep
(
sleep_time
)
def
run
(
self
):
if
self
.
running
==
False
:
# Spawn sampling thread
self
.
running
=
True
self
.
t_sampling
=
threading
.
Thread
(
target
=
self
.
sample_loop
)
# Trigger DAQ to start running
self
.
start
()
try
:
if
not
self
.
t_sampling
.
is_alive
():
print
(
'
Staring sampling thread
'
)
self
.
t_sampling
.
start
()
self
.
paused
=
False
except
RuntimeError
as
e
:
print
(
'
Error starting sampling thread:
'
,
e
)
else
:
print
(
'
Warning: Not starting new sampling thread; sampling thread already running!
'
)
def
run
(
self
):
if
self
.
running
==
False
:
# Spawn sampling thread
self
.
running
=
True
self
.
t_sampling
=
threading
.
Thread
(
target
=
self
.
sample_loop
)
try
:
if
not
self
.
t_sampling
.
is_alive
():
print
(
'
Staring sampling thread
'
)
self
.
t_sampling
.
start
()
self
.
paused
=
False
except
RuntimeError
as
e
:
print
(
'
Error starting sampling thread:
'
,
e
)
else
:
print
(
'
Warning: Not starting new sampling thread; sampling thread already running!
'
)
def
start
(
self
):
self
.
run
()
...
...
@@ -153,5 +150,5 @@ class nidaq(DAQ):
self
.
t_sampling
.
join
()
except
Exception
as
e
:
print
(
"
Error closing sampling thread:
"
,
e
)
super
().
close
()
This diff is collapsed.
Click to expand it.
pyratk/radars/radar.py
+
7
−
7
View file @
e97f9d62
...
...
@@ -19,6 +19,7 @@ from pyqtgraph import QtCore
from
pyratk.formatting
import
warning
from
profilehooks
import
profile
# CONSTANTS
POWER_THRESHOLD
=
4
# dBm
...
...
@@ -36,7 +37,7 @@ class Radar(object):
"""
# === INITIALIZATION METHODS ==============================================
def
__init__
(
self
,
data_mgr
,
data_id
x
,
loc
=
Point
(),
def
__init__
(
self
,
data_mgr
,
inde
x
,
loc
=
Point
(),
f0
=
24.150e9
,
fft_size
=
2
**
16
,
fft_win_size
=
2
**
12
,
cluda_thread
=
None
):
super
(
Radar
,
self
).
__init__
()
...
...
@@ -55,7 +56,7 @@ class Radar(object):
# Data stream parameters
# TODO: create DataStream object representing I or I/Q data
self
.
data_mgr
=
data_mgr
self
.
index
=
data_id
x
self
.
index
=
inde
x
# Physical parameters
self
.
f0
=
f0
...
...
@@ -128,8 +129,7 @@ class Radar(object):
# === CONTROL METHODS =====================================================
def
update
(
self
,
data
):
# Get data from data_mgr
channel_slice
=
2
*
self
.
index
data_slice
=
data
[
channel_slice
:
channel_slice
+
2
]
data_slice
=
np
.
array
((
data
[
self
.
index
[
0
]],
data
[
self
.
index
[
1
]]))
# TODO remove ts_data, use data_mgr.ts_buffer instead
self
.
ts_data
.
append
(
data_slice
)
...
...
@@ -156,11 +156,10 @@ class Radar(object):
# self.fmax = self.bin_to_freq(vmax_bin)
self
.
drho
=
self
.
freq_to_vel
(
self
.
fmax
)
print
(
'
(radar.py) radar
'
,
self
.
index
,
'
drho:
'
,
self
.
drho
)
#
print('(radar.py) radar', self.index, 'drho:', self.drho)
def
reset
(
self
):
"""
Reset all radar data.
"""
print
(
"
(radar.py) Resetting radar {:}...
"
.
format
(
self
.
index
))
self
.
ts_data
.
clear
()
...
...
@@ -210,12 +209,13 @@ class RadarArray(QtCore.QObject):
radar
.
reset
()
self
.
last_sample_index
=
-
1
# @profile(immediate=True)
def
update
(
self
,
data_tuple
):
"""
Update all radars in array.
"""
# start_time = time.time()
data
,
sample_index
=
data_tuple
print
(
'
(radar.py) sample_num:
'
,
sample_index
)
#
print('(radar.py) sample_num:', sample_index)
if
sample_index
==
self
.
last_sample_index
+
1
:
self
.
reset_flag
=
False
...
...
This diff is collapsed.
Click to expand it.
pyratk/widgets/fft_widget.py
+
9
−
6
View file @
e97f9d62
...
...
@@ -14,7 +14,7 @@ import time # Used for FPS calculations
class
FftWidget
(
pg
.
GraphicsLayoutWidget
):
def
__init__
(
self
,
radar
,
vmax_len
=
100
,
show_max_plot
=
False
,
fft_yrange
=
[
-
100
,
100
],
fft_xrange
=
[
-
5000
,
5000
]):
fft_yrange
=
[
-
100
,
100
],
fft_xrange
=
[
-
5000
0
,
5000
0
]):
super
(
FftWidget
,
self
).
__init__
()
# Copy arguments to member variables
...
...
@@ -24,7 +24,7 @@ class FftWidget(pg.GraphicsLayoutWidget):
self
.
vmax_len
=
vmax_len
self
.
update_period
=
\
self
.
source
.
sample_chunk_size
/
self
.
source
.
sample_rate
self
.
show_max_plot
=
show_max_plot
and
False
self
.
show_max_plot
=
show_max_plot
# Add FFT max plot to layout
if
show_max_plot
:
...
...
@@ -38,8 +38,8 @@ class FftWidget(pg.GraphicsLayoutWidget):
xMax
=
0
,
yMax
=
20
,
yMin
=-
20
)
self
.
vmax_pw
=
self
.
vmax_plot
.
plot
()
self
.
vmax_line
=
pg
.
InfiniteLine
(
angle
=
0
,
movable
=
False
)
self
.
vmax_plot
.
addItem
(
self
.
vmax_line
)
#
self.vmax_line = pg.InfiniteLine(angle=0, movable=False)
#
self.vmax_plot.addItem(self.vmax_line)
# self.a_pw = self.vmax_plot.plot()
self
.
vmax_plot
.
setLabel
(
'
left
'
,
text
=
"
Radial Velocity
"
,
units
=
"
m/s
"
)
...
...
@@ -54,6 +54,9 @@ class FftWidget(pg.GraphicsLayoutWidget):
# fft_xrange = [-50 / self.radar.bin_size, 50 / self.radar.bin_size]
# fft_yrange = [-100, 0]
for
r
in
fft_xrange
:
r
/=
self
.
radar
.
bin_size
# Add FFT plot
self
.
fft_plot
=
self
.
addPlot
()
...
...
@@ -74,7 +77,7 @@ class FftWidget(pg.GraphicsLayoutWidget):
self
.
fft_ax_bottom
=
self
.
fft_plot
.
getAxis
(
'
bottom
'
)
self
.
fft_ax_bottom
.
setScale
(
self
.
radar
.
bin_size
)
self
.
fft_plot
.
setLabel
(
'
bottom
'
,
text
=
"
Frequency
"
,
units
=
"
Hz
"
)
self
.
fft_plot
.
setLabel
(
'
left
'
,
text
=
"
P
ower
"
,
units
=
"
dB
m
"
)
self
.
fft_plot
.
setLabel
(
'
left
'
,
text
=
"
P
SD
"
,
units
=
"
dB
v
"
)
# FPS ticker data
self
.
lastTime
=
time
.
time
()
...
...
@@ -87,7 +90,7 @@ class FftWidget(pg.GraphicsLayoutWidget):
self
.
vmax_pw
.
setData
(
vmax_data
,
pen
=
pg
.
mkPen
({
'
color
'
:
"
FFF
"
}))
self
.
vmax_pw
.
setPos
(
-
vmax_ptr
,
0
)
self
.
vmax_line
.
setValue
(
vmax_data
[
-
1
])
#
self.vmax_line.setValue(vmax_data[-1])
# a_data = self.radar.ts_a.data
# a_ptr = self.radar.ts_a.head_ptr
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment