Skip to content

Commit 350a6a0

Browse files
committed
Update IQ radar API and add MIMO radar demo
1 parent b818e1f commit 350a6a0

75 files changed

Lines changed: 3911 additions & 1246 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎demos/iq-mimo-radar/README.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# IQ MIMO radar
2+
3+
Shows moving reflections in range–Doppler and range–azimuth plots. Two opposite
4+
corner sensors transmit OFDM waveforms, and the remaining sensors receive.
5+
6+
Enable transmit authorization in each controller's web interface settings, then run:
7+
8+
```sh
9+
./demos/iq-mimo-radar/iq-mimo-radar.py -s 192.168.1.2
10+
# Or a combined array:
11+
./demos/iq-mimo-radar/iq-mimo-radar.py -c config/aperture-kit-8x4.yml
12+
```
13+
14+
The demo calibrates at startup and mutes transmission when closed.
15+
16+
- **Left drawer:** start/stop, RX sample rate, antenna feeds and calibration.
17+
- **Right drawer:** color scale, color limits and velocity view.
18+
- **Footer:** capture coverage and plot rate.
19+
20+
Lower sample rates extend the displayed range but reduce range resolution.
21+
Changing the rate recalibrates the array. Use `--help` for command-line options.
22+
23+
See [IQ Radar](../../docs/iq-radar.rst) for background and API documentation.
24+
Processing is in [mimo_processing.py](mimo_processing.py). After editing the
25+
shaders, run `./demos/iq-mimo-radar/compile_shader.sh`.

‎demos/iq-mimo-radar/RadarPlot.qml‎

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import QtQuick
2+
import QtQuick.Controls
3+
4+
Rectangle {
5+
id: plot
6+
color: "#192329"
7+
radius: 6
8+
property string title
9+
property string textureName
10+
property string axisLabel
11+
property real minimum: -70
12+
property real maximum: 70
13+
property real dataMinimum: minimum
14+
property real dataMaximum: maximum
15+
property real rangeMaximum: 15
16+
property real floorDb: 12
17+
property real spanDb: 12
18+
property bool linearScale: true
19+
20+
Label {
21+
anchors.top: parent.top
22+
anchors.topMargin: 18
23+
anchors.horizontalCenter: parent.horizontalCenter
24+
text: plot.title
25+
font.pixelSize: 22
26+
}
27+
Image {
28+
id: samples
29+
visible: false
30+
cache: false
31+
smooth: true
32+
source: "image://radar/" + plot.textureName + "/" + backend.revision
33+
}
34+
Item {
35+
id: chart
36+
anchors.fill: parent
37+
anchors.margins: 24
38+
anchors.leftMargin: 76
39+
anchors.topMargin: 64
40+
anchors.bottomMargin: 74
41+
ShaderEffect {
42+
objectName: "heatmapShader"
43+
anchors.fill: parent
44+
property var source: samples
45+
property real floorDb: plot.floorDb
46+
property real spanDb: plot.spanDb
47+
property real linearScale: plot.linearScale ? 1 : 0
48+
property real xLow: (plot.minimum - plot.dataMinimum) / (plot.dataMaximum - plot.dataMinimum)
49+
property real xHigh: (plot.maximum - plot.dataMinimum) / (plot.dataMaximum - plot.dataMinimum)
50+
property real beamspacePeriod: backend.beamspacePeriod
51+
property real polar: 0
52+
property real legend: 0
53+
vertexShader: "heatmap.vert.qsb"
54+
fragmentShader: "heatmap.frag.qsb"
55+
}
56+
Repeater {
57+
model: 5
58+
Item {
59+
required property int index
60+
x: index * chart.width / 4
61+
height: chart.height
62+
Rectangle { width: 1; height: parent.height; color: "#24ffffff" }
63+
Label {
64+
anchors.top: parent.bottom
65+
anchors.topMargin: 10
66+
anchors.horizontalCenter: parent.left
67+
text: (plot.minimum + index * (plot.maximum - plot.minimum) / 4).toFixed(plot.textureName === "doppler" ? 1 : 0)
68+
font.pixelSize: 15
69+
}
70+
}
71+
}
72+
Repeater {
73+
model: 4
74+
Item {
75+
required property int index
76+
y: (1 - index / 3) * chart.height
77+
width: chart.width
78+
Rectangle { height: 1; width: parent.width; color: "#24ffffff" }
79+
Label {
80+
anchors.right: parent.left
81+
anchors.rightMargin: 12
82+
anchors.verticalCenter: parent.top
83+
text: (index * plot.rangeMaximum / 3).toFixed(0)
84+
font.pixelSize: 15
85+
}
86+
}
87+
}
88+
}
89+
Label {
90+
anchors.horizontalCenter: chart.horizontalCenter
91+
anchors.bottom: parent.bottom
92+
anchors.bottomMargin: 16
93+
text: plot.axisLabel
94+
font.pixelSize: 16
95+
}
96+
Label {
97+
x: 14 - width / 2
98+
y: chart.y + (chart.height - height) / 2
99+
rotation: -90
100+
text: "Range relative to zero (m)"
101+
font.pixelSize: 16
102+
}
103+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import QtQuick
2+
import QtQuick.Controls
3+
4+
Rectangle {
5+
id: plot
6+
color: "#192329"
7+
radius: 6
8+
property real rangeMaximum: 15
9+
property real floorDb: 12
10+
property real spanDb: 12
11+
property bool linearScale: true
12+
13+
Label {
14+
anchors.top: parent.top
15+
anchors.topMargin: 18
16+
anchors.horizontalCenter: parent.horizontalCenter
17+
text: "Range–azimuth"
18+
font.pixelSize: 22
19+
}
20+
Image {
21+
id: samples
22+
visible: false
23+
cache: false
24+
smooth: true
25+
source: "image://radar/azimuth/" + backend.revision
26+
}
27+
Item {
28+
anchors.fill: parent
29+
anchors.margins: 44
30+
anchors.topMargin: 90
31+
anchors.bottomMargin: 80
32+
Item {
33+
id: chart
34+
width: Math.min(parent.width, parent.height * 2)
35+
height: width / 2
36+
anchors.centerIn: parent
37+
ShaderEffect {
38+
anchors.fill: parent
39+
property var source: samples
40+
property real floorDb: plot.floorDb
41+
property real spanDb: plot.spanDb
42+
property real linearScale: plot.linearScale ? 1 : 0
43+
property real xLow: 0
44+
property real xHigh: 1
45+
property real legend: 0
46+
property real beamspacePeriod: backend.beamspacePeriod
47+
property real polar: 1
48+
vertexShader: "heatmap.vert.qsb"
49+
fragmentShader: "heatmap.frag.qsb"
50+
}
51+
Canvas {
52+
anchors.fill: parent
53+
onWidthChanged: requestPaint()
54+
onHeightChanged: requestPaint()
55+
onPaint: {
56+
const ctx = getContext("2d");
57+
ctx.reset();
58+
ctx.strokeStyle = "#40ffffff";
59+
ctx.lineWidth = 1;
60+
for (let ring = 1; ring <= 3; ++ring) {
61+
ctx.beginPath();
62+
ctx.arc(width / 2, height, height * ring / 3, Math.PI, 2 * Math.PI);
63+
ctx.stroke();
64+
}
65+
for (let angle = -90; angle <= 90; angle += 30) {
66+
const a = angle * Math.PI / 180;
67+
ctx.beginPath();
68+
ctx.moveTo(width / 2, height);
69+
ctx.lineTo(width / 2 + height * Math.sin(a), height - height * Math.cos(a));
70+
ctx.stroke();
71+
}
72+
}
73+
}
74+
Repeater {
75+
model: 7
76+
Label {
77+
required property int index
78+
readonly property real angle: (index * 30 - 90) * Math.PI / 180
79+
x: chart.width / 2 + (chart.height + 22) * Math.sin(angle) - width / 2
80+
y: chart.height - (chart.height + 22) * Math.cos(angle) - height / 2
81+
text: (index * 30 - 90) + "°"
82+
font.pixelSize: 15
83+
}
84+
}
85+
Repeater {
86+
model: 3
87+
Label {
88+
required property int index
89+
x: chart.width / 2 + chart.height * (index + 1) / 3 - width / 2
90+
y: chart.height + 14
91+
text: ((index + 1) * plot.rangeMaximum / 3).toFixed(0) + " m"
92+
font.pixelSize: 15
93+
}
94+
}
95+
}
96+
}
97+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
set -eu
3+
cd "$(dirname "$0")"
4+
"${QSB:-/usr/lib/qt6/bin/qsb}" --glsl "300 es,120,150" --hlsl 50 --msl 12 -o heatmap.frag.qsb heatmap.frag
5+
"${QSB:-/usr/lib/qt6/bin/qsb}" --glsl "300 es,120,150" --hlsl 50 --msl 12 -o heatmap.vert.qsb heatmap.vert

‎demos/iq-mimo-radar/heatmap.frag‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#version 440
2+
layout(location = 0) in vec2 qt_TexCoord0;
3+
layout(location = 1) in vec4 displayScale;
4+
layout(location = 2) in vec2 powerScale;
5+
layout(location = 3) in vec4 texelScale;
6+
layout(location = 0) out vec4 fragColor;
7+
layout(binding = 1) uniform sampler2D source;
8+
layout(std140, binding = 0) uniform buf {
9+
mat4 qt_Matrix;
10+
float qt_Opacity;
11+
float floorDb;
12+
float spanDb;
13+
float xLow;
14+
float xHigh;
15+
float legend;
16+
float polar;
17+
float linearScale;
18+
float beamspacePeriod;
19+
};
20+
21+
vec3 color(float t) {
22+
vec3 dark = vec3(0.067, 0.098, 0.118);
23+
vec3 blue = vec3(0.08, 0.30, 0.48);
24+
vec3 green = vec3(0.16, 0.72, 0.55);
25+
vec3 yellow = vec3(0.98, 0.87, 0.24);
26+
if (t < 0.3) return mix(dark, blue, t / 0.3);
27+
if (t < 0.7) return mix(blue, green, (t - 0.3) / 0.4);
28+
return mix(green, yellow, (t - 0.7) / 0.3);
29+
}
30+
31+
void main() {
32+
float value;
33+
if (legend > 0.5) {
34+
value = qt_TexCoord0.x;
35+
} else {
36+
vec2 uv = qt_TexCoord0;
37+
if (polar > 0.5) {
38+
// Keep the nonlinear projection per pixel, including at the origin
39+
// and beamspace wrap. A mesh would only approximate these coordinates.
40+
float radius = length(uv);
41+
if (radius > 1.0) { fragColor = vec4(0.0); return; }
42+
float direction = radius > 0.0 ? uv.x / radius : 0.0;
43+
uv = vec2(fract(direction / beamspacePeriod + 0.5), radius);
44+
}
45+
uv = uv * texelScale.xy + texelScale.zw;
46+
vec3 encoded = texture(source, uv).rgb;
47+
value = dot(encoded.rg, displayScale.xy) + displayScale.z;
48+
value = clamp(value, 0.0, 1.0);
49+
if (linearScale > 0.5)
50+
value = (exp2((value - 1.0) * displayScale.w) - powerScale.x) * powerScale.y;
51+
}
52+
fragColor = vec4(color(value), 1.0) * qt_Opacity;
53+
}
3.87 KB
Binary file not shown.

‎demos/iq-mimo-radar/heatmap.vert‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#version 440
2+
layout(location = 0) in vec4 qt_Vertex;
3+
layout(location = 1) in vec2 qt_MultiTexCoord0;
4+
layout(location = 0) out vec2 qt_TexCoord0;
5+
layout(location = 1) out vec4 displayScale;
6+
layout(location = 2) out vec2 powerScale;
7+
layout(location = 3) out vec4 texelScale;
8+
layout(binding = 1) uniform sampler2D source;
9+
layout(std140, binding = 0) uniform buf {
10+
mat4 qt_Matrix;
11+
float qt_Opacity;
12+
float floorDb;
13+
float spanDb;
14+
float xLow;
15+
float xHigh;
16+
float legend;
17+
float polar;
18+
float linearScale;
19+
float beamspacePeriod;
20+
};
21+
22+
void main() {
23+
qt_TexCoord0 = qt_MultiTexCoord0;
24+
if (legend < 0.5) {
25+
qt_TexCoord0 = vec2(mix(xLow, xHigh, qt_MultiTexCoord0.x), 1.0 - qt_MultiTexCoord0.y);
26+
if (polar > 0.5)
27+
qt_TexCoord0.x = 2.0 * qt_MultiTexCoord0.x - 1.0;
28+
}
29+
// These depend only on display settings, not the sampled radar power.
30+
displayScale = vec4(vec2(65280.0, 255.0) * (128.0 / 65535.0) / spanDb,
31+
(-32.0 - floorDb) / spanDb, spanDb * (3.32192809489 / 10.0));
32+
float lower = exp2(-displayScale.w);
33+
powerScale = vec2(lower, 1.0 / (1.0 - lower));
34+
vec2 size = vec2(textureSize(source, 0));
35+
texelScale = vec4((size - 1.0) / size, 0.5 / size);
36+
gl_Position = qt_Matrix * qt_Vertex;
37+
}
3.01 KB
Binary file not shown.

0 commit comments

Comments
 (0)