basic_metric.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env python
  2. # Copyright (c) 2020 Computer Vision Center (CVC) at the Universitat Autonoma de
  3. # Barcelona (UAB).
  4. #
  5. # This work is licensed under the terms of the MIT license.
  6. # For a copy, see <https://opensource.org/licenses/MIT>.
  7. """
  8. This module provide BasicMetric, the basic class of all the metrics.
  9. """
  10. class BasicMetric(object):
  11. """
  12. Base class of all the metrics.
  13. """
  14. def __init__(self, town_map, log, criteria=None):
  15. """
  16. Initialization of the metric class. This calls the metrics log and creates the metrics
  17. Args:
  18. town_map (carla.Map): Map of the simulation. Used to access the Waypoint API.
  19. log (srunner.metrics.tools.Metricslog): instance of a class used to access the recorder information
  20. criteria (dict): list of dictionaries with all the criteria information
  21. """
  22. # Create the metrics of the simulation. This part is left to the user
  23. self._create_metric(town_map, log, criteria)
  24. def _create_metric(self, town_map, log, criteria):
  25. """
  26. Pure virtual function to setup the metrics by the user.
  27. Args:
  28. town_map (carla.Map): Map of the simulation. Used to access the Waypoint API.
  29. log (srunner.metrics.tools.Metricslog): instance of a class used to access the recorder information
  30. criteria (dict): dictionaries with all the criteria information
  31. """
  32. raise NotImplementedError(
  33. "This function should be re-implemented by all metrics"
  34. "If this error becomes visible the class hierarchy is somehow broken")