-
Notifications
You must be signed in to change notification settings - Fork 0
Python UWB REST API
Ranging UWB nodes has never been that easy with simple python function call that returns when the ranging is done with the measure value
def test_uwb_twr():
for i in range(10):
initiator = 0
responder = 1
range_measure = uwb_twr(initiator, responder)
print(f"mp> range-{i} ({initiator})->({responder}) = {range_measure}")
return
console output :
mp> range-0 (0)->(1) = 0.436
mp> range-1 (0)->(1) = 0.389
mp> range-2 (0)->(1) = 0.394
mp> range-3 (0)->(1) = 0.371
mp> range-4 (0)->(1) = 0.399
mp> range-5 (0)->(1) = 0.347
mp> range-6 (0)->(1) = 0.375
mp> range-7 (0)->(1) = 0.356
mp> range-8 (0)->(1) = 0.371
mp> range-9 (0)->(1) = 0.403
and this is the output of the RF simplemesh
sniffer
sm{"uwb_cmd": "twr", "at_ms": 100, "initiator": 0, "responder": 1}
sm/C24FD51212E905F0{"initiator":0,"range":"0.436","responder":1,"seq":0,"uwb_cmd":"twr"}
sm{"uwb_cmd": "twr", "at_ms": 100, "initiator": 0, "responder": 1}
sm/C24FD51212E905F0{"initiator":0,"range":"0.389","responder":1,"seq":0,"uwb_cmd":"twr"}
sm{"uwb_cmd": "twr", "at_ms": 100, "initiator": 0, "responder": 1}
sm/C24FD51212E905F0{"initiator":0,"range":"0.394","responder":1,"seq":0,"uwb_cmd":"twr"}
sm{"uwb_cmd": "twr", "at_ms": 100, "initiator": 0, "responder": 1}
sm/C24FD51212E905F0{"initiator":0,"range":"0.371","responder":1,"seq":0,"uwb_cmd":"twr"}
sm{"uwb_cmd": "twr", "at_ms": 100, "initiator": 0, "responder": 1}
sm/C24FD51212E905F0{"initiator":0,"range":"0.399","responder":1,"seq":0,"uwb_cmd":"twr"}
sm{"uwb_cmd": "twr", "at_ms": 100, "initiator": 0, "responder": 1}
sm/C24FD51212E905F0{"initiator":0,"range":"0.347","responder":1,"seq":0,"uwb_cmd":"twr"}
sm{"uwb_cmd": "twr", "at_ms": 100, "initiator": 0, "responder": 1}
sm/C24FD51212E905F0{"initiator":0,"range":"0.375","responder":1,"seq":0,"uwb_cmd":"twr"}
sm{"uwb_cmd": "twr", "at_ms": 100, "initiator": 0, "responder": 1}
sm/C24FD51212E905F0{"initiator":0,"range":"0.356","responder":1,"seq":0,"uwb_cmd":"twr"}
sm{"uwb_cmd": "twr", "at_ms": 100, "initiator": 0, "responder": 1}
sm/C24FD51212E905F0{"initiator":0,"range":"0.371","responder":1,"seq":0,"uwb_cmd":"twr"}
sm{"uwb_cmd": "twr", "at_ms": 100, "initiator": 0, "responder": 1}
sm/C24FD51212E905F0{"initiator":0,"range":"0.403","responder":1,"seq":0,"uwb_cmd":"twr"}
Two Way Ranging Python API now supporting lists and count repeating sequences https://github.com/HomeSmartMesh/mesh_position/blob/6172ca5e348bad86b3946b5b430dc5ce9fd6ae81/py_serial/meshposition.py#L246
def db_uwb_twr(fileName):
print(f"-----------------test_uwb_twr_db({fileName})-----------------")
initiator = 0
responders = [1, 2, 3, 4]
result_list = uwb_twr(initiator=initiator, responders=responders, step_ms=10, count=3, count_ms=50)
newFileName = save_json_timestamp(fileName,result_list)
print(f"db_uwb_twr> saved results in {newFileName}")
return
Added new function to retrieve the accumulator of the Channel Impulse Response this high level python API is calling the underlying firmware function dwt_readaccdata() and sending it through simplemesh RF to the gateway.
Python usage Steps :
call a ping between two nodes uwb_ping_diag(n_init,n_resp) call a request to retrieve the cir accumulator uwb_cir("Resp") convert with numpy frombuffer with type i2 and plot We can notice the first path index of 750.4375 matches a rising edge of the accumulator cir
twr_list = mp.uwb_twr(initiator="Wired", responders=["Simple","Green"], step_ms=10, count=50, count_ms=30)
atl.plot_twr_list([("Wired","Simple"),("Wired","Green")], twr_list)
lists_list = [
("Green",["Simple","RR"]),
("RL",["Simple","RR"])
]
atl.range_graph("test_square_1",lists_list)
- graph generation python notebook mesh_position/ranging_graph.ipynb at main · HomeSmartMesh/mesh_position · GitHub 2
- graph viewing repo https://github.com/NetworkGraphs/graphysics