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
interface adapted to h1, locked robote pelvis orientation so it does …
…not fall
  • Loading branch information
LeaStef committed Aug 21, 2025
commit 6e1e766b907b5d11afbde7312301f2adc05cb987
135 changes: 88 additions & 47 deletions abr_control/interfaces/nv_isaacsim.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import numpy as np
import os
from isaacsim import SimulationApp
from .interface import Interface
from abr_control.utils import download_meshes, transformations


class IsaacSim(Interface):
"""An interface for IsaacSim.
Expand All @@ -16,7 +15,7 @@ class IsaacSim(Interface):
simulation time step in seconds

"""
def __init__(self, robot_config, dt=0.001):
def __init__(self, robot_config, dt=0.001, force_download=False):

super().__init__(robot_config)
self.dt = dt # time step
Expand All @@ -25,70 +24,73 @@ def __init__(self, robot_config, dt=0.001):
self.q = np.zeros(self.robot_config.N_JOINTS) # joint angles
self.dq = np.zeros(self.robot_config.N_JOINTS) # joint_velocities

self.import_config = None
self.world = None
self.prim_path = None
self.robot = None
self.ai_link = None
#self.misc_handles = {} # for tracking miscellaneous object handles
self.prim_path = "/World/robot"
self.name = "robot"

'''
# joint target velocities, as part of the torque limiting control
# these need to be super high so that the joints are always moving
# at the maximum allowed torque
self.joint_target_velocities = np.ones(robot_config.N_JOINTS) * 10000.0
'''

#self.misc_handles = {} # for tracking miscellaneous object handles


def connect(self, load_scene=True, force_download=False):
def connect(self, load_scene=True):
if load_scene:
"""All initial setup."""
self.simulation_app = SimulationApp({"headless": False})
from isaacsim.core.api import World # type: ignore
from isaacsim.asset.importer.urdf import _urdf # type: ignore
from omni.isaac.core.robots.robot import Robot # type: ignore
from omni.isaac.core.utils.stage import add_reference_to_stage # type: ignore
import omni.isaac.core.utils.stage as stage_utils # type: ignore
import omni.kit.commands # type: ignore
import omni
from isaacsim.robot.policy.examples.robots.h1 import H1FlatTerrainPolicy
from isaacsim.storage.native import get_assets_root_path


# Create a world
self.world = World(physics_dt=self.dt,rendering_dt=self.dt)
self.stage = omni.usd.get_context().get_stage()
self.world.add_physics_callback("send_actions", self.send_actions)
self.world.scene.add_default_ground_plane()

# setting up import configuration:
status, import_config = omni.kit.commands.execute("MJCFCreateImportConfig")
import_config.set_fix_base(False)
import_config.set_make_default_prim(False)

file_name = self.robot_config.filename.split(".")[0]
self.xml_file = os.path.join( f"{file_name}.xml")

omni.kit.commands.execute(
"MJCFCreateAsset",
mjcf_path=self.xml_file,
import_config=import_config,
prim_path="/UR5"


assets_root_path = get_assets_root_path()


self.h1 = H1FlatTerrainPolicy(
prim_path=self.prim_path,
name=self.name,
usd_path=assets_root_path + "/Isaac/Robots/Unitree/H1/h1.usd",
position=np.array([0, 0, 1.05]),
)

stage_utils.add_reference_to_stage(
usd_path=assets_root_path + "/Isaac/Robots/Unitree/H1/h1.usd",
prim_path=self.prim_path,
)

else:
self.world = SimulationApp.getWorld()

# Get the articulation
from omni.isaac.core.articulations import Articulation, ArticulationSubset # type: ignore

from omni.isaac.core.articulations import Articulation# type: ignore
import omni.isaac.core.utils.stage as stage_utils # type: ignore

# Resetting the world needs to be called before querying anything related to an articulation specifically.
# Its recommended to always do a reset after adding your assets, for physics handles to be propagated properly


self.world.reset()
# Load robot
self.articulation = Articulation(prim_path=self.prim_path, name=self.name)
self.articulation.initialize()
print("DOF names:", self.articulation.dof_names)


# necessary so self.q and self.dq are accessible
self.world.initialize_physics()


# Load robot
#self.articulation = Articulation(prim_path=self.prim_path, name="ur5")
#self.articulation.initialize()
#print("DOF names:", self.articulation.dof_names)







Expand Down Expand Up @@ -129,8 +131,17 @@ def send_target_angles(self, q):


# works well
#self.articulation.set_joint_positions(q)

self.articulation.set_joint_positions(q)
'''
tar = np.zeros(17)
self.articulation.set_joint_positions(tar)

self.articulation.set_joint_positions([0., 0., 0., 0.,
0., 0., 0., 0.,
0., 0., 0., 0.,
0., 0., 0., 0.,
0., 0., 0., 0.])
'''

# works but just sets robot abruptly to the target angles
#self.robot.set_joint_positions(q)
Expand All @@ -149,17 +160,36 @@ def send_target_angles(self, q):
self.world.step(render=True) # execute one physics step and one rendering step



def get_feedback(self):
def get_feedback(self, arm_only=True):
"""Return a dictionary of information needed by the controller.

Returns the joint angles and joint velocities in [rad] and [rad/sec],
respectively
"""
# Get the joint angles and velocities
#self.q = self.articulation.get_joint_positions()
#self.dq = self.articulation.get_joint_velocities()
#return {"q": self.q, "dq": self.dq}
q = self.articulation.get_joint_positions()
dq = self.articulation.get_joint_velocities()

# get all 12 DOF of the robot
if arm_only == False:
self.q = q
self.dq = dq
else:
# only get the DOF of the (right) arm
self.q[0] = q[6] # right_shoulder_pitch_joint
self.q[1] = q[10] # right_shoulder_roll_joint
self.q[2] = q[14] # right_shoulder_yaw_joint
self.q[3] = q[18] # right_elbow_joint

self.dq[0] = dq[6] # right_shoulder_pitch_joint
self.dq[1] = dq[10] # right_shoulder_roll_joint
self.dq[2] = dq[14] # right_shoulder_yaw_joint
self.dq[3] = dq[18] # right_elbow_joint

return {"q": self.q, "dq": self.dq}




def get_xyz(self, name):
Expand Down Expand Up @@ -202,3 +232,14 @@ def set_xyz(self, name, xyz):
"""
_cube = self.world.scene.get_object(name)
_cube.set_world_pose(xyz, np.array([0., 0., 0., 1.])) # set the position and orientation of the object



# method for keep_standing
def send_actions(self, dt):
pelvis_prim_path = '/World/robot/pelvis'
from pxr import Gf # type: ignore
prim=self.stage.GetPrimAtPath(pelvis_prim_path)
prim.GetAttribute("xformOp:orient").Set(Gf.Quatd(1.0 ,0.0 ,0.0 ,0.0))
#prim.GetAttribute("xformOp:orient").Set(Gf.Quatd(0.70711 ,0.70711 ,0.0 ,0.0))

40 changes: 40 additions & 0 deletions examples/isaacsim/h1_lock_orientation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
Running the joint controller with an inverse kinematics path planner
for a Mujoco simulation. The path planning system will generate
a trajectory in joint space that moves the end effector in a straight line
to the target, which changes every n time steps.
"""
import numpy as np
#from abr_control.arms.mujoco_config import MujocoConfig as arm
from abr_control.arms import jaco2 as arm
from abr_control.interfaces.nv_isaacsim import IsaacSim


robot_config = arm.Config()

# create our path planner
n_timesteps = 2000
# create our interface
dt = 0.001
interface = IsaacSim(robot_config, dt=dt)
interface.connect()


try:
print("\nSimulation starting...")
count = 0
while 1:

feedback = interface.get_feedback(arm_only=False)
q=feedback["q"]
#print("Q: ", q)

interface.send_target_angles(q)
count += 1


finally:
# stop and reset the simulation
interface.disconnect()

print("Simulation terminated...")