Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
3672d6e
added basic interface for isaacsim
LeaStef Apr 22, 2025
0a7b3d6
create world with dt
LeaStef Apr 24, 2025
73d07bb
implemented method connect in interface for isaacsim
LeaStef Apr 25, 2025
f34bf78
implemented method get_feedback to provide joint angles and joint ang…
LeaStef Apr 25, 2025
e2fe8ac
implemented sned_target_angles
LeaStef Apr 28, 2025
6578760
add method to provide pose
LeaStef May 1, 2025
b953b7f
example script to make arm follow cube
LeaStef May 1, 2025
a2ca838
added methods getOreintation() and set_xyz to isaac interface
LeaStef May 6, 2025
0362a48
switched urdf import to xml import
LeaStef May 13, 2025
6e1e766
interface adapted to h1, locked robote pelvis orientation so it does …
LeaStef May 16, 2025
8149846
fixed getfeedback to work only for arm DOFs
LeaStef May 20, 2025
4e70b1a
added config file for H1
LeaStef May 21, 2025
25ab5ca
added matrix for segment lengths of arm
LeaStef May 23, 2025
59d3925
added articulation view
LeaStef May 23, 2025
fb9445b
working example with floating robot
LeaStef Jun 17, 2025
0d70a58
implementation method quaternion, Tx, R
LeaStef Jun 20, 2025
adfa03d
floating control now works for ur5 and jaco2
LeaStef Jun 24, 2025
9e412b8
adapted tu num of controlled DOF
LeaStef Jun 24, 2025
bc7a01e
generalized send u
LeaStef Jun 24, 2025
361b35c
new implementation of the method connect, following the structure of …
LeaStef Jun 25, 2025
00471ef
Create a visual-only cube (no collision)
LeaStef Jun 27, 2025
96b2151
fixed gains of arm joints, which were to stiff for force control
LeaStef Jul 7, 2025
04d54a8
fixed def M
LeaStef Jul 7, 2025
823aa6f
Example with force_osc working
LeaStef Jul 8, 2025
c2593a2
added example linear path gaussian velocity
LeaStef Jul 8, 2025
1da42b9
adaptations for no EE
LeaStef Jul 10, 2025
fc6bd28
force control working for UR5 and jaco2
LeaStef Jul 10, 2025
f7bbb1e
adapted mass matrix to extract the correct, controlled joints
LeaStef Jul 14, 2025
4ec172c
added torso joint and used standing method in setup for h1
LeaStef Jul 15, 2025
53067fb
integrated robot H1 with hands
LeaStef Jul 16, 2025
62cdbec
fixed method set_gains_force_control so it adresses the right joints
LeaStef Jul 16, 2025
ff9299a
adapted method send_forces to work with abritary list of joint indices
LeaStef Jul 16, 2025
b1cb9ea
fixed helper methods for arbitrary indices
LeaStef Jul 17, 2025
15dca0a
removed coriolis forces from function for gravity compensation
LeaStef Jul 30, 2025
4d51236
fixed indexing of jacobian due to non-fixed base
LeaStef Aug 6, 2025
0e1a270
fixed method M
LeaStef Aug 7, 2025
24db8ef
force control OSC working for H1 without gravity
LeaStef Aug 11, 2025
090944b
fixed offset for virtual EE
LeaStef Aug 14, 2025
e6df5fe
fixed calc of body_link in J() and removed obsolete h1 setup
LeaStef Aug 15, 2025
429213d
works with gravity now on all 4 robots (weird fix for h1)
LeaStef Aug 19, 2025
be900e3
example force_osc_xyz_linear_path_gaussian_velocity works with ur5 an…
LeaStef Aug 20, 2025
c503fbe
added documentation
LeaStef Aug 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed offset for virtual EE
  • Loading branch information
LeaStef committed Aug 21, 2025
commit 090944b319e90cdefdbdcbe9e189964f4941d6b2
191 changes: 73 additions & 118 deletions abr_control/arms/isaacsim_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,38 +76,53 @@ def __init__(self, robot_type):
self.robot_path = "/Isaac/Robots/UniversalRobots/ur5/ur5.usd"
self.has_EE = False # UR5 has no end-effector
self.EE_parent_link = "wrist_3_link"
self.ee_offset=[0., 0., 0.]
START_ANGLES = "0 -.67 -.67 0 0 0"
self.target_min = np.array([-0.5, -0.5, 0.5])
self.target_range = [1, 1, 0.5]
self.controlled_dof = ['shoulder_pan_joint', 'shoulder_lift_joint', 'elbow_joint', 'wrist_1_joint', 'wrist_2_joint', 'wrist_3_joint']
print(f"Virtual end effector with name '{self.ee_link_name}' is attached as robot has none.")
print(f"Virtual end effector with name '{self.ee_link_name}' is attached, as robot has none.")

elif self.robot_type == "jaco2":
self.robot_path = "/Isaac/Robots/Kinova/Jaco2/J2N6S300/j2n6s300_instanceable.usd"
self.has_EE = True # jaco2 has an end-effector
self.ee_link_name = "j2n6s300_end_effector"
START_ANGLES = "2.0 3.14 1.57 4.71 0.0 3.04"
self.target_min = np.array([-0.5, -0.5, 0.5])
self.target_range = [1, 1, 0.5]
self.controlled_dof = ['j2n6s300_joint_1', 'j2n6s300_joint_2', 'j2n6s300_joint_3', 'j2n6s300_joint_4', 'j2n6s300_joint_5', 'j2n6s300_joint_6']
print(f"End effector with name '{self.ee_link_name}' specified in UDS, using it ...")

elif self.robot_type == "h1":
self.robot_path = "/Isaac/Robots/Unitree/H1/h1.usd"
self.has_EE = False # H1 has no end-effector
self.EE_parent_link = "right_elbow_link"
#self.ee_link_name = "right_elbow_link"
self.ee_offset=[0.26455, 0.00118, -0.0209] # for H1
START_ANGLES = "0. 0. 0. 0."
self.target_min = np.array([0.1, -0.55, 1.4])
# self.target_min = np.array([0.1, -0.5, 1.4])
self.target_min = np.array([0.12, -0.4, 1.3])
self.target_range = np.array([
0.4 - 0.12, # x range
0.12 - (-0.4), # y range
2.2 - 1.3 # z range
])
self.controlled_dof = ['right_shoulder_pitch_joint','right_shoulder_roll_joint', 'right_shoulder_yaw_joint','right_elbow_joint']
self.lock_prim_standing = '/World/robot/pelvis'
print(f"Virtual end effector with name '{self.ee_link_name}' is attached as robot has none.")
print(f"Virtual end effector with name '{self.ee_link_name}' is attached, as robot has none.")

elif self.robot_type == "h1_hands":
self.robot_path = "/Isaac/Robots/Unitree/H1/h1_with_hand.usd"
self.has_EE = True # H1 with hands has an end-effector
#self.EE_parent_link = "right_elbow_link"
self.ee_link_name = "right_hand_link"
START_ANGLES = "0. 0. 0. 0. 0."
self.target_min = np.array([0.1, -0.55, 1.4])
# self.target_min = np.array([0.1, -0.55, 1.4])
self.target_min = np.array([0.12, -0.4, 1.3])
self.target_range = np.array([
0.49 - 0.12, # x range
0.12 - (-0.4), # y range
2.2 - 1.3 # z range
])
self.controlled_dof = ['right_shoulder_pitch_joint','right_shoulder_roll_joint', 'right_shoulder_yaw_joint','right_elbow_joint','right_hand_joint']
self.lock_prim_standing = '/World/robot/pelvis'
print(f"End effector with name '{self.ee_link_name}' specified in UDS, using it ...")
Expand All @@ -116,7 +131,7 @@ def __init__(self, robot_type):



def _connect(self, world, stage, articulation, articulation_view, dof_indices, joint_indices, prim_path):
def _connect(self, world, stage, articulation_view, dof_indices, joint_indices, prim_path):

"""Called by the interface once the Mujoco simulation is created,
this connects the config to the simulator so it can access the
Expand All @@ -135,15 +150,14 @@ def _connect(self, world, stage, articulation, articulation_view, dof_indices, j
# get access to the Isaac simulation
self.world = world
self.stage = stage
self.articulation = articulation
self.articulation_view = articulation_view
self.dof_indices = np.copy(dof_indices)
self.joint_indices = np.copy(joint_indices)
self.prim_path = prim_path
self.N_JOINTS = len(self.dof_indices)
self.N_ALL_DOF = self.articulation_view.num_dof
self.N_ALL_JOINTS = self.articulation_view.num_joints
# offset for non-fixed articulation base (mobile robots), necessary for indexing jacobian matrices etc correctly
# offset for non-fixed base (mobile robots), necessary for indexing jacobian matrices etc correctly
self.base_offset = 6 if not self.is_fixed_base() else 0

self.jac_indices = np.hstack(
Expand Down Expand Up @@ -200,69 +214,62 @@ def dJ(self, name, q=None, dq=None, x=None):
raise NotImplementedError


def J(self, name, q=None, x=None, object_type="body"):
if object_type == "body":
jacobians = self.articulation_view.get_jacobians(clone=True)
if jacobians.shape[0] == 0:
raise RuntimeError("ArticulationView contains no environments. Make sure it's properly initialized and contains articulations.")
def J(self, name, q=None, x=None):
jacobians = self.articulation_view.get_jacobians(clone=True)
if jacobians.shape[0] == 0:
raise RuntimeError("ArticulationView contains no environments.")

# TODO this could be fixed by attachind virtual EE
if self.robot_type is "ur5":
link_index = 5
elif self.robot_type is "jaco2":
link_index = 5
# TODO this could be fixed by attachind virtual EE
if self.robot_type is "ur5":
link_index = 5
elif self.robot_type is "jaco2":
link_index = 5
# [6, 10, 14, 18]
elif self.robot_type is "h1":
#link_index = 18
link_index = 24
# [6, 10, 14, 18, 20]
elif self.robot_type is "h1_hands":
#link_index = 20
link_index = 25

env_idx = 0 # Assuming single environment
J_full = jacobians[env_idx, link_index, :, :]
if len(jacobians.shape) == 4:
# apply offset for non-fixed articulation base (mobile robots
indices = self.dof_indices + self.base_offset
# Extract only the columns for controllable DOFs
J = J_full[:, indices]
else:
raise RuntimeError(f"Unexpected jacobians shape: {jacobians.shape}")

# Assign to internal storage
# Linear velocity Jacobian (first 3 rows)
self._J6N[:3, :] = J[:3, :]
# Angular velocity Jacobian (last 3 rows)
self._J6N[3:, :] = J[3:, :]
elif self.robot_type is "h1":
#link_index = 18
link_index = 24
# [6, 10, 14, 18, 20]
elif self.robot_type is "h1_hands":
#link_index = 20
link_index = 25

env_idx = 0 # Assuming single environment
J_full = jacobians[env_idx, link_index, :, :]
if len(jacobians.shape) == 4:
# apply offset for non-fixed base (mobile robots)
indices = self.dof_indices + self.base_offset
# Extract only the columns for controllable DOFs
J = J_full[:, indices]
else:
raise RuntimeError(f"Unexpected jacobians shape: {jacobians.shape}")

# Additional validation - check if Jacobian makes sense (non-zero values)
if np.allclose(J, 0):
raise RuntimeError("Jacobian is all zeros - check robot configuration and joint addresses")
# Assign to internal storage
# Linear velocity Jacobian (first 3 rows)
self._J6N[:3, :] = J[:3, :]
# Angular velocity Jacobian (last 3 rows)
self._J6N[3:, :] = J[3:, :]

elif object_type == "geom":
raise NotImplementedError("Calculating the Jacobian for 'geom' is not yet implemented.")
elif object_type == "site":
raise NotImplementedError("Calculating the Jacobian for 'site' is not yet implemented.")
else:
raise ValueError(f"Invalid object type specified: {object_type}")
# Additional validation - check if Jacobian makes sense (non-zero values)
if np.allclose(J, 0):
raise RuntimeError("Jacobian is all zeros - check robot configuration and joint addresses")

return np.copy(self._J6N)



def M(self, q=None):
"""
Returns the inertia matrix for the controlled arm joints.
"""
# get_mass_matrices returns (num_envs, joint_count, joint_count)
self._MNN= self.articulation_view.get_mass_matrices()[0]
# apply offset for non-fixed articulation base (mobile robots)
# apply offset for non-fixed base (mobile robots)
indices = self.dof_indices + self.base_offset
M = self._MNN[np.ix_(indices, indices)]
return M


def R(self, name, q=None, object_type="body"):
def R(self, name, q=None):
"""
Returns the rotation matrix of the specified object in Isaac Sim.

Expand All @@ -272,19 +279,8 @@ def R(self, name, q=None, object_type="body"):
The name of the object (body, geom, or site) in the USD stage.
q : np.ndarray, optional
Joint positions (not used here unless you want to simulate a different state).
object_type : str
One of "body", "geom", or "site".
"""

if object_type == "body":
prim_path = self._get_prim_path(name)
elif object_type in ["site", "geom"]:
# Assume full path is given or fixed base path
prim_path = f"{self.prim_path}/{name}"
else:
raise ValueError(f"Unsupported object type: {object_type}")


prim_path = self._get_prim_path(name)
prim = self.stage.GetPrimAtPath(prim_path)
if not prim.IsValid():
raise RuntimeError(f"Prim '{prim_path}' not found")
Expand All @@ -304,7 +300,7 @@ def R(self, name, q=None, object_type="body"):


def quaternion(self, name, q=None):
"""Returns the quaternion of the specified body
"""Returns the quaternion
Parameters
----------

Expand Down Expand Up @@ -335,7 +331,7 @@ def C(self):


def T(self, name, q=None, x=None):
"""Get the transform matrix of the specified body.
"""Get the transform matrix.

Parameters
----------
Expand All @@ -350,19 +346,10 @@ def T(self, name, q=None, x=None):
raise NotImplementedError


def Tx(self, name, q=None, x=None, object_type="body"):
def Tx(self, name, q=None, x=None):
"""Simplified version that only gets current position without state changes."""
if name == "EE": name = self.ee_link_name
# Get prim path
if object_type in ["body", "link"]:
prim_path = self._get_prim_path(name)
elif object_type == "joint":
# For joints, you might want the parent link position
prim_path = self._get_prim_path(name)
else:
raise ValueError(f"Unsupported object_type: {object_type}")

# Get world position
prim_path = self._get_prim_path(name)
prim = self.stage.GetPrimAtPath(prim_path)
if not prim.IsValid():
raise RuntimeError(f"Invalid prim at path: {prim_path}")
Expand All @@ -371,42 +358,10 @@ def Tx(self, name, q=None, x=None, object_type="body"):
position = matrix.ExtractTranslation()

return np.array([position[0], position[1], position[2]], dtype=np.float64)

'''
def get_xyz(self, prim_path):
"""Returns the xyz position of the specified object

prim_path : string
path of the object you want the xyz position of
"""
transform_matrix = self.get_transform(prim_path)
translation = transform_matrix.ExtractTranslation()
return np.array([translation[0], translation[1], translation[2]], dtype=np.float64)



# TODO check if necessary
def get_transform(self, prim_path):
_cube = self.stage.GetPrimAtPath(prim_path)
# Check if it's an Xformable
if not _cube.IsValid() or not UsdGeom.Xformable(_cube):
print(f"Prim at {_cube.GetPath()} is not a valid Xformable.")
else:
xformable = UsdGeom.Xformable(_cube)
# Get the local transformation matrix
transform_matrix = xformable.GetLocalTransformation()

return transform_matrix

'''






def T_inv(self, name, q=None, x=None):
"""Get the inverse transform matrix of the specified body.
"""Get the inverse transform matrix.

Parameters
----------
Expand All @@ -431,22 +386,22 @@ def _get_prim_path(self, name):
return None

def get_joint_positions(self):
all_positions = self.articulation.get_joint_positions()
return all_positions[self.dof_indices]
full_positions = self.articulation_view.get_joint_positions()[0]
return full_positions[self.dof_indices]

def get_joint_velocities(self):
all_velocities = self.articulation.get_joint_velocities()
return all_velocities[self.dof_indices]
full_velocities = self.articulation_view.get_joint_velocities()[0]
return full_velocities[self.dof_indices]

def set_joint_positions(self, q):
full_positions = self.articulation.get_joint_positions()
full_positions = self.articulation_view.get_joint_positions()[0]
full_positions[self.dof_indices] = q
self.articulation.set_joint_positions(full_positions)
self.articulation_view.set_joint_positions(full_positions)

def set_joint_velocities(self, dq):
full_velocities = self.articulation.get_joint_velocities()
full_velocities = self.articulation_view.get_joint_velocities()[0]
full_velocities[self.dof_indices] = dq
self.articulation.set_joint_velocities(full_velocities)
self.articulation_view.set_joint_velocities(full_velocities)

def is_fixed_base(self):
num_dof = self.articulation_view.num_dof
Expand Down
Loading