Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust client functions #209

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

nbuffon
Copy link
Member

@nbuffon nbuffon commented Nov 15, 2024

New features

How to test

  1. Launch json_counter example

    cargo run --example json_counter
    

    Example runs and yields about the number of JSON messages received among the total

    Received 1000 messages including 997 as JSON
    Received 2000 messages including 1997 as JSON
    Received 3000 messages including 2997 as JSON
    ...

  2. Configure OTLP collector
    Edit the example/config.ini file to set the OTLP collector endpoint config by filling the following section

    [telemetry]
    host="otlp.domain.ext"
    port=4318
    ; Optionnal, defaults to "v1/traces"
    path="custom/v1/traces"
    
  3. Launch telemetry example

    cargo run --example telemetry --features telemetry
    

    Example runs and sends 4 traces

    Transport: standard MQTT; TLS disabled
    INFO [telemetry] logger ready on log
    INFO [telemetry] Send a trace with a single span 'ping' root span
    INFO [telemetry] └─ Ping                  trace_id: 4d9183d7274f4b8c850d46887f35141a, span_id: bd458664e66f860e
    DEBUG [reqwest::connect] starting new connection: http://90.84.47.115:18000/
    INFO [telemetry] Send a trace with a single span 'pong' root span linked with the previous one 'ping'
    INFO [telemetry] └─ Pong                  trace_id: 8479671f21bf9b0fd166b8ead1ff2761, span_id: 3c153c5e70a8a2a2
    INFO [telemetry] Send a single trace with two spans
    INFO [telemetry] └─ Root                  trace_id: cd4a1ee42952fcafc5eaf61f1881eca2, span_id: 7580f10ca1595e5b
    INFO [telemetry]    └─ Child              trace_id: cd4a1ee42952fcafc5eaf61f1881eca2, span_id: d570aff4e9889e95
    INFO [telemetry] Send a trace with 3 spans from 3 threads
    INFO [telemetry] └─ Main thread           trace_id: 6b1fe1d4b7aa574bbbe4b987053bcfd2, span_id: e5050064d17d0527
    INFO [telemetry]    ├─ Sender thread      trace_id: 6b1fe1d4b7aa574bbbe4b987053bcfd2, span_id: 9f449076f02efdd6
    INFO [telemetry]    └─ Listener thread    trace_id: 6b1fe1d4b7aa574bbbe4b987053bcfd2, span_id: d1bb7d93ec83207e
    
  4. Prepare a test script

    cat <<EOF > /tmp/test_copycat.sh
    #! /usr/bin/bash
    mosquitto_pub -h test.mosquitto.org -p 1884 -u rw -P readwrite -t default/outQueue/v2x/cam/ora_car_testcon2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2 -m '{"type":"cam","origin":"self","version":"1.2.0","source_uuid":"ora_car_2222","timestamp":1618591358923,   "message":{"protocol_version":2,"station_id":1077952580,"generation_delta_time":31571,"basic_container":{"station_type":5,   "reference_position":{"latitude":486230934,"longitude":22419064,"altitude":10000},"confidence":{"position_confidence_ellipse":   {"semi_major_confidence":0,"semi_minor_confidence":0,"semi_major_orientation":0},"altitude":1}},"high_frequency_container":   {"heading":2375,"speed":137,"drive_direction":0,"vehicle_length":47,"vehicle_width":24,"longitudinal_acceleration":1,   "lateral_acceleration":0,"vertical_acceleration":0,"yaw_rate":-27,"lane_position":0,"curvature":0,"confidence":{"heading":2,   "speed":3,"vehicle_length":1,"vehicle_width":1,"longitudinal_acceleration":5,"yaw_rate":6,"lane_position":1,"curvature":7}},   "low_frequency_container":{"vehicle_role":0,"exterior_lights":"00000000","path_history":[{"path_position":{},   "path_delta_time":1}]}}}'
    sleep 0.2
    mosquitto_pub -h test.mosquitto.org -p 1884 -u rw -P readwrite -t default/outQueue/v2x/cam/ora_car_testcon2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2 -m '{"type":"cam","origin":"self","version":"1.2.0","source_uuid":"ora_car_2222","timestamp":1618591358923,   "message":{"protocol_version":2,"station_id":1077952580,"generation_delta_time":31571,"basic_container":{"station_type":5,   "reference_position":{"latitude":486230934,"longitude":22419064,"altitude":10000},"confidence":{"position_confidence_ellipse":   {"semi_major_confidence":0,"semi_minor_confidence":0,"semi_major_orientation":0},"altitude":1}},"high_frequency_container":   {"heading":2375,"speed":137,"drive_direction":0,"vehicle_length":47,"vehicle_width":24,"longitudinal_acceleration":1,   "lateral_acceleration":0,"vertical_acceleration":0,"yaw_rate":-27,"lane_position":0,"curvature":0,"confidence":{"heading":2,   "speed":3,"vehicle_length":1,"vehicle_width":1,"longitudinal_acceleration":5,"yaw_rate":6,"lane_position":1,"curvature":7}},   "low_frequency_container":{"vehicle_role":0,"exterior_lights":"00000000","path_history":[{"path_position":{},   "path_delta_time":1}]}}}'
    sleep 0.2
    mosquitto_pub -h test.mosquitto.org -p 1884 -u rw -P readwrite -t default/outQueue/v2x/cam/ora_car_testcon2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2 -m '{"type":"cam","origin":"self","version":"1.2.0","source_uuid":"ora_car_2222","timestamp":1618591358923,   "message":{"protocol_version":2,"station_id":1077952580,"generation_delta_time":31571,"basic_container":{"station_type":5,   "reference_position":{"latitude":486230934,"longitude":22419064,"altitude":10000},"confidence":{"position_confidence_ellipse":   {"semi_major_confidence":0,"semi_minor_confidence":0,"semi_major_orientation":0},"altitude":1}},"high_frequency_container":   {"heading":2375,"speed":137,"drive_direction":0,"vehicle_length":47,"vehicle_width":24,"longitudinal_acceleration":1,   "lateral_acceleration":0,"vertical_acceleration":0,"yaw_rate":-27,"lane_position":0,"curvature":0,"confidence":{"heading":2,   "speed":3,"vehicle_length":1,"vehicle_width":1,"longitudinal_acceleration":5,"yaw_rate":6,"lane_position":1,"curvature":7}},   "low_frequency_container":{"vehicle_role":0,"exterior_lights":"00000000","path_history":[{"path_position":{},   "path_delta_time":1}]}}}'
    sleep 0.2
    mosquitto_pub -h test.mosquitto.org -p 1884 -u rw -P readwrite -t default/outQueue/v2x/cam/ora_car_testcon2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2 -m '{"type":"cam","origin":"self","version":"1.2.0","source_uuid":"ora_car_2222","timestamp":1618591358923,   "message":{"protocol_version":2,"station_id":1077952580,"generation_delta_time":31571,"basic_container":{"station_type":5,   "reference_position":{"latitude":486230934,"longitude":22419064,"altitude":10000},"confidence":{"position_confidence_ellipse":   {"semi_major_confidence":0,"semi_minor_confidence":0,"semi_major_orientation":0},"altitude":1}},"high_frequency_container":   {"heading":2375,"speed":137,"drive_direction":0,"vehicle_length":47,"vehicle_width":24,"longitudinal_acceleration":1,   "lateral_acceleration":0,"vertical_acceleration":0,"yaw_rate":-27,"lane_position":0,"curvature":0,"confidence":{"heading":2,   "speed":3,"vehicle_length":1,"vehicle_width":1,"longitudinal_acceleration":5,"yaw_rate":6,"lane_position":1,"curvature":7}},   "low_frequency_container":{"vehicle_role":0,"exterior_lights":"00000000","path_history":[{"path_position":{},   "path_delta_time":1}]}}}'
    sleep 3
    mosquitto_pub -h test.mosquitto.org -p 1884 -u rw -P readwrite -t default/outQueue/v2x/cam/ora_car_testcon2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2/2 -m '{"type":"cam","origin":"self","version":"1.2.0","source_uuid":"ora_car_2222","timestamp":1618591358923,   "message":{"protocol_version":2,"station_id":1077952580,"generation_delta_time":31571,"basic_container":{"station_type":5,   "reference_position":{"latitude":486230934,"longitude":22419064,"altitude":10000},"confidence":{"position_confidence_ellipse":   {"semi_major_confidence":0,"semi_minor_confidence":0,"semi_major_orientation":0},"altitude":1}},"high_frequency_container":   {"heading":2375,"speed":137,"drive_direction":0,"vehicle_length":47,"vehicle_width":24,"longitudinal_acceleration":1,   "lateral_acceleration":0,"vertical_acceleration":0,"yaw_rate":-27,"lane_position":0,"curvature":0,"confidence":{"heading":2,   "speed":3,"vehicle_length":1,"vehicle_width":1,"longitudinal_acceleration":5,"yaw_rate":6,"lane_position":1,"curvature":7}},   "low_frequency_container":{"vehicle_role":0,"exterior_lights":"00000000","path_history":[{"path_position":{},   "path_delta_time":1}]}}}'
    EOF
    
  5. Launch copycat example

    cargo run --example copycat --features geo_routing
    

    => The example correctly runs

  6. Launch the script

    chmod +x /tmp/test_copycat.sh && /tmp/test_copycat.sh
    

    => Several reception must be logged

    DEBUG [copycat] item received: Packet { topic: GeoTopic { prefix: "default", queue: Out, suffix: "v2x", message_type: CAM, uuid: "ora_car_testcon2", geo_extension: Quadkey { tiles: [Two, Two, Two, Two, Two, Two, Two, Two, Two, Two, Two, Two, Two, Two, Two, Two, Two, Two, Two] } }, payload: Exchange { type_field: "cam", origin: "self", version: "1.2.0", source_uuid: "ora_car_2222", timestamp: 1618591358923, path: [], message: CAM(CooperativeAwarenessMessage { protocol_version: 2, station_id: 1077952580, generation_delta_time: 31571, basic_container: BasicContainer { station_type: Some(5), reference_position: ReferencePosition { latitude: 486230934, longitude: 22419064, altitude: 10000 }, confidence: Some(PositionConfidence { position_confidence_ellipse: Some(PositionConfidenceEllipse { semi_major_confidence: Some(0), semi_minor_confidence: Some(0), semi_major_orientation: Some(0) }), altitude: Some(1) }) }, high_frequency_container: HighFrequencyContainer { heading: Some(2375), speed: Some(137), drive_direction: Some(0), vehicle_length: Some(47), vehicle_width: Some(24), curvature: Some(0), curvature_calculation_mode: None, longitudinal_acceleration: Some(1), yaw_rate: Some(-27), acceleration_control: None, lane_position: Some(0), lateral_acceleration: Some(0), vertical_acceleration: Some(0), confidence: Some(HighFrequencyConfidence { heading: Some(2), speed: Some(3), vehicle_length: Some(1), yaw_rate: Some(6), longitudinal_acceleration: Some(5), curvature: Some(7), lateral_acceleration: None, vertical_acceleration: None }) }, low_frequency_container: Some(LowFrequencyContainer { vehicle_role: Some(0), exterior_lights: "00000000", path_history: [PathHistory { path_position: PathPosition { delta_latitude: None, delta_longitude: None, delta_altitude: None }, path_delta_time: Some(1) }] }) }) }, properties: PublishProperties { payload_format_indicator: None, message_expiry_interval: None, topic_alias: None, response_topic: None, correlation_data: None, user_properties: [], subscription_identifiers: [], content_type: None } }

    => One message publication must be logged

    DEBUG [libits::client::application::pipeline] Packet to publish...
    INFO [libits::client::application::pipeline] Cannot trace exchange, missing gateway component name in node configuration
    DEBUG [libits::client::application::pipeline] Packet published!
    DEBUG [rumqttc::v5::state] Publish. Topic = default/inQueue/v2x/cam/com_orange_its-client_10000/2/2/2/2/2/2/2/2/2/2/2/2/2/ 2/2/2/2/2/2, Pkid = 2, Payload Size = 962

`application.rs` is already restricted to `mobility` feature in
`client.rs` so it is useless to restrict here again

Signed-off-by: Nicolas Buffon <nicolas.buffon@orange.com>
"High level" function to easily create a CAM message with a minimum of
information

Signed-off-by: Nicolas Buffon <nicolas.buffon@orange.com>
Signed-off-by: Nicolas Buffon <nicolas.buffon@orange.com>
Signed-off-by: Nicolas Buffon <nicolas.buffon@orange.com>
@nbuffon nbuffon added the Rust Rust code label Nov 15, 2024
@nbuffon nbuffon self-assigned this Nov 15, 2024
@ymorin-orange
Copy link
Member

Test 6 KO:

$ cargo run --example copycat --features geo_routing
   Compiling libits-client v2.0.0 (/home/nyma7486/dev/work/5GCroCo/its-client/gh-209/rust)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 4.34s
     Running `target/debug/examples/copycat`
Transport: standard MQTT; TLS enabled
INFO [copycat] logger ready on log
INFO [libits::client::application::pipeline] Analysis thread count set to: 4
Log is written to log/copycat_rCURRENT.log
INFO [libits::client::application::pipeline] mqtt client subscribing starting...
INFO [libits::client::application::pipeline] mqtt client subscribing finished
INFO [libits::client::application::pipeline] Starting MQTT listening thread...
INFO [libits::client::application::pipeline] MQTT listening thread started!
INFO [libits::client::application::pipeline] starting mqtt router dispatching...
INFO [libits::client::application::pipeline] mqtt router dispatching started
INFO [libits::client::application::pipeline] starting monitor reception thread...
INFO [libits::client::application::pipeline] monitor reception thread started
INFO [libits::transport::mqtt::mqtt_client] listening started
INFO [libits::transport::mqtt::mqtt_router] Registered route for topic: default/outQueue/v2x/cam
INFO [libits::client::application::pipeline] starting filtering...
INFO [libits::client::application::pipeline] starting analyser generation...
INFO [libits::client::application::pipeline] starting analyser generation...
INFO [libits::client::application::pipeline] starting analyser generation...
INFO [libits::client::application::pipeline] starting analyser generation...
INFO [libits::client::application::pipeline] filter started
INFO [libits::client::application::pipeline] Starting configuration reader thread...
INFO [libits::transport::mqtt::mqtt_router] Registered route for topic: default/outQueue/v2x/cpm
INFO [libits::transport::mqtt::mqtt_router] Registered route for topic: default/outQueue/v2x/denm
INFO [libits::transport::mqtt::mqtt_router] Registered route for topic: default/outQueue/v2x/cam
INFO [libits::transport::mqtt::mqtt_router] Registered route for topic: default/outQueue/info
INFO [libits::client::application::pipeline] Configuration reader thread started!
INFO [libits::client::application::pipeline] starting monitor reception thread...
INFO [libits::client::application::pipeline] monitor reception thread started
INFO [libits::client::application::pipeline] Starting MQTT publishing thread...
INFO [libits::client::application::pipeline] Cannot trace exchange, missing gateway component name in node configuration
INFO [copycat] we start to schedule 1077952580 from ora_car_2222
INFO [libits::client::application::pipeline] Cannot trace exchange, missing gateway component name in node configuration
INFO [copycat] we start to schedule 1077952580 from ora_car_2222
INFO [libits::client::application::pipeline] Cannot trace exchange, missing gateway component name in node configuration
INFO [copycat] we start to schedule 1077952580 from ora_car_2222
INFO [libits::client::application::pipeline] Cannot trace exchange, missing gateway component name in node configuration
INFO [copycat] we start to schedule 1077952580 from ora_car_2222
INFO [libits::client::application::pipeline] Cannot trace exchange, missing gateway component name in node configuration
INFO [copycat] we start to schedule 1077952580 from ora_car_2222
INFO [copycat] we treat the scheduled item 1 1077952580 from ora_car_2222
INFO [libits::client::application::pipeline] Cannot trace exchange, missing gateway component name in node configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Rust code
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Exchange mobility message for application Fix perceived object heading computation
2 participants