Skip to content
Snippets Groups Projects
Commit 3b4b95b5 authored by jcarpent's avatar jcarpent
Browse files

[Examples] Update example of loading URDF

parent 4c6bec99
No related branches found
No related tags found
No related merge requests found
##
## Copyright (c) 2018 CNRS
##
## This file is part of Pinocchio
## Pinocchio is free software: you can redistribute it
## and/or modify it under the terms of the GNU Lesser General Public
## License as published by the Free Software Foundation, either version
## 3 of the License, or (at your option) any later version.
##
## Pinocchio is distributed in the hope that it will be
## useful, but WITHOUT ANY WARRANTY; without even the implied warranty
## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Lesser Public License for more details. You should have
## received a copy of the GNU Lesser General Public License along with
## Pinocchio If not, see
## <http:##www.gnu.org/licenses/>.
##
##
## In this short script, we show how to a load a robot model from its URDF description.
## Here, the robot model is ROMEO, but a similar approach can be done by with rospkg.
##
import pinocchio as pin
from pinocchio.romeo_wrapper import RomeoWrapper
from pinocchio.romeo_wrapper import RobotWrapper
## Load Romeo with RomeoWrapper
# Load Romeo with RomeoWrapper
import os
current_path = os.getcwd()
......@@ -11,14 +34,15 @@ mesh_dir = model_path
urdf_filename = "romeo.urdf"
urdf_model_path = model_path + "/urdf/" + urdf_filename
robot = RomeoWrapper(urdf_model_path, [mesh_dir])
robot = RobotWrapper(urdf_model_path, [mesh_dir])
## alias
# alias
model = robot.model
data = robot.data
## do whatever, e.g. compute the center of mass position in the world frame
# do whatever, e.g. compute the center of mass position expressed in the world frame
q0 = robot.q0
com = robot.com(q0)
# This last command is similar to
# This last command is similar to:
com2 = pin.centerOfMass(model,data,q0)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment