Skip to content

Commit

Permalink
Add utility module for ur10 and update differential_ik_whole_body to …
Browse files Browse the repository at this point in the history
…use ur10
  • Loading branch information
kumar-sanjeeev committed Jan 15, 2025
1 parent 0721205 commit 188b3dc
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 6 deletions.
12 changes: 6 additions & 6 deletions examples/differential_ik_whole_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
joint_limit_nullspace_component,
collision_avoidance_nullspace_component,
)
from pyroboplan.models.ur5 import (
load_ur5_on_base_models,
add_ur5_on_base_self_collisions,
)

from pyroboplan.models.ur10 import (
load_ur10_on_base_models,
add_ur10_on_base_self_collisions,
)

if __name__ == "__main__":
# Create models and data
model, collision_model, visual_model = load_ur5_on_base_models()
add_ur5_on_base_self_collisions(model, collision_model)
model, collision_model, visual_model = load_ur10_on_base_models()
add_ur10_on_base_self_collisions(model, collision_model)

data = model.createData()
collision_data = collision_model.createData()
Expand Down
47 changes: 47 additions & 0 deletions src/pyroboplan/models/ur10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
""" Utilities to load example Universal Robots UR10 robot models. """

import os
import pinocchio

from .utils import get_example_models_folder


def load_ur10_on_base_models():
"""
Gets the example UR10 on base models.
Returns
-------
tuple[`pinocchio.Model`]
A 3-tuple containing the model, collision geometry model, and visual geometry model.
"""
models_folder = get_example_models_folder()
package_dir = os.path.join(models_folder, "ur_description")
urdf_filename = os.path.join(package_dir, "urdf", "ur10_on_base.urdf")

return pinocchio.buildModelsFromUrdf(urdf_filename, package_dirs=models_folder)


def add_ur10_on_base_self_collisions(model, collision_model, srdf_filename=None):
"""
Adds link self-collisions to the UR10 collision model.
This uses an SRDF file to remove any excluded collision pairs.
Parameters
----------
model : `pinocchio.Model`
The Panda model.
collision_model : `pinocchio.Model`
The Panda collision geometry model.
srdf_filename : str, optional
Path to the SRDF file describing the excluded collision pairs.
If not specified, uses a default file included with the Panda model.
"""
if srdf_filename is None:
models_folder = get_example_models_folder()
package_dir = os.path.join(models_folder, "ur_description")
srdf_filename = os.path.join(package_dir, "srdf", "ur10_on_base.srdf")

collision_model.addAllCollisionPairs()
pinocchio.removeCollisionPairs(model, collision_model, srdf_filename)

0 comments on commit 188b3dc

Please sign in to comment.