Skip to content

Commit

Permalink
Merge pull request #2443 from jorisv/topic/fix_examples
Browse files Browse the repository at this point in the history
Fix some examples
  • Loading branch information
jcarpent authored Oct 4, 2024
2 parents 5d591b5 + 4b8fbfa commit b7763d9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 38 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fix compilation issue with MSCV and C++17 ([#2437](https://github.com/stack-of-tasks/pinocchio/pull/2437))
- Fix `pinocchio-test-py-robot_wrapper` when building with SDF and collision support ([#2437](https://github.com/stack-of-tasks/pinocchio/pull/2437))
- Fix crash when calling `Inertia::FromDynamicParameters` in Python with wrong vector size ([#2296](https://github.com/stack-of-tasks/pinocchio/pull/2296))
- Fix `examples/cassie-simulation.py` and `examples/talos-simulation.py` ([#2443](https://github.com/stack-of-tasks/pinocchio/pull/2443))

### Changed

Expand Down
44 changes: 6 additions & 38 deletions examples/cassie-simulation.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,11 @@
from time import sleep

import example_robot_data
import numpy as np
import pinocchio
from example_robot_data import readParamsFromSrdf
from pinocchio import JointModelFreeFlyer

model_dir = "/local/rbudhira/devel/install/sot/share/example-robot-data/robots/"
# pinocchio_model_dir = join(dirname(dirname(str(abspath(__file__)))), "models")
sdf_filename = model_dir + "cassie_description/robots/cassie.sdf"
srdf_path = model_dir + "cassie_description/srdf/cassie_v2.srdf"
package_dir = model_dir + "../../"

sdf_parent_guidance = [
"left-roll-op",
"left-yaw-op",
"left-pitch-op",
"left-knee-op",
"left-tarsus-spring-joint",
"left-foot-op",
"right-roll-op",
"right-yaw-op",
"right-pitch-op",
"right-knee-op",
"right-tarsus-spring-joint",
"right-foot-op",
]


robot = pinocchio.RobotWrapper.BuildFromSDF(
sdf_filename,
package_dirs=[package_dir],
root_joint=JointModelFreeFlyer(),
root_link_name="pelvis",
parent_guidance=sdf_parent_guidance,
)

robot.q0 = readParamsFromSrdf(
robot.model, srdf_path, has_rotor_parameters=False, referencePose="standing"
)
from pinocchio.visualize import GepettoVisualizer

robot = example_robot_data.load("cassie")

constraint_models = robot.constraint_models

Expand Down Expand Up @@ -92,9 +59,10 @@
mid_point /= 4.0


robot.initDisplay(loadModel=True)
robot.setVisualizer(GepettoVisualizer())
robot.initViewer()
robot.loadViewerModel("pinocchio")
gui = robot.viewer.gui

robot.display(robot.q0)
q0 = robot.q0.copy()
constraint_datas = pinocchio.StdVec_RigidConstraintData()
Expand Down
2 changes: 2 additions & 0 deletions examples/talos-simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import example_robot_data
import numpy as np
import pinocchio
from pinocchio.visualize import GepettoVisualizer

robot = example_robot_data.load("talos")
model = robot.model
Expand Down Expand Up @@ -53,6 +54,7 @@
pinocchio.rpy.rpyToMatrix(np.array([0, -np.pi / 2, 0.0])), np.array([0.6, 0.4, 1.0])
)

robot.setVisualizer(GepettoVisualizer())
robot.initViewer()
robot.loadViewerModel("pinocchio")
gui = robot.viewer.gui
Expand Down

0 comments on commit b7763d9

Please sign in to comment.