rviz-viewer.py
Go to the documentation of this file.
1 # NOTE: this example needs RViz to be installed
2 # usage: start ROS master (roscore) and then run this test
3 
4 
5 from pathlib import Path
6 
7 import pinocchio as pin
8 from pinocchio.visualize import RVizVisualizer
9 
10 # Load the URDF model.
11 # Conversion with str seems to be necessary when executing this file with ipython
12 pinocchio_model_dir = Path(__file__).parent.parent / "models"
13 
14 model_path = pinocchio_model_dir / "example-robot-data/robots"
15 mesh_dir = pinocchio_model_dir
16 urdf_filename = "talos_reduced.urdf"
17 urdf_model_path = model_path / "talos_data/robots" / urdf_filename
18 
19 model, collision_model, visual_model = pin.buildModelsFromUrdf(
20  urdf_model_path, mesh_dir, pin.JointModelFreeFlyer()
21 )
22 viz = RVizVisualizer(model, collision_model, visual_model)
23 
24 # Initialize the viewer.
25 viz.initViewer()
26 viz.loadViewerModel("pinocchio")
27 
28 # Display a robot configuration.
29 q0 = pin.neutral(model)
30 viz.display(q0)
31 
32 # Display another robot.
33 viz2 = RVizVisualizer(model, collision_model, visual_model)
34 viz2.initViewer(viz.viewer)
35 viz2.loadViewerModel(rootNodeName="pinocchio2")
36 q = q0.copy()
37 q[1] = 1.0
38 viz2.display(q)
39 
40 input("Press enter to exit...")
41 
42 viz.clean()
pinocchio.visualize
Definition: bindings/python/pinocchio/visualize/__init__.py:1
pinocchio.visualize.rviz_visualizer.RVizVisualizer
Definition: rviz_visualizer.py:59


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:32