RoboMeshCat - Set of utilities for visualizing robots in web-based visualizer MeshCat.
Project description
RoboMeshCat
Set of utilities for visualizing robots in web-based visualizer MeshCat. The whole library is object and robot centric allowing you to modify properties of instances rather than manipulating the visualization tree of the MeshCat itself. The library allows you to easily generate videos like this (source code is here):
Installation
From
conda install -c conda-forge robomeshcat
Features
Object and robot centric rendering
- supported objects shapes are sphere, cuboid, cylinder, and mesh; you can control:
- color
- transparency/opacity
- pose
- robots can be loaded from URDF (internally represented by pinocchio
library) and you can control:
- color
- transparency/opacity
- pose of the base
- configuration, i.e. joint values
from robomeshcat import Object, Robot, Scene
from example_robot_data.robots_loader import PandaLoader
from pathlib import Path
"Create a scene that stores all objects and robots and has rendering capability"
scene = Scene()
obj = Object.create_sphere(radius=0.1, name='red_sphere', opacity=0.5, color=[1., 0., 0.])
scene.add_object(obj)
robot = Robot(urdf_path=PandaLoader().df_path, mesh_folder_path=Path(PandaLoader().model_path).parent.parent)
scene.add_robot(robot)
"Render the initial scene"
scene.render()
"Update object position in x-axis and robot first joint"
obj.pos[0] = 1. # or scene['red_sphere'].pos[0] = 1.
robot[0] = 3.14
scene.render()
Animation rendering
- you can easily animate properties:
- poses of the objects
- configurations and poses of robots
- camera pose and zoom
- animation is published automatically after 'with' command finishes/closes
from robomeshcat import Scene
scene = Scene()
with scene.animation(fps=30):
scene.render() # generate first frame
scene.camera_zoom = 0.4 # set the camera zoom, you can also set position and rotation of camera
scene['obj'].pos[1] = 1. # move hte object in the second frame
scene.render() # generate second frame
Image generation
from robomeshcat import Scene
scene = Scene()
img = scene.render_image()
Video recording
from robomeshcat import Scene
scene = Scene()
with scene.video_recording(filename='/tmp/video.mp4', fps=30):
pass
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
robomeshcat-1.0.2.tar.gz
(448.1 kB
view hashes)
Built Distribution
Close
Hashes for robomeshcat-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 878ca9083713c0c5c9f8b35c7fd805cd57ae285875ad2fcac4c849408e63e6f5 |
|
MD5 | 86732103f16d1419c764772c4d4a7d33 |
|
BLAKE2b-256 | e016ff6cfcb0bb7839dbfa2dff69228a7547669d1313d8ade0b1cbf5e2886a4a |