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
example script to make arm follow cube
  • Loading branch information
LeaStef committed Aug 21, 2025
commit b953b7fa5dc0af6203fbedaf7fc44776fb6766d2
66 changes: 18 additions & 48 deletions abr_control/interfaces/nv_isaacsim.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import numpy as np
from abr_control.utils import download_meshes, transformations
from isaacsim import SimulationApp
from .interface import Interface


class IsaacSim(Interface):
"""An interface for IsaacSim.

Expand All @@ -26,12 +24,11 @@ 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.robot_model = None
self.urdf_path = None
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

'''
Expand All @@ -43,23 +40,18 @@ def __init__(self, robot_config, dt=0.001):


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.core.api.objects import DynamicCuboid # type: ignore
from isaacsim.core.utils.extensions import get_extension_path_from_name # type: ignore
from isaacsim.asset.importer.urdf import _urdf # type: ignore
from omni.isaac.core.robots.robot import Robot # type: ignore
import omni.kit.commands # type: ignore
import omni.usd # type: ignore
import omni
# Create a world
self.world = World(physics_dt=self.dt,rendering_dt=self.dt)
self.world.scene.add_default_ground_plane()


# Acquire the URDF extension interface for parsing and importing URDF files
urdf_interface = _urdf.acquire_urdf_interface()

Expand All @@ -72,61 +64,40 @@ def connect(self, load_scene=True):
self.import_config.distance_scale = 1 # Set distance scale for the robot
self.import_config.density = 0.0 # Set density to 0 (use default values)


# Retrieve the path of the URDF file from the extension
extension_path = get_extension_path_from_name("isaacsim.asset.importer.urdf")
root_path = extension_path + "/data/urdf/robots/ur10/urdf"
#root_path = extension_path + "/data/urdf/robots/ur5/urdf"
file_name = "ur10.urdf"
#file_name = "ur5.urdf"

# Parse the robot's URDF file to generate a robot model
result, self.robot_model = omni.kit.commands.execute(
"URDFParseFile",
urdf_path="{}/{}".format(root_path, file_name),
import_config=self.import_config
)
# 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()


# Set the path to the URDF file
root_path = '/home/steffen/workspace_common/ur_description/urdf/'
file_name = 'ur5.urdf'
imported_robot = urdf_interface.parse_urdf(root_path, file_name, self.import_config)
self.prim_path = urdf_interface.import_robot(root_path, file_name, imported_robot, self.import_config, "ur5")
self.robot = Robot(self.prim_path)
self.ai_link = self.world.scene.add(self.robot)
else:
self.world = SimulationApp.getWorld()


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

# Import the robot onto the current stage and retrieve its prim path
result, prim_path_ur = omni.kit.commands.execute(
"URDFImportRobot",
urdf_robot=self.robot_model,
import_config=self.import_config,
)


# 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()
# necessary so self.q and self.dq are accessible
self.world.initialize_physics()

# Load robot
self.articulation = Articulation(prim_path=prim_path_ur, name="ur10")
self.articulation = Articulation(prim_path=self.prim_path, name="ur5")
self.articulation.initialize()


print("Started Isaacsim as stand alone app...")





def disconnect(self):
"""Any socket closing etc that must be done to properly shut down"""
self.simulation_app.close() # close Isaac Sim
print("IsaacSim connection closed...")



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 @@ -148,14 +119,13 @@ def send_target_angles(self, q):
q : numpy.array
the target joint angles [radians]
"""
# Set the target angles for the joints
from isaacsim.core.utils.types import ArticulationAction # type: ignore
self.articulation.get_articulation_controller().apply_action(ArticulationAction(q))
self.robot.set_joint_positions(q)

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



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

Expand Down
5 changes: 3 additions & 2 deletions examples/isaacsim/flying_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ def step(self, velocity):
linear_velocity = self._cube.get_linear_velocity()
return np.concatenate([position, linear_velocity, orientation], axis=0)

def _get_obj_pose(self):
return self._cube.get_world_pose()
def _get_obj_pos(self):
position, orientation = self._cube.get_world_pose()
return position
89 changes: 89 additions & 0 deletions examples/isaacsim/position_joint_control_inverse_kinematics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
"""
Running the joint controller with an inverse kinematics path planner
in IsaacSim. The path planning system will generate
a trajectory in joint space that moves the end effector in a straight line
to the target, which can be moved by the user.
"""

import numpy as np
from abr_control.arms import ur5 as arm
from abr_control.controllers import Joint, path_planners

from abr_control.interfaces.nv_isaacsim import IsaacSim
from flying_cube import FlyingCube
from abr_control.utils import transformations


if __name__ == "__main__":
dt = 0.001

# change this flag to False to use position control
use_force_control = False
# Initialize our robot config
robot_config = arm.Config()
if use_force_control:
# create an operational space controller
ctrlr = Joint(robot_config, kp=300, kv=20)

# create our path planner
n_timesteps = 2000
path_planner = path_planners.InverseKinematics(robot_config)

# Create our interface
interface = IsaacSim(robot_config, dt=dt)
interface.connect()

flying_cube = FlyingCube(dt, interface.world)
feedback = interface.get_feedback()
print ("q : " + str(feedback["q"]))
print ("dq : " + str(feedback["dq"]))

count = 0
for t in np.arange(0, 100, dt):
# get arm feedback
#velocity = np.array([np.sin(t), np.cos(t), 0.])
#state = flying_cube.step(velocity)

feedback = interface.get_feedback()
hand_xyz = robot_config.Tx("EE", feedback["q"])

if count % n_timesteps == 0:
# get pos of flying cube
target_xyz = flying_cube._get_obj_pos()
# print('target_xyz ', target_xyz)

R = robot_config.R("EE", q=feedback["q"])
target_orientation = transformations.euler_from_matrix(R, "sxyz")

# can use 3 different methods to calculate inverse kinematics
# see inverse_kinematics.py file for details
path_planner.generate_path(
position=feedback["q"],
target_position=np.hstack([target_xyz, target_orientation]),
method=3,
dt=0.005,
n_timesteps=n_timesteps,
plot=False,
)

# returns desired [position, velocity]
target, _ = path_planner.next()
if use_force_control:
# generate an operational space control signal
u = ctrlr.generate(
q=feedback["q"],
dq=feedback["dq"],
target=target,
)

# apply the control signal, step the sim forward
interface.send_forces(u)

else:
# use position control
interface.send_target_angles(target[: robot_config.N_JOINTS])

count += 1
# stop and reset the simulation
interface.disconnect()
print("Simulation terminated...")
30 changes: 30 additions & 0 deletions examples/isaacsim/ur5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import numpy as np
from abr_control.arms import ur5 as arm
from abr_control.interfaces.nv_isaacsim import IsaacSim
from abr_control.utils import transformations

# Sim step size
dt = 0.005

# Initialize our robot config
robot_config = arm.Config()

# Create our interface
interface = IsaacSim(robot_config, dt=dt)
interface.connect()
feedback = interface.get_feedback()
print ("q : " + str(feedback["q"]))
print ("dq : " + str(feedback["dq"]))

count = 0

for i in range(5000):
val = count % 6
interface.send_target_angles(np.array([val, 5.6,1.0,0.0,0.0,0.0]))

count += 1
import time
time.sleep(5)


interface.disconnect()