use new api for run command in examples
This commit is contained in:
parent
a2aa7301d4
commit
6c33c8e37e
@ -10,15 +10,22 @@ from where_fi.collection.ingest import RealtimeCSIProducer
|
|||||||
from where_fi.config import config
|
from where_fi.config import config
|
||||||
from where_fi.visualise import server as visualise
|
from where_fi.visualise import server as visualise
|
||||||
|
|
||||||
producer = RealtimeCSIProducer()
|
app = CSIApplication(visualise_raw=True)
|
||||||
app = CSIApplication(producer, visualise_raw=True)
|
|
||||||
visualise.figures.all_figures["median"] = visualise.figures.RandomVariable(
|
visualise.figures.all_figures["median"] = visualise.figures.RandomVariable(
|
||||||
"Median Phase"
|
"Median Phase"
|
||||||
)
|
)
|
||||||
visualise.figures.all_figures["magn"] = visualise.figures.RandomVariable(
|
visualise.figures.all_figures["median_magn"] = visualise.figures.RandomVariable(
|
||||||
"Median Magnitude"
|
"Median Magnitude"
|
||||||
)
|
)
|
||||||
|
visualise.figures.all_figures["denoised"] = visualise.figures.PerAntennaFigure(
|
||||||
|
[
|
||||||
|
visualise.figures.SimpleLineChart("Denoised CSI Phase", "Subcarrier", "Phase"),
|
||||||
|
visualise.figures.SimpleLineChart(
|
||||||
|
"Denoised CSI Amplitude", "Subcarrier", "Amplitude"
|
||||||
|
),
|
||||||
|
],
|
||||||
|
[np.angle, np.abs],
|
||||||
|
)
|
||||||
measurements: list[np.complex64] = []
|
measurements: list[np.complex64] = []
|
||||||
|
|
||||||
|
|
||||||
@ -76,27 +83,28 @@ def _(proc: CSIMatrix) -> None:
|
|||||||
if proc_magn[i].full():
|
if proc_magn[i].full():
|
||||||
proc_magn[i].get()
|
proc_magn[i].get()
|
||||||
proc_magn[i].put(magn)
|
proc_magn[i].put(magn)
|
||||||
if cnt % 100 == 0:
|
print(sum(proc_phase[0, 0, 0].queue))
|
||||||
print(sum(proc_phase[0, 0, 0].queue))
|
app.visualise_data(
|
||||||
app.visualise_data(
|
np.array([x.queue for x in proc_phase.values()]),
|
||||||
np.array([x.queue for x in proc_phase.values()]),
|
"median",
|
||||||
"median",
|
)
|
||||||
)
|
app.visualise_data(
|
||||||
app.visualise_data(
|
np.array([x.queue for x in proc_magn.values()]),
|
||||||
np.array([x.queue for x in proc_magn.values()]),
|
"median_magn",
|
||||||
"magn",
|
)
|
||||||
)
|
app.visualise_data(
|
||||||
app.visualise_data(
|
np.array([x.queue for x in subcarrier_phase.values()]),
|
||||||
np.array([x.queue for x in subcarrier_phase.values()]),
|
visualise.figures.Figure.PHASE_ANALYSIS,
|
||||||
visualise.figures.Figure.PHASE_ANALYSIS,
|
)
|
||||||
)
|
app.visualise_data(
|
||||||
app.visualise_data(
|
np.array([x.queue for x in subcarrier_magn.values()]),
|
||||||
np.array([x.queue for x in subcarrier_magn.values()]),
|
visualise.figures.Figure.MAGN_ANALYSIS,
|
||||||
visualise.figures.Figure.MAGN_ANALYSIS,
|
)
|
||||||
)
|
app.visualise_data(proc, "denoised")
|
||||||
cnt += 1
|
cnt += 1
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
print("Starting app")
|
print("Starting app")
|
||||||
|
app.set_producer(RealtimeCSIProducer())
|
||||||
app.start()
|
app.start()
|
||||||
|
|||||||
@ -12,8 +12,7 @@ from where_fi.application import CSIApplication
|
|||||||
from where_fi.collection.ingest import RealtimeCSIProducer
|
from where_fi.collection.ingest import RealtimeCSIProducer
|
||||||
|
|
||||||
# Connect to a FeitCSI host
|
# Connect to a FeitCSI host
|
||||||
producer = RealtimeCSIProducer()
|
app = CSIApplication(visualise_raw=True)
|
||||||
app = CSIApplication(producer)
|
|
||||||
|
|
||||||
|
|
||||||
# Stores historical data for each receiving antenna, for each subcarrier
|
# Stores historical data for each receiving antenna, for each subcarrier
|
||||||
@ -21,7 +20,7 @@ historical: dict[tuple[int, int], Queue[np.complex64]] = {}
|
|||||||
|
|
||||||
MAGN_THRESHOLD = 20
|
MAGN_THRESHOLD = 20
|
||||||
PHASE_THRESHOLD = 0.5
|
PHASE_THRESHOLD = 0.5
|
||||||
QUEUE_SIZE = 2000
|
QUEUE_SIZE = 20
|
||||||
|
|
||||||
|
|
||||||
@app.on_process
|
@app.on_process
|
||||||
@ -62,6 +61,10 @@ def _(sample: npt.NDArray[np.complex64]) -> None:
|
|||||||
np.abs(mean - current) > MAGN_THRESHOLD
|
np.abs(mean - current) > MAGN_THRESHOLD
|
||||||
or np.abs(np.angle(mean) - np.angle(current)) > PHASE_THRESHOLD
|
or np.abs(np.angle(mean) - np.angle(current)) > PHASE_THRESHOLD
|
||||||
):
|
):
|
||||||
|
print(
|
||||||
|
f"Change detected in antenna {antenna}, subcarrier {subcarrier}: "
|
||||||
|
f"magn: {np.abs(mean - current)}, angle: {np.abs(np.angle(mean) - np.angle(current))}"
|
||||||
|
)
|
||||||
change = True
|
change = True
|
||||||
if change:
|
if change:
|
||||||
print("Motion detected!")
|
print("Motion detected!")
|
||||||
@ -69,4 +72,8 @@ def _(sample: npt.NDArray[np.complex64]) -> None:
|
|||||||
print("No motion detected!")
|
print("No motion detected!")
|
||||||
|
|
||||||
|
|
||||||
app.start()
|
if __name__ == "__main__":
|
||||||
|
# Start the application
|
||||||
|
print("Starting app")
|
||||||
|
app.set_producer(RealtimeCSIProducer())
|
||||||
|
app.start()
|
||||||
|
|||||||
@ -8,16 +8,8 @@ from where_fi.collection import CSIMatrix
|
|||||||
from where_fi.collection.ingest import RealtimeCSIProducer
|
from where_fi.collection.ingest import RealtimeCSIProducer
|
||||||
from where_fi.config import config
|
from where_fi.config import config
|
||||||
from where_fi.processing import aoa
|
from where_fi.processing import aoa
|
||||||
from where_fi.visualise import server as visualise
|
|
||||||
|
|
||||||
producer = RealtimeCSIProducer()
|
app = CSIApplication(visualise_raw=True)
|
||||||
app = CSIApplication(producer, visualise_raw=True)
|
|
||||||
visualise.figures.all_figures["median"] = visualise.figures.RandomVariable(
|
|
||||||
"Median Phase"
|
|
||||||
)
|
|
||||||
visualise.figures.all_figures["magn"] = visualise.figures.RandomVariable(
|
|
||||||
"Median Magnitude"
|
|
||||||
)
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
@ -65,4 +57,7 @@ def _(_: CSIMatrix) -> None:
|
|||||||
# return torch.abs(c)[:, 0, 0]
|
# return torch.abs(c)[:, 0, 0]
|
||||||
|
|
||||||
|
|
||||||
app.start()
|
if __name__ == "__main__":
|
||||||
|
producer = RealtimeCSIProducer()
|
||||||
|
app.set_producer(producer)
|
||||||
|
app.start()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user