Unverified Commit e92c3629 authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

Fixes the body index used for computing end-effector Jacobian (#22)

* fixes ee body index for single-arm jacobian

* changes initialization of ee-body-index for static code checks

* fixes the ee body index in mobile-manip class
parent 66d5b603
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.2.2" version = "0.2.3"
# Description # Description
title = "ORBIT framework for Robot Learning" title = "ORBIT framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.2.3 (2023-02-24)
~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Fixed the end-effector body index used for getting the Jacobian in the :class:`SingleArm` and :class:`MobileManipulator` classes.
0.2.2 (2023-01-27) 0.2.2 (2023-01-27)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
......
...@@ -97,7 +97,9 @@ class MobileManipulator(SingleArmManipulator): ...@@ -97,7 +97,9 @@ class MobileManipulator(SingleArmManipulator):
# jacobian # jacobian
if self.cfg.data_info.enable_jacobian: if self.cfg.data_info.enable_jacobian:
jacobians = self.articulations.get_jacobians(indices=self._ALL_INDICES, clone=False) jacobians = self.articulations.get_jacobians(indices=self._ALL_INDICES, clone=False)
self._data.ee_jacobian[:] = jacobians[:, self.ee_body_index, :, self.base_num_dof : self.arm_num_dof] # Returned jacobian: [batch, body, 6, dof] does not include the base body (i.e. the first link).
# So we need to subtract 1 from the body index to get the correct jacobian.
self._data.ee_jacobian[:] = jacobians[:, self.ee_body_index - 1, :, self.base_num_dof : self.arm_num_dof]
# mass matrix # mass matrix
if self.cfg.data_info.enable_mass_matrix: if self.cfg.data_info.enable_mass_matrix:
mass_matrices = self.articulations.get_mass_matrices(indices=self._ALL_INDICES, clone=False) mass_matrices = self.articulations.get_mass_matrices(indices=self._ALL_INDICES, clone=False)
......
...@@ -150,10 +150,12 @@ class SingleArmManipulator(RobotBase): ...@@ -150,10 +150,12 @@ class SingleArmManipulator(RobotBase):
super()._process_info_cfg() super()._process_info_cfg()
# resolve regex expressions for indices # resolve regex expressions for indices
# -- end-effector body # -- end-effector body
self.ee_body_index = None self.ee_body_index = -1
for body_index, body_name in enumerate(self.body_names): for body_index, body_name in enumerate(self.body_names):
if re.fullmatch(self.cfg.ee_info.body_name, body_name): if re.fullmatch(self.cfg.ee_info.body_name, body_name):
self.ee_body_index = body_index self.ee_body_index = body_index
if self.ee_body_index == -1:
raise ValueError(f"Could not find end-effector body with name: {self.cfg.ee_info.body_name}")
# -- tool sites # -- tool sites
if self.cfg.meta_info.tool_sites_names: if self.cfg.meta_info.tool_sites_names:
tool_sites_names = list() tool_sites_names = list()
...@@ -163,6 +165,10 @@ class SingleArmManipulator(RobotBase): ...@@ -163,6 +165,10 @@ class SingleArmManipulator(RobotBase):
if re.fullmatch(re_key, body_name): if re.fullmatch(re_key, body_name):
tool_sites_names.append(body_name) tool_sites_names.append(body_name)
tool_sites_indices.append(body_index) tool_sites_indices.append(body_index)
# check valid indices
if len(tool_sites_names) == 0:
raise ValueError(f"Could not find any tool sites with names: {self.cfg.meta_info.tool_sites_names}")
# create dictionary to map names to indices
self.tool_sites_indices: Dict[str, int] = dict(zip(tool_sites_names, tool_sites_indices)) self.tool_sites_indices: Dict[str, int] = dict(zip(tool_sites_names, tool_sites_indices))
else: else:
self.tool_sites_indices = None self.tool_sites_indices = None
...@@ -212,7 +218,9 @@ class SingleArmManipulator(RobotBase): ...@@ -212,7 +218,9 @@ class SingleArmManipulator(RobotBase):
# jacobian # jacobian
if self.cfg.data_info.enable_jacobian: if self.cfg.data_info.enable_jacobian:
jacobians = self.articulations.get_jacobians(indices=self._ALL_INDICES, clone=False) jacobians = self.articulations.get_jacobians(indices=self._ALL_INDICES, clone=False)
self._data.ee_jacobian[:] = jacobians[:, self.ee_body_index, :, : self.arm_num_dof] # Returned jacobian: [batch, body, 6, dof] does not include the base body (i.e. the first link).
# So we need to subtract 1 from the body index to get the correct jacobian.
self._data.ee_jacobian[:] = jacobians[:, self.ee_body_index - 1, :, : self.arm_num_dof]
# mass matrix # mass matrix
if self.cfg.data_info.enable_mass_matrix: if self.cfg.data_info.enable_mass_matrix:
mass_matrices = self.articulations.get_mass_matrices(indices=self._ALL_INDICES, clone=False) mass_matrices = self.articulations.get_mass_matrices(indices=self._ALL_INDICES, clone=False)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment