Skip to content

Commit

Permalink
[Examples] Add example on how to load a Romeo with Python
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarpent committed Jun 8, 2017

Verified

This commit was signed with the committer’s verified signature.
1 parent 08e3a70 commit 3f2cd50
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Pinocchio examples in Python

This directory contains minimal examples on how to use **Pinocchio** with the Python bindings.
24 changes: 24 additions & 0 deletions examples/python/load-romeo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pinocchio as pin
from pinocchio.romeo_wrapper import RomeoWrapper

## Load Romeo with RomeoWrapper
import os
current_path = os.getcwd()

# The model of Romeo is contained in the path PINOCCHIO_GIT_REPOSITORY/models/romeo
model_path = current_path + "/" + "../../models/romeo"
mesh_dir = model_path
urdf_filename = "romeo.urdf"
urdf_model_path = model_path + "/urdf/" + urdf_filename

robot = RomeoWrapper(urdf_model_path, [mesh_dir])

## alias
model = robot.model
data = robot.data

## do whatever, e.g. compute the center of mass position in the world frame
q0 = robot.q0
com = robot.com(q0)
# This last command is similar to
com2 = pin.centerOfMass(model,data,q0)

0 comments on commit 3f2cd50

Please sign in to comment.