Closed beyazit-yalcinkaya closed 4 months ago
Can be reproduced with the following minimal example:
param map = localPath('assets/maps/CARLA/Town05.xodr')
param carla_map = 'Town05'
param time_step = 1.0/10
model scenic.domains.driving.model
behavior TestBehavior1():
while True:
print("FOO")
wait
behavior TestBehavior2():
while True:
print("BAR")
wait
scenario Sub(target):
setup:
override target with behavior TestBehavior2()
scenario Main():
setup:
ego = new Car #with behavior TestBehavior1()
compose:
do Sub(ego)
Workaround for now: Set a default behavior.
Fixed in #252
System Details
Detailed Description
If a behavior is not specified for an agent initially, its behavior cannot be overridden afterward by another scenario.
Steps To Reproduce
model scenic.simulators.newtonian.driving_model
CONSTANTS
EGO_SPEED = 10 THROTTLE_ACTION = 0.6 BRAKE_ACTION = 1.0 EGO_TO_OBSTACLE = Range(-20, -15) EGO_BRAKING_THRESHOLD = 11
behavior FollowTrajectoryBehaviorAvoidCollision(target_speed, trajectory): try: do FollowTrajectoryBehavior(target_speed=target_speed, trajectory=trajectory)
scenario SubScenario1(target): setup:
print(f"X = {X}")
scenario SubScenario2(target, direction): setup:
print(f"X = {X}")
scenario SubScenario2S(target): compose: do SubScenario2(target, ManeuverType.STRAIGHT)
scenario SubScenario2L(target): compose: do SubScenario2(target, ManeuverType.LEFT_TURN)
scenario Main(): setup:
print(f"X = {X}")
import math import os.path import sys
from dotmap import DotMap
from verifai.samplers import ScenicSampler from verifai.scenic_server import ScenicServer from verifai.falsifier import generic_falsifier, compositional_falsifier from verifai.monitor import specification_monitor, mtl_specification
Load the Scenic scenario and create a sampler from it
if len(sys.argv) > 1: path = sys.argv[1] else: path = os.path.join(os.path.dirname(file), 'newtonian/intersection.scenic')
sampler = ScenicSampler.fromScenario(path, mode2D=True)
Define the specification (i.e. evaluation metric) as an MTL formula.
Our example spec will say that the ego object stays at least 5 meters away
from all other objects.
class MyMonitor(specification_monitor): def init(self): self.specification = mtl_specification(['G safe']) super().init(self.specification)
Set up the falsifier
falsifier_params = DotMap( n_iters=2, verbosity=1, save_error_table=True, save_safe_table=True,
uncomment to save these tables to files; we'll print them out below
) server_options = DotMap(maxSteps=100, verbosity=0) falsifier = generic_falsifier(sampler=sampler, monitor=MyMonitor(), falsifier_params=falsifier_params, server_class=ScenicServer, server_options=server_options)
Perform falsification and print the results
falsifier.run_falsifier() print('Error table:') print(falsifier.error_table.table) print('Safe table:') print(falsifier.safe_table.table)
ego = new Car following roadDirection from 171.87 @ 2.04 for EGO_TO_OBSTACLE, with behavior FollowLaneBehavior(0)