Skip to content

Commit

Permalink
added test.scenic to test verifai problems
Browse files Browse the repository at this point in the history
  • Loading branch information
tcdanielh committed Apr 14, 2024
1 parent af895f8 commit 3382ad9
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 2 deletions.
80 changes: 80 additions & 0 deletions examples/airsim/test.scenic
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# ------------------------------------------------------ PROBLEM 1 ------------------------------------------------------
""" import math
# NOTE: add your world info path here
param worldInfoPath = "C:/Users/piegu/Scenic/examples/airsim/worldInfo/droneBlocks"
# drone1 patrols to every location in points. ego spawns somehwere in the center area and tries to catch it before time ends
model scenic.simulators.airsim.model
behavior Catch(target, speed = 5,tolerance = 1, offset = (0,0,0)):
try:
while True:
targetPosition = target.position + offset
velocity = targetPosition-self.position
distance = magnitude(velocity)
velocity = (velocity / distance) * speed
if distance > tolerance:
take SetVelocity(velocity)
wait
interrupt when (distance from self to drone1) < 3:
print("Caught drone1!")
terminate
behavior Patrol(positions, loop=True, smooth = False, speed = 5,tolerance = 2):
while True:
pos = VerifaiOptions(positions)
do FlyToPosition(pos,speed=speed,pidMode= not smooth,tolerance=tolerance)
if not loop:
return
centerArea = RectangularRegion(Vector(0,0,0), 0, 30, 30)
points = [(-1,2,2),(1,4,2),(-1,4,2),(-1,2,4),(1,2,4),(1,4,4),(-1,4,4)]
drone1 = new Drone at (0,0,0),
with behavior Patrol(points,True)
ego = new Drone in centerArea,
with behavior Catch(drone1)
terminate after 2 seconds """

# ------------------------------------------------------ PROBLEM 2 ------------------------------------------------------
""" import math
# NOTE: add your world info path here
param worldInfoPath = "C:/Users/piegu/Scenic/examples/airsim/worldInfo/droneBlocks"
model scenic.simulators.airsim.model
centerArea = RectangularRegion(Vector(0,0,0), 0, 30, 30)
ego = new Drone in centerArea
drone1 = new Drone in centerArea
terminate after 2 seconds """


# ------------------------------------------------------ PROBLEM 3 ------------------------------------------------------
# NOTE: add your world info path here
""" param worldInfoPath = "C:/Users/piegu/Scenic/examples/airsim/worldInfo/droneBlocks"
model scenic.simulators.airsim.model
centerArea = RectangularRegion(Vector(0,200,30), 0, 100,100)
ego = new Drone at (0,0,0)
obj1 = new StaticObj in centerArea,
with assetName "Cone", # use * to pick a random asset in assets
with width Range(3,10),
with length Range(3,10),
with height 10
terminate after 2 seconds """
4 changes: 2 additions & 2 deletions src/scenic/simulators/airsim/verifai_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from verifai.monitor import specification_monitor
import math

path_to_scenic_script = 'C:/Users/piegu/Scenic/examples/airsim/catchDrone.scenic'
path_to_scenic_script = 'C:/Users/piegu/Scenic/examples/airsim/test.scenic'
sampler = ScenicSampler.fromScenario(path_to_scenic_script)

class confidence_spec(specification_monitor):
Expand Down Expand Up @@ -38,7 +38,7 @@ def specification(simulation):

falsifier = generic_falsifier(sampler=sampler,
falsifier_params=falsifier_params,
monitor=confidence_spec(),
# monitor=confidence_spec(),
server_class=ScenicServer,
server_options=server_options)
falsifier.run_falsifier()
Expand Down

0 comments on commit 3382ad9

Please sign in to comment.