forked from BerkeleyLearnVerify/Scenic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
237,942 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import math | ||
|
||
# NOTE: add your world info path here | ||
param worldInfoPath = "examples/airsim/worldInfo/nh" | ||
|
||
model scenic.simulators.airsim.model | ||
|
||
# This demo includes 1 adversarial drone, and 1 drone (ego) looking for this adversary. | ||
|
||
class AdversaryDrone(Drone): # Drone class defined in model.scenic | ||
patrolPoints: [] | ||
patrolPointsProb: [] | ||
|
||
# Find the adversary. drone1 is the adversary target | ||
behavior FindAdversary(positions, speed = 5): | ||
# try-interrupt statements: https://scenic-lang.readthedocs.io/en/latest/reference/statements.html#try-interrupt-statement | ||
try: | ||
print("POSSIBLE POSITIONS:") | ||
print(positions) | ||
while ((distance from self to drone1) >= 1): | ||
selectedPoint = Discrete({positions[0]:drone1.patrolPointsProb[0], | ||
positions[1]:drone1.patrolPointsProb[1], | ||
positions[2]:drone1.patrolPointsProb[2], | ||
positions[3]:drone1.patrolPointsProb[3]}) | ||
|
||
print("EGO CHECKING POSITION:") | ||
print(selectedPoint) | ||
|
||
do FlyToPosition(selectedPoint, speed=speed, tolerance=1,pidMode=True) # FlyToPosition behavior defined in behaviors.scenic | ||
|
||
interrupt when (distance from self to drone1) < 15: | ||
# when I see that I am within 15 meters of adversary, follow it | ||
print("FOLLOWING ADVERSARY") | ||
do Follow(drone1, speed=10, tolerance=1, offset=(0,0,0)) # Follow behavior defined in behaviors.scenic | ||
|
||
interrupt when distance from self to drone1 < 7: | ||
# when I get within 7 meters of adversary, terminate scenario | ||
print("ADVERSARY FOUND") | ||
terminate | ||
|
||
# Adversary behavior. Patrol through given points. | ||
behavior AdversaryBehavior(points, speed): | ||
do Patrol(points, loop=True, speed=speed) # Patrol behavior defined in behaviors.scenic | ||
|
||
ground = getPrexistingObj("nh") | ||
area1 = RectangularRegion(Vector(0,0,0), 0, 10, 70) | ||
area2 = RectangularRegion(Vector(0,0,0), 0, 70, 10) | ||
|
||
workspaceArea = area1.union(area2) | ||
|
||
platforms = [] | ||
blockCount = 4 | ||
for i in range(blockCount): | ||
platforms.append(new StaticObj on ground, | ||
contained in workspaceArea, | ||
with assetName "Cone", # use * to pick a random asset in assets | ||
with parentOrientation 0, | ||
with width 5, | ||
with length 5, | ||
with height 10) | ||
|
||
points = [] | ||
for plat in platforms: | ||
point = new Point on plat | ||
points.append(point.position) | ||
|
||
adversarySpawn = Options(points) | ||
|
||
# Adversary drone spawning at random point | ||
drone1 = new AdversaryDrone at adversarySpawn + (0,0,2), | ||
with behavior AdversaryBehavior(points, speed=2) | ||
# drone1.patrolPoints = possiblePoints | ||
drone1.patrolPointsProb = [0.4, 0.2, 0.1, 0.3] # Probability distribution on the patrolPoints | ||
|
||
# ego drone spawning somwhere in the middle of the workspace area | ||
ego = new Drone at (Range(-5, 5),Range(-5, 5),10), | ||
with behavior FindAdversary(points, speed=5) | ||
|
||
|
||
|
||
# took too long to locate so terminate after x seconds | ||
terminate after 15 seconds | ||
|
||
record final (distance to drone1) as dist |
309 changes: 309 additions & 0 deletions
309
examples/airsim/worldInfo/nh/assets/1M_Cube_Chamfer.obj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,309 @@ | ||
# https://github.com/mikedh/trimesh | ||
v -46.00000000 -50.00000000 46.00000000 | ||
v -46.00000000 -50.00000000 -46.00000000 | ||
v -48.00000000 -49.46409988 -46.00000000 | ||
v -48.00000000 -49.46409988 46.00000000 | ||
v -49.46410370 -48.00000000 -46.00000000 | ||
v -49.46410370 -48.00000000 46.00000000 | ||
v -50.00000000 -46.00000000 -46.00000000 | ||
v -50.00000000 -46.00000000 46.00000000 | ||
v -50.00000000 46.00000000 -46.00000000 | ||
v -50.00000000 46.00000000 46.00000000 | ||
v -49.46410370 48.00000000 -46.00000000 | ||
v -49.46410370 48.00000000 46.00000000 | ||
v -48.00000000 49.46409988 -46.00000000 | ||
v -48.00000000 49.46409988 46.00000000 | ||
v -46.00000000 50.00000000 -46.00000000 | ||
v -46.00000000 50.00000000 46.00000000 | ||
v 46.00000000 50.00000000 -46.00000000 | ||
v 46.00000000 50.00000000 46.00000000 | ||
v 48.00000000 49.46409988 -46.00000000 | ||
v 48.00000000 49.46409988 46.00000000 | ||
v 49.46410370 48.00000000 -46.00000000 | ||
v 49.46410370 48.00000000 46.00000000 | ||
v 50.00000000 46.00000000 -46.00000000 | ||
v 50.00000000 46.00000000 46.00000000 | ||
v 50.00000000 -46.00000000 -46.00000000 | ||
v 50.00000000 -46.00000000 46.00000000 | ||
v 49.46410370 -48.00000000 -46.00000000 | ||
v 49.46410370 -48.00000000 46.00000000 | ||
v 48.00000000 -49.46409988 -46.00000000 | ||
v 48.00000000 -49.46409988 46.00000000 | ||
v 46.00000000 -50.00000000 -46.00000000 | ||
v 46.00000000 -50.00000000 46.00000000 | ||
v -46.00000000 -49.46410370 48.00000000 | ||
v -47.73205185 -49.00000000 48.00000000 | ||
v 46.00000000 -49.46410370 48.00000000 | ||
v -49.00000000 -47.73205185 48.00000000 | ||
v 47.73205185 -49.00000000 48.00000000 | ||
v -49.46410370 -46.00000000 48.00000000 | ||
v 49.00000000 -47.73205185 48.00000000 | ||
v -49.46410370 46.00000000 48.00000000 | ||
v 49.46410370 -46.00000000 48.00000000 | ||
v -49.00000000 47.73205185 48.00000000 | ||
v 49.46410370 46.00000000 48.00000000 | ||
v -47.73205185 49.00000000 48.00000000 | ||
v 49.00000000 47.73205185 48.00000000 | ||
v -46.00000000 49.46410370 48.00000000 | ||
v 47.73205185 49.00000000 48.00000000 | ||
v 46.00000000 49.46410370 48.00000000 | ||
v 47.00000000 47.73205185 49.46409607 | ||
v 46.00000000 48.00000000 49.46409607 | ||
v -46.00000000 48.00000000 49.46409607 | ||
v -47.00000000 47.73205185 49.46409607 | ||
v -46.00000000 46.00000000 50.00000000 | ||
v -47.73205185 47.00000000 49.46409607 | ||
v -48.00000000 46.00000000 49.46409607 | ||
v 46.00000000 46.00000000 50.00000000 | ||
v -48.00000000 -46.00000000 49.46409607 | ||
v -46.00000000 -46.00000000 50.00000000 | ||
v -47.73205185 -47.00000000 49.46409607 | ||
v -47.00000000 -47.73205185 49.46409607 | ||
v -46.00000000 -48.00000000 49.46409607 | ||
v 46.00000000 -46.00000000 50.00000000 | ||
v 46.00000000 -48.00000000 49.46409607 | ||
v 47.00000000 -47.73205185 49.46409607 | ||
v 47.73205185 -47.00000000 49.46409607 | ||
v 48.00000000 -46.00000000 49.46409607 | ||
v 48.00000000 46.00000000 49.46409607 | ||
v 47.73205185 47.00000000 49.46409607 | ||
v -47.73205185 -49.00000000 -48.00000000 | ||
v -46.00000000 -49.46410370 -48.00000000 | ||
v -49.00000000 -47.73205185 -48.00000000 | ||
v 46.00000000 -49.46410370 -48.00000000 | ||
v -49.46410370 -46.00000000 -48.00000000 | ||
v 47.73205185 -49.00000000 -48.00000000 | ||
v -49.46410370 46.00000000 -48.00000000 | ||
v 49.00000000 -47.73205185 -48.00000000 | ||
v -49.00000000 47.73205185 -48.00000000 | ||
v 49.46410370 -46.00000000 -48.00000000 | ||
v -47.73205185 49.00000000 -48.00000000 | ||
v 49.46410370 46.00000000 -48.00000000 | ||
v -46.00000000 49.46410370 -48.00000000 | ||
v 49.00000000 47.73205185 -48.00000000 | ||
v 46.00000000 49.46410370 -48.00000000 | ||
v 47.73205185 49.00000000 -48.00000000 | ||
v 46.00000000 48.00000000 -49.46409988 | ||
v 47.00000000 47.73205185 -49.46409988 | ||
v 47.73205185 47.00000000 -49.46409988 | ||
v 48.00000000 46.00000000 -49.46409988 | ||
v 46.00000000 46.00000000 -50.00000000 | ||
v 48.00000000 -46.00000000 -49.46409988 | ||
v -46.00000000 48.00000000 -49.46409988 | ||
v 47.73205185 -47.00000000 -49.46409988 | ||
v -47.00000000 47.73205185 -49.46409988 | ||
v 47.00000000 -47.73205185 -49.46409988 | ||
v -47.73205185 47.00000000 -49.46409988 | ||
v -46.00000000 46.00000000 -50.00000000 | ||
v -48.00000000 46.00000000 -49.46409988 | ||
v -48.00000000 -46.00000000 -49.46409988 | ||
v 46.00000000 -46.00000000 -50.00000000 | ||
v -46.00000000 -46.00000000 -50.00000000 | ||
v -47.73205185 -47.00000000 -49.46409988 | ||
v 46.00000000 -48.00000000 -49.46409988 | ||
v -47.00000000 -47.73205185 -49.46409988 | ||
v -46.00000000 -48.00000000 -49.46409988 | ||
f 3 2 1 | ||
f 1 4 3 | ||
f 5 3 4 | ||
f 4 6 5 | ||
f 7 5 6 | ||
f 6 8 7 | ||
f 9 7 8 | ||
f 8 10 9 | ||
f 11 9 10 | ||
f 10 12 11 | ||
f 13 11 12 | ||
f 12 14 13 | ||
f 15 13 14 | ||
f 14 16 15 | ||
f 17 15 16 | ||
f 16 18 17 | ||
f 19 17 18 | ||
f 18 20 19 | ||
f 21 19 20 | ||
f 20 22 21 | ||
f 23 21 22 | ||
f 22 24 23 | ||
f 25 23 24 | ||
f 24 26 25 | ||
f 27 25 26 | ||
f 26 28 27 | ||
f 29 27 28 | ||
f 28 30 29 | ||
f 31 29 30 | ||
f 30 32 31 | ||
f 2 31 32 | ||
f 32 1 2 | ||
f 4 1 33 | ||
f 33 34 4 | ||
f 6 4 34 | ||
f 35 33 1 | ||
f 1 32 35 | ||
f 34 36 6 | ||
f 8 6 36 | ||
f 37 35 32 | ||
f 32 30 37 | ||
f 36 38 8 | ||
f 10 8 38 | ||
f 39 37 30 | ||
f 30 28 39 | ||
f 38 40 10 | ||
f 12 10 40 | ||
f 41 39 28 | ||
f 28 26 41 | ||
f 40 42 12 | ||
f 14 12 42 | ||
f 43 41 26 | ||
f 26 24 43 | ||
f 42 44 14 | ||
f 16 14 44 | ||
f 45 43 24 | ||
f 24 22 45 | ||
f 44 46 16 | ||
f 18 16 46 | ||
f 47 45 22 | ||
f 22 20 47 | ||
f 20 18 48 | ||
f 48 47 20 | ||
f 46 48 18 | ||
f 45 47 49 | ||
f 47 48 50 | ||
f 50 49 47 | ||
f 48 46 51 | ||
f 51 50 48 | ||
f 52 51 46 | ||
f 46 44 52 | ||
f 50 51 53 | ||
f 51 52 53 | ||
f 54 52 44 | ||
f 52 54 53 | ||
f 44 42 54 | ||
f 55 54 42 | ||
f 54 55 53 | ||
f 42 40 55 | ||
f 53 56 50 | ||
f 49 50 56 | ||
f 57 55 40 | ||
f 40 38 57 | ||
f 58 53 55 | ||
f 55 57 58 | ||
f 56 53 58 | ||
f 59 57 38 | ||
f 57 59 58 | ||
f 38 36 59 | ||
f 60 59 36 | ||
f 59 60 58 | ||
f 36 34 60 | ||
f 61 60 34 | ||
f 60 61 58 | ||
f 34 33 61 | ||
f 62 58 61 | ||
f 58 62 56 | ||
f 63 61 33 | ||
f 61 63 62 | ||
f 33 35 63 | ||
f 64 63 35 | ||
f 63 64 62 | ||
f 35 37 64 | ||
f 65 64 37 | ||
f 64 65 62 | ||
f 37 39 65 | ||
f 65 66 62 | ||
f 66 65 39 | ||
f 56 62 66 | ||
f 39 41 66 | ||
f 67 66 41 | ||
f 66 67 56 | ||
f 41 43 67 | ||
f 67 68 56 | ||
f 68 67 43 | ||
f 68 49 56 | ||
f 43 45 68 | ||
f 49 68 45 | ||
f 2 3 69 | ||
f 69 70 2 | ||
f 31 2 70 | ||
f 71 69 3 | ||
f 3 5 71 | ||
f 70 72 31 | ||
f 29 31 72 | ||
f 73 71 5 | ||
f 5 7 73 | ||
f 72 74 29 | ||
f 27 29 74 | ||
f 75 73 7 | ||
f 7 9 75 | ||
f 74 76 27 | ||
f 25 27 76 | ||
f 77 75 9 | ||
f 9 11 77 | ||
f 76 78 25 | ||
f 23 25 78 | ||
f 79 77 11 | ||
f 11 13 79 | ||
f 78 80 23 | ||
f 21 23 80 | ||
f 81 79 13 | ||
f 13 15 81 | ||
f 80 82 21 | ||
f 19 21 82 | ||
f 83 81 15 | ||
f 15 17 83 | ||
f 17 19 84 | ||
f 84 83 17 | ||
f 82 84 19 | ||
f 81 83 85 | ||
f 83 84 86 | ||
f 86 85 83 | ||
f 84 82 87 | ||
f 87 86 84 | ||
f 88 87 82 | ||
f 82 80 88 | ||
f 87 89 86 | ||
f 88 89 87 | ||
f 86 89 85 | ||
f 90 88 80 | ||
f 80 78 90 | ||
f 85 91 81 | ||
f 91 85 89 | ||
f 79 81 91 | ||
f 92 90 78 | ||
f 78 76 92 | ||
f 91 93 79 | ||
f 77 79 93 | ||
f 94 92 76 | ||
f 76 74 94 | ||
f 93 95 77 | ||
f 75 77 95 | ||
f 91 96 93 | ||
f 93 96 95 | ||
f 89 96 91 | ||
f 95 97 75 | ||
f 95 96 97 | ||
f 73 75 97 | ||
f 97 98 73 | ||
f 98 97 96 | ||
f 71 73 98 | ||
f 96 89 99 | ||
f 99 89 88 | ||
f 88 90 99 | ||
f 92 99 90 | ||
f 94 99 92 | ||
f 96 100 98 | ||
f 99 100 96 | ||
f 98 101 71 | ||
f 98 100 101 | ||
f 69 71 101 | ||
f 102 99 94 | ||
f 100 99 102 | ||
f 102 94 74 | ||
f 74 72 102 | ||
f 101 103 69 | ||
f 101 100 103 | ||
f 70 69 103 | ||
f 102 104 100 | ||
f 103 100 104 | ||
f 104 102 72 | ||
f 103 104 70 | ||
f 72 70 104 |
Oops, something went wrong.