Skip to content

Commit

Permalink
Update MockMUSTSensorScript
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbourelly999 committed Jun 27, 2024
1 parent 4fd36ec commit 3483b17
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/v2i-hub/MUSTSensorDriverPlugin/scripts/MockMUSTSensor.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#!/usr/bin/python3

import socket
import sys
import time
import argparse
from dataclasses import dataclass
from enum import Enum
import random


class DetectionClassification(Enum):
"""Enumeration used for indentifying type of detection
"""Enumeration used for identifying type of detection
"""
SEDAN='sedan'
VAN='van'
TRUCK='truck'
class DetectionSize(Enum):
"""Enumeration used for indentifying the type of KafkaLogMessage
"""Enumeration used for identifying the type of KafkaLogMessage
"""
SMALL='small'
MEDIUM='medium'
Expand All @@ -38,8 +38,15 @@ class MUSTDetection:
def to_csv(self):
return f'{self.classification.value},{self.x},{self.y},{self.heading},{self.speed},{self.size.value},{self.confidence},{self.track_id},{self.timestamp}'

def move_detection():
return
def update_detection(detection):
"""Function moves detection and heading by random increment and changes speed to a random value between 0 and 10.
"""
detection.x = random.uniform(-1.0, 1.0) + detection.x
detection.y = random.uniform(-1.0, 1.0) + detection.y
detection.heading = random.uniform(-5.0, 5.0) + detection.heading
detection.speed = random.uniform(0.0, 10)
detection.timestamp = round(time.time())


def create_socket():
return socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
Expand Down Expand Up @@ -67,6 +74,7 @@ def main():
print("Mocking MUST Sensor detections ...")
while True:
for detection in detections:
update_detection(detection)
send_detection(sock,detection,host)
time.sleep(1)

Expand Down

0 comments on commit 3483b17

Please sign in to comment.