Skip to content

Commit

Permalink
Update random map generation script
Browse files Browse the repository at this point in the history
  • Loading branch information
victorreijgwart committed Dec 30, 2024
1 parent 28803ee commit 12b4728
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions examples/python/edit/generate_random_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,29 @@
# Create an empty map
user_home = os.path.expanduser('~')
your_map = wave.Map.create({
"type": "hashed_chunked_wavelet_octree",
"type": "hashed_wavelet_octree",
"min_cell_width": {
"meters": 0.1
}
})

# Create a large box of free space
map_aabb = wave.AABB(min=np.array([-50.0, -50.0, -10.0]),
max=np.array([50.0, 50.0, 10.0]))
map_aabb = wave.AABB(min=np.array([-50.0, -50.0, -50.0]),
max=np.array([50.0, 50.0, 50.0]))
wave.edit.sum(your_map, map_aabb, -0.05)

# Add random obstacles and cutouts
num_obstacles = 1000
num_obstacles = 500
for idx in range(num_obstacles):
random_center = np.random.rand(3)
random_center -= 0.5
random_center *= 2.0
random_center *= np.array([44.0, 44.0, 4.0])
random_center = 2.0 * (np.random.rand(3) - 0.5)
random_center *= np.array([50.0, 50.0, 50.0])
random_width = 10.0 * np.random.rand(3)
update = float(np.random.rand(1)[0] * 0.2)
if np.random.rand(1)[0] < 0.7:
random_radius = float(5.0 * np.random.rand(1)[0])
random_radius = float(random_width[0])
sphere = wave.Sphere(center=random_center, radius=random_radius)
wave.edit.sum(your_map, sphere, update)
else:
random_width = 5.0 * np.random.rand(3)
box = wave.AABB(min=random_center - random_width,
max=random_center + random_width)
wave.edit.sum(your_map, box, update)
Expand Down

0 comments on commit 12b4728

Please sign in to comment.