Merge pull request #29 from Rhinemann/lab4/yushchenko-SCRUM-81-DataProcessing-implementation
[L4] SCRUM-81: implementation data processing function
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
from app.entities.agent_data import AgentData
|
from app.entities.agent_data import AgentData
|
||||||
from app.entities.processed_agent_data import ProcessedAgentData
|
from app.entities.processed_agent_data import ProcessedAgentData
|
||||||
|
|
||||||
|
_last_detection_state = {}
|
||||||
|
|
||||||
def process_agent_data(
|
def process_agent_data(
|
||||||
agent_data: AgentData,
|
agent_data: AgentData,
|
||||||
@@ -12,8 +13,24 @@ def process_agent_data(
|
|||||||
Returns:
|
Returns:
|
||||||
processed_data_batch (ProcessedAgentData): Processed data containing the classified state of the road surface and agent data.
|
processed_data_batch (ProcessedAgentData): Processed data containing the classified state of the road surface and agent data.
|
||||||
"""
|
"""
|
||||||
# Implement it
|
user_id = agent_data.user_id
|
||||||
|
road_state = "normal"
|
||||||
|
|
||||||
|
last_detection_state = _last_detection_state.get(user_id, False)
|
||||||
|
|
||||||
|
if (agent_data.accelerometer.z < 0.6):
|
||||||
|
road_state = "pothole"
|
||||||
|
elif (agent_data.accelerometer.z > 1.2):
|
||||||
|
road_state = "bump"
|
||||||
|
|
||||||
|
detection_happened = road_state != "normal"
|
||||||
|
|
||||||
|
if not (not last_detection_state and detection_happened):
|
||||||
|
road_state = "normal"
|
||||||
|
|
||||||
|
_last_detection_state[user_id] = detection_happened
|
||||||
|
|
||||||
return ProcessedAgentData(
|
return ProcessedAgentData(
|
||||||
road_state="normal",
|
road_state=road_state,
|
||||||
agent_data=agent_data
|
agent_data=agent_data
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user