Skip to main content

DM Robotics: Controllers Library (Python)

Contents:

Cartesian 6D to Joint Velocity Mapper

Python bindings for dm_robotics/controllers/lsqp/cartesian_6d_to_joint_velocity_mapper.

This module consists of two classes:

  • cartesian_6d_to_joint_velocity_mapper.Parameters
  • cartesian_6d_to_joint_velocity_mapper.Mapper

The mapper solves a constrained linear least-squares optimization problem at every iteration to compute the joint velocities that best achieve the desired Cartesian 6D velocity of an object.

In its most basic configuration, it computes the joint velocities that achieve the desired Cartesian 6d velocity with singularity robustness. In addition, this mapper also supports the following functionality:

  • Nullspace control can be enabled to bias the joint velocities to a desired value without affecting the accuracy of the resultant Cartesian velocity;
  • Collision avoidance can be enabled between any two MuJoCo geoms;
  • Limits on the joint positions, velocities, and accelerations can be defined to ensure that the computed joint velocities do not result in limit violations.

Please refer to dm_robotics/controllers/lsqp/cartesian_6d_to_joint_velocity_mapper.h or the class docstrings for more information.

Dependencies:

  • dm_robotics/least_squares_qp
  • dm_robotics/controllers
  • dm_control

Usage

from dm_control import mujoco
from dm_control.mujoco.wrapper.mjbindings import enums
from dm_robotics.controllers import cartesian_6d_to_joint_velocity_mapper

# Initialize simulation. Assumes velocity controlled robot.
# physics.data.ctrl[:] is an array of size 7 that corresponds to the commanded
# velocities of the joints with IDs 7, 8, 9, 10, 12, 13, 14.
physics = mujoco.Physics(...) # Create MuJoCo physics.

# Create mapper parameters.
params = cartesian_6d_to_joint_velocity_mapper.Parameters()
#
# Set model parameters.
params.model = physics.model
params.joint_ids = [7, 8, 9, 10, 12, 13, 14]  # MuJoCo joint IDs being controlled.
params.object_type = enums.mjtObj.mjOBJ_SITE  # MuJoCo object being controlled.
params.object_name = "end_effector"  # name of MuJoCo object being controlled.
params.integration_timestep = 0.005  # Amount of time the joint velocities will be executed for.
#
# Enable joint position limit constraint. Limits are read automatically from the
# model.
params.enable_joint_position_limits = True
params.joint_position_limit_velocity_scale = 0.95
params.minimum_distance_from_joint_position_limit = 0.01  # ~0.5deg.
#
# Enable joint velocity limits.
params.enable_joint_velocity_limits = True
params.joint_velocity_magnitude_limits = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
#
# Enable joint acceleration limits.
params.enable_joint_acceleration_limits = True
params.remove_joint_acceleration_limits_if_in_conflict = True
params.joint_acceleration_magnitude_limits = [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0]
#
# Enable collision avoidance between the following geoms:
#   * "gripper" and "base_link"
#   * "base_link" and "floor"
#   * "link1" and "floor"
#   * "gripper" and "floor"
#   * "link1" and "link4"
#   * "link1" and "link5"
#   * "link1" and "link6"
#   * "link2" and "link4"
#   * "link2" and "link5"
#   * "link2" and "link6"
# Note that collision avoidance will not be enabled for a pair of geoms if they
# are attached to the same body or are attached to bodies that have a
# parent-child relationship.
params.enable_collision_avoidance = True
params.collision_avoidance_normal_velocity_scale = 0.5
params.minimum_distance_from_collisions = 0.01
params.collision_detection_distance = 0.3
params.collision_pairs = [(["gripper"], ["base_link"]),
                          (["base_link", "link1", "gripper"], ["floor"]),
                          (["link1", "link2"], ["link4", "link5", "link6"])]
#
# Numerical stability parameters.
params.check_solution_validity = True
params.solution_tolerance = 1e-3
params.regularization_weight = 1e-2
params.enable_nullspace_control = True
params.return_error_on_nullspace_failure = False
params.nullspace_projection_slack = 1e-7

# Create mapper.
mapper = cartesian_6d_to_joint_velocity_mapper.Mapper(params)

# Compute joint velocities and apply them to the joint velocity actuator
# commands at every step.
while True:
  # The nullspace bias is often chosen to be a velocity towards the mid-range of
  # the joints, but can be chosen to be any 7D joint velocity vector.
  nullspace_joint_velocity_bias = get_nullspace_bias()
  target_cartesian_velocity = get_end_effector_target_velocity()
  solution = mapper.compute_joint_velocities(physics.data, target_velocity,
                                             nullspace_bias)
  physics.data.ctrl[:] = solution
  physics.step()

Release files for dm-robotics-controllers 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for dm-robotics-controllers 0.10.0
File
dm_robotics_controllers-0.10.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
dm_robotics_controllers-0.10.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
dm_robotics_controllers-0.10.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
dm_robotics_controllers-0.10.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details

Total release size: 16.1 MB

Release files / dm_robotics_controllers-0.10.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL dm_robotics_controllers-0.10.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 4.0 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
eca7b396c1420106c46cf9ee77c48c3e9b84a0fa71d2e7d067af1bf33ac126e7
BLAKE2b-256 checksum
How to use checksums
d095de35b4439120714c758f61ac7455c4f4eac3151a20d617562c93b384559b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / dm_robotics_controllers-0.10.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL dm_robotics_controllers-0.10.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 4.0 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
37a9f89811b047631a75449d487eda683bf76d8433399b02220cf66b5ea436ee
BLAKE2b-256 checksum
How to use checksums
7a087de1948c005fa82e56c157b68532446c2dac80be6d25766642cf65cdc833
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / dm_robotics_controllers-0.10.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL dm_robotics_controllers-0.10.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 4.0 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e18d9b923fc5dce3ac4bc6dc77da3c8a1f6e6e6157ad06f9bd10f4794ad7562d
BLAKE2b-256 checksum
How to use checksums
54d9bd069c50c162be9796d1b41c9c456f8081a59437b45001e4ad3301d41d7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / dm_robotics_controllers-0.10.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL dm_robotics_controllers-0.10.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 4.0 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
5dc608afd3145e05d4d2648f463e167a0179c8b7e6573a4e6dd2a738a2a71f21
BLAKE2b-256 checksum
How to use checksums
22d16b45ac913c5119220f461134c8675d54c59a1ccedb5f1118f12fb95e6502
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.10.0 This release

4 release files

0.9.0

5 release files

0.8.1

5 release files

0.6.0

3 release files

0.5.0

4 release files

0.4.0

3 release files

0.3.0

3 release files

0.2.0

3 release files

0.1.0

3 release files

0.0.4

4 release files

0.0.3

4 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page