route_scenario_configuration.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env python
  2. # Copyright (c) 2019 Intel Corporation
  3. #
  4. # This work is licensed under the terms of the MIT license.
  5. # For a copy, see <https://opensource.org/licenses/MIT>.
  6. """
  7. This module provides the key configuration parameters for a route-based scenario
  8. """
  9. import carla
  10. from agents.navigation.local_planner import RoadOption
  11. from srunner.scenarioconfigs.scenario_configuration import ScenarioConfiguration
  12. class RouteConfiguration(object):
  13. """
  14. This class provides the basic configuration for a route
  15. """
  16. def __init__(self, route=None):
  17. self.data = route
  18. def parse_xml(self, node):
  19. """
  20. Parse route config XML
  21. """
  22. self.data = []
  23. for waypoint in node.iter("waypoint"):
  24. x = float(waypoint.attrib.get('x', 0))
  25. y = float(waypoint.attrib.get('y', 0))
  26. z = float(waypoint.attrib.get('z', 0))
  27. c = waypoint.attrib.get('connection', '')
  28. connection = RoadOption[c.split('.')[1]]
  29. self.data.append((carla.Location(x, y, z), connection))
  30. class RouteScenarioConfiguration(ScenarioConfiguration):
  31. """
  32. Basic configuration of a RouteScenario
  33. """
  34. trajectory = None
  35. scenario_file = None