Distance constraint#

The DistanceConstraint can be used to constrain the distance between two points to be lower than a given value.

Creating the constraint#

You can use the add_distance_constraint() method on the solver to create a distance constraint:

# Creating a distance constraint, constraining the right foot to remain within 0.3 meters of the trunk
distance_constraint = solver.add_distance_constraint("trunk", "right_foot", 0.3)
distance_constraint.configure("distance", "hard")

This will constrain the distance between the “trunk” and “right_foot” frames to be less than 0.3 meters.

Updating the constraint#

The constraint distance can be updated by setting the distance_max property:

# Update the constraint distance
distance_constraint.distance_max = 0.5

Example#

In the following example, an humanoid robot moves its right foot, which is constrained to remain within 0.3 meters of the trunk.

Humanoid robot with distance constraint

Example code: kinematics/humanoid_distance.py