-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
4d553d9
commit bfc80f2
Showing
5 changed files
with
31 additions
and
8 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
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 |
---|---|---|
@@ -1,18 +1,38 @@ | ||
import math | ||
import numpy as np | ||
import pypolo | ||
import pyvista as pv | ||
from tqdm import tqdm | ||
|
||
array = np.load("./data/N17E073.npy").astype(np.float64) | ||
array /= 100 | ||
array = array[:, :, np.newaxis] | ||
env = pypolo.utils.TensorMap(array, origin=np.zeros(3), resolution=0.1) | ||
|
||
plotter = pv.Plotter() | ||
plotter = pv.Plotter(off_screen=True) | ||
terrain = env.grid.warp_by_scalar() | ||
plotter.add_mesh(terrain, cmap="terrain") | ||
plotter.add_axes(interactive=True) | ||
auv = pv.read("./data/auv.stl") | ||
auv = auv.translate([0, 0, array.max()]).scale(2) | ||
plotter.add_mesh(auv, color="orange") | ||
plotter.add_bounding_box(line_width=1, color='grey') | ||
plotter.show() | ||
robot_mesh = pv.read("./data/robot_mesh.stl") | ||
robot_mesh = robot_mesh.translate([0, 0, array.max()]).scale(2) | ||
|
||
state = np.array([5.0, 5.0, 0, 10.0, 0]) | ||
robot = pypolo.robots.DifferentialDriveRobot(hertz=60.0, state=state) | ||
|
||
plotter.open_gif("./animation.gif") | ||
num_steps = 100 | ||
for i in tqdm(range(num_steps)): | ||
action = np.array([0.0, np.random.uniform(-0.5, 0.5)]) | ||
robot.take(action) | ||
updated_robot_mesh = robot_mesh.rotate_z( | ||
robot.state[2] * 180 / math.pi).translate( | ||
(robot.state[0], robot.state[1], 0)) | ||
|
||
plotter.add_axes() | ||
plotter.add_mesh(terrain, cmap="terrain", lighting=False) | ||
plotter.add_mesh(updated_robot_mesh, color="orange", lighting=False) | ||
plotter.add_bounding_box(line_width=1, color='grey') | ||
plotter.add_text(f"Timestep: {i:03d}", font_size=18) | ||
|
||
plotter.write_frame() | ||
plotter.clear() | ||
|
||
plotter.close() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.