2 Commits
Author SHA1 Message Date
Ashin Walpola 875b389496 Add the bench RSU to the stored MAPEMs and let the bundle script take new files
The list now includes Berliner Tor / Kolbergstrasse (-1/23 rev 2), taken
from the 2026-11-25 V2X log. tools/mapem_bundle.py merges MAPEMs from V2X
log databases or hex text files into the existing list instead of
rebuilding it from the test corpus.
2026-11-30 14:00:59 +01:00
Ashin Walpola 750a752527 Ship the recorded HafenCity MAPEMs with the app and match SPATEMs to them
A SPATEM can now be placed on its lanes without the intersection's MAPEM
being received. The bundle (assets/mapem/hamburg.txt, built by
tools/mapem_bundle.py) holds 15 intersections, 16 revisions, from the
2026-03-18 drive.

Matching is on region, intersection id and revision, never on station id,
and a stored map more than 2 km from the rider is ignored. A live MAPEM of
the SPATEM's revision wins; a stored one of another revision is never used.
2026-11-30 13:45:34 +01:00
8 changed files with 351 additions and 6 deletions
+13
View File
@@ -5,6 +5,19 @@ Engineering to-do list. The reviewer-facing open items live in
## Waiting on hardware
### Stored HafenCity MAPEMs (added 2026-11-30)
The app ships 15 intersections (16 revisions) from the 2026-03-18 drive plus the bench RSU
(Berliner Tor / Kolbergstrasse, -1/23 rev 2) in `assets/mapem/hamburg.txt`, and matches a SPATEM to
them on region, intersection id, revision and, when known, position within 2 km. Add to the list with
`py -3.11 tools/mapem_bundle.py <V2X log .db or hex .txt>`, then run the tests and rebuild.
- [ ] Bench RSU sending its SPATEM **without** the MAPEM: the lanes appear on the V2X map; logcat says
`storedMaps: 17 intersection revisions loaded`.
- [ ] Ride through HafenCity: note intersections whose SPATEM shows no lanes (revision changed since
March, or not in the bundle) and check on the ones that do that the shown light matches the real one.
- [ ] Not built yet: saving newly heard or changed MAPEMs on the phone, so the list updates itself.
### Large SPATEM / MAPEM through V2X_RX in fragments (added 2026-11-23)
The 2026-11-23 bench run (CiT node sending a 377 B MAPEM and 58 B SPATEM, then 1198 B and 888 B ones; phone on
+36
View File
@@ -0,0 +1,36 @@
# Stored MAPEMs. One UPER MAPEM per line, hex, each below a comment naming its intersections.
# Written by tools/mapem_bundle.py; add to it with that script.
# -1/23 rev 2 Berliner Tor / Kolbergstrasse
02054149af940801038e42cbcb669dd97920a9bf9205e825efd98b2f2cfcfa72c3cf9e5000b8255642f5d9c50d15ac419009601456c0ad802742cbcb669dd97920a9bf920d3b85080000600370c942ae092d5b0496ad024a56c125ab4092d5b0496ad824a568125ab6092d5a0496ad824a568125ab6092d5b0496ad024b56c1252b4092d5b0496ad824b5681252b6092d5a0496ad824b5681252b6092d5b0496ad024b56c125ab409295b0496ad824b568125ab609295a0496ad824b568125ab609295b0496ad024b56c125ab4092d5b0494ad824b568125ab609295b0494af824a57c124abc09295f0494af824a57c124abe09295f0488b5023c6a4121b3e2b0440001005831000100a8011f0b2f2d9a7765e482a6fe4837f5e824400001b85c18db0494ad824b56c125ab4092d5b0494ad024b56c125ab6092d5a0496ad824a568125ab6092d5a0496ad824a56c125ab4092d5b0496ad024a56c125ab6092d5a0496ad824b5681252b6092d5a0496ad824b56c1252b4092d5b0496ad024b56c1252b6092d5a0496ad824b568125ab609295a0496ad824b56c125ab409295b0496ad024b56c125ab609295a0496ad024a57c1252be09295f0492af024a57c1252be09255f0494af824f54c125328090d9e6c03425efd98b2f2cfcfa72c3cf9e541a771210000140078119d1800ee41c05f21b02db0e818a85c0b83ca054de002d4f2819e72c0c4b820665c90378e181af6e00c1b1a06118d02ecc1016c6b00be36a05edb502f6da01756c40ac36e057db902c0dd01a87640fab8c07a17803cebb81d84a808c32e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb81606e00afb6e2b0220004025834000181a802232f7ecc597967e7d3961e7cf2a0dfd7a1110000078127d5dc0e143005822002dd0e815188809bbb6054de00278ee01756d80c538005e5b90342d581ad6d80c1318060d8d0320cc818a6f40be36a05edb402f6da81826e40b3b78057dba02bedd01176640ec252079d7803cebb81f67140d3bae057db802bedb815f6e00afb6e0581b802bedb815f6e00afb6e057db802c0db815f6e00afb6e057db802c0db815f6e00afb6e057db802bedb81606e00afb6e057db802bedb815f6e00b036e057db802bedb815f6e00b036e057db802bedb815f6e00afb6ed80acc2cba5064cbc9048c3d7874cd97ae5e5df0e3d195069dc684000060010072364504510b82a992815148e0a864705452382a192015148e0a8a4705432382a291c150c8e0a8a4705452382a191c1514900a864705452382a4920151c900a924805492402a4920151c900a924805492402a4920151c900a9248054523829691814bc8e0a5e46052f238ac0900014116090000a0aa00cd42cba5064cbc9048c3d7874cd97ae5e5df0e3d19506febd0c880000200edba82086a0f05372202a191c15148e0a8a4705432382a291c150c8e0a8a4705452382a192015148e0a864705452382a291c150c8e0a8a4705492402a39201524900a924805472402a49201524900a924805472402a49201524900a9649053323829791c14bc8e0a5e46
# 1/1 rev 2 MAP_ITS_03\310\5.2
020500ff3b6208000308cd8342fc9a94efb067719b16171aae6500010001042ac7d5cd389e98d881450d240314200000057fb8d632200bce2061ad419ea25e00b0c8000101100c22200000059f074a9208f383d45501c3ae04804284000000b3028afdd1005e7102f56a8cf4b2f10585c00008108059110000002cf9d66620479c1ea2a80e1d70240e14021000000afe339584401544436946e3336cd18161f0000406201e4404200000166fb9320822a20f5136070eac12049210000002da0a08c79440179c983032e44c65da950583400018208030910000002cc6471bc0479c01555001829524082420000005b405716c08802f393038666c98e9b4ca0b0580003051005122000000598a2612208f3802aaa003052a480e484000000b3fb5a9011005e726084ccb931dd694c1609000060c2008244000000b30d2bda811e70055540060a54900450800000166133693a200bce205cad619e8e5e40b0a8000107100a22200000059f6e4ef808f383d45501c3ae0
# 1/1 rev 3 MAP_ITS_03_312_6.3
020500122a7408000308cd8342fc9a94efb0677d9b1657db2e6700010001062ac7e6c6389e8341014524240624200000059ea6242680020f415a1ec1588e2b0f800010c58190001008807a1100000024c39963a0047520009a34400c488800001275dcc1282adf5432370612029210000002cf37d0e1400107a6ac8f5e2c3f05874000086880721100000024c1d54ff004d518015aa09010908000001678e47d7a00083d55607af462682c36000043840350880000011fff07a800a6a209f39744818884000008b2e9d3f290004010d4a213ca82111ad0e8406d62116d4d68858e97467aa96a885aa924436b45c23d796a1058d3a083a6a50464733833c0cbd4669e94f0c8072c4103fcbb04b1c511588900018cac26000103c4044c8880000126576511013e0d00a711e201244400000093af12d881eb2b01e74b60902d1080000115fc181fa80020096a4109f540888ce878201eb208b6e6b442cb4b833d54b5442d549221b4a2e11eb4b5082d69cc41d3528232199c19dea5f03346ca8c63f7963881d25e025263702c2200010404020888000001276bc64a03d65603ce96c12052210000022bfb788c50004014d442140a801118d0f0401566116e4d60859e97067aa96a885aa924436545e23d596b105cd39083a2a50463f33a33b9cbe8667c9540c7d52ca10344bd048d4700583c000208880391100000024ef2cdc507aaac079d2d8241034220000459a259348800204f8341af5cf8611763104bd05d624aa065128a0f7894104006bc13240944056c49e62aa158c3a828600085500c622eb8730895ccd000030ba13ca530488e430eb0920005125841000289ac1c800145161a8000a34b0e400051b587a00028e2c0e00020256568000a3a4804284400003b386364310004156faa39c2e57035afc482b6f2813cf0819cdb785571ada1979ba9161e4000c04b0e200060358690003022c460001c156564000c164802284400008b399d62a10004156faa2a42e231d0a74fa39696cb07321e5992446dae872dbc7a8ebb98b61552610872ffbd15a5e5087ccf660f91e9e1c977e43c4680876ec760f448f61f5b1bcd60e8000c0cb084000607584a0003042ca9000182840ad08084000002ccd297ba0460c01c590010ab6102a22021000000b38ab28f0118307acb383d159810498102000000ced41692400104bef10084c04104d8102000000cdbf17ed400103430f008480810518102000000cd5a8a54400104baee008540c10558102000000cc7bcbaa4001034712008501010590084000000cedf14c3400104bef08085c14005c8084000000cd63565e400103410d020c2010800000198af19ba8002068a20010c83000c901080000019aee16ac80020979dd042c604080000033c1c4df11005e7043d2f828b4245410b58102000000ceb84f91440179c0f13420a2c0a16042e604080000033a813b591005e7043f2f828bc2c5c10bd8102000000ce568b4e440179c0f0b420a2e0c18043060408000003326059991005e704412f828c4347810c58102000000cc4c12e7440179c0f53720a300e1f04326040800000330d948d51005e704432f028cc3c8010cd8102000000cbe80ebb440179c0efb440a32102100346021000004b46d8a439011511e0c1d8a4cb65b8926d06c5e07ab22d1f7516880fe5da278bab400f658c450f407da2e614f600356021000000b6a9c1bb5811511071d308806ee200
# 1900/2396 rev 3 MAP_ITS_23_2396_12.3
02050000302908000309cd8342fc9a94efb2677d93372dafb164b99c1db0257018ab1d58e8e27e146a05147090109080000036724ae59a00082bf0c873a533b86ab9744e0f30280082b0f800011b581200010f0807a1100000024c7271ad0283e701d9938901490800000267454e862200b9c0afc325d81822680081a9433856210000238b0b2000226101042200000049982e3d20507ce03794c12099201080000059d293e968802ce02c00c4940c976e2b14800011d589100010f880a2101080000059a3d628608c18141f380fad9620042440000012f9c386f0479c083bf6815a10400402d50288091901080000059fb1c8a208ce0741b960462fa92049a10000002cf2f675e400107d6d59337672e4160e8000640200e444000000b36da793011e7057e1902305ec9028d08000001679c9464a200bce0fadab26710e4a82c0a00010849044d0084000002ceca6a5144017381f63564ce21c951581c0002112c508000cdc400c48084000002be5766e0118302dcd220224750010903510800000165f65842a0008141f3849d7eee0b0b4000523100b32200000059ed9cbb208dfa3eb6ac12280586f092072210000002cbab7026440179c0a0f9c24e7f3a1583c0003122c08800149490045088000055f69ed86880319003180044a105023267dc19ec9ec221fd7801103bc52ac2e0001c9d60e4001050b082000829589400039b2c3d00020e1620800107220104404200000166abcf410233809194d052051120aa201080000097df5f51a200b061627950072de224f7e6515844000495ac0c80028a810598102000002cc90aebd400142bedca002018f738142e1658082ec08100000066a9780a200083129e4142c185a0830c0810000005f9539de800203c182050c8697020cb020400000598af5cae8002890e1f4004059b2f8286038bc10698102000000ce416b404001031d8a8286c3cc0106d8102000000cf0c2383400104e475828683cc410718102000000bf0debb500040d06380a1d1032041d60408000002ffb15c3400104c0720287044cc10798102000000cd03e0c5400101aaf68287c48d0107d8102000000ce9f212e400106a7098287848d40
# 3/120 rev 1 MAP_ITS_01_120_6.1
0205000177d308000308cd8342fc9a94efb0637d8b2617db2e6300030078022ac82671b8a0b56681450d24082420000009b0b7aaf068002007d7d19e59bdc336c362416070000210200624400000096234d61701f050c0ca66424072420000009b0c26ac968002007d7d026ce490efc723816090000212200824400000096248d5c701f050c0d0e7424062420000009b0cc0aa228002007d7d080962c3107b510160b000020a200a24400000096261157941f050c0d82502401142000000db0fc4b77480020f76960f87a503d0ad0bc79c59d402c2a000081840288880000012c26a2d6700225b426f5aa12010a10000006d883e5a74400107c1430b95a9745ea760a3cf1cf101613000040e20124440000009614e56644008aba13a8d84102d8102000000d86415bfe4001032b83828300c0410318102000000d86ed5961400104ac708282c0c0810358102000000d871b5886400103599002838100c10398102000000d87f954df400105027c028341010
# 3/121 rev 4 MAP_ITS_01_121_17.4
0205001233b4080003094d8342fc9a94efb0637d8b2637d8b75cd2000600f211558fedf6713dabfa1000028a1648042804200000461f312fd8230614fdc0c4cf1896272fc441ba6f9ae4761b7ed0585c0000808805990108000001619f932823061bca52c900450c00000518076e341515ba04d9582c271ad0113b9eec89daf8b08ebaeeb00b0a8000102100a3230000000628f98c86f294b2408342000000d65639ec023ce0bc87315ca1680f3262e715db99b82c18800080c4018888800001596176a20970839bc6c386ab992049a010800001165c5ab2823060bb87a15a395f0afc0a005b9e08a2c4a27e1582c0001822c188000814401448084000002b0c0f68c11830315ea81a1ff8901cd0c0000045913a65c08f382f71ac57385883cbe0c641b58521d003d41609000060c20082460000008c0e9d5b0311ef05cfe08040c60408000000cb496b0061f3f828341030103581020000003014d07c078b020a0c040d
# 3/165 rev 1 MAP_ITS_01_165_15.1
020500ffef5d080003094d8342fc9a94efb0637d8b66b7d8b55cc60006014a04558f6b78713f201c028a364802284000001b33e3b8c100040ef7fab781e42500100fec303744f578961b0000202b1220002025889000103080699100000024d519dfa049209022245c40490888000011f11e60c01390a099d54a4820884400000afcd8fe8400100a0859557cd9ebc56150000618b0b800030e100a22200000049fe5d2fe0e7b1607ffb91207a210000002bee6440d0004027214555f367af0584c000186880491100000024f9f2a440e16ad00daef7100b22021000000b68056211811830e626d40e12172405242000000d9d5252d880023c10d5205c537262e3faab1707ce302c35000103c9018908000008673e753ea0008f05154c16fb5c40bb02bb05e073cc3f04474c781990a8f2b13721e25a9243d2ed82416230000a2020228440000008f9dd1e5009c8504ceaa5240724200000219d5058fa8002aed1c60400416f65cb0bc0abf45e6d3e43f0547505fed4183c9a4d90787da428f4b16060589400028892061a11000006cda81e3440010492091612197b20918f19604973cd51458510003092c24800184d6164000c28b0380007045824000382920e1210000004ce74320940010e2b41c1e8ad8538c2b2200202c0c801040c400c48800000126e8fad98211d6c2fe76488020901080000059cb06a5c08c182b8f2415ada64836480420000016667b4bda200ad407e67103ed3c02c3900020544038c8084000002cd075dd60460c124824088917240824021000004b3960b365100551176a63106d8f01160ed380b4c295c5d194622d7e9812681d23d0fa5153e0ff17b23d7ada3016250000a2c480428042000001665e96d0a200b06276ad495432f25a00202c3a000241c104d8102000000cca3ec05440179c0cf3d80a140a08041460408000003371db3e11005e704c50a0084c2410558102000000cdfd6c42440179c0f34c00a160b0a04166040800000339da94cd1005e70434d0028542c2c105d8102000000ccd1a110440179c0d3ba60a180c1704186040800000336ec8bb11005e704b3168285c306010658102000000bfd757351005e703a33782868346410698102000000cc6020f9440179c1123460a190d1a
# 3/1745 rev 3 MAP_ITS_17_1745_10.3
0205001232f808000309cd8342fc9a94efb16f7d8b768d6fb160b99c000c1b441aab20465ce27b0616200005142c9018500840000029cdab9811831be7757237397f3c160700002022006640420000014eca07808c18a1a4d701130f2480a28400000107be3e71bdfb7b02763f7313a5f2c02c0a00004084008c880000010fd80c408c00f14389e912009a100000022e1e3902466a17006191ec0583c000101880389100000022dc876e13eb63681e7ff09010d0084000002af164ba0460c9109184e38b68e58161100004082010240420000015767bcb8230627d6c7703d9f20205b020400000058a2ba0899615400405060185820630204000000388cc701917d014160818081ac08100000016992fc21847b50010141c061a081cc08100000017afb170258840141a081c
# 3/2052 rev 3 MAP_ITS_20_2052_12.3
020500ffb03a08000309cd8342fc9a94efb2617d9306acafb164b99c000c20101aab1e4648e2792cf4200005147090045088000012ae75c04981c3fc0af425700c8b0d200010758610000842c19000082560e8000414b08400020b100d4220000004ab43ef77211deee423f1e00806211000000255a2f7a5208797761300f50401888800000120b8a97e07cdbd20e6a7c4200e444000000905b146b83ac1f207a9bd5100822021000000b05b242b411830e6f7c81f28f50900c90800000220af6ee48700c2b164fc27a3da35900101604400060c200424400000095784205742e3bd205e9e6f2404242000000882c6b8f61c030a55ccf0ea80084ecde1f20586c0002021202921000000241669b230e1e8425a1908269058640002029204a21000000855a3271aa0901774433c9e8a19741bfa20c68e211d4cb282c1e000140890291080000042ad05397784753c821a86f430cb7ae071091c6a88f22548160d0000a024816880420000056ad90b85d822d41344f6086dcbd3e210366a115fba3080ea34047072f80b088000503040e604080000015718dfd3c06c3ac0a0f060e040f6040800000157df5fefc1944540a0e060f04104021000001b00937ad811510e408dc1d26fe87d4687c9364585f014220e20002240420000006ae33bf0a022a223e379604126040800000103c179400f8cf40a130813041360408000001041e69b010e1aa0a120812041460210000003023a78e8118303f92e02854245010558084000000c09b5a490460c1049a80a140915041660408000001045f4e6c1096560a170a16041760408000001042e41a40f71aa0a160a1704186021000000302ce4e841183042f95828642c6010658084000000c0a3d0730460c0f49aa0a180b19041a60408000001573d9dc4c0663de0a1b0c1a041b6040800000157b79dcbc195c2c0a1a0c1b041c602100000035734de22411830176f202874347010758084000000d5ec978a30460c195c1e0a1c0d1d
# 3/2349 rev 5 MAP_ITS_23_2349_7.5
0205001225f4080003094d8342fc9a94efb2677d93368e6fb75cd60006125a15558ef699713ed5421000028a32480628400000210dd38b307adb8d50fd212fb05ab16030deb8169c6c0b08400010410082220000004816f339a186c76031b42312051a1000000255ab37dd109db78654f907a8b15841000103ac160001018901c908000004210c0d4f8e26a6b0146282d061e1af13b19a906239b1158290001842c108000c24401448800000121c5b01c831e898595f156200824400000090dee85fc19d45c2ca58a824093420000004ab50afe2213b4f0ca9f2cf4d80b04800040524011402100000110d8195a09810c4e83c5748003d127582c3200014084030c8084000002559df82ee00f0ea08dc9e10900850800000221b5120e930ef8b0c5ea73302c0a9080585c0002818805991000000255a06819e01b8ee88c2ddec901890800000220e3cd351232117c07112216961cccdfcc16168000c14081ac081000000217ed2e681e2ca8141c0e1a081cc0810000002193cfa7820f60c141a0e1c081ec0810000002adab420381ed9f41420101e0820c0810000002add6c085a2165c10010141e12200822c08100000060cb4dc40230682d5d0400405090508820930204000001847937b208c182bb86c142216240826c08100000060280d8c023060529f5050a0589820a3020400000181c8366608c1a37f895001014261828082a804200000160148e0e022a2434b5e1b2adb7bdf182858342c00588084000000c0dddc35045451bec288008082e804200000060c78e3b022a282e1d34004050c0706000c101080000058494b9be08a8876547d07c51a820fb0204000000ab7a2ffd287ce9140040510078f821030204000000ab83efa6c083d85050f84100
# 3/2394 rev 4 MAP_ITS_23_2394_9.4
0205001230ec080003094d8342fc9a94efb2677d93372d2fb95cd2000612b411558ef699713ed5421000028a2a480248042000002276537e41352fa0187e4eae20b232790161b0000208201a840420000011f6e775412e4d4c2411a3120112100000044ee66e9026a8940b8f2153a91e74a8160b0e8000105100e42200000047dfcd300485b4f096d6b4480e680420000072711f1330e7745db154609e8e8505fb5cdc8f1480082a4e2f20d442b039f41fb073c33ae82c3500008309018d080000072739316c8e7765da151d0fd0e8bc55115a30148a96cadc3520920e8647a51ce54ec42b0420003075829000184080211100000024f4269620717400728cb5100522200000049e5055560e127a0e55974480648400000213bf6b5249c49d2e83edad69c14947809678005251e02c2500010184024c8800000126a950af02bc0d836a839920622100000043f9e5cf020dd9f8cc4ee1619511c880b058000503240b44200000087f6cb00845234f196fdc18329f38dc16090000a0448148840000020ff594ba084c6a632a037bc4536e52109921c0773ce0b092000601241734200000189bad43cc0ae830155b0460e67a77e1cf18dd60b5c581595995a2a11d90010161c800041c081e80420000026657d178823063261b84844d2dd4332fbbb814200e1400204042000001673b12d4823061c4b3983d6ea00208b020400000099d0c3b40635d2050904088209302040000009cf748780a3a32050884090209b02040000009d69d88c894d4e4004050a0489820a302040000009ce35ff00776720509850a020ab02040000009db5d5d286eaab4004050b058a820b302040000009e12d10408a578050a860b00
# 3/2421 rev 3 MAP_ITS_24_2421_4.3
020500ffa9ca080003094d8342fc9a94efb2697d93464c6fb45cce000612ea0d558ed997713d5c091000028a2648028824000050a83ba1c42fcf8a22e087009109a0126f6242756da84fc6101980f4cc2083ff41236e31890ef08087c4e20c2b0980001015859000284880491090000024c6167cf07d31607f246d24034420000028540df9e22a37b710e244384d34b50953af8002f8b09dcc26311ef95821d7ec091d316c482f86843e5f109158340000812c2c80014204018888000001262c947503ef8c83f623992029201080000089815d9100fd2321ef762924dc7229605824000101880221010800000470b7d8404e63d909567a4480e4840000011304dad2c1f7c643cdec4749c95458c0b0280002041002422000000470dace3000f7882439e992041211000008cc18aa2c0479c3d7a240b1de1d41834360edb79060d0f02c2d0000c14402cc888000011e4d25a0093c110c8907848146864000020f8173670c4b30018d83c010d28c03c8a60434a30ac24800101960c400080e48186844000010f59d338046c080a39070871382b80ac0900018296088000c16081ac0810000001ccd781a07ea53050703868207302040000007378cb1a2116410010141a101c081ec0810000001fa73a1e07d27c050804878208302040000007f22b6d020758c141e12200822c081000000178e62a013b7c0142414220824c0810000001f3ca9d00ba20a05088509020ab020400000073a1c3a21e79fd0010142c102a082cc08100000015dd6f682085ac142a0e2c0
# 3/2422 rev 3 MAP_ITS_24_2422_4.3
02050012453c080003094d8342fc9a94efb2697d93464cafb45cce000612ec0d558edbb6713db4271000028a1648022804200000124e7184f87144432d02ac1ce82c22000040440208808400000239b7ff2c25d5b508b8dd1490085080000011de03e583e53c5acb595d0a660b07800010210072220000004737bf2b84d6b881167b9c120312100000023a8ef010644b72a905e574d41607000040620062440000008f085cb40f9e8f21eeb18c90149048000011c9174ac213e70b207d4e6d02c12000081040104848000011e10b6ee1c5110c5a5113c0812c0810000001d8abc640881760505018482053020400000092cce1fa077ace050482050206b0204000000766ce9001dda20141c061a081cc0810000001dc574e0087969050682070
# 3/2423 rev 3 MAP_ITS_24_2423_9.3
020500ffaf52080003094d8342fc9a94efb2697d93464cefb95cce000612ee0d558ee835713e2ed41000025826481468400000088b6f52463d9757153c45e9d4160f0000208200e4440000008f4296df0e2a86e1ecf15c9024d0800000111547408c7b0eae2a78bbd3702c1a000041440188880000011e7df0461c550dc3d9e2b92041a100000082284fc10020e5088f1d20037b3c00ecf5020ce582c110000818401048c800001242f185c81e4ab42d4ffd920092100000043c2b6a5c38aa1b933e488c0b420307422b0b80003075821000209880599100000023519e4202759e188fd9e3c90149048000021e0d77d61c530dc99dd44445a12783c7158210002042c560000c0c90085088000011bc63d1247523222237efe748ac2c800142562a4008228480628400000211fb6ca700ece3a374ee35c0ea6360233e403ad8e0ac19000182960e8000c16202a6424000008d429a420020e508ef1e201035810200000035e96c980f8d040a0e070d040e604080000009203260103b5e0a0d070e040f60408000000e6ffd6f05a50802840203c1041810200000036ed72c00bd3ee0a0f0810041160408000000eb13c5803eb2e028482444104981020000002e34dc6040ac3828442448104d0084000000acddda4045a8104b2a0a140a0c001420210000002e85bc2d045a80fc4ba0
# 3/2429 rev 1 MAP_ITS_24_2429_6.1
020500ffbb17080003094d8342fc9a94efb2697d93464e6fb65cc6000612fa04558f3b5e713fb33b028a16480228400000136f2ba4725000401215623f755b21ddebb582c2e0000404402c8880000012dfd6ca280750f1915e966412010a10000004dbd7290ba4001003e4b042b99a21c94b9082c32000040840308880000012e038c9a88784f2c15e966412019210000010dbdbc972940010e7bbda2c97bff1682f008f119b1d1e4bf4583cc268205a4fd783cf46d201906bc0b09800030310091220000004b749f29e800e8ff11252858202b0204000001b7f012348800208e5ae05030202020330204000001b7c1b276e8002876a3e40242828141014101d8102000000dbca595644001468448a0121414100a0c0810c0810000006dd8f4bc2200081c6944140e0a0e081a80420000076e0c2cde820008b3db3a477dcd350b15b57c58d1a163cc668245cabe041ae1fe87b16e1b02838082000388084000000dbce298244001084d33a
# 3/256 rev 1 HH02\256\9
02050012346c08000304c890c195c64d5b5c7300030100022ac7c7a8389ef572014534240324200000199b50cc1808f38b1e5c807c676f18f952ee11f1a1fea4e0861aa276811138fd611600587400030088072110000002b900ea3011e700353b04e7c88240424200000199b6dce6408f38b1d9c807c586f30f920ee31f141fea4e0561a9276791138fd5d1600587c0003010807a110000002b9246ebc11e700353b04e7c88240524200000199b8ad0b208f38b1c9c847c486f40f8eeee61f0e5fea4e0261a9276711130fd5916015884000301ac46000181040410880000015ca3f9a608f3801a9d8273e440808a110000002b96af7dc11e700353b04e7c88240b442000000571d7c37823ce006a762ad88446502c1a0001c144018888000001670131d7023ce0fb1a50ec56f84818884000000aa643d2c11e700373b156c422328160f0000e0c200e444000000b37d28a1c11e707d8d28762b7c240d44200000055295c5008f3801d9d4ab62111942b088000707585100068408041110000002cde6e1600479c1f634a1d8adf04028c880000011f325e3c08ec100c403d24802284000000b2a9bc23811e75bcd3166800a473afb2445871000084ac3c80004296204000216b11200010c585400018b92010a10000008cb09f0250479c4f0bafa075fce43e54f8233801a29443e34fa00292c21000083560e800041cb06400020f240934200000087fd26b5061a9f32c43e2a2a926300681960c4001020b07200081158410004092c45000384d6208001c28b0f4000e15587200070b0209203040800009a074bf208199c0509848c00099030408000099eb539a07ea64041440608100001344da7180fbcc80a150a1900152060810000134a89790104b38082c80c1020000268d30788209670142e1634002e40c10200002681d27e81f7990106101820400004d2864f603fb3202864306c006481820400004d3121060406ce020d202040800007416c37821a98414362a38003640810200001597e8201e667c107101020400002a5dd2003d2cf828745874007481020400003997e22c10bcc2083c80810200001d5b7bf8086261050f8b8f000f90204080000744ecb581e867c1081010204000039a9661c0f433e0a21181f002120408100000e8e3e2604313082112010408000076bdee5821998414463240004640410200001d64324a079d9f042440208100000eadb837043530828946884009480820400002c7fcb703cccf8213302040800007dd2f3d02627b4144e0844084ec0810200001e603ea6067a13051302118214201040800007e57e7c82627ac14520a48005240410200001e24bc76067a15042a40408100000fd8f057033d0a028ac3c9400ac81020400004c661fc504c4f602162020408000098a5be020981e3051688130016902040800007edc7df01a087410b901020400003da3c5140cfc2e0a2f1127002f20408100000fafd0c004c2f48218202040800007dab80b82617a814622450006240810200001ee6a120067e16043240208100000fd1f170033f0b828cc4ca400cc80820400004c9ea08204c2f4821a201040800007a92935819f868146a2854006a40410200001f5223660985e6
# 4/937 rev 4 MAP_ITS_09_937_23.4
0205000161d3080003094d8342fc9a94efb0737dcb36f7d9335cd20008075210558f5971713d6892028a6e48042840000022c6c0b9c40010d27c262b5fd6d04692a02de8f01164b04b19200010158b40001012c52000080c4065088800001211eeb9c08d0254c4483312202c64440000090a2f2a1829ec3405110e71014322200000485d4143c159243427882192008a11000006b2582bd90004166f902ba8f452c7d7501092facf54856168000608b041000313100b22220000048d5f923a1e8ca5858a0c364834884400002306464ad90004015d544352e75e02e51c00ba5b00b94722b044000405585c0002830802091100000234af1c50537d8501afde48906110880000160b608c9a000909aaa420642eb9312c3a000141d62c4000810b14200040a100e22220000048d120fe61db6b2859b0bb64826684400001313ec197d000469d62738cf7293720e568530ac12000182560b0000c28481448440000231cb93bf500045a40a182d2b4fb0598c482df0b41673182b04200070b58cc00040612069211000004c758cba940011ff68eba3edcad4c98f33af20b14400090d24255422000005944a82e6800200e6cc0947a720b2a8000a0e102a7222000004b458cb5700fbdc216caba692132a11000002ca44829e4001000f6b84bcd2e0594c0005078814b9110000025a2ff5bea07dee10b655d34908d9088000036c157ae9620008c64ecc118d7540c43c89530219c6a7182caa0002c4090919088000036c1572f5020008c9c8d981894d3c643b214f12197ca6082ca60002c44900c50084000006b0d9ac051005512547788092989d1a09680f09c2b25fc2058bc000609080b990108000005848c15d208a8812d0442a086588028901080000056a9a355022a219c7894545fb0c481848440000131da833c900047bd54a98fceaa0b26b1ee3a02c5900024549054d088000046256038520008d6c074e12219ce00d127027048a809736016328001a2c080cc08100000059f94c10800203a66b0503870b8203b02040000016a67288a0008317654140c1c300810c081000000581d541a800203de8c0504878c8204b02040000016401421a000830b5e014101e34081ec081000000635166592000819c394142020360820c0810000005af6c0d2800209931b0507880e0208b02040000018ce5949a800209931b0509088e8209302040000018c788fca80020670e50508888f020db020400000184f62b94800205d0f7050e090f820e30204000001859fb09c80020a3309050d8910020eb02040000018403a50280020a130d050f0990820f30204000001836da038800205f0f3050e8991020fb02040000018461186c8002038a5905100a11821030204000001866015ec80020c79a7050f8a120210b0204000001892d9084800203ae7005110a928211302040000018a7e0e6280020c559005108a930213b0204000001b08a2b91e80020838d405140b13821430204000001b0860bebe800207cb2c05138b140215a0108000001895212308002039e6605160a948016101080000018aa8103e80020c659a042d60210000003615c97dc500040f26540a2e162a042e60210000003616d972b1000410e1ac0a2d162b042f4021000000317bf219900040ce9ca0a30112c00302021000000318a12bb10004131e36086280420000005a8846b080020c3d82051907168019101080000016740257200080f19f810cd0084000000b1909a7d00041862f60a340f2e0034202100000030f4e6219000407a50a086a8042000000633066aa200081b237c146c205e006c40420000005aa9c31e8002093b21043740210000003087f37a10004079d060a3814300038202100000030d202e990004186afa0
@@ -30,7 +30,9 @@ import com.hawhamburg.micr0bu.domain.cam.OwnStationIds
import com.hawhamburg.micr0bu.domain.cam.OwnTxLoopback
import com.hawhamburg.micr0bu.domain.cam.StationType
import com.hawhamburg.micr0bu.domain.denm.DenmEvent
import com.hawhamburg.micr0bu.domain.map.IntersectionGeometry
import com.hawhamburg.micr0bu.domain.map.MapEvent
import com.hawhamburg.micr0bu.domain.map.StoredMaps
import com.hawhamburg.micr0bu.domain.spat.SpatEvent
import com.hawhamburg.micr0bu.domain.usecase.UseCaseAlert
import com.hawhamburg.micr0bu.domain.usecase.UseCaseDetectionEngine
@@ -210,6 +212,10 @@ class CamUseCaseRepository @Inject constructor(
*/
val decodedMap: SharedFlow<MapEvent> = _decodedMap.asSharedFlow()
private val _storedMaps = MutableStateFlow<List<IntersectionGeometry>>(emptyList())
/** The intersections the app ships with ([StoredMaps]); empty until the asset has been read. */
val storedMaps: StateFlow<List<IntersectionGeometry>> = _storedMaps.asStateFlow()
private val _decodedDenm = MutableSharedFlow<DenmEvent>(replay = 32, extraBufferCapacity = 32)
/**
* DENMs decoded from UPER, from either hardware path: the ESP32-C5 serial link or the CiT
@@ -220,6 +226,17 @@ class CamUseCaseRepository @Inject constructor(
val decodedDenm: SharedFlow<DenmEvent> = _decodedDenm.asSharedFlow()
init {
scope.launch {
runCatching {
context.assets.open(StoredMaps.ASSET_PATH).bufferedReader().use { StoredMaps.parse(it.readText()) }
}
.onSuccess {
_storedMaps.value = it
Log.d(TAG, "storedMaps: ${it.size} intersection revisions loaded")
}
.onFailure { Log.e(TAG, "storedMaps: cannot read ${StoredMaps.ASSET_PATH}", it) }
}
scope.launch {
mqttRepository.messages.collect { msg ->
when (msg.topic) {
@@ -0,0 +1,38 @@
package com.hawhamburg.micr0bu.domain.map
import com.hawhamburg.micr0bu.domain.asn1.MapemUperCodec
/**
* Intersection geometry the app ships with (`assets/mapem/hamburg.txt`, built by
* `tools/mapem_bundle.py` from recorded MAPEMs), so a SPATEM can be placed on its lanes without
* waiting for, or ever receiving, the intersection's MAPEM.
*
* Which stored intersection a SPATEM belongs to is decided in
* [com.hawhamburg.micr0bu.domain.spat.TrafficLights.geometryFor].
*/
object StoredMaps {
const val ASSET_PATH = "mapem/hamburg.txt"
/**
* One UPER MAPEM per line as hex; blank lines and `#` comments are skipped, as is a line that
* does not decode, so one bad entry does not cost the rest.
*/
fun parse(text: String): List<IntersectionGeometry> =
text.lineSequence()
.map { it.trim() }
.filter { it.isNotEmpty() && !it.startsWith("#") }
.mapNotNull { hexToBytes(it) }
.flatMap { MapemUperCodec.decode(it, 0L)?.intersections.orEmpty() }
.toList()
private fun hexToBytes(hex: String): ByteArray? {
if (hex.length % 2 != 0) return null
return ByteArray(hex.length / 2) { i ->
val high = Character.digit(hex[2 * i], 16)
val low = Character.digit(hex[2 * i + 1], 16)
if (high < 0 || low < 0) return null
(high * 16 + low).toByte()
}
}
}
@@ -153,6 +153,44 @@ object TrafficLights {
fun pickGeometry(candidates: List<IntersectionGeometry>, spatRevision: Int?): IntersectionGeometry? =
candidates.lastOrNull { it.revision == spatRevision } ?: candidates.lastOrNull()
/** A stored MAPEM is only used for a rider this close to its reference point. */
const val STORED_MAP_RADIUS_M = 2_000.0
/**
* The geometry for the intersection a SPATEM names, out of what was heard on air ([live],
* oldest first) and what the app ships with ([stored]).
*
* Both are matched on region and intersection id ([IntersectionGeometry.key]), never on the
* sending station: one intersection is heard under several station ids. In order:
*
* 1. a live MAPEM of the SPATEM's revision;
* 2. a stored one of that revision, within [STORED_MAP_RADIUS_M] of [own] when the position
* is known;
* 3. the newest live one of another revision (flagged by [TrafficLight.revisionMismatch]).
*
* A stored MAPEM of another revision is never used: it may be months old, and its signal groups
* could put the wrong light on a lane.
*/
fun geometryFor(
key: String,
spatRevision: Int,
live: List<IntersectionGeometry>,
stored: List<IntersectionGeometry>,
own: MapPoint? = null,
): IntersectionGeometry? {
val heard = pickGeometry(live.filter { it.key == key }, spatRevision)
if (heard?.revision == spatRevision) return heard
val shipped = stored.lastOrNull {
it.key == key && it.revision == spatRevision && (own == null || isNear(it, own))
}
return shipped ?: heard
}
private fun isNear(geometry: IntersectionGeometry, own: MapPoint): Boolean {
val (east, north) = geometry.toLocal(own)
return hypot(east, north) <= STORED_MAP_RADIUS_M
}
internal fun Maneuvers.single(): Turn? {
val turns = listOfNotNull(
Turn.STRAIGHT.takeIf { straight }, Turn.LEFT.takeIf { left },
@@ -302,20 +302,22 @@ class MqttViewModel @Inject constructor(
/**
* [spatIntersections] with each SPATEM's signal groups placed on its MAPEM's lanes, and the
* rider's own approach picked from their position and heading. An intersection whose MAPEM has
* not been heard (yet) is still listed, with no lanes: its signal groups stay bare numbers.
* rider's own approach picked from their position and heading. The MAPEM is one heard on air or
* one the app ships with ([TrafficLights.geometryFor]). An intersection with neither is still
* listed, with no lanes: its signal groups stay bare numbers.
*/
val trafficLights: StateFlow<List<TrafficLight>> = combine(
spatIntersections,
mapGeometries,
camUseCaseRepository.storedMaps,
camUseCaseRepository.ownPosition,
) { spats, geometries, own ->
val byKey = geometries.groupBy { it.key }
) { spats, live, stored, own ->
val position = own?.let { MapPoint(it.latitude, it.longitude) }
spats.map { spat ->
TrafficLights.join(
signal = spat,
geometry = TrafficLights.pickGeometry(byKey[spat.key].orEmpty(), spat.state.revision),
own = own?.let { MapPoint(it.latitude, it.longitude) },
geometry = TrafficLights.geometryFor(spat.key, spat.state.revision, live, stored, position),
own = position,
ownHeadingDeg = own?.headingDeg,
ownSpeedMps = own?.speedMps,
)
@@ -0,0 +1,105 @@
package com.hawhamburg.micr0bu
import com.hawhamburg.micr0bu.domain.asn1.SpatemUperCodec
import com.hawhamburg.micr0bu.domain.map.MapPoint
import com.hawhamburg.micr0bu.domain.map.StoredMaps
import com.hawhamburg.micr0bu.domain.spat.SpatIntersection
import com.hawhamburg.micr0bu.domain.spat.TrafficLights
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertSame
import org.junit.Assert.assertTrue
import org.junit.Test
import java.io.File
/** The bundled intersections, and which of them a SPATEM is matched to. */
class StoredMapsTest {
private val stored by lazy { StoredMaps.parse(File("src/main/assets/${StoredMaps.ASSET_PATH}").readText()) }
private val one by lazy { stored.last { it.key == "3/2349" } }
private val here by lazy { MapPoint(one.refLatitude, one.refLongitude) }
private fun pick(
key: String = one.key,
revision: Int = one.revision,
live: List<com.hawhamburg.micr0bu.domain.map.IntersectionGeometry> = emptyList(),
own: MapPoint? = here,
) = TrafficLights.geometryFor(key, revision, live, stored, own)
@Test
fun `bundle holds the recorded Hamburg intersections and the bench RSU, one per revision`() {
// Lower bounds: tools/mapem_bundle.py adds to the list.
assertTrue(stored.size >= 17)
assertTrue(stored.count { it.region != null } >= 16)
assertEquals(stored.size, stored.map { it.key to it.revision }.toSet().size)
}
@Test
fun `the bench RSU's SPATEM joins its stored intersection`() {
val hex = javaClass.classLoader!!.getResource("spatem_road_rsu_888.hex")!!.readText().trim()
val spat = SpatemUperCodec.decode(hex.chunked(2).map { it.toInt(16).toByte() }.toByteArray(), 0L)!!
val state = spat.intersections.single()
val matched = TrafficLights.geometryFor(state.key, state.revision, emptyList(), stored)!!
assertEquals("-1/23", matched.key)
val light = TrafficLights.join(SpatIntersection(state, spat.stationId, null, 0L), matched)
assertTrue(light.approaches.isNotEmpty())
assertFalse(light.revisionMismatch)
}
@Test
fun `every recorded intersection joins the SPATEM recorded for it`() {
val samples = javaClass.classLoader!!.getResource("mapem/spat_samples.txt")!!.readText()
.lines().filter { it.isNotBlank() }.associate { line ->
val (key, revision, hex) = line.split(" ")
(key to revision.toInt()) to hex.chunked(2).map { it.toInt(16).toByte() }.toByteArray()
}
// Entries added later may have no recorded SPATEM; the original 16 all do.
val sampled = stored.filter { it.region != null && (it.key to it.revision) in samples }
assertTrue(sampled.size >= 16)
for (geometry in sampled) {
val spat = SpatemUperCodec.decode(samples.getValue(geometry.key to geometry.revision), 0L)!!
val state = spat.intersections.single { it.key == geometry.key && it.revision == geometry.revision }
val matched = TrafficLights.geometryFor(state.key, state.revision, emptyList(), stored)
assertSame(geometry, matched)
val light = TrafficLights.join(SpatIntersection(state, spat.stationId, null, 0L), matched)
assertTrue("no approaches for ${geometry.key}", light.approaches.isNotEmpty())
assertFalse(light.revisionMismatch)
}
}
@Test
fun `matched on region and id together`() {
assertSame(one, pick())
assertNull(pick(key = "4/2349"))
assertNull(pick(key = "-1/2349"))
}
@Test
fun `a stored map of another revision is not used`() {
assertNull(pick(revision = one.revision + 1))
}
@Test
fun `a stored map far from the rider is not used, an unknown position does not block it`() {
// 0.03 deg of latitude is 3.3 km, beyond the radius; 0.01 deg is 1.1 km, inside it.
assertNull(pick(own = MapPoint(one.refLatitude + 0.03, one.refLongitude)))
assertSame(one, pick(own = MapPoint(one.refLatitude + 0.01, one.refLongitude)))
assertSame(one, pick(own = null))
}
@Test
fun `a live map of the same revision wins over the stored one`() {
val live = one.copy(name = "live")
assertSame(live, pick(live = listOf(live)))
}
@Test
fun `the stored map wins over a live one of another revision`() {
val live = one.copy(revision = one.revision + 1)
assertSame(one, pick(live = listOf(live)))
// And with nothing stored for the SPATEM's revision, the live one is still the fallback.
assertSame(live, pick(revision = one.revision + 2, live = listOf(live)))
}
}
+96
View File
@@ -0,0 +1,96 @@
"""Adds MAPEMs to the list the app ships with (app/src/main/assets/mapem/hamburg.txt).
py -3.11 tools/mapem_bundle.py FILE [FILE ...]
FILE is either
- a .db saved by the app's V2X data logger (its MAPEM rows are taken), or
- a text file with one UPER MAPEM per line as hex (`#hex <hex>` lines, as in the test corpus, too).
The list keeps what it already has and gains one entry per intersection and revision. A MAPEM of an
intersection and revision already listed replaces that entry. Review the printed changes, run the
unit tests, rebuild the app. Needs asn1tools (the ETSI modules in asn1/).
"""
import re
import sqlite3
import sys
from pathlib import Path
import asn1tools
ROOT = Path(__file__).resolve().parent.parent
ASN = ROOT / 'asn1'
OUT = ROOT / 'app/src/main/assets/mapem/hamburg.txt'
HEADER = ['# Stored MAPEMs. One UPER MAPEM per line, hex, each below a comment naming its intersections.',
'# Written by tools/mapem_bundle.py; add to it with that script.']
HEX = re.compile(r'(?:#hex )?((?:[0-9a-fA-F]{2})+)$')
def read_hex_lines(path):
for line in path.read_text(encoding='utf-8').splitlines():
found = HEX.match(line.strip())
if found:
yield bytes.fromhex(found[1])
def read_log(path):
db = sqlite3.connect(f'file:{path.resolve().as_posix()}?mode=ro', uri=True)
try:
for (payload,) in db.execute("select distinct payload from messages where msg_type = 'MAPEM'"):
yield bytes(payload)
finally:
db.close()
def add(entries, spec, uper, source):
"""Puts [uper] into entries {(key, revision): (uper, label)}; returns the keys that changed."""
try:
decoded = spec.decode('MAPEM', uper)
except Exception as error: # asn1tools raises several types
print(f' skipped a message from {source} that does not decode: {error}')
return []
changed = []
for i in decoded['map'].get('intersections', []):
key = (f"{i['id'].get('region', -1)}/{i['id']['id']}", i['revision'])
if key not in entries or entries[key][0] != uper:
changed.append((key, 'replaced' if key in entries else 'added', i.get('name')))
entries[key] = (uper, i.get('name'))
return changed
def main(files):
if not files:
raise SystemExit(__doc__)
spec = asn1tools.compile_files([str(ASN / n) for n in
('spatem_2_2_1.asn', 'mapem_2_2_1.asn', 'dsrc_2_2_1.asn', 'cdd_2_2_1.asn')], 'uper')
entries = {}
if OUT.exists():
for uper in read_hex_lines(OUT):
add(entries, spec, uper, OUT.name)
for name in files:
path = Path(name)
if not path.is_file():
raise SystemExit(f'{name}: no such file')
reader = read_log if path.suffix.lower() == '.db' else read_hex_lines
changed = [c for uper in reader(path) for c in add(entries, spec, uper, path.name)]
print(f'{path.name}: {len(changed)} change(s)')
for (key, revision), what, label in changed:
print(f' {what} {key} rev {revision} {label}')
body = []
written = set()
for (key, revision), (uper, _) in sorted(entries.items()):
if uper in written:
continue
written.add(uper)
body += [f'# {k} rev {r} {label}' for (k, r), (u, label) in sorted(entries.items()) if u == uper]
body.append(uper.hex())
OUT.parent.mkdir(parents=True, exist_ok=True)
OUT.write_text('\n'.join(HEADER + body) + '\n', encoding='utf-8', newline='\n')
print(f'{OUT.relative_to(ROOT)}: {len(entries)} intersection revisions, '
f'{len({k for k, _ in entries})} intersections')
if __name__ == '__main__':
main(sys.argv[1:])