Skip to content

Commit

Permalink
Merge pull request loco-3d#1215 from cmastalli/topic/display-thrust
Browse files Browse the repository at this point in the history
Extended displayers to show thrust + cleaned their code
  • Loading branch information
cmastalli committed Jan 27, 2024
2 parents 38c9eb3 + b02781b commit dd5318f
Show file tree
Hide file tree
Showing 13 changed files with 399 additions and 352 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

* Enabled display of thrust and simplied displayers code in https://github.com/loco-3d/crocoddyl/pull/1215
* Introduced floating base thruster actuation model in https://github.com/loco-3d/crocoddyl/pull/1213
* Fixed quadruped and biped examples in https://github.com/loco-3d/crocoddyl/pull/1208
* Fixed terminal computation in Python models in https://github.com/loco-3d/crocoddyl/pull/1204
Expand Down
572 changes: 339 additions & 233 deletions bindings/python/crocoddyl/__init__.py

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions examples/bipedal_walk_fwddyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@

gepetto.corbaserver.Client()
cameraTF = [3.0, 3.68, 0.84, 0.2, 0.62, 0.72, 0.22]
display = crocoddyl.GepettoDisplay(
talos_legs, 4, 4, cameraTF, frameNames=[rightFoot, leftFoot]
)
display = crocoddyl.GepettoDisplay(talos_legs, 4, 4, cameraTF)
except Exception:
display = crocoddyl.MeshcatDisplay(talos_legs, frameNames=[rightFoot, leftFoot])
display = crocoddyl.MeshcatDisplay(talos_legs)
display.rate = -1
display.freq = 1
while True:
Expand Down
6 changes: 2 additions & 4 deletions examples/bipedal_walk_invdyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@

gepetto.corbaserver.Client()
cameraTF = [3.0, 3.68, 0.84, 0.2, 0.62, 0.72, 0.22]
display = crocoddyl.GepettoDisplay(
talos_legs, 4, 4, cameraTF, frameNames=[rightFoot, leftFoot]
)
display = crocoddyl.GepettoDisplay(talos_legs, 4, 4, cameraTF)
except Exception:
display = crocoddyl.MeshcatDisplay(talos_legs, frameNames=[rightFoot, leftFoot])
display = crocoddyl.MeshcatDisplay(talos_legs)
display.rate = -1
display.freq = 1
while True:
Expand Down
6 changes: 2 additions & 4 deletions examples/bipedal_walk_ubound.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,9 @@

gepetto.corbaserver.Client()
cameraTF = [3.0, 3.68, 0.84, 0.2, 0.62, 0.72, 0.22]
display = crocoddyl.GepettoDisplay(
talos_legs, 4, 4, cameraTF, frameNames=[rightFoot, leftFoot]
)
display = crocoddyl.GepettoDisplay(talos_legs, 4, 4, cameraTF)
except Exception:
display = crocoddyl.MeshcatDisplay(talos_legs, frameNames=[rightFoot, leftFoot])
display = crocoddyl.MeshcatDisplay(talos_legs)
display.rate = -1
display.freq = 1
while True:
Expand Down
8 changes: 2 additions & 6 deletions examples/boxfddp_vs_boxddp.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,9 @@

gepetto.corbaserver.Client()
cameraTF = [2.0, 2.68, 0.84, 0.2, 0.62, 0.72, 0.22]
display = crocoddyl.GepettoDisplay(
anymal, 4, 4, cameraTF, frameNames=[lfFoot, rfFoot, lhFoot, rhFoot]
)
display = crocoddyl.GepettoDisplay(anymal, 4, 4, cameraTF)
except Exception:
display = crocoddyl.MeshcatDisplay(
anymal, frameNames=[lfFoot, rfFoot, lhFoot, rhFoot]
)
display = crocoddyl.MeshcatDisplay(anymal)
display.rate = -1
display.freq = 1
while True:
Expand Down
43 changes: 15 additions & 28 deletions examples/humanoid_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,6 @@
comRef = (rfPos0 + lfPos0) / 2
comRef[2] = pinocchio.centerOfMass(rmodel, rdata, q0)[2].item()

# Initialize viewer
display = None
if WITHDISPLAY:
if display is None:
try:
import gepetto

gepetto.corbaserver.Client()
display = crocoddyl.GepettoDisplay(robot, frameNames=[rightFoot, leftFoot])
display.robot.viewer.gui.addSphere(
"world/point", 0.05, [1.0, 0.0, 0.0, 1.0]
) # radius = .1, RGBA=1001
display.robot.viewer.gui.applyConfiguration(
"world/point", [*target.tolist(), 0.0, 0.0, 0.0, 1.0]
) # xyz+quaternion
except Exception:
display = crocoddyl.MeshcatDisplay(robot, frameNames=[rightFoot, leftFoot])

# Add contact to the model
contactModel = crocoddyl.ContactModelMultiple(state, actuation.nu)
supportContactModelLeft = crocoddyl.ContactModel6D(
Expand Down Expand Up @@ -180,17 +162,22 @@
solver.solve(xs, us, 500, False, 0.1)

# Visualizing the solution in gepetto-viewer
display = None
if WITHDISPLAY:
try:
import gepetto

gepetto.corbaserver.Client()
cameraTF = [1.4, 0.0, 0.2, 0.5, 0.5, 0.5, 0.5]
display = crocoddyl.GepettoDisplay(
robot, 4, 4, cameraTF, frameNames=[rightFoot, leftFoot]
)
except Exception:
display = crocoddyl.MeshcatDisplay(robot, frameNames=[rightFoot, leftFoot])
if display is None:
try:
import gepetto

gepetto.corbaserver.Client()
display = crocoddyl.GepettoDisplay(robot)
display.robot.viewer.gui.addSphere(
"world/point", 0.05, [1.0, 0.0, 0.0, 1.0]
) # radius = .1, RGBA=1001
display.robot.viewer.gui.applyConfiguration(
"world/point", [*target.tolist(), 0.0, 0.0, 0.0, 1.0]
) # xyz+quaternion
except Exception:
display = crocoddyl.MeshcatDisplay(robot)
display.rate = -1
display.freq = 1
while True:
Expand Down
42 changes: 15 additions & 27 deletions examples/humanoid_manipulation_ubound.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,6 @@
comRef = (rfPos0 + lfPos0) / 2
comRef[2] = pinocchio.centerOfMass(rmodel, rdata, q0)[2].item()

# Initialize viewer
display = None
if WITHDISPLAY:
if display is None:
try:
import gepetto

gepetto.corbaserver.Client()
display = crocoddyl.GepettoDisplay(robot, frameNames=[rightFoot, leftFoot])
display.robot.viewer.gui.addSphere(
"world/point", 0.05, [1.0, 0.0, 0.0, 1.0]
) # radius = .1, RGBA=1001
display.robot.viewer.gui.applyConfiguration(
"world/point", [*target.tolist(), 0.0, 0.0, 0.0, 1.0]
) # xyz+quaternion
except Exception:
display = crocoddyl.MeshcatDisplay(robot, frameNames=[rightFoot, leftFoot])
# Add contact to the model
contactModel = crocoddyl.ContactModelMultiple(state, actuation.nu)
supportContactModelLeft = crocoddyl.ContactModel6D(
Expand Down Expand Up @@ -182,17 +165,22 @@
solver.solve(xs, us, 500, False, 1e-9)

# Visualizing the solution in gepetto-viewer
display = None
if WITHDISPLAY:
try:
import gepetto

gepetto.corbaserver.Client()
cameraTF = [1.4, 0.0, 0.2, 0.5, 0.5, 0.5, 0.5]
display = crocoddyl.GepettoDisplay(
robot, 4, 4, cameraTF, frameNames=[rightFoot, leftFoot]
)
except Exception:
display = crocoddyl.MeshcatDisplay(robot, frameNames=[rightFoot, leftFoot])
if display is None:
try:
import gepetto

gepetto.corbaserver.Client()
display = crocoddyl.GepettoDisplay(robot)
display.robot.viewer.gui.addSphere(
"world/point", 0.05, [1.0, 0.0, 0.0, 1.0]
) # radius = .1, RGBA=1001
display.robot.viewer.gui.applyConfiguration(
"world/point", [*target.tolist(), 0.0, 0.0, 0.0, 1.0]
) # xyz+quaternion
except Exception:
display = crocoddyl.MeshcatDisplay(robot)
display.rate = -1
display.freq = 1
while True:
Expand Down
41 changes: 14 additions & 27 deletions examples/humanoid_taichi.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,6 @@
comRef = (rfPos0 + lfPos0) / 2
comRef[2] = pinocchio.centerOfMass(rmodel, rdata, q0)[2].item()

# Initialize viewer
display = None
if WITHDISPLAY:
if display is None:
try:
import gepetto

gepetto.corbaserver.Client()
display = crocoddyl.GepettoDisplay(robot, frameNames=[rightFoot, leftFoot])
display.robot.viewer.gui.addSphere(
"world/point", 0.05, [1.0, 0.0, 0.0, 1.0]
) # radius = .1, RGBA=1001
display.robot.viewer.gui.applyConfiguration(
"world/point", [*target.tolist(), 0.0, 0.0, 0.0, 1.0]
) # xyz+quaternion
except Exception:
display = crocoddyl.MeshcatDisplay(robot, frameNames=[rightFoot, leftFoot])

# Create two contact models used along the motion
contactModel1Foot = crocoddyl.ContactModelMultiple(state, actuation.nu)
contactModel2Feet = crocoddyl.ContactModelMultiple(state, actuation.nu)
Expand Down Expand Up @@ -230,17 +212,22 @@
solver.solve(xs, us, 500, False, 1e-9)

# Visualizing the solution in gepetto-viewer
display = None
if WITHDISPLAY:
try:
import gepetto
if display is None:
try:
import gepetto

gepetto.corbaserver.Client()
cameraTF = [1.4, 0.0, 0.2, 0.5, 0.5, 0.5, 0.5]
display = crocoddyl.GepettoDisplay(
robot, 4, 4, cameraTF, frameNames=[rightFoot, leftFoot]
)
except Exception:
display = crocoddyl.MeshcatDisplay(robot, frameNames=[rightFoot, leftFoot])
gepetto.corbaserver.Client()
display = crocoddyl.GepettoDisplay(robot)
display.robot.viewer.gui.addSphere(
"world/point", 0.05, [1.0, 0.0, 0.0, 1.0]
) # radius = .1, RGBA=1001
display.robot.viewer.gui.applyConfiguration(
"world/point", [*target.tolist(), 0.0, 0.0, 0.0, 1.0]
) # xyz+quaternion
except Exception:
display = crocoddyl.MeshcatDisplay(robot)
display.rate = -1
display.freq = 1
while True:
Expand Down
2 changes: 1 addition & 1 deletion examples/notebooks/bipedal_walking.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"ddp = crocoddyl.SolverFDDP(problem)\n",
"\n",
"# Using the meshcat displayer, you could enable gepetto viewer for nicer view\n",
"# display = crocoddyl.GepettoDisplay(talos_legs, 4, 4, frameNames=[rightFoot, leftFoot])\n",
"# display = crocoddyl.GepettoDisplay(talos_legs, 4, 4)\n",
"display = crocoddyl.MeshcatDisplay(talos_legs, 4, 4, False)\n",
"ddp.setCallbacks(\n",
" [\n",
Expand Down
8 changes: 2 additions & 6 deletions examples/quadrupedal_gaits_fwddyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,9 @@

gepetto.corbaserver.Client()
cameraTF = [2.0, 2.68, 0.84, 0.2, 0.62, 0.72, 0.22]
display = crocoddyl.GepettoDisplay(
anymal, 4, 4, cameraTF, frameNames=[lfFoot, rfFoot, lhFoot, rhFoot]
)
display = crocoddyl.GepettoDisplay(anymal, 4, 4, cameraTF)
except Exception:
display = crocoddyl.MeshcatDisplay(
anymal, frameNames=[lfFoot, rfFoot, lhFoot, rhFoot]
)
display = crocoddyl.MeshcatDisplay(anymal)
display.rate = -1
display.freq = 1
while True:
Expand Down
8 changes: 2 additions & 6 deletions examples/quadrupedal_gaits_invdyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,9 @@

gepetto.corbaserver.Client()
cameraTF = [2.0, 2.68, 0.84, 0.2, 0.62, 0.72, 0.22]
display = crocoddyl.GepettoDisplay(
anymal, 4, 4, cameraTF, frameNames=[lfFoot, rfFoot, lhFoot, rhFoot]
)
display = crocoddyl.GepettoDisplay(anymal, 4, 4, cameraTF)
except Exception:
display = crocoddyl.MeshcatDisplay(
anymal, frameNames=[lfFoot, rfFoot, lhFoot, rhFoot]
)
display = crocoddyl.MeshcatDisplay(anymal)
display.rate = -1
display.freq = 1
while True:
Expand Down
8 changes: 2 additions & 6 deletions examples/quadrupedal_walk_ubound.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,9 @@

gepetto.corbaserver.Client()
cameraTF = [2.0, 2.68, 0.84, 0.2, 0.62, 0.72, 0.22]
display = crocoddyl.GepettoDisplay(
anymal, 4, 4, cameraTF, frameNames=[lfFoot, rfFoot, lhFoot, rhFoot]
)
display = crocoddyl.GepettoDisplay(anymal, 4, 4, cameraTF)
except Exception:
display = crocoddyl.MeshcatDisplay(
anymal, frameNames=[lfFoot, rfFoot, lhFoot, rhFoot]
)
display = crocoddyl.MeshcatDisplay(anymal)
display.rate = -1
display.freq = 1
while True:
Expand Down

0 comments on commit dd5318f

Please sign in to comment.