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 import pinocchio as pin
5 from os.path import dirname, join, abspath
6 
7 from pinocchio.visualize import RVizVisualizer
8 
9 # Load the URDF model.
10 # Conversion with str seems to be necessary when executing this file with ipython
11 pinocchio_model_dir = join(dirname(dirname(str(abspath(__file__)))),"models")
12 
13 model_path = join(pinocchio_model_dir,"example-robot-data/robots")
14 mesh_dir = pinocchio_model_dir
15 urdf_filename = "talos_reduced.urdf"
16 urdf_model_path = join(join(model_path,"talos_data/robots"),urdf_filename)
17 
18 model, collision_model, visual_model = pin.buildModelsFromUrdf(urdf_model_path, mesh_dir, pin.JointModelFreeFlyer())
19 viz = RVizVisualizer(model, collision_model, visual_model)
20 
21 # Initialize the viewer.
22 viz.initViewer()
23 viz.loadViewerModel("pinocchio")
24 
25 # Display a robot configuration.
26 q0 = pin.neutral(model)
27 viz.display(q0)
28 
29 # Display another robot.
30 viz2 = RVizVisualizer(model, collision_model, visual_model)
31 viz2.initViewer(viz.viewer)
32 viz2.loadViewerModel(rootNodeName = "pinocchio2")
33 q = q0.copy()
34 q[1] = 1.0
35 viz2.display(q)
36 
37 input("Press enter to exit...")
38 
39 viz.clean()


pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:32