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 indexing of jacobian due to non-fixed base
  • Loading branch information
LeaStef committed Aug 21, 2025
commit 4d5123666e8836b895c8bfce86ab478a236a4fc4
125 changes: 72 additions & 53 deletions abr_control/arms/isaacsim_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __init__(self, robot_type, folder=None, use_sim_state=True, force_download=F
self.ee_link_name = "EE" # name used for virtual end-effector, overwritten if one exists already

if self.robot_type == "ur5":
self.ctrlr_dof = [True, True, True, False, False, False]
#self.ctrlr_dof = [True, True, True, False, False, False]
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"
Expand All @@ -87,7 +87,7 @@ def __init__(self, robot_type, folder=None, use_sim_state=True, force_download=F
print(f"Virtual end effector with name '{self.ee_link_name}' is attached as robot has none.")

elif self.robot_type == "jaco2":
self.ctrlr_dof = [True, True, True, False, False, False]
#self.ctrlr_dof = [True, True, True, False, False, False]
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"
Expand All @@ -97,20 +97,21 @@ def __init__(self, robot_type, folder=None, use_sim_state=True, force_download=F
print(f"End effector with name '{self.ee_link_name}' specified in UDS, using it ...")

elif self.robot_type == "h1":
self.ctrlr_dof = [True, True, True, False]
#self.ctrlr_dof = [True, True, True, False]
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"
START_ANGLES = "0. 0. 0. 0."
self.target_min = np.array([0.1, -0.55, 1.4])
self.controlled_joints = ['right_shoulder_pitch_joint','right_shoulder_roll_joint', 'right_shoulder_yaw_joint','right_elbow_joint']

print(f"Virtual end effector with name '{self.ee_link_name}' is attached as robot has none.")

elif self.robot_type == "h1_hands":
self.ctrlr_dof = [True, True, True, False, False]
#self.ctrlr_dof = [True, True, True, False, False]
self.robot_path = "/Isaac/Robots/Unitree/H1/h1_with_hand.usd"
self.has_EE = True # H1 has no end-effector
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."
Expand All @@ -124,7 +125,7 @@ def __init__(self, robot_type, folder=None, use_sim_state=True, force_download=F



def _connect(self, world, stage, articulation, articulation_view, joint_pos_addrs, joint_vel_addrs, prim_path):
def _connect(self, world, stage, articulation, articulation_view, joint_pos_addrs, joint_alt_pos_addrs, joint_vel_addrs, 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 @@ -148,6 +149,8 @@ def _connect(self, world, stage, articulation, articulation_view, joint_pos_addr
self.articulation = articulation
self.articulation_view = articulation_view
self.joint_pos_addrs = np.copy(joint_pos_addrs)
# alternative joint addresses, used for the Jacobian
self.joint_alt_pos_addrs = np.copy(joint_alt_pos_addrs)
self.joint_vel_addrs = np.copy(joint_vel_addrs)
self.prim_path = prim_path
self.N_JOINTS = len(self.joint_vel_addrs)
Expand Down Expand Up @@ -178,6 +181,12 @@ def _connect(self, world, stage, articulation, articulation_view, joint_pos_addr
self._x = np.ones(4)
self.N_ALL_JOINTS = N_ALL_JOINTS

'''
def g(self, q=None):
g_full = self.articulation_view.get_generalized_gravity_forces()[0]
return -g_full[self.joint_pos_addrs]
'''


def g(self, q=None):
"""
Expand All @@ -194,6 +203,7 @@ def g(self, q=None):

return -gravity
#return -g




Expand All @@ -220,75 +230,55 @@ def dJ(self, name, q=None, dq=None, x=None):




def J(self, name, q=None, x=None, object_type="body"):
if name == "EE":
name = self.ee_link_name

# Check for unsupported features
if x is not None and not np.allclose(x, 0):
raise Exception("x offset currently not supported, set to None")



def J(self, name, q=None, x=None, object_type="body"):
if object_type == "body":
# Get Jacobians from articulation view - ensure proper tensor handling
jacobians = self.articulation_view.get_jacobians(clone=True)

# Convert to numpy if it's a tensor
if hasattr(jacobians, 'cpu'):
jacobians = jacobians.cpu().numpy()
elif hasattr(jacobians, 'numpy'):
jacobians = jacobians.numpy()

# Check if ArticulationView has any environments
if jacobians.shape[0] == 0:
raise RuntimeError("ArticulationView contains no environments. Make sure it's properly initialized and contains articulations.")


# 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 = 18
link_index = 24
# [6, 10, 14, 18, 20]
elif self.robot_type is "h1_hands":
link_index = 20

#link_index = 20
link_index = 25


env_idx = 0 # Assuming single environment

# shape is (1, 13, 6, 12)
J_full = jacobians[env_idx, link_index, :, :]
if len(jacobians.shape) == 4:
# Shape: (num_envs, num_bodies, 6, num_dofs)
J_full = jacobians[env_idx, link_index, :, :]
elif len(jacobians.shape) == 3:
# Shape: (num_envs, num_bodies * 6, num_dofs)
start_row = link_index * 6
end_row = start_row + 6
J_full = jacobians[env_idx, start_row:end_row, :]
# Fixed articulation base (robotic manipulators): (env, num_bodies - 1, 6, num_dof)
if self.is_fixed_base():
jacobian_columns = self.joint_pos_addrs

# Non-fixed articulation base (mobile robots): (env, num_bodies, 6, num_dof + base_dofs)
else:
jacobian_base_offset = 2 # Empirically determined for H1
jacobian_columns = self.joint_pos_addrs + jacobian_base_offset

else:
raise RuntimeError(f"Unexpected jacobians shape: {jacobians.shape}")

# Extract only the columns for controllable DOFs
# This gives us the end-effector Jacobian w.r.t. only the arm joints
J = J_full[:, self.joint_pos_addrs]

# Check for NaN or inf values
if np.any(np.isnan(J)) or np.any(np.isinf(J)):
raise RuntimeError("Jacobian contains NaN or infinite values")



# Extract only the columns for controllable DOFs
# This gives us the end-effector Jacobian w.r.t. only the right arm joints
J = J_full[:, jacobian_columns]

# 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:, :]

#print(f"Robot type: {self.robot_type}")
#print(f"Link index: {link_index}")
#print(f"Arm joint indices: {self.joint_pos_addrs}")
#print(f"J_full shape: {J_full.shape}")
#print(f"J shape after filtering: {J.shape}")
#print(f"self.joint_pos_addrs: {self.joint_pos_addrs}")

# Additional validation - check if Jacobian makes sense (non-zero values)
if np.allclose(J, 0):
Expand All @@ -304,6 +294,28 @@ def J(self, name, q=None, x=None, object_type="body"):
return np.copy(self._J6N)




def M(self, q=None):
"""
Returns the inertia matrix for the controlled arm joints.
"""
M = self.articulation_view.get_mass_matrices()
M_full = M[0]

# Fixed articulation base (robotic manipulators):
if self.is_fixed_base():
M_arm = M_full[np.ix_(self.joint_pos_addrs, self.joint_pos_addrs)]

# Non-fixed articulation base (mobile robots):
else:
controlled_indices = self.joint_pos_addrs + 6
M_arm = M_full[np.ix_(controlled_indices, controlled_indices)]

return np.copy(M_arm)


'''
def M(self, q=None):
"""
Returns the inertia matrix for the controlled arm_joints.
Expand All @@ -321,6 +333,7 @@ def M(self, q=None):
# extract only the controlled DOF
M_arm = M_full[np.ix_(self.joint_pos_addrs, self.joint_pos_addrs)]
return np.copy(M_arm)
'''


def R(self, name, q=None, object_type="body"):
Expand Down Expand Up @@ -496,3 +509,9 @@ def set_joint_velocities(self, dq):
full_velocities[self.joint_vel_addrs] = dq
self.articulation.set_joint_velocities(full_velocities)


def is_fixed_base(self):
num_dof = self.articulation_view.num_dof
jacobian_shape = self.articulation_view.get_jacobian_shape()[2]
return num_dof == jacobian_shape

Loading