-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvironment.py
56 lines (47 loc) · 1.84 KB
/
environment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from omni.isaac.core.objects import FixedCuboid, VisualCuboid
import numpy as np
import json
import os
from settings import SITUATION_NAME, SITUATIONS_PATH
import util
def create_cube(world, path:str, name:str, id:int, position:np.ndarray, scale:np.ndarray, color:np.ndarray):
world.scene.add(
FixedCuboid(
prim_path=f"/World/{path}/{name}{id:02}",
name=f"{name.lower()}{id:02}",
translation=position,
scale=scale,
color=color,
)
)
def create_floor_cube(world, path:str, name:str, id:int, position:np.ndarray, scale:np.ndarray, color:np.ndarray):
world.scene.add(
VisualCuboid(
prim_path=f"/World/{path}/{name}{id:02}",
name=f"{name.lower()}{id:02}",
translation=position,
scale=scale,
color=color,
)
)
wall_index = 0
def add_wall(world, position:np.ndarray, scale:np.ndarray, color:np.ndarray):
global wall_index
create_cube(world, "Walls", "Cube", wall_index, position, scale, color)
wall_index += 1
def load_situation():
file_address = f"{os.path.dirname(__file__)}/{SITUATIONS_PATH}/{SITUATION_NAME}.json"
if not os.path.isfile(file_address):
util.debug_log("Situation", f"Could not load situation from file address {file_address}")
return
with open(file_address, 'r') as file:
situation = json.load(file)
return situation
def create_situation_walls(world, walls_color:np.ndarray):
situation = load_situation()
for situationJSON in situation["wall"]:
position = situationJSON['position']
position = np.array([position['x'], position['z'], position['y']])
scale = situationJSON['scale']
scale = np.array([scale['x'], scale['z'], scale['y']])
add_wall(world, position, scale, walls_color)