Constraints
We also provide a util class to compute the constraints. The ConstraintList
is a collection of the Constraint
instances that is available in env_info
. Here
is an simple example explaining how to use the constraint functions.
Here is an example of how to access the constraints:
from air_hockey_challenge.framework import AirHockeyChallengeWrapper
env = AirHockeyChallengeWrapper('3dof-hit')
# Setup the environment
obs = env.reset()
env_info = env.env_info
# Get the keys of the available constraint
print(env_info['constraints'].keys())
# dict_keys(['joint_pos_constr', 'joint_vel_constr', 'ee_constr'])
# Get the joint position and velocity from the observation
q = obs[env_info['joint_pos_ids']]
dq = obs[env_info['joint_vel_ids']]
# Get a dictionary of the constraint functions {"constraint_name": ndarray}
c = env_info['constraints'].fun(q, dq)
# Get a dictionary of the constraint jacobian {"constraint_name": 2d ndarray}
jac = env_info['constraints'].jacobian(q, dq)
# Get value of the constraint function by name
c_ee = env_info['constraints'].get('ee_constr').fun(q, dq)
# Get jacobian of the constraint function by name
jac_vel = env_info['constraints'].get('joint_vel_constr').jacobian(q, dq)
We also list all of the available constraint here:
Class Name |
Key |
Output Dim |
Description |
---|---|---|---|
JointPositionConstraint |
“joint_pos_constr” |
2 * num_joints |
\(q_l < q_{cmd} < q_u\) |
JointVelocityConstraint |
“joint_vel_constr” |
2 * num_joints |
\(\dot{q}_l < \dot{q}_{cmd} < \dot{q}_u\) |
EndEffectorConstraint |
“ee_constr” |
5 |
\(l_x < x_{ee},\) \(l_y < y_{ee} < u_y,\) \(z_{ee} > \mathrm{table\,height - tolerance}\), \(z_{ee} < \mathrm{table\, height + tolerance}\). |
LinkConstraint (7DoF Robot Only) |
“link_constr” |
2 |
\(z_{elbow} > 0.25\), \(z_{wrist} > 0.25\) |