Skip to content

Commit 1fc8c16

Browse files
Modifying LDM and Sending and Recieving V2X Messages Through Ethernet Files
Feature/ldm fixes
2 parents 833941e + 1aeac98 commit 1fc8c16

25 files changed

+335
-245
lines changed

docs/.nojekyll

Whitespace-only changes.

docs/_sources/modules/facilities/local_dynamic_map.rst.txt

Lines changed: 88 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Local Dynamic Map Overview
2222
The Local Dynamic Map follows the `ETSI EN 302 895 V1.1.1
2323
(2014-09) <https://www.etsi.org/deliver/etsi_en/302800_302899/302895/01.01.01_60/en_302895v010101p.pdf>`__
2424
standard. Newer standards have been published, but no significant
25-
relevant changes have been introduced.
25+
relevant changes have been introduced. Please refer to the ETSI standard for more detailed information.
2626

2727
The Local Dynamic Map is composed of two subcomponents:
2828

@@ -31,7 +31,7 @@ The Local Dynamic Map is composed of two subcomponents:
3131

3232
--------------
3333

34-
Local Dynamic Map Service
34+
LDM Service
3535
~~~~~~~~~~~~~~~~~~~~~~~~~
3636

3737
The LDM is connected to authorized `LDM Data Providers <#ldm-data-providers>`__ and `LDM Data Consumers <#ldm-data-consumers>`__. `LDM Data
@@ -45,9 +45,10 @@ of interfaces:
4545
The LDM provides:
4646

4747
- Mechanisms for facilities to register and deregister as `LDM Data Providers <#ldm-data-providers>`__.
48-
- Mechanisms for applications to register and deregister as `LDM Data Providers <#ldm-data-providers>`__ or `LDM Data Consumers <#ldm-data-consumers>`__. - Verification of the authorization of `LDM Data Providers <#ldm-data-providers>`__ and `LDM Data Consumers <#ldm-data-consumers>`__ before granting data access.
48+
- Mechanisms for applications to register and deregister as `LDM Data Providers <#ldm-data-providers>`__ or `LDM Data Consumers <#ldm-data-consumers>`__.
49+
- Verification of the authorization of `LDM Data Providers <#ldm-data-providers>`__ and `LDM Data Consumers <#ldm-data-consumers>`__ before granting data access.
4950

50-
Local Dynamic Map Maintenance
51+
LDM Maintenance
5152
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5253

5354
The LDM is responsible for maintaining all `LDM Data
@@ -401,92 +402,118 @@ This will call the ldm_subscrition_callback every 0.5 seconds (notifiy_time) wit
401402
Quickstart
402403
----------
403404

404-
The Local Dynamic Map can be used in conjunction with the `VRU Awareness
405-
Message <vru-basic-service.md>`__ in its simplest form as follows:
405+
The Local Dynamic Map can be used in conjunction with any Facility Layer component, in this case the `VRU Awareness
406+
Message <vru-basic-service.md>`__ is presented;
406407

407408
.. code:: py
408409
409-
import logging
410-
import logging.config
410+
import logging
411+
import argparse
412+
from time import sleep
413+
from sys import exit
411414
412-
from flexstack.facilities.vru_awareness_service.vru_awareness_service import VRUAwarenessService
413-
from flexstack.facilities.vru_awareness_service.vam_transmission_management import DeviceDataProvider
414-
from flexstack.utils.static_location_service import ThreadStaticLocationService as LocationService
415415
416-
from flexstack.facilities.local_dynamic_map.factory import ldm_factory
417-
from flexstack.facilities.local_dynamic_map.ldm_classes import Location
416+
from flexstack.facilities.vru_awareness_service.vru_awareness_service import VRUAwarenessService
417+
from flexstack.facilities.vru_awareness_service.vam_transmission_management import DeviceDataProvider
418+
from flexstack.utils.static_location_service import ThreadStaticLocationService as LocationService
418419
419-
from flexstack.btp.router import Router as BTPRouter
420+
from flexstack.facilities.local_dynamic_map.factory import LDMFactory
421+
from flexstack.facilities.local_dynamic_map.ldm_classes import (
422+
Location,
423+
RequestDataObjectsResp,
424+
)
420425
421-
from flexstack.geonet.router import Router
422-
from flexstack.geonet.mib import MIB
423-
from flexstack.geonet.gn_address import GNAddress, M, ST, MID
426+
from flexstack.btp.router import Router as BTPRouter
424427
425-
from flexstack.linklayer.raw_link_layer import RawLinkLayer
428+
from flexstack.geonet.router import Router
429+
from flexstack.geonet.mib import MIB
430+
from flexstack.geonet.gn_address import GNAddress, M, ST, MID
426431
432+
from flexstack.linklayer.raw_link_layer import RawLinkLayer
427433
428-
logging.basicConfig(level=logging.INFO)
429434
435+
def __configure_logging(log_level: str) -> None:
436+
numeric_level = getattr(logging, log_level.upper(), None)
437+
if not isinstance(numeric_level, int):
438+
raise ValueError(f"Invalid log level: {log_level}")
439+
logging.basicConfig(level=numeric_level)
430440
431-
# Geonet
432-
mac_address = b"\x00\x00\x00\x00\x00\x00"
433-
mib = MIB()
434-
gn_addr = GNAddress()
435-
gn_addr.set_m(M.GN_MULTICAST)
436-
gn_addr.set_st(ST.CYCLIST)
437-
gn_addr.set_mid(MID(mac_address))
438-
mib.itsGnLocalGnAddr = gn_addr
439-
gn_router = Router(mib=mib, sign_service=None)
440441
441-
# Link-Layer
442-
ll = RawLinkLayer(iface="eth0", mac_address=mac_address,
443-
receive_callback=gn_router.gn_data_indicate)
444-
gn_router.link_layer = ll
442+
def ldm_subscription_callback(response: RequestDataObjectsResp) -> None:
443+
print(response.data_objects)
445444
446-
# BTP
447-
btp_router = BTPRouter(gn_router)
448-
gn_router.register_indication_callback(btp_router.btp_data_indication)
449445
446+
def configure_v2x(station_id: int, log_level: str) -> None | Exception:
447+
# Configure logging level
448+
__configure_logging(log_level)
450449
451-
# Facility - Location Service
452-
location_service = LocationService()
450+
# Geonet
451+
mac_address = b"\x00\x00\x00\x00\x00" + bytes([station_id])
452+
mib = MIB()
453+
gn_addr = GNAddress()
454+
gn_addr.set_m(M.GN_MULTICAST)
455+
gn_addr.set_st(ST.CYCLIST)
456+
gn_addr.set_mid(MID(mac_address))
457+
gn_router = Router(mib=mib, sign_service=None)
453458
454-
location_service.add_callback(gn_router.refresh_ego_position_vector)
459+
# Link-Layer
460+
ll = RawLinkLayer(iface="lo", mac_address=mac_address, receive_callback=gn_router.gn_data_indicate)
461+
gn_router.link_layer = ll
455462
456-
# Facility - Local Dynamic Maps
457-
ldm_location = Location.initializer()
458-
location_service.add_callback(ldm_location.location_service_callback)
459-
local_dynamic_map = ldm_factory(
460-
ldm_location, ldm_maintenance_type="Reactive", ldm_service_type="Reactive", ldm_database_type="Dictionary"
461-
)
463+
# BTP
464+
btp_router = BTPRouter(gn_router)
465+
gn_router.register_indication_callback(btp_router.btp_data_indication)
466+
467+
468+
# Facility - Location Service
469+
location_service = LocationService()
462470
463-
# Facility - Device Data Provider
464-
device_data_provider = DeviceDataProvider()
465-
device_data_provider.station_id = 1
466-
device_data_provider.station_type = 2 # Cyclist
471+
location_service.add_callback(gn_router.refresh_ego_position_vector)
467472
468-
# Facility - VRU Awareness Service
469-
vru_awareness_service = VRUAwarenessService(btp_router=btp_router,
470-
device_data_provider=device_data_provider,
471-
ldm=local_dynamic_map)
473+
# Facility - Local Dynamic Maps
474+
ldm_location = Location.initializer()
475+
location_service.add_callback(ldm_location.location_service_callback)
476+
ldm_factory = LDMFactory()
477+
local_dynamic_map = ldm_factory.create_ldm(
478+
ldm_location, ldm_maintenance_type="Reactive", ldm_service_type="Reactive", ldm_database_type="Dictionary"
479+
)
480+
ldm_factory.subscribe_to_ldm(
481+
own_station_id=station_id,
482+
ldm_location=ldm_location,
483+
callback_function=ldm_subscription_callback,
484+
)
472485
473-
location_service.add_callback(vru_awareness_service.vam_transmission_management.location_service_callback)
486+
# Facility - Device Data Provider
487+
device_data_provider = DeviceDataProvider(station_id=station_id)
474488
475-
# Applications would be declared here
489+
# Facility - VRU Awareness Service
490+
vru_awareness_service = VRUAwarenessService(
491+
btp_router=btp_router, device_data_provider=device_data_provider, ldm=local_dynamic_map
492+
)
493+
btp_router.freeze_callbacks()
494+
location_service.add_callback(vru_awareness_service.vam_transmission_management.location_service_callback)
495+
496+
497+
if __name__ == "__main__":
498+
args = argparse.ArgumentParser(description="FlexStack CAM Sender/Receiver")
499+
args.add_argument("--station-id", type=int, default=0, help="Station ID")
500+
args.add_argument("--log-level", type=str, default="INFO", help="Logging level (DEBUG, INFO)")
501+
args = args.parse_args()
502+
503+
configure_v2x(args.station_id, args.log_level)
504+
try:
505+
while True:
506+
sleep(1)
507+
except KeyboardInterrupt:
508+
print("\nKeyboardInterrupt caught. Cleaning up...")
509+
exit(0)
476510
477511
The only issue that may be encountered here is `Networking
478512
Interface <issues-networking-interface.md>`__.
479513

480514
Logging is included to provide a way to visualize sent messages. View
481515
`Logging <logging.md>`__ for detailed usage instructions.
482516

483-
--------------
484-
485-
Interfacing with the VRU Basic Service
486-
--------------------------------------
487-
488-
Interaction between the application layer and lower facility layers is
489-
done through the `Local Dynamic Map <local-dynamic-map.md>`__.
490517

491518
--------------
492519

docs/_sources/modules/tutorials/rawlinklayer-ethernet-deployment.rst.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,21 @@ Or;
9494
9595
AttributeError: 'RawLinkLayer' object has no attribute 'sock'
9696
97-
To fix this use ``sudo``. To use ``sudo`` the current path must be
98-
exported. To run the script run;
97+
To fix this use ``sudo``. Two options are possible;
9998

100-
.. code:: py
99+
1. Enter the command ``sudo su`` to become root.
100+
101+
.. code:: py
102+
103+
sudo su
104+
source <name_of_virtual_environment>/bin/activate
105+
python <name_of_script>.py
106+
107+
2. Run the script with ``sudo`` directly.
108+
109+
.. code:: py
101110
102-
sudo env PATH=$PATH python test.py
111+
sudo env PATH=$PATH python <name_of_script>.py
103112
104113
This should work and logging messages showing the components internal
105114
logs should start appearing.

docs/architecture.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@
136136
</li>
137137
<li class="toctree-l1"><a class="reference internal" href="modules/facilities/local_dynamic_map.html">Local Dynamic Map</a><ul>
138138
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#local-dynamic-map-overview">Local Dynamic Map Overview</a><ul>
139-
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#local-dynamic-map-service">Local Dynamic Map Service</a></li>
140-
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#local-dynamic-map-maintenance">Local Dynamic Map Maintenance</a></li>
139+
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#ldm-service">LDM Service</a></li>
140+
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#ldm-maintenance">LDM Maintenance</a></li>
141141
</ul>
142142
</li>
143143
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#ldm-declaration">LDM Declaration</a><ul>
@@ -154,7 +154,6 @@
154154
</ul>
155155
</li>
156156
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#quickstart">Quickstart</a></li>
157-
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#interfacing-with-the-vru-basic-service">Interfacing with the VRU Basic Service</a></li>
158157
</ul>
159158
</li>
160159
</ul>

docs/genindex.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@
133133
</li>
134134
<li class="toctree-l1"><a class="reference internal" href="modules/facilities/local_dynamic_map.html">Local Dynamic Map</a><ul>
135135
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#local-dynamic-map-overview">Local Dynamic Map Overview</a><ul>
136-
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#local-dynamic-map-service">Local Dynamic Map Service</a></li>
137-
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#local-dynamic-map-maintenance">Local Dynamic Map Maintenance</a></li>
136+
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#ldm-service">LDM Service</a></li>
137+
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#ldm-maintenance">LDM Maintenance</a></li>
138138
</ul>
139139
</li>
140140
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#ldm-declaration">LDM Declaration</a><ul>
@@ -151,7 +151,6 @@
151151
</ul>
152152
</li>
153153
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#quickstart">Quickstart</a></li>
154-
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#interfacing-with-the-vru-basic-service">Interfacing with the VRU Basic Service</a></li>
155154
</ul>
156155
</li>
157156
</ul>

docs/getting_started.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@
136136
</li>
137137
<li class="toctree-l1"><a class="reference internal" href="modules/facilities/local_dynamic_map.html">Local Dynamic Map</a><ul>
138138
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#local-dynamic-map-overview">Local Dynamic Map Overview</a><ul>
139-
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#local-dynamic-map-service">Local Dynamic Map Service</a></li>
140-
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#local-dynamic-map-maintenance">Local Dynamic Map Maintenance</a></li>
139+
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#ldm-service">LDM Service</a></li>
140+
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#ldm-maintenance">LDM Maintenance</a></li>
141141
</ul>
142142
</li>
143143
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#ldm-declaration">LDM Declaration</a><ul>
@@ -154,7 +154,6 @@
154154
</ul>
155155
</li>
156156
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#quickstart">Quickstart</a></li>
157-
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#interfacing-with-the-vru-basic-service">Interfacing with the VRU Basic Service</a></li>
158157
</ul>
159158
</li>
160159
</ul>

docs/index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@
135135
</li>
136136
<li class="toctree-l1"><a class="reference internal" href="modules/facilities/local_dynamic_map.html">Local Dynamic Map</a><ul>
137137
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#local-dynamic-map-overview">Local Dynamic Map Overview</a><ul>
138-
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#local-dynamic-map-service">Local Dynamic Map Service</a></li>
139-
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#local-dynamic-map-maintenance">Local Dynamic Map Maintenance</a></li>
138+
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#ldm-service">LDM Service</a></li>
139+
<li class="toctree-l3"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#ldm-maintenance">LDM Maintenance</a></li>
140140
</ul>
141141
</li>
142142
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#ldm-declaration">LDM Declaration</a><ul>
@@ -153,7 +153,6 @@
153153
</ul>
154154
</li>
155155
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#quickstart">Quickstart</a></li>
156-
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#interfacing-with-the-vru-basic-service">Interfacing with the VRU Basic Service</a></li>
157156
</ul>
158157
</li>
159158
</ul>
@@ -351,7 +350,6 @@ <h1>Attributions<a class="headerlink" href="#attributions" title="Permalink to t
351350
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#ldm-declaration">LDM Declaration</a></li>
352351
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#local-dynamic-map-interfacing-options">Local Dynamic Map Interfacing Options</a></li>
353352
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#quickstart">Quickstart</a></li>
354-
<li class="toctree-l2"><a class="reference internal" href="modules/facilities/local_dynamic_map.html#interfacing-with-the-vru-basic-service">Interfacing with the VRU Basic Service</a></li>
355353
</ul>
356354
</li>
357355
</ul>

docs/modules/applications.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@
136136
</li>
137137
<li class="toctree-l1"><a class="reference internal" href="facilities/local_dynamic_map.html">Local Dynamic Map</a><ul>
138138
<li class="toctree-l2"><a class="reference internal" href="facilities/local_dynamic_map.html#local-dynamic-map-overview">Local Dynamic Map Overview</a><ul>
139-
<li class="toctree-l3"><a class="reference internal" href="facilities/local_dynamic_map.html#local-dynamic-map-service">Local Dynamic Map Service</a></li>
140-
<li class="toctree-l3"><a class="reference internal" href="facilities/local_dynamic_map.html#local-dynamic-map-maintenance">Local Dynamic Map Maintenance</a></li>
139+
<li class="toctree-l3"><a class="reference internal" href="facilities/local_dynamic_map.html#ldm-service">LDM Service</a></li>
140+
<li class="toctree-l3"><a class="reference internal" href="facilities/local_dynamic_map.html#ldm-maintenance">LDM Maintenance</a></li>
141141
</ul>
142142
</li>
143143
<li class="toctree-l2"><a class="reference internal" href="facilities/local_dynamic_map.html#ldm-declaration">LDM Declaration</a><ul>
@@ -154,7 +154,6 @@
154154
</ul>
155155
</li>
156156
<li class="toctree-l2"><a class="reference internal" href="facilities/local_dynamic_map.html#quickstart">Quickstart</a></li>
157-
<li class="toctree-l2"><a class="reference internal" href="facilities/local_dynamic_map.html#interfacing-with-the-vru-basic-service">Interfacing with the VRU Basic Service</a></li>
158157
</ul>
159158
</li>
160159
</ul>

docs/modules/btp.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@
136136
</li>
137137
<li class="toctree-l1"><a class="reference internal" href="facilities/local_dynamic_map.html">Local Dynamic Map</a><ul>
138138
<li class="toctree-l2"><a class="reference internal" href="facilities/local_dynamic_map.html#local-dynamic-map-overview">Local Dynamic Map Overview</a><ul>
139-
<li class="toctree-l3"><a class="reference internal" href="facilities/local_dynamic_map.html#local-dynamic-map-service">Local Dynamic Map Service</a></li>
140-
<li class="toctree-l3"><a class="reference internal" href="facilities/local_dynamic_map.html#local-dynamic-map-maintenance">Local Dynamic Map Maintenance</a></li>
139+
<li class="toctree-l3"><a class="reference internal" href="facilities/local_dynamic_map.html#ldm-service">LDM Service</a></li>
140+
<li class="toctree-l3"><a class="reference internal" href="facilities/local_dynamic_map.html#ldm-maintenance">LDM Maintenance</a></li>
141141
</ul>
142142
</li>
143143
<li class="toctree-l2"><a class="reference internal" href="facilities/local_dynamic_map.html#ldm-declaration">LDM Declaration</a><ul>
@@ -154,7 +154,6 @@
154154
</ul>
155155
</li>
156156
<li class="toctree-l2"><a class="reference internal" href="facilities/local_dynamic_map.html#quickstart">Quickstart</a></li>
157-
<li class="toctree-l2"><a class="reference internal" href="facilities/local_dynamic_map.html#interfacing-with-the-vru-basic-service">Interfacing with the VRU Basic Service</a></li>
158157
</ul>
159158
</li>
160159
</ul>

0 commit comments

Comments
 (0)