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 calc of body_link in J() and removed obsolete h1 setup
  • Loading branch information
LeaStef committed Aug 21, 2025
commit e6df5fe469890344f80522a7e2fdedb4cd1dfe2f
66 changes: 23 additions & 43 deletions abr_control/arms/isaacsim_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def __init__(self, robot_type):
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_parent_link = "j2n6s300_link_6"
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])
Expand All @@ -99,12 +100,11 @@ def __init__(self, robot_type):
self.EE_parent_link = "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.5, 1.4])
self.target_min = np.array([0.12, -0.4, 1.3])
self.target_min = np.array([0.12, -0.4, 1.4])
self.target_range = np.array([
0.4 - 0.12, # x range
0.12 - (-0.4), # y range
2.2 - 1.3 # z range
0.05 - (-0.4), # y range
2.2 - 1.4 # 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'
Expand All @@ -113,15 +113,14 @@ def __init__(self, robot_type):
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_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.12, -0.4, 1.3])
self.target_min = np.array([0.12, -0.4, 1.4])
self.target_range = np.array([
0.49 - 0.12, # x range
0.12 - (-0.4), # y range
2.2 - 1.3 # z range
0.05 - (-0.4), # y range
2.2 - 1.4 # 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'
Expand Down Expand Up @@ -158,7 +157,7 @@ def _connect(self, world, stage, articulation_view, dof_indices, joint_indices,
self.N_ALL_DOF = self.articulation_view.num_dof
self.N_ALL_JOINTS = self.articulation_view.num_joints
# 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.base_offset = 6 if not self._is_fixed_base() else 0

self.jac_indices = np.hstack(
# 6 because position and rotation Jacobians are 3 x N_JOINTS
Expand All @@ -183,17 +182,14 @@ def _connect(self, world, stage, articulation_view, dof_indices, joint_indices,
self._x = np.ones(4)


# works but gets bumpy when out of reach and weird for higher targets
def g(self, q=None):

full_gravity = self.articulation_view.get_generalized_gravity_forces()[0]
# Drop the first 6 base DOFs for floating-base robots
joint_gravity = full_gravity[6:]

#return joint_gravity[self.dof_indices]

return np.zeros(len(self.dof_indices)) # No gravity compensation in this example

joint_gravity = full_gravity[self.base_offset:]
# for some reason gravity is inverted for fixed_base
sign = -1 if self._is_fixed_base() else 1
return sign * joint_gravity [self.dof_indices]


def dJ(self, name, q=None, dq=None, x=None):
"""Returns the derivative of the Jacobian wrt to time
Expand All @@ -219,22 +215,11 @@ def J(self, name, q=None, x=None):
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
# [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

offset = 0 if not self._is_fixed_base() else -1
body_index = self.articulation_view.get_body_index(self.EE_parent_link) + offset

env_idx = 0 # Assuming single environment
J_full = jacobians[env_idx, link_index, :, :]
J_full = jacobians[env_idx, body_index, :, :]
if len(jacobians.shape) == 4:
# apply offset for non-fixed base (mobile robots)
indices = self.dof_indices + self.base_offset
Expand All @@ -243,13 +228,11 @@ def J(self, name, q=None, x=None):
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:, :]

# 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")

Expand Down Expand Up @@ -376,34 +359,31 @@ def T_inv(self, name, q=None, x=None):
raise NotImplementedError


# HELPER FUNCTIONS
# get the prim path for the name of the link, joint, or site
def _get_prim_path(self, name):
for prim in self.stage.Traverse():
#TODO could be more general to inlcude TCP etc
if str(prim.GetPath()).endswith(name):
return prim.GetPath()
return None

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

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

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

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

def is_fixed_base(self):
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
Expand Down
31 changes: 9 additions & 22 deletions abr_control/interfaces/nv_isaacsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
from omni.isaac.core.articulations import ArticulationView # type: ignore
#from isaacsim.core.prims import Articulation # type: ignore
from isaacsim.core.api.robots import Robot # type: ignore

from pxr import UsdGeom, Gf, UsdShade, Sdf # type: ignore
from isaacsim.core.utils.nucleus import get_assets_root_path # type: ignore
from isaacsim.robot.policy.examples.robots import H1FlatTerrainPolicy # type: ignore
import isaacsim.core.utils.numpy.rotations as rot_utils # type: ignore


Expand Down Expand Up @@ -56,22 +54,12 @@ def connect(self, joint_names=None):
robot_usd_path = f"{assets_root_path}{self.robot_config.robot_path}"
print(f"Robot '{self.robot_config.robot_type}' is loaded from USD path: {robot_usd_path}")

if self.robot_config.robot_type.startswith("h1"):
self.h1 = H1FlatTerrainPolicy(
prim_path=self.prim_path,
name=self.robot_config.robot_type,
usd_path=robot_usd_path,
position=np.array([0, 0 , 0]),
orientation=rot_utils.euler_angles_to_quats(np.array([0, 0, 0]), degrees=True),
stage_utils.add_reference_to_stage(
usd_path=robot_usd_path,
prim_path=self.prim_path,
)

else:
stage_utils.add_reference_to_stage(
usd_path=robot_usd_path,
prim_path=self.prim_path,
)
robot = self.world.scene.add(Robot(prim_path=self.prim_path, name=self.robot_config.robot_type))

robot = self.world.scene.add(Robot(prim_path=self.prim_path, name=self.robot_config.robot_type))

self.world.reset()

self.articulation_view = ArticulationView(prim_paths_expr=self.prim_path, name=self.robot_config.robot_type + "_view")
Expand All @@ -92,7 +80,6 @@ def connect(self, joint_names=None):
# Get joint information
self.dof_indices = []
self.joint_indices = []
self.joint_dyn_addrs = []

if joint_names is None:
print("No joint names provided, using all controllable joints.")
Expand Down Expand Up @@ -150,7 +137,7 @@ def send_target_angles(self, q):
q : numpy.array
the target joint angles [radians]
"""
self.robot_config.set_joint_positions(q)
self.robot_config._set_joint_positions(q)
self.world.step(render=True)


Expand All @@ -159,8 +146,8 @@ def get_feedback(self):
Returns the joint angles and joint velocities in [rad] and [rad/sec],
respectively
"""
self.q = self.robot_config.get_joint_positions()
self.dq = self.robot_config.get_joint_velocities()
self.q = self.robot_config._get_joint_positions()
self.dq = self.robot_config._get_joint_velocities()
return {"q": self.q, "dq": self.dq}


Expand Down Expand Up @@ -218,7 +205,7 @@ def set_gains_force_control(self):
stiffness = np.ones(self.robot_config.N_ALL_DOF) * 100.0 # Default high stiffness
damping = np.ones(self.robot_config.N_ALL_DOF) * 10.0 # Default damping

if self.robot_config.is_fixed_base():
if self.robot_config._is_fixed_base():
controlled_s = 0.0
controlled_d = 0.1
else:
Expand Down
24 changes: 7 additions & 17 deletions examples/IsaacSim/force_osc_xyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
if len(sys.argv) > 1:
arm_model = sys.argv[1]
else:
arm_model = "ur5"
arm_model = "h1_hands" # "h1_hands" / "h1" / jaco2 / ur5
robot_config = arm(arm_model)

dt = 0.007 # 143 Hz
Expand All @@ -24,21 +24,15 @@

# create our IsaacSim interface
interface = IsaacSim(robot_config, dt=dt)

#interface.connect(joint_names=robot_config.controlled_dof)
interface.connect()


interface.send_target_angles(robot_config.START_ANGLES)
isaac_target = interface.create_target_prim(prim_path=target_prim_path)

interface.set_gains_force_control()

# disable gravity
interface.articulation_view.set_body_disable_gravity(True)
gravity = interface.articulation_view.get_body_disable_gravity()[0]
print("Gravity disabled: ", gravity)

# interface.articulation_view.set_body_disable_gravity(True)
# gravity = interface.articulation_view.get_body_disable_gravity()[0]
# print("Gravity disabled: ", gravity)

# damp the movements of the arm
damping = Damping(robot_config, kv=30) #kv=10)
Expand All @@ -62,8 +56,8 @@

def gen_target(interface):
target_min = robot_config.target_min
target_range = np.array([1, 1, 0.5])
target_xyz = (target_min + np.random.rand(3)) * target_range
target_range = robot_config.target_range
target_xyz = target_min + np.random.rand(3) * target_range
interface.set_xyz(target_prim_path, target_xyz)


Expand Down Expand Up @@ -100,21 +94,17 @@ def gen_target(interface):
#interface.world.step(render=True)



# calculate end-effector position
ee_xyz = robot_config.Tx(robot_config.ee_link_name, q=feedback["q"])
# track data
ee_track.append(np.copy(ee_xyz))
target_track.append(np.copy(target[:3]))

error = np.linalg.norm(ee_xyz - target[:3])
if error < 0.02:
# interface.model.geom(target_geom).rgba = green
if error < 0.1: #0.02:
count += 1
else:
count = 0
# interface.model.geom(target_geom).rgba = red

if count >= 50:
print("Generating a new target")
gen_target(interface)
Expand Down