Further cleanup

This commit is contained in:
Pasch, Frederik 2020-07-06 15:40:03 +02:00 committed by Marc Garcia Puig
parent bc898acdf9
commit 2cb29ba938
3 changed files with 13 additions and 9 deletions

View File

@ -22,6 +22,7 @@ Use ARROWS or WASD keys for control.
Space : hand-brake Space : hand-brake
P : toggle autopilot P : toggle autopilot
TAB : change view
Backspace : change vehicle Backspace : change vehicle
R : toggle recording images to disk R : toggle recording images to disk
@ -102,7 +103,6 @@ try:
from pygame.locals import K_r from pygame.locals import K_r
from pygame.locals import K_s from pygame.locals import K_s
from pygame.locals import K_t from pygame.locals import K_t
from pygame.locals import K_u
from pygame.locals import K_w from pygame.locals import K_w
from pygame.locals import K_l from pygame.locals import K_l
from pygame.locals import K_i from pygame.locals import K_i
@ -138,7 +138,7 @@ class World(object):
print(' Make sure it exists, has the same name of your town, and is correct.') print(' Make sure it exists, has the same name of your town, and is correct.')
sys.exit(1) sys.exit(1)
self.external_actor = args.externalActor self.external_actor = args.externalActor
self.hud = HUD(args.width, args.height, carla_world) self.hud = HUD(args.width, args.height, carla_world)
self.recording_frame_num = 0 self.recording_frame_num = 0
self.recording = False self.recording = False
@ -668,7 +668,8 @@ class HUD(object):
if len(item) == 6 and item[2] < 0.0: if len(item) == 6 and item[2] < 0.0:
for steering_range in item[5]: for steering_range in item[5]:
starting_value = min(steering_range[0], steering_range[1]) starting_value = min(steering_range[0], steering_range[1])
length = (max(steering_range[0], steering_range[1]) - min(steering_range[0], steering_range[1])) / 2 length = (max(steering_range[0], steering_range[1]) -
min(steering_range[0], steering_range[1])) / 2
rect = pygame.Rect( rect = pygame.Rect(
(bar_h_offset + (starting_value + 1) * (bar_width / 2), v_offset + 2), (length * bar_width, 14)) (bar_h_offset + (starting_value + 1) * (bar_width / 2), v_offset + 2), (length * bar_width, 14))
pygame.draw.rect(display, (0, 255, 0), rect) pygame.draw.rect(display, (0, 255, 0), rect)

View File

@ -42,7 +42,7 @@ class RssStateInfo(object):
if object_state: if object_state:
self.distance = math.sqrt((float(ego_dynamics_on_route.ego_center.x) - float(object_state.centerPoint.x))**2 + self.distance = math.sqrt((float(ego_dynamics_on_route.ego_center.x) - float(object_state.centerPoint.x))**2 +
(float(ego_dynamics_on_route.ego_center.y) - float(object_state.centerPoint.y))**2) (float(ego_dynamics_on_route.ego_center.y) - float(object_state.centerPoint.y))**2)
def get_actor(self, world): def get_actor(self, world):
return world.get_actor(self.rss_state.objectId) return world.get_actor(self.rss_state.objectId)
@ -402,7 +402,7 @@ class RssSensor(object):
if self.state_visualizer: if self.state_visualizer:
self.state_visualizer.tick(self.individual_rss_states) self.state_visualizer.tick(self.individual_rss_states)
self.debug_visualizer.tick(self.route, not response.proper_response.isSafe, self.debug_visualizer.tick(self.route, not response.proper_response.isSafe,
self.individual_rss_states, self.ego_dynamics_on_route) self.individual_rss_states, self.ego_dynamics_on_route)
else: else:
print("ignore outdated response {}".format(delta_time)) print("ignore outdated response {}".format(delta_time))

View File

@ -20,6 +20,7 @@ else:
import libad_map_access_python2 as admap import libad_map_access_python2 as admap
import libad_rss_map_integration_python2 as rssmap import libad_rss_map_integration_python2 as rssmap
class RssStateVisualizer(object): class RssStateVisualizer(object):
def __init__(self, display_dimensions, font, world): def __init__(self, display_dimensions, font, world):
@ -77,27 +78,27 @@ class RssStateVisualizer(object):
pygame.draw.polygon( pygame.draw.polygon(
state_surface, ( state_surface, (
255, 255, 255), ((xpos + 1, v_offset + 1 + 4), (xpos + 6, v_offset + 1 + 0), (xpos + 11, v_offset + 1 + 4), 255, 255, 255), ((xpos + 1, v_offset + 1 + 4), (xpos + 6, v_offset + 1 + 0), (xpos + 11, v_offset + 1 + 4),
(xpos + 7, v_offset + 1 + 4), (xpos + 7, v_offset + 1 + 12), (xpos + 5, v_offset + 1 + 12), (xpos + 5, v_offset + 1 + 4))) (xpos + 7, v_offset + 1 + 4), (xpos + 7, v_offset + 1 + 12), (xpos + 5, v_offset + 1 + 12), (xpos + 5, v_offset + 1 + 4)))
xpos += 14 xpos += 14
if not state.rss_state.longitudinalState.isSafe and ((state.rss_state.longitudinalState.rssStateInformation.evaluator == "LongitudinalDistanceOppositeDirectionEgoCorrectLane") or (state.rss_state.longitudinalState.rssStateInformation.evaluator == "LongitudinalDistanceOppositeDirection")): if not state.rss_state.longitudinalState.isSafe and ((state.rss_state.longitudinalState.rssStateInformation.evaluator == "LongitudinalDistanceOppositeDirectionEgoCorrectLane") or (state.rss_state.longitudinalState.rssStateInformation.evaluator == "LongitudinalDistanceOppositeDirection")):
pygame.draw.polygon( pygame.draw.polygon(
state_surface, ( state_surface, (
255, 255, 255), ((xpos + 2, v_offset + 1 + 8), (xpos + 6, v_offset + 1 + 12), (xpos + 10, v_offset + 1 + 8), 255, 255, 255), ((xpos + 2, v_offset + 1 + 8), (xpos + 6, v_offset + 1 + 12), (xpos + 10, v_offset + 1 + 8),
(xpos + 7, v_offset + 1 + 8), (xpos + 7, v_offset + 1 + 0), (xpos + 5, v_offset + 1 + 0), (xpos + 5, v_offset + 1 + 8))) (xpos + 7, v_offset + 1 + 8), (xpos + 7, v_offset + 1 + 0), (xpos + 5, v_offset + 1 + 0), (xpos + 5, v_offset + 1 + 8)))
xpos += 14 xpos += 14
if not state.rss_state.lateralStateRight.isSafe and not (state.rss_state.lateralStateRight.rssStateInformation.evaluator == "None"): if not state.rss_state.lateralStateRight.isSafe and not (state.rss_state.lateralStateRight.rssStateInformation.evaluator == "None"):
pygame.draw.polygon( pygame.draw.polygon(
state_surface, ( state_surface, (
255, 255, 255), ((xpos + 0, v_offset + 1 + 4), (xpos + 8, v_offset + 1 + 4), (xpos + 8, v_offset + 1 + 1), 255, 255, 255), ((xpos + 0, v_offset + 1 + 4), (xpos + 8, v_offset + 1 + 4), (xpos + 8, v_offset + 1 + 1),
(xpos + 12, v_offset + 1 + 6), (xpos + 8, v_offset + 1 + 10), (xpos + 8, v_offset + 1 + 8), (xpos + 0, v_offset + 1 + 8))) (xpos + 12, v_offset + 1 + 6), (xpos + 8, v_offset + 1 + 10), (xpos + 8, v_offset + 1 + 8), (xpos + 0, v_offset + 1 + 8)))
xpos += 14 xpos += 14
if not state.rss_state.lateralStateLeft.isSafe and not (state.rss_state.lateralStateLeft.rssStateInformation.evaluator == "None"): if not state.rss_state.lateralStateLeft.isSafe and not (state.rss_state.lateralStateLeft.rssStateInformation.evaluator == "None"):
pygame.draw.polygon( pygame.draw.polygon(
state_surface, ( state_surface, (
255, 255, 255), ((xpos + 0, v_offset + 1 + 6), (xpos + 4, v_offset + 1 + 1), (xpos + 4, v_offset + 1 + 4), 255, 255, 255), ((xpos + 0, v_offset + 1 + 6), (xpos + 4, v_offset + 1 + 1), (xpos + 4, v_offset + 1 + 4),
(xpos + 12, v_offset + 1 + 4), (xpos + 12, v_offset + 1 + 8), (xpos + 4, v_offset + 1 + 8), (xpos + 4, v_offset + 1 + 10))) (xpos + 12, v_offset + 1 + 4), (xpos + 12, v_offset + 1 + 8), (xpos + 4, v_offset + 1 + 8), (xpos + 4, v_offset + 1 + 10)))
xpos += 14 xpos += 14
elif state.actor_calculation_mode == rssmap.RssMode.Unstructured: elif state.actor_calculation_mode == rssmap.RssMode.Unstructured:
text = "" text = ""
@ -117,6 +118,7 @@ class RssStateVisualizer(object):
if self._surface: if self._surface:
display.blit(self._surface, (0, v_offset)) display.blit(self._surface, (0, v_offset))
def get_matrix(transform): def get_matrix(transform):
""" """
Creates matrix from carla transform. Creates matrix from carla transform.
@ -419,6 +421,7 @@ class RssUnstructuredSceneVisualizer(object):
# -- RssBoundingBoxVisualizer ------------------------------------------------------ # -- RssBoundingBoxVisualizer ------------------------------------------------------
# ============================================================================== # ==============================================================================
class RssBoundingBoxVisualizer(object): class RssBoundingBoxVisualizer(object):
def __init__(self, display_dimensions, world, camera): def __init__(self, display_dimensions, world, camera):