-
Notifications
You must be signed in to change notification settings - Fork 10
feat(ur5_ws): Add UR5e bringup, Isaac Sim, and Isaac Lab support #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
stanl1y
wants to merge
2
commits into
j3soon:main
Choose a base branch
from
stanl1y:feat/ur5_ws-isaac
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Isaac Sim / Isaac Lab examples for ur5_ws | ||
|
|
||
| Minimal scripts that load a Universal Robots UR5 or UR5e in Isaac Sim and Isaac Lab. | ||
|
|
||
| | Script | Runtime | Purpose | | ||
| | --- | --- | --- | | ||
| | `spawn_ur.py` | Isaac Sim standalone | Load UR5/UR5e USD, run physics, render. Good first sanity check. | | ||
| | `ur_isaaclab_minimal.py` | Isaac Lab | Load UR5/UR5e as an `Articulation` with `InteractiveScene`. Scaffold for RL / Reach / Pick. | | ||
|
|
||
| ## How to run | ||
|
|
||
| Inside the `ur5_ws` container (Isaac Sim and Isaac Lab installed via the build args in `docker/compose.yaml`): | ||
|
|
||
| ```sh | ||
| # Convenience wrappers in ur5_ws/scripts/ | ||
| ./scripts/isaac_sim_ur5.sh | ||
| ./scripts/isaac_sim_ur5e.sh | ||
|
|
||
| # Or directly: | ||
| ${ISAACSIM_PYTHON_EXE} scripts/isaac/spawn_ur.py --ur_type ur5e | ||
| ~/IsaacLab/isaaclab.sh -p scripts/isaac/ur_isaaclab_minimal.py --ur_type ur5 | ||
| ``` | ||
|
|
||
| Pass `--headless` to the Isaac Sim script for offscreen rendering (e.g., on a cluster without a desktop). | ||
|
|
||
| ## Extending to RL / manipulation tasks | ||
|
|
||
| `ur_isaaclab_minimal.py` is intentionally bare. To turn it into a full Reach or Pick task, copy the UR10 manager-based config in Isaac Lab — typically at: | ||
|
|
||
| ``` | ||
| $ISAACLAB_PATH/source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/reach/config/ur_10/ | ||
| ``` | ||
|
|
||
| Swap the `usd_path` and joint init values for UR5/UR5e (joint names are identical across the UR family, so the joint-name lists in the config don't need to change). | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| """Spawn a UR5 or UR5e in Isaac Sim and step the physics loop. | ||
|
|
||
| Usage (inside the ur5_ws container): | ||
| ${ISAACSIM_PYTHON_EXE} ur5_ws/scripts/isaac/spawn_ur.py --ur_type ur5 | ||
| ${ISAACSIM_PYTHON_EXE} ur5_ws/scripts/isaac/spawn_ur.py --ur_type ur5e --headless | ||
|
|
||
| The convenience wrappers ur5_ws/scripts/isaac_sim_ur5.sh and isaac_sim_ur5e.sh | ||
| just call this script with the appropriate --ur_type. | ||
| """ | ||
|
|
||
| import argparse | ||
|
|
||
| parser = argparse.ArgumentParser(description="Spawn a UR robot in Isaac Sim") | ||
| parser.add_argument("--ur_type", choices=["ur5", "ur5e"], default="ur5") | ||
| parser.add_argument("--headless", action="store_true") | ||
| parser.add_argument( | ||
| "--steps", | ||
| type=int, | ||
| default=0, | ||
| help="number of physics steps to run; 0 = until the window is closed", | ||
| ) | ||
| args = parser.parse_args() | ||
|
|
||
| from isaacsim import SimulationApp | ||
|
|
||
| simulation_app = SimulationApp({"headless": args.headless}) | ||
|
|
||
| from isaacsim.core.api import World | ||
| from isaacsim.core.utils.stage import add_reference_to_stage | ||
| from isaacsim.storage.native import get_assets_root_path | ||
|
|
||
| assets_root = get_assets_root_path() | ||
| if assets_root is None: | ||
| raise RuntimeError( | ||
| "Could not resolve Isaac Sim assets root. " | ||
| "Check Nucleus connectivity or set ISAAC_NUCLEUS_DIR." | ||
| ) | ||
|
|
||
| usd_path = f"{assets_root}/Isaac/Robots/UniversalRobots/{args.ur_type}/{args.ur_type}.usd" | ||
| prim_path = f"/World/{args.ur_type.upper()}" | ||
|
|
||
| world = World(stage_units_in_meters=1.0) | ||
| world.scene.add_default_ground_plane() | ||
| add_reference_to_stage(usd_path=usd_path, prim_path=prim_path) | ||
| world.reset() | ||
|
|
||
| step = 0 | ||
| while simulation_app.is_running(): | ||
| world.step(render=True) | ||
| step += 1 | ||
| if args.steps > 0 and step >= args.steps: | ||
| break | ||
|
|
||
| simulation_app.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| """Minimal Isaac Lab scene with a UR5 or UR5e articulation. | ||
|
|
||
| Usage (inside the ur5_ws container): | ||
| ~/IsaacLab/isaaclab.sh -p ur5_ws/scripts/isaac/ur_isaaclab_minimal.py --ur_type ur5e | ||
|
|
||
| This is a scaffold: it loads the chosen UR USD into an Isaac Lab scene, | ||
| applies small random joint targets, and steps the simulator. Use it as a | ||
| starting point for Reach / Pick / RL tasks by swapping the USD path and | ||
| joint names into Isaac Lab's manager-based task templates under | ||
| isaaclab_tasks.manager_based.manipulation. | ||
| """ | ||
|
|
||
| import argparse | ||
|
|
||
| from isaaclab.app import AppLauncher | ||
|
|
||
| parser = argparse.ArgumentParser(description="Minimal UR articulation in Isaac Lab") | ||
| parser.add_argument("--ur_type", choices=["ur5", "ur5e"], default="ur5") | ||
| parser.add_argument("--num_envs", type=int, default=1) | ||
| parser.add_argument( | ||
| "--steps", | ||
| type=int, | ||
| default=0, | ||
| help="number of sim steps to run; 0 = until the window is closed or Ctrl-C", | ||
| ) | ||
| AppLauncher.add_app_launcher_args(parser) | ||
| args = parser.parse_args() | ||
|
|
||
| app_launcher = AppLauncher(args) | ||
| simulation_app = app_launcher.app | ||
|
|
||
| import torch | ||
|
|
||
| import isaaclab.sim as sim_utils | ||
| from isaaclab.assets import Articulation, ArticulationCfg, AssetBaseCfg | ||
| from isaaclab.actuators import ImplicitActuatorCfg | ||
| from isaaclab.scene import InteractiveScene, InteractiveSceneCfg | ||
| from isaaclab.utils import configclass | ||
| from isaacsim.storage.native import get_assets_root_path | ||
|
|
||
| assets_root = get_assets_root_path() | ||
| if assets_root is None: | ||
| raise RuntimeError("Could not resolve Isaac Sim assets root.") | ||
|
|
||
| usd_path = f"{assets_root}/Isaac/Robots/UniversalRobots/{args.ur_type}/{args.ur_type}.usd" | ||
|
|
||
| UR_CFG = ArticulationCfg( | ||
| prim_path="{ENV_REGEX_NS}/Robot", | ||
| spawn=sim_utils.UsdFileCfg(usd_path=usd_path), | ||
| init_state=ArticulationCfg.InitialStateCfg( | ||
| joint_pos={ | ||
| "shoulder_pan_joint": 0.0, | ||
| "shoulder_lift_joint": -1.57, | ||
| "elbow_joint": 1.57, | ||
| "wrist_1_joint": -1.57, | ||
| "wrist_2_joint": -1.57, | ||
| "wrist_3_joint": 0.0, | ||
| }, | ||
| ), | ||
| actuators={ | ||
| "arm": ImplicitActuatorCfg( | ||
| joint_names_expr=[".*"], stiffness=400.0, damping=40.0 | ||
| ), | ||
| }, | ||
| ) | ||
|
|
||
|
|
||
| @configclass | ||
| class URSceneCfg(InteractiveSceneCfg): | ||
| ground = AssetBaseCfg( | ||
| prim_path="/World/defaultGroundPlane", | ||
| spawn=sim_utils.GroundPlaneCfg(), | ||
| ) | ||
| light = AssetBaseCfg( | ||
| prim_path="/World/Light", | ||
| spawn=sim_utils.DomeLightCfg(intensity=2000.0, color=(0.75, 0.75, 0.75)), | ||
| ) | ||
| robot: ArticulationCfg = UR_CFG | ||
|
|
||
|
|
||
| sim_cfg = sim_utils.SimulationCfg(dt=1.0 / 120.0) | ||
| sim = sim_utils.SimulationContext(sim_cfg) | ||
| sim.set_camera_view([2.5, 2.5, 2.5], [0.0, 0.0, 0.0]) | ||
|
|
||
| scene = InteractiveScene(URSceneCfg(num_envs=args.num_envs, env_spacing=2.0)) | ||
| sim.reset() | ||
|
|
||
| robot: Articulation = scene["robot"] | ||
| default_joint_pos = robot.data.default_joint_pos.clone() | ||
|
|
||
| step = 0 | ||
| while simulation_app.is_running(): | ||
| target = default_joint_pos + 0.2 * torch.sin( | ||
| torch.tensor(step * 0.01, device=sim.device) | ||
| ) | ||
| robot.set_joint_position_target(target) | ||
| scene.write_data_to_sim() | ||
| sim.step() | ||
| scene.update(sim.get_physics_dt()) | ||
| step += 1 | ||
| if args.steps > 0 and step >= args.steps: | ||
| break | ||
|
|
||
| simulation_app.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/bin/bash -e | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)" | ||
|
|
||
| "${ISAACLAB_PATH}/isaaclab.sh" -p "${SCRIPT_DIR}/isaac/ur_isaaclab_minimal.py" "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/bin/bash -e | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)" | ||
|
|
||
| "${ISAACSIM_PYTHON_EXE}" "${SCRIPT_DIR}/isaac/spawn_ur.py" --ur_type ur5 "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/bin/bash -e | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)" | ||
|
|
||
| "${ISAACSIM_PYTHON_EXE}" "${SCRIPT_DIR}/isaac/spawn_ur.py" --ur_type ur5e "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/bin/bash -e | ||
|
|
||
| ros2 launch ur_robot_driver ur_control.launch.py \ | ||
| ur_type:=ur5e \ | ||
| use_rg2_gripper:=true \ | ||
| robot_ip:=192.168.56.101 \ | ||
| launch_rviz:=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/bin/bash -e | ||
|
|
||
| # Get the directory of this script. | ||
| # Reference: https://stackoverflow.com/q/59895 | ||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)" | ||
| UR5_WORKSPACE_DIR="${SCRIPT_DIR}/.." | ||
|
|
||
| # Reference: | ||
| # - https://docs.universal-robots.com/Universal_Robots_ROS2_Documentation/doc/ur_robot_driver/ur_calibration/doc/usage.html | ||
| ros2 launch ur_calibration calibration_correction.launch.py \ | ||
| robot_ip:=192.168.56.101 \ | ||
| target_filename:="${UR5_WORKSPACE_DIR}/src/Universal_Robots_ROS2_Description/config/ur5e/default_kinematics.yaml" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a language tag to the fenced code block.
The fence starting on Line 30 has no language, which triggers markdownlint MD040.
Suggested fix
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 30-30: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents