├── LICENSE ├── README.md └── isaac_rtde.py /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Fravebo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nvidia Isaac Universal Robots RTDE communication 2 | 3 | ## Introduction 4 | This example was created in collaboration with [Fravebot](https://www.fravebot.com/) company. This example is a simple demonstration of using Nvidia's Isaac Sim software to control a collaborative robot UR5e from Universal Robots. 5 | 6 | ```javascript 7 | Software 8 | ------------------------------------ 9 | | Nvidia Isaac Sim version 2022.2.0 10 | | Isaac Python version 3.7 11 | | - ur-rtde 1.5.5 12 | ``` 13 | 14 | 1) [Nvidia Isaac Requirements](https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/requirements.html) 15 | 16 | 2) [Nvidia Omniverse Isaac Instalation](https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/install_workstation.html) 17 | 18 | 3) Install [ur_rtde](https://gitlab.com/sdurobotics/ur_rtde) (Check docs Win/Lin). After install python bindings: 19 | 20 | ```console 21 | user@user-pc:~/.../isaac_sim-2022.2.0$ ./python.sh -m pip install ur_rtde 22 | ``` 23 | 24 | ## How-to-Start 25 | 26 | 1) Go to workspace Nvidia Omniverse Isaac 27 | 2) Clone repository 28 | 3) Run VM Polyscope or Real Robot. 29 | 4) Run command (robot-ip is ip adress of robot VM or Real): 30 | 31 | ```console 32 | user@user-pc:~/.../isaac_sim-2022.2.0$ ./python.sh test_fravebot/isaac_rtde.py --robot-ip 192.168.200.135 33 | ``` 34 | 35 | ## Video! 36 | 37 |

38 | Nvidia Isaac Sim Universal Robots UR5e RTDE 39 |

40 | 41 | ## :information_source: Contacts 42 | 43 | :mailbox: juricek@fravebot.com 44 | -------------------------------------------------------------------------------- /isaac_rtde.py: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | # Copyright (c) 2023 Fravebot 4 | 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | 12 | # The above copyright notice and this permission notice shall be included in all 13 | # copies or substantial portions of the Software. 14 | 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | # SOFTWARE. 22 | 23 | # Author: Martin Juříček 24 | 25 | # Isaac Sim app library 26 | from omni.isaac.kit import SimulationApp 27 | 28 | simulation_app = SimulationApp({"headless": False}) 29 | 30 | # Isaac Sim extenstions + core libraries 31 | from omni.isaac.motion_generation.lula import RmpFlow 32 | from omni.isaac.motion_generation import ArticulationMotionPolicy 33 | from omni.isaac.core.robots import Robot 34 | from omni.isaac.core.objects import cuboid 35 | from omni.isaac.core import World 36 | from omni.isaac.core.utils.stage import add_reference_to_stage 37 | from omni.isaac.core.utils.nucleus import get_assets_root_path 38 | from omni.isaac.motion_generation.interface_config_loader import ( 39 | load_supported_motion_policy_config, 40 | ) 41 | 42 | # ur rtde communication 43 | import rtde_control 44 | import rtde_receive 45 | 46 | import numpy as np 47 | import argparse 48 | import sys 49 | 50 | parser = argparse.ArgumentParser() 51 | parser.add_argument( 52 | "--robot-ip", 53 | type=str, 54 | default="127.0.0.1", 55 | help="IP adress of robot Real world UR Polyscope or VM UR Polyscope", 56 | ) 57 | arg = parser.parse_args() 58 | 59 | # set up paths and prims 60 | robot_name = "UR5e" 61 | prim_path = "/UR5e" 62 | usd_path = get_assets_root_path() + "/Isaac/Robots/UniversalRobots/ur5e/ur5e.usd" 63 | 64 | # set references to staget in isaac 65 | add_reference_to_stage(usd_path=usd_path, prim_path=prim_path) 66 | 67 | # add world 68 | my_world = World(stage_units_in_meters=1.0) 69 | my_world.scene.add_default_ground_plane() 70 | 71 | # add robot to world 72 | robot = my_world.scene.add(Robot(prim_path=prim_path, name=robot_name)) 73 | 74 | # The load_supported_motion_policy_config() function is currently the simplest way to load supported robots. 75 | # In the future, Isaac Sim will provide a centralized registry of robots with Lula robot description files 76 | # and RMP configuration files stored alongside the robot USD. 77 | rmp_config = load_supported_motion_policy_config(robot_name, "RMPflow") 78 | 79 | # Initialize an RmpFlow object and set up 80 | rmpflow = RmpFlow(**rmp_config) 81 | physics_dt = 1.0/60 82 | articulation_rmpflow = ArticulationMotionPolicy(robot, rmpflow, physics_dt) 83 | articulation_controller = robot.get_articulation_controller() 84 | 85 | # Make a target to follow 86 | target_cube = cuboid.VisualCuboid( 87 | "/World/target", position=np.array([0.5, 0, 0.5]), color=np.array([1.0, 0, 0]), size=0.1, scale=np.array([0.5,0.5,0.5]) 88 | ) 89 | 90 | # Make an obstacle to avoid 91 | ground = cuboid.VisualCuboid( 92 | "/World/ground", position=np.array([0.0, 0, -0.0525]), color=np.array([0, 1.0, 0]), size=0.1, scale=np.array([40,40,1]) 93 | ) 94 | rmpflow.add_obstacle(ground) 95 | 96 | # prereset world 97 | my_world.reset() 98 | 99 | # IP adress of robot Real world UR Polyscope or VM UR Polyscope 100 | try: 101 | rtde_r = rtde_receive.RTDEReceiveInterface(arg.robot_ip) 102 | rtde_c = rtde_control.RTDEControlInterface(arg.robot_ip) 103 | robot.set_joint_positions(np.array(rtde_r.getActualQ())) 104 | 105 | except: 106 | print("[ERROR] Robot is not connected") 107 | # close isaac sim 108 | simulation_app.close() 109 | sys.exit() 110 | 111 | while simulation_app.is_running(): 112 | # on step render 113 | my_world.step(render=True) 114 | if my_world.is_playing(): 115 | # first frame -> reset world 116 | if my_world.current_time_step_index == 0: 117 | my_world.reset() 118 | 119 | # set target to RMP Flow 120 | rmpflow.set_end_effector_target( 121 | target_position=target_cube.get_world_pose()[0], target_orientation=target_cube.get_world_pose()[1] 122 | ) 123 | 124 | # Parameters 125 | velocity = 0.1 126 | acceleration = 0.1 127 | dt = 1.0/500 # 2ms 128 | lookahead_time = 0.1 129 | gain = 300 130 | 131 | # jointq = get joints positions 132 | joint_q = robot.get_joint_positions() 133 | 134 | # time start period 135 | t_start = rtde_c.initPeriod() 136 | 137 | # run servoJ 138 | rtde_c.servoJ(joint_q, velocity, acceleration, dt, lookahead_time, gain) 139 | rtde_c.waitPeriod(t_start) 140 | 141 | # Query the current obstacle position 142 | rmpflow.update_world() 143 | actions = articulation_rmpflow.get_next_articulation_action() 144 | articulation_controller.apply_action(actions) 145 | 146 | # get actual q from robot and update isaac model 147 | robot.set_joint_positions(np.array(rtde_r.getActualQ())) 148 | 149 | # rtde control stop script and disconnect 150 | rtde_c.servoStop() 151 | rtde_c.stopScript() 152 | rtde_r.disconnect() 153 | 154 | # close isaac sim 155 | simulation_app.close() --------------------------------------------------------------------------------