Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whole Body Self Collision Barrier #94

Merged
merged 102 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
ec9914d
draft for com task
simeon-ned May 30, 2024
7da4325
draft for com task
simeon-ned May 30, 2024
bdab5fa
added docstrings for com task
simeon-ned May 30, 2024
ef7b9c7
draft for com task
simeon-ned May 30, 2024
c43347f
draft for com task
simeon-ned May 30, 2024
4b239b0
added docstrings for com task
simeon-ned May 30, 2024
378a001
feat: self collision barrier init
domrachev03 Jun 23, 2024
54bcafa
feat: two iiwa urdf model
domrachev03 Jun 23, 2024
710693d
feat: move collision updates to configuration file
domrachev03 Jun 23, 2024
75d97ef
example: kuka self-collision example init
domrachev03 Jun 23, 2024
94287bc
hotfix: fix typo
domrachev03 Jun 23, 2024
dc1d251
fix: calculate collisions w.r.t. parent frame, not joint
domrachev03 Jun 23, 2024
e107aca
Merge branch 'stephane-caron:main' into feature/com_task
domrachev03 Jun 24, 2024
ed7049d
fix: working barriers (both approaches)
domrachev03 Jun 24, 2024
2a1cc0b
fix: preformance optimization
domrachev03 Jun 24, 2024
81fbca0
docs: documantation of self_collision_barrier
domrachev03 Jun 24, 2024
705fb4b
docs: configuration and example
domrachev03 Jun 24, 2024
ba13c32
Update README.md
domrachev03 Jun 24, 2024
11098fa
refactor: autorefactoring & mypy refactoring
domrachev03 Jun 24, 2024
339e8e5
chore: update CHANGELOG.md
domrachev03 Jun 24, 2024
a156913
refactor: remove completed TODO
domrachev03 Jun 24, 2024
9f7187e
example: time-varying trajectory for kuka example
domrachev03 Jun 25, 2024
99a4186
Update README.md
domrachev03 Jun 25, 2024
b435a62
feat: taking dim closest collisions
domrachev03 Jun 25, 2024
594b02f
format: autoformatting
domrachev03 Jun 25, 2024
7fa181d
Merge branch 'feat/hpp_fcl_barrier' of https://github.com/domrachev03…
domrachev03 Jun 25, 2024
479718e
refactor: use Optional in typing
domrachev03 Jun 25, 2024
4c50d0f
fix: attempt to fix documentation
domrachev03 Jun 25, 2024
f7fa63e
fix: documentation fix
domrachev03 Jun 25, 2024
79323a1
fix: documentation fix
domrachev03 Jun 25, 2024
e441685
hotfix: return configuration limits
domrachev03 Jun 25, 2024
6de9967
tuned g1 example
simeon-ned Jun 26, 2024
8856bfe
tuned g1 example
simeon-ned Jun 26, 2024
ce04e38
Merge branch 'feature/com_task' of github.com:domrachev03/pink into f…
simeon-ned Jun 26, 2024
6e857cc
removed outdated go2 com example
simeon-ned Jun 26, 2024
436c2b6
minor renaming in com repr
simeon-ned Jun 26, 2024
eb062f4
added optional argument to ignore limits in solve
simeon-ned Jun 26, 2024
4d9db86
added optional argument to ignore limits in solve
simeon-ned Jun 26, 2024
7ff9ad9
refactor: autoformatting
domrachev03 Jun 26, 2024
3a63513
test: test com task
domrachev03 Jun 26, 2024
29891da
test: add test on limit ignorance
domrachev03 Jun 26, 2024
1f470a5
refactor: autorefacotring
domrachev03 Jun 26, 2024
7af2eaa
chore: update CHANGELOG.md
domrachev03 Jun 27, 2024
ce7f152
Update credentials
domrachev03 Jun 27, 2024
de77dff
example: fix example
domrachev03 Jun 27, 2024
2210656
refactor: remove redundant np.array copies
domrachev03 Jun 27, 2024
800c012
chore: fix README.md
domrachev03 Jun 27, 2024
30a9e65
refactor: rework configuration.py
domrachev03 Jun 27, 2024
839550c
refactor: refactor the self-collision barrier
domrachev03 Jun 27, 2024
b097d51
feat: move collision pair processing to utils
domrachev03 Jun 27, 2024
9ca7f91
refactor: autoformatting
domrachev03 Jun 27, 2024
0b7cd68
added safety_break to joints limits
simeon-ned Jun 30, 2024
92d8ae9
added safety_break to joints limits
simeon-ned Jun 30, 2024
fb8ae65
removed unnecesarry copy, added changelog
simeon-ned Jun 30, 2024
708142d
integration test for com task
simeon-ned Jun 30, 2024
07fd2c3
integration test for com task
simeon-ned Jun 30, 2024
20fd6c8
reworked doc strings
simeon-ned Jun 30, 2024
7b3dfae
fixed typo in CHANGELOG
simeon-ned Jun 30, 2024
8f9b0b2
Update CHANGELOG.md
simeon-ned Jul 2, 2024
4ff44da
Update CHANGELOG.md
simeon-ned Jul 2, 2024
de4abaf
Update pink/configuration.py
simeon-ned Jul 2, 2024
bf59f5a
Update pink/solve_ik.py
simeon-ned Jul 2, 2024
2fe0843
Update pink/configuration.py
simeon-ned Jul 2, 2024
23cde40
Update pink/configuration.py
simeon-ned Jul 2, 2024
0559d87
fixed minor typos, refeormated
simeon-ned Jul 2, 2024
2c7f1f6
Merge pull request #96 from domrachev03/feature/com_task
stephane-caron Jul 3, 2024
fb37542
feat: self collision barrier init
domrachev03 Jun 23, 2024
0cd55dc
feat: two iiwa urdf model
domrachev03 Jun 23, 2024
cf17f38
feat: move collision updates to configuration file
domrachev03 Jun 23, 2024
a883d7a
example: kuka self-collision example init
domrachev03 Jun 23, 2024
356f2ec
hotfix: fix typo
domrachev03 Jun 23, 2024
7e82924
fix: calculate collisions w.r.t. parent frame, not joint
domrachev03 Jun 23, 2024
b233582
fix: working barriers (both approaches)
domrachev03 Jun 24, 2024
57163fd
fix: preformance optimization
domrachev03 Jun 24, 2024
8c3f0cb
docs: documantation of self_collision_barrier
domrachev03 Jun 24, 2024
bbd7528
docs: configuration and example
domrachev03 Jun 24, 2024
b41e466
Update README.md
domrachev03 Jun 24, 2024
e2dfd75
refactor: autorefactoring & mypy refactoring
domrachev03 Jun 24, 2024
f0060b5
chore: update CHANGELOG.md
domrachev03 Jun 24, 2024
f66ee40
refactor: remove completed TODO
domrachev03 Jun 24, 2024
aca229f
example: time-varying trajectory for kuka example
domrachev03 Jun 25, 2024
70adb2c
feat: taking dim closest collisions
domrachev03 Jun 25, 2024
5634c0d
format: autoformatting
domrachev03 Jun 25, 2024
3704a47
Update README.md
domrachev03 Jun 25, 2024
d7a2d32
refactor: use Optional in typing
domrachev03 Jun 25, 2024
01d166b
fix: attempt to fix documentation
domrachev03 Jun 25, 2024
6367038
fix: documentation fix
domrachev03 Jun 25, 2024
81b5ddf
fix: documentation fix
domrachev03 Jun 25, 2024
ecbb7c0
Update credentials
domrachev03 Jun 27, 2024
5e2d7f1
example: fix example
domrachev03 Jun 27, 2024
187d309
refactor: remove redundant np.array copies
domrachev03 Jun 27, 2024
8001813
chore: fix README.md
domrachev03 Jun 27, 2024
e64ae64
refactor: rework configuration.py
domrachev03 Jun 27, 2024
445a8b3
refactor: refactor the self-collision barrier
domrachev03 Jun 27, 2024
5f0b03d
feat: move collision pair processing to utils
domrachev03 Jun 27, 2024
f2c3d2d
refactor: autoformatting
domrachev03 Jun 27, 2024
5963484
Merge branch 'feat/hpp_fcl_barrier' of https://github.com/domrachev03…
domrachev03 Jul 7, 2024
ce03e51
example: rewrite kuka example with pin.appendModel
domrachev03 Jul 7, 2024
90f6613
test: unit tests for configuration, self collision barrier, and utils
domrachev03 Jul 7, 2024
913767f
Update pink/barriers/self_collision_barrier.py
stephane-caron Jul 22, 2024
b303d1d
Update pink/configuration.py
stephane-caron Jul 22, 2024
d30f1e4
Update examples/barriers/README.md
stephane-caron Jul 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ All notable changes to this project will be documented in this file.
- Abstract Barrier ``Barrier``
- Frame Position Barrier ``PositionBarrier``
- Body Spherical Barrier ``BodySphericalBarrier``
- Examples for `UR5` manipulator and `go2` quadruped robot, and `yumi` two-armed manipulator which illustrate barriers effect.
- Whole-body Self-Collision Avoidance Barrier ``SelfCollisionBarrier``
- `ComTask` for Center of Mass tracking.
- **Breaking:** Updated the logic for handling the joint limits:
- The `check_limits` method now includes an optional `safety_break` argument to control whether execution should stop on exception.
- The solve_ik function now includes the `safety_break` that is forwarded to `check_limits`.
- Example: UR5 manipulator and GO2 quadruped robot with `PositionBarrier`
- Example: YUMI two-armed manipulator with `BodySphericalBarrier`
- Example: G1 humanoid squatting through regulating CoM.

### Changed

Expand Down
12 changes: 12 additions & 0 deletions doc/barriers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ Position barrier

.. automodule:: pink.barriers.position_barrier
:members:

Body Spherical barrier
======================

.. automodule:: pink.barriers.body_spherical_barrier
:members:

Whole Body Collision Avoidance
==============================

.. automodule:: pink.barriers.self_collision_barrier
:members:
20 changes: 19 additions & 1 deletion examples/barriers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ https://github.com/domrachev03/pink/assets/28687492/78281f44-3676-4d4d-9619-768b
| End-effector | $10^{2}$ |


## Yumi self-collision avoidance
## Yumi end-effector self-collision avoidance
Yumi two-armed manimpulator with constraint on minimal distance between frames, defined by end-effectors


Expand All @@ -60,3 +60,21 @@ https://github.com/domrachev03/pink/assets/28687492/f8c4bc8d-63e3-4bf7-a34f-e7ed
| Barrier | Gain |
|------|------|
| Body Spherical | $10^{2}$ |

## Iiwa whole-body collision avoidance
Two iiwas with custom collision geometry with some barely feasible tasks for end-effectors.


https://github.com/domrachev03/pink/assets/28687492/d64163b6-399f-4bbf-ac50-1135fa69c2da



| Task | Cost |
|------|------|
| End-effector | (50,10) |
| Posture | $10^{-3}$ |

| Barrier | Gain |
|------|------|
| Self Collision Avoidance | $10$ |

67 changes: 67 additions & 0 deletions examples/barriers/iiwa14_spheres_collision.srdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--This does not replace URDF, and is not an extension of URDF.
This is a format for representing semantic information about the robot structure.
A URDF file must exist for this robot as well, where the joints and the links that are referenced are defined
-->
<robot name="iiwa14">
<!--DISABLE COLLISIONS: By default it is assumed that any link of the robot could potentially come into collision with any other link in the robot. This tag disables collision checking between a specified pair of links. -->
<disable_collisions link1="left_iiwa_link_0" link2="left_iiwa_link_1" reason="Adjacent"/>
<disable_collisions link1="left_iiwa_link_1" link2="left_iiwa_link_2" reason="Adjacent"/>
<disable_collisions link1="left_iiwa_link_2" link2="left_iiwa_link_3" reason="Adjacent"/>
<disable_collisions link1="left_iiwa_link_3" link2="left_iiwa_link_4" reason="Adjacent"/>
<disable_collisions link1="left_iiwa_link_4" link2="left_iiwa_link_5" reason="Adjacent"/>
<disable_collisions link1="left_iiwa_link_5" link2="left_iiwa_link_6" reason="Adjacent"/>
<disable_collisions link1="left_iiwa_link_5" link2="left_iiwa_link_7" reason="Adjacent"/>
<disable_collisions link1="left_iiwa_link_6" link2="left_iiwa_link_7" reason="Adjacent"/>

<disable_collisions link1="left_iiwa_link_1" link2="left_iiwa_link_3" reason="Never"/>
<disable_collisions link1="left_iiwa_link_1" link2="left_iiwa_link_4" reason="Never"/>
<disable_collisions link1="left_iiwa_link_1" link2="left_iiwa_link_5" reason="Never"/>
<disable_collisions link1="left_iiwa_link_1" link2="left_iiwa_link_6" reason="Never"/>
<disable_collisions link1="left_iiwa_link_1" link2="left_iiwa_link_7" reason="Never"/>

<disable_collisions link1="left_iiwa_link_2" link2="left_iiwa_link_4" reason="Never"/>
<disable_collisions link1="left_iiwa_link_2" link2="left_iiwa_link_5" reason="Never"/>
<disable_collisions link1="left_iiwa_link_2" link2="left_iiwa_link_6" reason="Never"/>
<disable_collisions link1="left_iiwa_link_2" link2="left_iiwa_link_7" reason="Never"/>

<disable_collisions link1="left_iiwa_link_3" link2="left_iiwa_link_5" reason="Never"/>
<disable_collisions link1="left_iiwa_link_3" link2="left_iiwa_link_6" reason="Never"/>
<disable_collisions link1="left_iiwa_link_3" link2="left_iiwa_link_7" reason="Never"/>

<disable_collisions link1="left_iiwa_link_4" link2="left_iiwa_link_6" reason="Never"/>
<disable_collisions link1="left_iiwa_link_4" link2="left_iiwa_link_7" reason="Never"/>

<disable_collisions link1="right_iiwa_link_0" link2="right_iiwa_link_1" reason="Adjacent"/>
<disable_collisions link1="right_iiwa_link_1" link2="right_iiwa_link_2" reason="Adjacent"/>
<disable_collisions link1="right_iiwa_link_2" link2="right_iiwa_link_3" reason="Adjacent"/>
<disable_collisions link1="right_iiwa_link_3" link2="right_iiwa_link_4" reason="Adjacent"/>
<disable_collisions link1="right_iiwa_link_4" link2="right_iiwa_link_5" reason="Adjacent"/>
<disable_collisions link1="right_iiwa_link_5" link2="right_iiwa_link_6" reason="Adjacent"/>
<disable_collisions link1="right_iiwa_link_5" link2="right_iiwa_link_7" reason="Adjacent"/>
<disable_collisions link1="right_iiwa_link_6" link2="right_iiwa_link_7" reason="Adjacent"/>

<disable_collisions link1="right_iiwa_link_0" link2="right_iiwa_link_3" reason="Never"/>
<disable_collisions link1="right_iiwa_link_0" link2="right_iiwa_link_4" reason="Never"/>
<disable_collisions link1="right_iiwa_link_0" link2="right_iiwa_link_5" reason="Never"/>
<disable_collisions link1="right_iiwa_link_0" link2="right_iiwa_link_6" reason="Never"/>
<disable_collisions link1="right_iiwa_link_0" link2="right_iiwa_link_7" reason="Never"/>

<disable_collisions link1="right_iiwa_link_1" link2="right_iiwa_link_3" reason="Never"/>
<disable_collisions link1="right_iiwa_link_1" link2="right_iiwa_link_4" reason="Never"/>
<disable_collisions link1="right_iiwa_link_1" link2="right_iiwa_link_5" reason="Never"/>
<disable_collisions link1="right_iiwa_link_1" link2="right_iiwa_link_6" reason="Never"/>
<disable_collisions link1="right_iiwa_link_1" link2="right_iiwa_link_7" reason="Never"/>

<disable_collisions link1="right_iiwa_link_2" link2="right_iiwa_link_4" reason="Never"/>
<disable_collisions link1="right_iiwa_link_2" link2="right_iiwa_link_5" reason="Never"/>
<disable_collisions link1="right_iiwa_link_2" link2="right_iiwa_link_6" reason="Never"/>
<disable_collisions link1="right_iiwa_link_2" link2="right_iiwa_link_7" reason="Never"/>

<disable_collisions link1="right_iiwa_link_3" link2="right_iiwa_link_5" reason="Never"/>
<disable_collisions link1="right_iiwa_link_3" link2="right_iiwa_link_6" reason="Never"/>
<disable_collisions link1="right_iiwa_link_3" link2="right_iiwa_link_7" reason="Never"/>

<disable_collisions link1="right_iiwa_link_4" link2="right_iiwa_link_6" reason="Never"/>
<disable_collisions link1="right_iiwa_link_4" link2="right_iiwa_link_7" reason="Never"/>
</robot>
210 changes: 210 additions & 0 deletions examples/barriers/kukas_self_collision.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# SPDX-License-Identifier: Apache-2.0
# Copyright 2024 Ivan Domrachev, Simeon Nedelchev

"""Two iiwa14-s with full-body self-collision avoidance using hpp-fcl."""

import os
import meshcat_shapes
import numpy as np
import pinocchio as pin
import qpsolvers
from loop_rate_limiters import RateLimiter

from robot_descriptions.iiwa14_description import PACKAGE_PATH, REPOSITORY_PATH

import pink
from pink import solve_ik
from pink.utils import process_collision_pairs
from pink.barriers import SelfCollisionBarrier
from pink.tasks import FrameTask, PostureTask
from pink.visualization import start_meshcat_visualizer


def prefix_frames(
model: pin.Model, visual_model: pin.GeometryModel, geometry_model: pin.GeometryModel, prefix: str
) -> None:
for frame in model.frames:
frame.name = f"{prefix}_{frame.name}"
for i, name in enumerate(model.names):
model.names[i] = f"{prefix}_{name}"
for geom in visual_model.geometryObjects:
geom.name = f"{prefix}_{geom.name}"
for geom in collision_model.geometryObjects:
geom.name = f"{prefix}_{geom.name}"


if __name__ == "__main__":
# Empty model
model, visual_model, collision_model = pin.Model(), pin.GeometryModel(), pin.GeometryModel()
urdf_path = os.path.join(PACKAGE_PATH, "urdf", "iiwa14_spheres_collision.urdf")

# === Left arm ====
left_arm = pin.RobotWrapper.BuildFromURDF(urdf_path, package_dirs=[os.path.dirname(REPOSITORY_PATH)])

# Add prefix to frames, links and geons of the arm
prefix_frames(left_arm.model, left_arm.visual_model, left_arm.collision_model, "left")

# Place left arm on the left to the origin
left_arm_placement = pin.SE3.Identity()
left_arm_placement.translation = np.array([0.0, 0.2, 0.0])

# Add left arm's model, visual model and collision model to the main model
_, visual_model = pin.appendModel(
model,
left_arm.model,
visual_model,
left_arm.visual_model,
0,
left_arm_placement,
)
model, collision_model = pin.appendModel(
model,
left_arm.model,
collision_model,
left_arm.collision_model,
0,
left_arm_placement,
)

# === Right arm ====
right_arm = pin.RobotWrapper.BuildFromURDF(urdf_path, package_dirs=[os.path.dirname(REPOSITORY_PATH)])

# Add prefix to frames, links and geons of the arm
prefix_frames(right_arm.model, right_arm.visual_model, right_arm.collision_model, "right")

# Place left arm on the left to the origin
right_arm_placement = pin.SE3.Identity()
right_arm_placement.translation = np.array([0.0, -0.2, 0.0])

# Add left arm's model, visual model and collision model to the main model
_, visual_model = pin.appendModel(
model,
right_arm.model,
visual_model,
right_arm.visual_model,
0,
right_arm_placement,
)
model, collision_model = pin.appendModel(
model,
right_arm.model,
collision_model,
right_arm.collision_model,
0,
right_arm_placement,
)

# Assemble to the robot
robot = pin.RobotWrapper(
model,
collision_model=collision_model,
visual_model=visual_model,
)

srdf_path = os.path.dirname(os.path.realpath(__file__)) + "/iiwa14_spheres_collision.srdf"
print(srdf_path)
viz = start_meshcat_visualizer(robot)
q_ref = np.zeros(robot.model.nq)

# Collisions: processing collisions from urdf (include all) and srdf (exclude specified)
# and updating collision model and creating corresponding collision data
robot.collision_data = process_collision_pairs(robot.model, robot.collision_model, srdf_path)

configuration = pink.Configuration(
robot.model,
robot.data,
q_ref,
collision_model=robot.collision_model, # Collision model is required for self_collision_barrier
collision_data=robot.collision_data,
)

# Pink tasks
left_end_effector_task = FrameTask(
"left_iiwa_link_7",
position_cost=50.0, # [cost] / [m]
orientation_cost=10.0, # [cost] / [rad]
)
right_end_effector_task = FrameTask(
"right_iiwa_link_7",
position_cost=50.0, # [cost] / [m]
orientation_cost=10.0, # [cost] / [rad]
)

# Pink barriers
collision_barrier = SelfCollisionBarrier(
n_collision_pairs=len(robot.collision_model.collisionPairs),
gain=20.0,
safe_displacement_gain=1.0,
d_min=0.05,
)

posture_task = PostureTask(
cost=1e-3, # [cost] / [rad]
)

barriers = [collision_barrier]
tasks = [left_end_effector_task, right_end_effector_task, posture_task]

for task in tasks:
task.set_target_from_configuration(configuration)
viz.display(configuration.q)

viewer = viz.viewer
meshcat_shapes.frame(viewer["left_end_effector"], opacity=1.0)
meshcat_shapes.frame(viewer["right_end_effector"], opacity=1.0)
meshcat_shapes.frame(viewer["left_end_effector_target"], opacity=1.0)
meshcat_shapes.frame(viewer["right_end_effector_target"], opacity=1.0)

# Select QP solver
solver = qpsolvers.available_solvers[0]
if "osqp" in qpsolvers.available_solvers:
solver = "osqp"

rate = RateLimiter(frequency=50.0)
dt = rate.period
t = 0.0 # [s]
l_y_des = np.array([0.392, -0.392, 0.6])
r_y_des = np.array([0.392, 0.392, 0.6])

A = l_y_des.copy()
B = r_y_des.copy()

l_dy_des = np.zeros(3)
r_dy_des = np.zeros(3)

while True:
# Make a sinusoidal trajectory between points A and B
mu = (1 + np.cos(t)) / 2
l_y_des[:] = A + (B - A + 0.2 * np.array([0, 0, np.sin(mu * np.pi) ** 2])) * mu
r_y_des[:] = B + (A - B + 0.2 * np.array([0, 0, -np.sin(mu * np.pi) ** 2])) * mu

left_end_effector_task.transform_target_to_world.translation = l_y_des
right_end_effector_task.transform_target_to_world.translation = r_y_des

# Update visualization frames
viewer["left_end_effector"].set_transform(
configuration.get_transform_frame_to_world(left_end_effector_task.frame).np
)
viewer["right_end_effector"].set_transform(
configuration.get_transform_frame_to_world(right_end_effector_task.frame).np
)
viewer["left_end_effector_target"].set_transform(left_end_effector_task.transform_target_to_world.np)
viewer["right_end_effector_target"].set_transform(right_end_effector_task.transform_target_to_world.np)

velocity = solve_ik(
configuration,
tasks,
dt,
solver=solver,
barriers=barriers,
safety_break=False,
)
configuration.integrate_inplace(velocity, dt)

# Visualize result at fixed FPS
viz.display(configuration.q)
rate.sleep()
t += dt
16 changes: 12 additions & 4 deletions examples/barriers/meshcat_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ def __attach_axes(
position_cylinder_in_frame = 0.5 * length * np.eye(3)
for i in range(3):
dir_name = direction_names[i]
material = meshcat.geometry.MeshLambertMaterial(color=colors[i], opacity=opacity)
transform_cylinder_to_frame = meshcat.transformations.rotation_matrix(np.pi / 2, rotation_axes[i])
material = meshcat.geometry.MeshLambertMaterial(
color=colors[i], opacity=opacity
)
transform_cylinder_to_frame = meshcat.transformations.rotation_matrix(
np.pi / 2, rotation_axes[i]
)
transform_cylinder_to_frame[0:3, 3] = position_cylinder_in_frame[i]
cylinder = meshcat.geometry.Cylinder(length, thickness)
handle[dir_name].set_object(cylinder, material)
Expand Down Expand Up @@ -69,7 +73,9 @@ def frame(
As per the de-facto standard (Blender, OpenRAVE, RViz, ...), the
x-axis is red, the y-axis is green and the z-axis is blue.
"""
material = meshcat.geometry.MeshLambertMaterial(color=origin_color, opacity=opacity)
material = meshcat.geometry.MeshLambertMaterial(
color=origin_color, opacity=opacity
)
sphere = meshcat.geometry.Sphere(origin_radius)
handle.set_object(sphere, material)
__attach_axes(handle, axis_length, axis_thickness, opacity)
Expand All @@ -81,7 +87,9 @@ def sphere(
color: int = 0x000000,
opacity: float = 1.0,
):
material = meshcat.geometry.MeshLambertMaterial(color=color, opacity=opacity)
material = meshcat.geometry.MeshLambertMaterial(
color=color, opacity=opacity
)
sphere = meshcat.geometry.Sphere(
radius,
)
Expand Down
2 changes: 1 addition & 1 deletion examples/barriers/yumi_self_collision.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2022 Stéphane Caron

"""Yumi two-armed manipulator with definition of custom frame and
"""Yumi two-armed manipulator with definition of custom frame and
collision avoidance w.r.t. those frames."""

import meshcat_shapes
Expand Down
Loading
Loading