Skip to content

Commit

Permalink
refactor: pos_jac -> pos_jacobian_in_frame/world
Browse files Browse the repository at this point in the history
  • Loading branch information
domrachev03 committed May 18, 2024
1 parent 862de35 commit d691964
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pink/barriers/position_barrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,23 @@ def compute_jacobian(self, configuration: Configuration) -> np.ndarray:
Jacobian matrix
:math:`\frac{\partial h}{\partial q}(q)`.
"""
pos_jac = configuration.get_frame_jacobian(self.frame)[:3]
pos_jacobian_in_frame = configuration.get_frame_jacobian(self.frame)[
:3
]
# Transform jacobian to world aligned frame
rotation = configuration.get_transform_frame_to_world(
self.frame
).rotation
pos_jac = rotation @ pos_jac

# Select only relevant indices
pos_jac = pos_jac[self.indices]
# Apply rotation to trasfrom from world aligned to local frame
# and select only relevant indices
pos_jacobian_in_world = (rotation @ pos_jacobian_in_frame)[
self.indices
]

jacobians = []
if self.p_min is not None:
jacobians.append(pos_jac.copy())
jacobians.append(pos_jacobian_in_world.copy())
if self.p_max is not None:
jacobians.append(-pos_jac.copy())
jacobians.append(-pos_jacobian_in_world.copy())

return np.vstack(jacobians)

0 comments on commit d691964

Please sign in to comment.