Skip to content

Commit

Permalink
Added demo gif to README.
Browse files Browse the repository at this point in the history
  • Loading branch information
Weizhe-Chen committed May 10, 2023
1 parent 4d553d9 commit bfc80f2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<img src="docs/assets/images/social/logo.svg" align="right" width="200" alt="header pic"/>


## What Is PyPolo? 🧐
PyPolo is a Python library for Robotic Information Gathering (RIG) -- a robotics research area that aims to answer:

Expand All @@ -31,6 +32,8 @@ An illustration of RIG's potential use case is an Autonomous Surface Vehicle (AS

<img src="docs/assets/images/framework/framework.png" width="70%"/>

<img src="docs/assets/images/social/terrain_mapping.gif" width="70%"/>

## Why Would I Use PyPolo? 🤷

You might be interested in this library if you would like to
Expand Down
Binary file added demo/animation.gif
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.
36 changes: 28 additions & 8 deletions demo/main.py
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()
Binary file added docs/assets/images/social/terrain_mapping.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit bfc80f2

Please sign in to comment.