Generic visualizer of robot models based on MeshCat.
You can install the project with pypa/pip
, preferably in a virtual environment:
pip install git+https://github.com/ami-iit/meshcat-viz-python
Visualize a manipulator
import pathlib
import gym_ignition_models
import numpy as np
from meshcat_viz.world import MeshcatWorld
# Load a model resource
model_sdf_path = pathlib.Path(
gym_ignition_models.get_model_resource(
robot_name="panda", resource_type=gym_ignition_models.ResourceType.URDF_PATH
)
)
# Open the visualizer
world = MeshcatWorld()
world.open()
# Insert the model from a URDF/SDF resource.
# Note: for URDF files support, check details in https://github.com/ami-iit/rod.
model_name = world.insert_model(model_description=model_sdf_path)
# Update the base position
world.update_model(model_name=model_name, base_position=np.array([1.0, 0, 0]))
# Update the joint positions
s = world._jaxsim_models[model_name].joint_random_positions()
world.update_model(model_name=model_name, joint_positions=s)
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
@diegoferigo |
---|