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
adapted tu num of controlled DOF
  • Loading branch information
LeaStef committed Aug 21, 2025
commit 9e412b88e3241445013d0a9bc64fd7b64c73b123
89 changes: 81 additions & 8 deletions abr_control/arms/isaacsim_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def __init__(self, xml_file, folder=None, use_sim_state=True, force_download=Fal
self.robot = xml_file
self.use_sim_state = use_sim_state

def _connect(self, world, stage, articulation, articulation_view, joint_pos_addrs, joint_vel_addrs, prim_path, ee_name):
def _connect(self, world, stage, articulation, articulation_view, joint_pos_addrs, joint_vel_addrs, prim_path, ee_name, joint_names):

"""Called by the interface once the Mujoco simulation is created,
this connects the config to the simulator so it can access the
Expand Down Expand Up @@ -160,7 +160,9 @@ def _connect(self, world, stage, articulation, articulation_view, joint_pos_addr
#TODO: this is a hack for the jaco2 robot, which has 12 joints
#self.N_JOINTS = len(self.joint_vel_addrs)
#self.N_JOINTS = self.articulation_view.num_dof
self.N_JOINTS = 6
print("len(joint_names): ", len(joint_names))
#TODO always only considers the first N joints
self.N_JOINTS = len(joint_names)
print (f"Number of controllable joints: {self.N_JOINTS}")
# number of joints in the IsaacSim simulation
self.N_ALL_JOINTS = self.articulation_view.num_dof
Expand Down Expand Up @@ -224,7 +226,46 @@ def _load_state(self, q, dq=None, u=None):
return old_q, old_dq, old_u



def g(self, q=None):
"""
Returns the joint-space forces due to gravity, Coriolis, and centrifugal effects
in Isaac Sim (equivalent to MuJoCo's qfrc_bias).

Parameters
----------
q: np.ndarray, optional (Default: None)
Joint positions to compute the bias forces at. If None, uses current sim state.
"""
# Compute gravity and Coriolis/centrifugal separately
gravity = self.articulation_view.get_generalized_gravity_forces()
coriolis = self.articulation_view.get_coriolis_and_centrifugal_forces()

print(f"Raw gravity shape: {gravity.shape}")
print(f"Raw coriolis shape: {coriolis.shape}")

# Total generalized bias forces
g_full = gravity + coriolis
print(f"Combined g_full shape: {g_full.shape}")

# Handle batch dimension if present
if g_full.ndim == 2:
print(f"Detected batch dimension, original shape: {g_full.shape}")
if g_full.shape[0] == 1:
g_full = g_full[0] # Remove batch dimension
print(f"After removing batch dimension: {g_full.shape}")

if q is not None:
print(f"q shape: {q.shape}")
# If q is provided, ensure g matches the size of q
if len(g_full) != len(q):
print(f"Truncating g from {len(g_full)} to {len(q)} elements")
g_full = g_full[:len(q)]

print(f"Final g shape: {g_full.shape}")
return -g_full
'''

def g(self, q=None):
"""
Returns the joint-space forces due to gravity, Coriolis, and centrifugal effects
Expand Down Expand Up @@ -260,8 +301,7 @@ def g(self, q=None):
### self.world.step(render=False)

return -g # match MuJoCo's negative qfrc_bias convention


'''

def dJ(self, name, q=None, dq=None, x=None):
"""Returns the derivative of the Jacobian wrt to time
Expand Down Expand Up @@ -438,21 +478,27 @@ def M(self, q=None):
np.ndarray
Dense inertia matrix (DoF x DoF)
"""

'''

if not self.use_sim_state and q is not None:
# Save current joint state
old_q = self.articulation_view.get_joint_positions()
self.articulation_view.set_joint_positions(q)
### self.world.step(render=False) # required to update PhysX buffers

'''

# Get mass matrix
M = self.articulation_view.get_mass_matrices()
#print(f"Mass matrix M: {M}")
if q is not None:
M = M[0, :len(q), :len(q)] # Ensure M is square and matches q size


'''
if not self.use_sim_state and q is not None:
# Restore previous state
self.articulation_view.set_joint_positions(old_q)
### self.world.step(render=False)
'''

return M

Expand Down Expand Up @@ -574,7 +620,34 @@ def T(self, name, q=None, x=None):
# TODO if ever required
raise NotImplementedError

def Tx(self, name, q=None, x=None, object_type="body"):
def Tx(self, name, q=None, object_type="body"):
"""Simplified version that only gets current position without state changes."""
#TODO handle q
if name == "EE":
name = self.ee_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 = self.stage.GetPrimAtPath(prim_path)
if not prim.IsValid():
raise RuntimeError(f"Invalid prim at path: {prim_path}")

matrix = omni.usd.utils.get_world_transform_matrix(prim)
position = matrix.ExtractTranslation()

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



def Tx_old(self, name, q=None, x=None, object_type="body"):
""" Returns the world-frame Cartesian position of a named link, joint, or site.

Parameters
Expand Down
36 changes: 32 additions & 4 deletions abr_control/interfaces/nv_isaacsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ def connect(self, joint_names=None):
self.joint_pos_addrs,
self.joint_vel_addrs,
self.prim_path,
self.ee_name
self.ee_name,
joint_names
)


Expand Down Expand Up @@ -220,9 +221,24 @@ def get_joint_vel_addrs(self, joint_name):
index = dof_name_to_index[joint_name]

return index
'''
def send_forces(self, u):
"""Applies the set of torques u to the arm."""



# Create full torque vector for all DOFs
total_dofs = self.articulation_view.num_dof
full_torques = np.zeros(total_dofs)

# Apply control torques to the controlled joints
full_torques[:len(u)] = u

# Apply the control signal
self.articulation_view.set_joint_efforts(full_torques)

# Move simulation ahead one time step
self.world.step(render=True)

'''
def send_forces(self, u):
"""Applies the set of torques u to the arm. If interfacing to
a simulation, also moves dynamics forward one time step.
Expand All @@ -235,7 +251,7 @@ def send_forces(self, u):

# move simulation ahead one time step
self.world.step(render=True) # execute one physics step and one rendering step


def send_target_angles(self, q):
"""Moves the arm to the specified joint angles
Expand All @@ -256,6 +272,17 @@ def send_target_angles(self, q):
print("len(q) : ", len(q))
print("robot_config.N_JOINTS: ", self.robot_config.N_JOINTS)
# Check if the length of q is greater than the number of joints
if len(q) > self.robot_config.N_JOINTS:
q_new = q[:self.robot_config.N_JOINTS]
self.articulation_view.set_joint_positions(q_new)
elif len(q) < self.robot_config.N_ALL_JOINTS :
q_new = self.articulation_view.get_joint_positions() # Shape: (1, 12)
q_new[0, :len(q)] = q # Update first N_JOINTS for environment 0
self.articulation_view.set_joint_positions(q_new)
else:
self.articulation_view.set_joint_positions(q)

'''
if len(q) > self.robot_config.N_JOINTS:
q_new = q[:self.robot_config.N_JOINTS]
self.articulation_view.set_joint_positions(q_new)
Expand All @@ -265,6 +292,7 @@ def send_target_angles(self, q):
self.articulation_view.set_joint_positions(q_new)
else:
self.articulation_view.set_joint_positions(q)
'''



Expand Down