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
added methods getOreintation() and set_xyz to isaac interface
  • Loading branch information
LeaStef committed Aug 21, 2025
commit a2ca8382709330f2e78d6a07be3a7ff9c3d9f76f
41 changes: 37 additions & 4 deletions abr_control/interfaces/nv_isaacsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ def send_forces(self, u):
u : np.array
An array of joint torques [Nm]
"""
# Apply some torque
self.articulation.set_joint_efforts(u)
# Apply the control signal
#self.articulation.set_joint_efforts(u)
#self.robot.set_joint_efforts(u)
self.robot.set_joint_efforts(u)

# move simulation ahead one time step
self.world.step(render=True) # execute one physics step and one rendering step
Expand All @@ -119,8 +121,10 @@ def send_target_angles(self, q):
q : numpy.array
the target joint angles [radians]
"""
print("robot joint pos: ", self.robot.get_joint_positions())
print("q: ", 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

Expand Down Expand Up @@ -148,4 +152,33 @@ def get_xyz(self, name):
obj = self.world.scene.get_object(name)
object_position, object_orientation = obj.get_world_pose()

return object_position
return object_position


def get_orientation(self, name):
"""Returns the orientation of an object in CoppeliaSim

the Euler angles [radians] are returned in the relative xyz frame.
http://www.coppeliarobotics.com/helpFiles/en/eulerAngles.htm

Parameters
----------
name : string
the name of the object of interest
"""

obj = self.world.scene.get_object(name)
object_position, object_orientation = obj.get_world_pose()
return object_orientation


def set_xyz(self, name, xyz):
"""Set the position of an object in the environment.

name : string
the name of the object
xyz : np.array
the [x,y,z] location of the target [meters]
"""
_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
41 changes: 41 additions & 0 deletions examples/isaacsim/blog_minimal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import numpy as np
from abr_control.arms import ur5 as arm
from abr_control.controllers import OSC
from abr_control.interfaces.nv_isaacsim import IsaacSim
from flying_cube import FlyingCube

# https://studywolf.wordpress.com/2017/07/01/abr-control-0-1-repo-public-release/


# initialize our robot config for the ur5
robot_config = arm.Config(use_cython=True)

# instantiate controller
ctrlr = OSC(robot_config, kp=200, vmax=[0.5, 0])


# create our VREP interface
interface = IsaacSim(robot_config, dt=.001)
interface.connect()

isaac_target = FlyingCube(interface.dt, interface.world, name="target", prim_path="/World/target")
target_xyz = np.array([0.2, 0.2, 0.2])
# set the target object's position in VREP
interface.set_xyz(name='target', xyz=target_xyz)

count = 0.0
while count < 4000: # run for 1.5 simulated seconds
# get joint angle and velocity feedback
feedback = interface.get_feedback()
# calculate the control signal
u = ctrlr.generate(
q=feedback['q'],
dq=feedback['dq'],
target=target_xyz)


# send forces into VREP, step the sim forward
interface.send_forces(u)

count += 1
interface.disconnect()
21 changes: 11 additions & 10 deletions examples/isaacsim/flying_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@

class FlyingCube():

def __init__(self, dt, world):
def __init__(self, dt, world, prim_path="/World/random_cube", name="fancy_cube", position=np.array([0, 0, 1.0]), scale=np.array([0.1015, 0.1015, 0.1015]), color=np.array([0, 0, 1.0])):
# IsaacSim imports must be done after instantiating the SimulationApp, which is done by the setup in the isaacsim interface
from omni.isaac.core.objects import DynamicCuboid # type: ignore
from omni.isaac.dynamic_control import _dynamic_control # type: ignore

self.world = world
fancy_cube = self.world.scene.add(
DynamicCuboid(
prim_path="/World/random_cube",
name="fancy_cube",
position=np.array([0, 0, 1.0]),
scale=np.array([0.1015, 0.1015, 0.1015]),
color=np.array([0, 0, 1.0]),
prim_path=prim_path,
name=name,
position=position,
scale=scale,
color=color,
)
)
# Set the cube to be dynamic using dynamic_control
self._dc = _dynamic_control.acquire_dynamic_control_interface()
self.cube_handle = self._dc.get_rigid_body("/World/random_cube")
self._cube = self.world.scene.get_object("fancy_cube")
self.cube_handle = self._dc.get_rigid_body(prim_path)
self._cube = self.world.scene.get_object(name)

# Add velocity as an attribute of the world so that it is available at callback time
self.input_velocity = np.zeros(3)
self.world.add_physics_callback("send_actions", self.send_actions)
self.world.add_physics_callback("make_state", self.make_state)

self.world.add_physics_callback(name + "_send_actions", self.send_actions)
self.world.add_physics_callback(name + "_make_state", self.make_state)

def send_actions(self, dt):
self._dc.set_rigid_body_linear_velocity(self.cube_handle, self.input_velocity)
Expand Down
173 changes: 173 additions & 0 deletions examples/isaacsim/force_osc_xyz_avoid_obstacle path_planner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
"""
Move the UR5 CoppeliaSim arm to a target position while avoiding an obstacle.
The simulation ends after 1500 time steps, and the trajectory
of the end-effector is plotted in 3D.
"""
import numpy as np
from flying_cube import FlyingCube
from abr_control.arms import ur5 as arm
from abr_control.controllers import Joint, path_planners
from abr_control.utils import transformations



from abr_control.controllers import OSC, AvoidObstacles, Damping
from abr_control.interfaces.nv_isaacsim import IsaacSim

# initialize our robot config
robot_config = arm.Config()
# change this flag to False to use position control
use_force_control = False
n_timesteps = 2000
path_planner = path_planners.InverseKinematics(robot_config)



avoid = AvoidObstacles(robot_config)
# damp the movements of the arm
if use_force_control:
# create an operational space controller
damping = Damping(robot_config, kv=10)
# instantiate the REACH controller with obstacle avoidance
ctrlr = OSC(
robot_config,
kp=200,
null_controllers=[avoid, damping],
vmax=[0.5, 0], # [m/s, rad/s]
# control (x, y, z) out of [x, y, z, alpha, beta, gamma]
ctrlr_dof=[True, True, True, False, False, False],
)

# create our CoppeliaSim interface
interface = IsaacSim(robot_config, dt=0.005)
interface.connect()

# set up lists for tracking data
ee_track = []
target_track = []
obstacle_track = []

moving_obstacle = True
isaac_obstacle = FlyingCube(interface.dt, interface.world, name ="obstacle", prim_path="/World/obstacle", color=np.array([0, 1.0, 0]))
isaac_target = FlyingCube(interface.dt, interface.world, name="target", prim_path="/World/target")
obstacle_xyz = np.array([0.09596, -0.2661, 0.64204])
try:
# get visual position of end point of object
feedback = interface.get_feedback()
start = robot_config.Tx("EE", q=feedback["q"])
# make the target offset from that start position
target_xyz = start + np.array([0.2, -0.2, 0.0])
interface.set_xyz(name="target", xyz=target_xyz)
interface.set_xyz(name="obstacle", xyz=obstacle_xyz)


count = 0.0
obs_count = 0.0
print("\nSimulation starting...\n")

while count < n_timesteps :
# get joint angle and velocity feedback
feedback = interface.get_feedback()
#target = np.hstack(
# [interface.get_xyz("target"), interface.get_orientation("target")]
#)

# position control
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((
[interface.get_xyz("target"), interface.get_orientation("target")])),
method=3,
plot=False,
)
# returns desired [position, velocity]
target, _ = path_planner.next()



# get obstacle position from IsaacSim
obs_x, obs_y, obs_z = interface.get_xyz("obstacle") # pylint: disable=W0632
# update avoidance system about obstacle position
avoid.set_obstacles([[obs_x, obs_y, obs_z, 0.05]])
if moving_obstacle is True:
obs_x = 0.125 + 0.25 * np.sin(obs_count)
obs_count += 0.05
interface.set_xyz(name="obstacle", xyz=[obs_x, obs_y, obs_z])

if use_force_control:
# calculate the control signal
u = ctrlr.generate(
q=feedback["q"],
dq=feedback["dq"],
target=target,
)
# send forces into IsaacSim, step the sim forward
interface.send_forces(u)
else:
# use position control, send angles into IsaacSim
interface.send_target_angles(target[: robot_config.N_JOINTS])




#print( 'robot_config: ' , robot_config)
#print( 'robot_config.N_JOINTS: ' , robot_config.N_JOINTS)
#print( 'target[: robot_config.N_JOINTS]: ' , target[: robot_config.N_JOINTS])


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

count += 1

finally:
# stop and reset IsaacSim
interface.disconnect()

print("Simulation terminated...")

ee_track = np.array(ee_track)
target_track = np.array(target_track)
obstacle_track = np.array(obstacle_track)

if ee_track.shape[0] > 0:
# plot distance from target and 3D trajectory
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d # pylint: disable=W0611

fig = plt.figure(figsize=(8, 12))
ax1 = fig.add_subplot(211)
ax1.set_ylabel("Distance (m)")
ax1.set_xlabel("Time (ms)")
ax1.set_title("Distance to target")
ax1.plot(
np.sqrt(np.sum((np.array(target_track) - np.array(ee_track)) ** 2, axis=1))
)

ax2 = fig.add_subplot(212, projection="3d")
ax2.set_title("End-Effector Trajectory")
ax2.plot(ee_track[:, 0], ee_track[:, 1], ee_track[:, 2], label="ee_xyz")
ax2.scatter(
target_track[0, 0],
target_track[0, 1],
target_track[0, 2],
label="target",
c="g",
)
ax2.plot(
obstacle_track[:, 0],
obstacle_track[:, 1],
target_track[:, 2],
label="obstacle",
c="r",
)
ax2.legend()
plt.show()
Loading