Слияние кода завершено, страница обновится автоматически
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# Author : HuangXinghui Lordon
from initial.initial import CarState
from perception.perception import DistanceData
def run(distanceData, previous_distance, current_distance, MyCar):
"""
Distance data smothing to better planning and control.
Aiming at the unstable output of the deep learning model,
the data smoothing is designed, and the inf data is represented
by the distance of the previous successful recognition.
Args:
distanceData: Estimated distance data transmitted to the decision and control module,
DistanceData class type defined in perception.py
previous_distance: Last measured distance through model stability,
DistanceData class type defined in perception.py
current_distance: Current distance data from perception module,
DistanceData class type defined in perception.py
MyCar: autonomous driving vehicle parameters,
CarState class type defined in initial.py
Return:
None element
"""
distance_left, distance_mid, distance_right = distanceData.get_distance()
# Setting middle distance
if distance_mid != float('inf'):
previous_distance.set_distance_mid(distance_mid)
else:
current_distance.set_distance_mid(previous_distance.distance_mid)
distanceData.set_distance_mid(current_distance.distance_mid)
if MyCar.changing:
# When vehicle changes lane, all distance and previous distance set to infinity.
distanceData.set_distance_left(float('inf'))
distanceData.set_distance_right(float('inf'))
distanceData.set_distance_mid(float('inf'))
previous_distance.set_distance_left(float('inf'))
previous_distance.set_distance_right(float('inf'))
previous_distance.set_distance_mid(float('inf'))
else:
# Setting left and right distance
if distance_left != float('inf'):
previous_distance.set_distance_left(distance_left)
else:
current_distance.set_distance_left(previous_distance.distance_left)
distanceData.set_distance_left(current_distance.distance_left)
if distance_right != float('inf'):
previous_distance.set_distance_right(distance_right)
else:
current_distance.set_distance_right(previous_distance.distance_right)
distanceData.set_distance_right(current_distance.distance_right)
# Judging overtake numbers and computing staight driving time.
if MyCar.overtakeSum > MyCar.lastovertakeSum:
MyCar.time = 0
distanceData.set_distance_mid(float('inf'))
distanceData.set_distance_left(float('inf'))
distanceData.set_distance_right(float('inf'))
MyCar.lastovertakeSum = MyCar.overtakeSum
else:
MyCar.time += 1
return None
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Комментарий ( 0 )