freeride.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/usr/bin/env python
  2. # Copyright (c) 2019-2020 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. Simple freeride scenario. No action, no triggers. Ego vehicle can simply cruise around.
  8. """
  9. import py_trees
  10. from srunner.scenariomanager.scenarioatomics.atomic_behaviors import Idle
  11. from srunner.scenariomanager.scenarioatomics.atomic_criteria import CollisionTest
  12. from srunner.scenarios.basic_scenario import BasicScenario
  13. class FreeRide(BasicScenario):
  14. """
  15. Implementation of a simple free ride scenario that consits only of the ego vehicle
  16. """
  17. def __init__(self, world, ego_vehicles, config, randomize=False, debug_mode=False, criteria_enable=True,
  18. timeout=10000000):
  19. """
  20. Setup all relevant parameters and create scenario
  21. """
  22. # Timeout of scenario in seconds
  23. self.timeout = timeout
  24. super(FreeRide, self).__init__("FreeRide",
  25. ego_vehicles,
  26. config,
  27. world,
  28. debug_mode,
  29. criteria_enable=criteria_enable)
  30. def _setup_scenario_trigger(self, config):
  31. """
  32. """
  33. return None
  34. def _create_behavior(self):
  35. """
  36. """
  37. sequence = py_trees.composites.Sequence("Sequence Behavior")
  38. sequence.add_child(Idle())
  39. return sequence
  40. def _create_test_criteria(self):
  41. """
  42. A list of all test criteria will be created that is later used
  43. in parallel behavior tree.
  44. """
  45. criteria = []
  46. for ego_vehicle in self.ego_vehicles:
  47. collision_criterion = CollisionTest(ego_vehicle)
  48. criteria.append(collision_criterion)
  49. return criteria
  50. def __del__(self):
  51. """
  52. Remove all actors upon deletion
  53. """
  54. self.remove_all_actors()