克隆下来必须带上正在用的视觉权重和本机 site.yaml,否则感知只能指到一台机器上的路径,别人起不来。

顶视迁臂改走厂家 MoveL,D405 框心对准后再对孔;夹爪停在 caught 时 open 不再把相同目标当成已经张开,init 会真的回零。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
arm_dev
2026-10-12 17:08:43 +08:00
parent b903161113
commit f882c4309c
187 changed files with 22898 additions and 104 deletions
@@ -0,0 +1,40 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG] "
type: Bug
labels: bug
assignees: bsoe-flexiv
---
## Version info
- Isaac Sim Workspace: [e.g. v1.0]
- Flexiv Elements Studio: [e.g. v3.8]
- NVIDIA Isaac Sim: [e.g. v4.2.0]
- OS: [e.g. Ubuntu 22.04, x86_64]
## How urgent is this bug? Have you found any workarounds?
On a scale of 1 to 10.
## Describe the issue and expected behavior
The issue is ...
The correct behavior you expect is ...
## Steps to reproduce
1. '....'
2. '....'
3. '....'
4. See error
## Screenshots
If applicable, add screenshots to help explain your issue.
## Additional context
Add any other context about the issue.
@@ -0,0 +1,29 @@
---
name: Feature request
about: Suggest a new feature
title: "[FEATURE] "
type: Feature
labels: enhancement
assignees: bsoe-flexiv
---
## How urgent is this feature?
On a scale of 1 to 10.
## Is this feature request related to a problem?
This new feature is needed so that ... can be solved.
## Describe the solution you'd like
What you want to happen.
## Describe alternatives you've considered
Any alternative solutions or workarounds you've considered.
## Additional context
Add any other context or screenshots about this feature.
@@ -0,0 +1,29 @@
---
name: Question
about: Ask a question
title: "[QUESTION] "
type: Question
labels: help wanted
assignees: bsoe-flexiv
---
## There might already be an answer to your question
Someone might have asked similar questions before, you can search in the [Issues](https://github.com/flexivrobotics/isaac_sim_ws/issues?q=is%3Aissue) tab.
## Looking for information related to Isaac Sim?
You can find the complete documentation of NVIDIA Isaac Sim [here](https://docs.isaacsim.omniverse.nvidia.com/latest/index.html).
## Not sure how to get started and build your own simulation workflow?
You can [contact Flexiv](https://www.flexiv.com/contact) to seek technical support and explore turnkey solution options.
## Is this related to a specific version of Isaac Sim Workspace?
If yes, please specify.
## Please describe your question
Texts, screenshots, links, code blocks ...
+8
View File
@@ -0,0 +1,8 @@
.vscode
.vs
.DS_Store
.thumbs
extscache/
cache/
*.log
__pycache__
+201
View File
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+164
View File
@@ -0,0 +1,164 @@
# Flexiv Isaac Sim Workspace
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
## Overview
This workspace is an example integration of **NVIDIA Isaac Sim** with **Flexiv Elements Studio**, connected via [Flexiv Sim Plugin](https://github.com/flexivrobotics/flexiv_sim_plugin). It demonstrates how to use the Flexiv Sim Plugin API alongside the Nvidia Isaac Sim API to relay robot control commands and physics state between Elements Studio and Isaac Sim, so that simulated Flexiv robots are driven by the same force-torque controller used on real robots and can be programmed with the Flexiv RDK.
```
┌─────────────────────────────────────────┐
│ User Program with RDK Client │
│ (send robot commands) │
└───────────────────┬─────────────────────┘
│ RDK API
▼
┌─────────────────────────────────────────┐
│ Flexiv Elements Studio │
│ (simulated controller + RDK Server) │
└───────────────────┬─────────────────────┘
│ Flexiv Sim Plugin API
▼
┌─────────────────────────────────────────┐
│ Flexiv Isaac Sim Workspace │
│ (Flexiv Sim Plugin API + Isaac Sim API) │
└───────────────────┬─────────────────────┘
│ Isaac Sim API
▼
┌─────────────────────────────────────────┐
│ NVIDIA Isaac Sim │
│ (physics engine) │
└─────────────────────────────────────────┘
```
## Compatibility
| **Supported OS** | **Supported processor** | **Supported language** |
| ---------------- | ----------------------- | ---------------------- |
| Ubuntu 22.04 | x86_64 | Python |
## Demos
### 1. Tower of Hanoi
[![Rizon 4 Masters the Tower of Hanoi Game in Issac Sim with the Flexiv-Isaac Sim Bridge App](https://img.youtube.com/vi/jZT6Ei0L3gk/0.jpg)](https://www.youtube.com/watch?v=jZT6Ei0L3gk)
### 2. Peg-in-hole
https://github.com/user-attachments/assets/e575bf70-9ffb-47a5-8aec-4cda8d25c08e
### 3. Single robot polish
https://github.com/user-attachments/assets/a0c39e70-4469-4405-a07d-e0d8a0ad589b
### 4. Dual robot polish
https://github.com/user-attachments/assets/7462a9bd-3cfd-40cc-95f7-b4fda0a74f30
## Pre-requisites
Before using the Flexiv Isaac Sim Workspace, follow the setup instructions in
[Flexiv Sim Plugin](https://github.com/flexivrobotics/flexiv_sim_plugin?tab=readme-ov-file#flexiv-elements-studio-setup).
## Workspace setup
1. Install NVIDIA [Isaac Sim](https://docs.isaacsim.omniverse.nvidia.com/latest/installation/index.html).
2. Note down Isaac Sim's installation directory, e.g. `~/isaacsim`.
3. Run the following script in this repo to install Flexiv's Isaac Sim extensions and apps to the Isaac Sim installation directory so that Isaac Sim can load them:
bash install_ws.sh <isaac_sim_root_dir>
For example:
bash install_ws.sh ~/isaacsim
## Verify setup
To verify that the workspace setup is successful, run the example Python application:
cd <isaac_sim_root_dir>
./python.sh standalone_examples/api/isaacsim.robot.manipulators/flexiv/follow_target_with_rmpflow.py exts/isaacsim.robot.manipulators.examples/data/flexiv/Rizon4.usd
WARNING: When running Isaac Sim for the first time, it takes a couple of minutes to warm up the shader cache. You will notice that the CPU is fully loaded and the Isaac Sim window seems frozen. Please wait patiently and do not force quit the program.
After the example program is up and running, select the `TargetCube` prim under `World` from the Stage view, then drag it around, the robot TCP should follow the cube.
### Run Flexiv-Isaac Bridge App
1. Edit the configuration file `standalone_examples/api/isaacsim.robot.manipulators/flexiv/app_config.yaml` according to the instructions in it.
2. Start Flexiv-Isaac Bridge App using configurations in `app_config.yaml`:
cd <isaac_sim_root_dir>
./python.sh standalone_examples/api/isaacsim.robot.manipulators/flexiv/flexiv_isaac_bridge_app.py --config standalone_examples/api/isaacsim.robot.manipulators/flexiv/app_config.yaml
3. The app will launch an Isaac Sim window and start the physics loop (i.e. *Play*) automatically.
4. Go back to Elements Studio, then restart the exited simulator by toggle on the *Connect* button.
5. Wait for the connection to establish. If the connection is successful, you should see in Elements Studio a robot at home pose with no error.
### Verify everything is working
1. In Elements Studio, use the simulated motion bar to enter free-drive mode.
2. Use Cartesian or joint jogging to move the robot around, check that the robot in Isaac Sim is also moving.
3. Jog the robot along Cartesian Z axis and let the robot make contact with the desk in the example environment, check that a large TCP force is rendered as an orange line in Elements Studio visualization.
4. Create a test project and add some primitives, then execute the project and check that the robot in Isaac Sim is acting as desired.
## After the first run
To restart the whole setup after the first run:
1. Start the Flexiv-Isaac Bridge app first.
2. Then start the simulated robot in Elements Studio.
If you have made some changes and need to restart the Isaac Sim app:
1. Close Flexiv-Isaac Bridge app.
2. In Elements Studio, click *CHANGE CONNECTION*, then toggle off the *Connect* button to close the simulated robot. You do not need to exit the whole Elements Studio program.
3. Restart Flexiv-Isaac Bridge app.
4. Toggle on the *Connect* button to restart the simulated robot.
Alternatively, you can leave the simulated robot running and just restart the Isaac Sim app. The simulated robot in Elements Studio will sync with Isaac Sim after the app is restarted. However, soft error might occur and you can just clear them from Elements Studio and continue to normal operations.
## Multi-robot support
This framework supports simulating and controlling multiple robots:
1. Add multiple robots in the configuration file `standalone_examples/api/isaacsim.robot.manipulators/flexiv/app_config.yaml`.
2. Start Flexiv-Isaac Bridge App using the updated configurations in `app_config.yaml`:
cd <isaac_sim_root_dir>
./python.sh standalone_examples/api/isaacsim.robot.manipulators/flexiv/flexiv_isaac_bridge_app.py --config standalone_examples/api/isaacsim.robot.manipulators/flexiv/app_config.yaml
3. Find a second Ubuntu 22.04 computer, connect it to the first computer via Ethernet cable. Then on the first computer, check that this wired Ethernet connection is visible in the network settings, then change the IPv4 setting of this wired connection to "Shared to other computers". Alternatively, connect both computers to the same network router via **wired** connection.
4. Make sure both computers are able to ping each other.
5. Install Flexiv Elements Studio on the **second** computer, then create a new simulated robot. Now each computer has a robot controller with Elements Studio.
6. Start the first simulated robot on the first computer, then wait for connection with Isaac Sim. You should see one of the robots in Isaac Sim moves a little bit when the connection is established.
7. Start the second simulated robot on the second computer, then wait for connection with Isaac Sim. You should see the other robot in Isaac Sim moves a little bit when the connection is established.
8. Execute test projects from both Elements Studios and check that both robots are working in Isaac Sim.
## Collect data from the simulated robot(s)
You can collect data from the simulated robot(s) using [Flexiv DDK](https://github.com/flexivrobotics/flexiv_ddk) (Data Distribution Kit) at up to 1kHz frequency:
1. Set up Flexiv DDK according to the instructions found in the repo.
2. Start Isaac Sim and Elements Studio.
3. Run DDK programs to collect data from one or more simulated robots.
Note: the DDK program doesn't have to run on the same computer as the Elements Studio, it can be any computer that's under the same local network as the Elements Studio computer.
## Control the simulated robot(s) programmatically
Besides using the drag-and-drop graphical interface in Elements Studio to create projects to control the simulated robot(s), you can also control them programmatically using [Flexiv RDK](https://github.com/flexivrobotics/flexiv_rdk) (Robotic Development Kit) in a real-time or non-real-time manner:
1. Set up Flexiv RDK according to the instructions found in the repo.
2. Start Isaac Sim and Elements Studio.
3. In Elements Studio, go to *Settings* → *Remote Mode*, then enable Remote Mode and select *Ethernet* from the drop-down list.
4. Restart the simulated robot by clicking *CHANGE CONNECTION*, then toggle off and on the *Connect* button.
5. Run RDK programs to control one or more simulated robots.
Note: the RDK program doesn't have to run on the same computer as the Elements Studio, it can be any computer that's under the same local network as the Elements Studio computer.
@@ -0,0 +1,10 @@
# Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from isaacsim.robot.manipulators.examples.flexiv.flexiv_serial import FlexivSerial
from isaacsim.robot.manipulators.examples.flexiv.kinematics_solver import KinematicsSolver
@@ -0,0 +1,11 @@
# Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from isaacsim.robot.manipulators.examples.flexiv.controllers.pick_place_controller import PickPlaceController
from isaacsim.robot.manipulators.examples.flexiv.controllers.rmpflow_controller import RMPFlowController
from isaacsim.robot.manipulators.examples.flexiv.controllers.stacking_controller import StackingController
@@ -0,0 +1,48 @@
# Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from typing import List, Optional
import isaacsim.robot.manipulators.controllers as manipulators_controllers
from isaacsim.core.prims import SingleArticulation
from isaacsim.robot.manipulators.examples.franka.controllers.rmpflow_controller import RMPFlowController
from isaacsim.robot.manipulators.grippers.parallel_gripper import ParallelGripper
class PickPlaceController(manipulators_controllers.PickPlaceController):
"""[summary]
Args:
name (str): [description]
gripper (ParallelGripper): [description]
robot_articulation (SingleArticulation): [description]
end_effector_initial_height (Optional[float], optional): [description]. Defaults to None.
events_dt (Optional[List[float]], optional): [description]. Defaults to None.
"""
def __init__(
self,
name: str,
gripper: ParallelGripper,
robot_articulation: SingleArticulation,
end_effector_initial_height: Optional[float] = None,
events_dt: Optional[List[float]] = None,
) -> None:
if events_dt is None:
events_dt = [0.008, 0.005, 1, 0.1, 0.05, 0.05, 0.0025, 1, 0.008, 0.08]
manipulators_controllers.PickPlaceController.__init__(
self,
name=name,
cspace_controller=RMPFlowController(
name=name + "_cspace_controller", robot_articulation=robot_articulation
),
gripper=gripper,
end_effector_initial_height=end_effector_initial_height,
events_dt=events_dt,
)
return
@@ -0,0 +1,57 @@
# Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
import isaacsim.robot_motion.motion_generation as mg
from isaacsim.core.prims import SingleArticulation
class RMPFlowController(mg.MotionPolicyController):
"""[summary]
Args:
name (str): [description]
robot_articulation (SingleArticulation): [description]
physics_dt (float, optional): [description]. Defaults to 1.0/60.0.
"""
def __init__(
self,
name: str,
robot_articulation: SingleArticulation,
physics_dt: float = 1.0 / 60.0,
) -> None:
self.rmp_flow_config = (
mg.interface_config_loader.load_supported_motion_policy_config(
"Rizon4", "RMPflow"
)
)
self.rmp_flow = mg.lula.motion_policies.RmpFlow(**self.rmp_flow_config)
self.articulation_rmp = mg.ArticulationMotionPolicy(
robot_articulation, self.rmp_flow, physics_dt
)
mg.MotionPolicyController.__init__(
self, name=name, articulation_motion_policy=self.articulation_rmp
)
(
self._default_position,
self._default_orientation,
) = self._articulation_motion_policy._robot_articulation.get_world_pose()
self._motion_policy.set_robot_base_pose(
robot_position=self._default_position,
robot_orientation=self._default_orientation,
)
return
def reset(self):
mg.MotionPolicyController.reset(self)
self._motion_policy.set_robot_base_pose(
robot_position=self._default_position,
robot_orientation=self._default_orientation,
)
@@ -0,0 +1,47 @@
# Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from typing import List
import isaacsim.robot.manipulators.controllers as manipulators_controllers
from isaacsim.core.prims import SingleArticulation
from isaacsim.robot.manipulators.examples.franka.controllers.pick_place_controller import PickPlaceController
from isaacsim.robot.manipulators.grippers.parallel_gripper import ParallelGripper
class StackingController(manipulators_controllers.StackingController):
"""[summary]
Args:
name (str): [description]
gripper (ParallelGripper): [description]
robot_prim_path (str): [description]
picking_order_cube_names (List[str]): [description]
robot_observation_name (str): [description]
"""
def __init__(
self,
name: str,
gripper: ParallelGripper,
robot_articulation: SingleArticulation,
picking_order_cube_names: List[str],
robot_observation_name: str,
) -> None:
manipulators_controllers.StackingController.__init__(
self,
name=name,
pick_place_controller=PickPlaceController(
name=name + "_pick_place_controller",
gripper=gripper,
robot_articulation=robot_articulation,
),
picking_order_cube_names=picking_order_cube_names,
robot_observation_name=robot_observation_name,
)
return
@@ -0,0 +1,211 @@
# Copyright (c) 2022-2024, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
import numpy as np
import spdlog
from typing import Optional, List
from isaacsim.core.api.robots.robot import Robot
from isaacsim.core.prims import SingleRigidPrim
from isaacsim.robot.manipulators.grippers.gripper import Gripper
from isaacsim.robot.manipulators.grippers.parallel_gripper import ParallelGripper
from isaacsim.robot.manipulators.grippers.surface_gripper import SurfaceGripper
class FlexivSerial(Robot):
"""
Control interface for one Flexiv serial robot.
Params:
prim_path (str): Primitive path of this robot articulation in the stage. E.g. /World/Flexiv
name (str): name of this robot articulation.
end_effector_prim_name (str): name of the primitive in the robot articulation to be used as end effector.
arm_dof (int): degrees of freedom of the robotic arm, excluding any gripper DoF.
pos_in_world (Optional[List[float]]): position (x, y, z) of the robot in world [m].
ori_in_world (Optional[List[float]]): orientation (quaternion w, x, y, z) of the robot in world [].
gripper (Optional[Gripper]): Constructed gripper instance.
"""
def __init__(
self,
prim_path: str,
name: str,
end_effector_prim_name: str,
arm_dof: int = 7,
pos_in_world: Optional[List[float]] = None,
ori_in_world: Optional[List[float]] = None,
gripper: Optional[Gripper] = None,
) -> None:
self._arm_dof = arm_dof
self._gripper = gripper
self._default_kps = None
self._default_kds = None
self._end_effector = None
self._end_effector_prim_path = prim_path + "/" + end_effector_prim_name
self._logger = spdlog.ConsoleLogger("flexiv::" + name)
# Construct base
super().__init__(
prim_path=prim_path,
name=name,
position=pos_in_world,
orientation=ori_in_world,
)
return
def switch_control_mode(self, mode: str) -> None:
"""
Switch control mode for all robot joints, gripper excluded.
Params:
mode (str): Desired control mode, options are "position", "velocity", and "effort".
"""
# Reset default gains for articulation view
if self._default_kps is not None and self._default_kds is not None:
self._articulation_view.set_gains(
kps=self._default_kps, kds=self._default_kds
)
# Set control mode for all robot joints, but leave gripper joints unchanged
self._articulation_view.switch_control_mode(
mode, joint_indices=np.arange(0, self._arm_dof)
)
self._logger.info(f"Control mode switched to [{mode}]")
return
@property
def end_effector(self) -> SingleRigidPrim:
"""
Access reference to the _end_effector member.
Return:
SingleRigidPrim: Reference to the end-effector instance.
"""
return self._end_effector
@property
def gripper(self) -> Gripper:
"""
Access reference to the _gripper member.
Return:
Gripper: Reference to the gripper instance.
"""
return self._gripper
@property
def q(self) -> List[float]:
"""
Get current positions of all robot joints, gripper excluded.
Return:
List[float]: Joint positions [rad].
"""
if self._articulation_view.is_physics_handle_valid():
return self.get_joint_positions(
joint_indices=np.arange(0, self._arm_dof)
).tolist()
else:
return np.zeros(self._arm_dof).tolist()
@property
def dq(self) -> List[float]:
"""
Get current velocities of all robot joints, gripper excluded.
Return:
List[float]: Joint velocities [rad/s].
"""
if self._articulation_view.is_physics_handle_valid():
return self.get_joint_velocities(
joint_indices=np.arange(0, self._arm_dof)
).tolist()
else:
return np.zeros(self._arm_dof).tolist()
@property
def tau(self) -> List[float]:
"""
Get current torques of all robot joints, gripper excluded.
Return:
List[float]: Joint torques [Nm].
"""
if self._articulation_view.is_physics_handle_valid():
return self.get_measured_joint_efforts(
joint_indices=np.arange(0, self._arm_dof)
).tolist()
else:
return np.zeros(self._arm_dof).tolist()
def apply_torques(self, tau_d: List[float]) -> None:
"""
Apply desired torques to all robot joints, gripper excluded.
Params:
tau_d (List[float]): Desired joint torques.
"""
# Apply only to robot joints, leave out gripper joints, which are controlled by gripper controller
self.set_joint_efforts(tau_d, joint_indices=np.arange(0, self._arm_dof))
return
def teleport_to(self, q_d: List[float]) -> None:
"""
Instantly teleport all robot joints to desired positions. This is usually used to set robot to initial positions.
No control is involved in the process. Call apply_torques() immediately after to kick in the joint controls.
Params:
q_d (List[float]): Desired joint positions.
"""
self.set_joint_positions(q_d, joint_indices=np.arange(0, self._arm_dof))
return
def initialize(self, physics_sim_view=None) -> None:
"""
Initialize the articulation interface, set up torque drive mode
"""
super().initialize(physics_sim_view=physics_sim_view)
# Initialize end-effector
self._end_effector = SingleRigidPrim(
prim_path=self._end_effector_prim_path, name=self.name + "_end_effector"
)
self._end_effector.initialize(physics_sim_view)
# Initialize gripper if any
if isinstance(self._gripper, ParallelGripper):
self._gripper.initialize(
physics_sim_view=physics_sim_view,
articulation_apply_action_func=self.apply_action,
get_joint_positions_func=self.get_joint_positions,
set_joint_positions_func=self.set_joint_positions,
dof_names=self.dof_names,
)
elif isinstance(self._gripper, SurfaceGripper):
self._gripper.initialize(
physics_sim_view=physics_sim_view, articulation_num_dofs=self.num_dof
)
# Joints output torque instead of acceleration
self.get_articulation_controller().set_effort_modes("force")
# Save default gains because calling _articulation_view.switch_control_mode() will change _articulation_view._default_kps,
# which makes switching control mode from "effort" back to "position" not possible
self._default_kps, self._default_kds = self._articulation_view.get_gains()
return
def post_reset(self) -> None:
"""
Post reset articulation
"""
super().post_reset()
self._end_effector.post_reset()
if self._gripper is not None:
self._gripper.post_reset()
return
@@ -0,0 +1,44 @@
# Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from typing import Optional
import isaacsim.robot_motion.motion_generation.interface_config_loader as interface_config_loader
from isaacsim.core.prims import SingleArticulation
from isaacsim.robot_motion.motion_generation.articulation_kinematics_solver import ArticulationKinematicsSolver
from isaacsim.robot_motion.motion_generation.lula.kinematics import LulaKinematicsSolver
class KinematicsSolver(ArticulationKinematicsSolver):
"""Kinematics Solver for Flexiv robot. This class loads a LulaKinematicsSovler object
Args:
robot_articulation (SingleArticulation): An initialized Articulation object representing this Flexiv
end_effector_frame_name (Optional[str]): The name of the Flexiv end effector. If None, an end effector link will
be automatically selected. Defaults to None.
"""
def __init__(
self,
robot_articulation: SingleArticulation,
end_effector_frame_name: Optional[str] = None,
) -> None:
kinematics_config = (
interface_config_loader.load_supported_lula_kinematics_solver_config(
"Rizon4"
)
)
self._kinematics = LulaKinematicsSolver(**kinematics_config)
if end_effector_frame_name is None:
end_effector_frame_name = "flange"
ArticulationKinematicsSolver.__init__(
self, robot_articulation, self._kinematics, end_effector_frame_name
)
return
@@ -0,0 +1,11 @@
# Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from isaacsim.robot.manipulators.examples.flexiv.tasks.follow_target import FollowTarget
from isaacsim.robot.manipulators.examples.flexiv.tasks.pick_place import PickPlace
from isaacsim.robot.manipulators.examples.flexiv.tasks.stacking import Stacking
@@ -0,0 +1,84 @@
# Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from typing import Optional
import isaacsim.core.api.tasks as tasks
import numpy as np
from isaacsim.core.utils.prims import is_prim_path_valid
from isaacsim.core.utils.string import find_unique_string_name
from isaacsim.core.utils.stage import add_reference_to_stage
from isaacsim.robot.manipulators.examples.flexiv import FlexivSerial
class FollowTarget(tasks.FollowTarget):
"""[summary]
Args:
name (str, optional): [description]. Defaults to "flexiv_follow_target".
target_prim_path (Optional[str], optional): [description]. Defaults to None.
target_name (Optional[str], optional): [description]. Defaults to None.
target_position (Optional[np.ndarray], optional): [description]. Defaults to None.
target_orientation (Optional[np.ndarray], optional): [description]. Defaults to None.
offset (Optional[np.ndarray], optional): [description]. Defaults to None.
flexiv_prim_path (Optional[str], optional): [description]. Defaults to None.
flexiv_robot_name (Optional[str], optional): [description]. Defaults to None.
"""
def __init__(
self,
name: str = "flexiv_follow_target",
target_prim_path: Optional[str] = None,
target_name: Optional[str] = None,
target_position: Optional[np.ndarray] = None,
target_orientation: Optional[np.ndarray] = None,
offset: Optional[np.ndarray] = None,
flexiv_prim_path: Optional[str] = None,
flexiv_robot_name: Optional[str] = None,
usd_path: Optional[str] = None,
) -> None:
tasks.FollowTarget.__init__(
self,
name=name,
target_prim_path=target_prim_path,
target_name=target_name,
target_position=target_position,
target_orientation=target_orientation,
offset=offset,
)
self._flexiv_prim_path = flexiv_prim_path
self._flexiv_robot_name = flexiv_robot_name
self._usd_path = usd_path
return
def set_robot(self) -> FlexivSerial:
"""[summary]
Returns:
FlexivSerial: [description]
"""
if self._flexiv_prim_path is None:
self._flexiv_prim_path = find_unique_string_name(
initial_name="/World/Flexiv",
is_unique_fn=lambda x: not is_prim_path_valid(x),
)
if self._flexiv_robot_name is None:
self._flexiv_robot_name = find_unique_string_name(
initial_name="Rizon4",
is_unique_fn=lambda x: not self.scene.object_exists(x),
)
add_reference_to_stage(
usd_path=self._usd_path, prim_path=self._flexiv_prim_path
)
return FlexivSerial(
prim_path=self._flexiv_prim_path,
name=self._flexiv_robot_name,
end_effector_prim_name="flange",
)
@@ -0,0 +1,64 @@
# Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from typing import Optional
import isaacsim.core.api.tasks as tasks
import numpy as np
from isaacsim.core.utils.prims import is_prim_path_valid
from isaacsim.core.utils.string import find_unique_string_name
from isaacsim.robot.manipulators.examples.flexiv import FlexivSerial
class PickPlace(tasks.PickPlace):
"""[summary]
Args:
name (str, optional): [description]. Defaults to "flexiv_pick_place".
cube_initial_position (Optional[np.ndarray], optional): [description]. Defaults to None.
cube_initial_orientation (Optional[np.ndarray], optional): [description]. Defaults to None.
target_position (Optional[np.ndarray], optional): [description]. Defaults to None.
cube_size (Optional[np.ndarray], optional): [description]. Defaults to None.
offset (Optional[np.ndarray], optional): [description]. Defaults to None.
"""
def __init__(
self,
name: str = "flexiv_pick_place",
cube_initial_position: Optional[np.ndarray] = None,
cube_initial_orientation: Optional[np.ndarray] = None,
target_position: Optional[np.ndarray] = None,
cube_size: Optional[np.ndarray] = None,
offset: Optional[np.ndarray] = None,
) -> None:
tasks.PickPlace.__init__(
self,
name=name,
cube_initial_position=cube_initial_position,
cube_initial_orientation=cube_initial_orientation,
target_position=target_position,
cube_size=cube_size,
offset=offset,
)
return
def set_robot(self) -> FlexivSerial:
"""[summary]
Returns:
FlexivSerial: [description]
"""
flexiv_prim_path = find_unique_string_name(
initial_name="/World/Flexiv",
is_unique_fn=lambda x: not is_prim_path_valid(x),
)
flexiv_robot_name = find_unique_string_name(
initial_name="Rizon4",
is_unique_fn=lambda x: not self.scene.object_exists(x),
)
return FlexivSerial(prim_path=flexiv_prim_path, name=flexiv_robot_name)
@@ -0,0 +1,64 @@
# Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
from typing import Optional
import numpy as np
from isaacsim.core.api.tasks import Stacking as BaseStacking
from isaacsim.core.utils.prims import is_prim_path_valid
from isaacsim.core.utils.stage import get_stage_units
from isaacsim.core.utils.string import find_unique_string_name
from isaacsim.robot.manipulators.examples.flexiv import FlexivSerial
class Stacking(BaseStacking):
"""[summary]
Args:
name (str, optional): [description]. Defaults to "flexiv_stacking".
target_position (Optional[np.ndarray], optional): [description]. Defaults to None.
cube_size (Optional[np.ndarray], optional): [description]. Defaults to None.
offset (Optional[np.ndarray], optional): [description]. Defaults to None.
"""
def __init__(
self,
name: str = "flexiv_stacking",
target_position: Optional[np.ndarray] = None,
cube_size: Optional[np.ndarray] = None,
offset: Optional[np.ndarray] = None,
) -> None:
if target_position is None:
target_position = np.array([0.5, 0.5, 0]) / get_stage_units()
BaseStacking.__init__(
self,
name=name,
cube_initial_positions=np.array([[0.3, 0.3, 0.3], [0.3, -0.3, 0.3]])
/ get_stage_units(),
cube_initial_orientations=None,
stack_target_position=target_position,
cube_size=cube_size,
offset=offset,
)
return
def set_robot(self) -> FlexivSerial:
"""[summary]
Returns:
FlexivSerial: [description]
"""
flexiv_prim_path = find_unique_string_name(
initial_name="/World/Flexiv",
is_unique_fn=lambda x: not is_prim_path_valid(x),
)
flexiv_robot_name = find_unique_string_name(
initial_name="Rizon4",
is_unique_fn=lambda x: not self.scene.object_exists(x),
)
return FlexivSerial(prim_path=flexiv_prim_path, name=flexiv_robot_name)
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
# Install Flexiv's Isaac Sim workspace to the NVIDIA Isaac Sim installation directory.
# Absolute path of this script
SCRIPT_PATH="$(dirname $(readlink -f $0))"
set -e
# Check script arguments
if [ "$#" -lt 1 ]; then
echo "Error: invalid script argument"
echo "Required argument: [isaac_sim_root]"
echo " isaac_sim_root: absolute path to Isaac Sim installation root directory"
exit 1
fi
ISAAC_ROOT=$1
# Install files
cp -r $SCRIPT_PATH/exts/ $ISAAC_ROOT
cp -r $SCRIPT_PATH/standalone_examples/ $ISAAC_ROOT
@@ -0,0 +1,71 @@
# One or more robots to add to the scene.
# NOTE: Add or remove [serial_number] blocks to control which robots are added to the scene.
robots:
- serial_number: "Rizon4-00001" # Serial number of robot 1
usd: "/path/to/robot1.usd" # Absolute path to the usd file of robot 1, see exts/isaacsim.robot.manipulators.examples/data/flexiv/
position: # Position in world frame to put robot 1
x: 0.0
y: 0.0
z: 0.0
orientation: # Orientation (quaternion) in world frame to put robot 1
w: 1.0
x: 0.0
y: 0.0
z: 0.0
- serial_number: "Rizon4-00002" # Serial number of robot 2
usd: "/path/to/robot2.usd" # Absolute path to the usd file of robot 2
position: # Position in world frame to put robot 2
x: 1.0
y: 0.0
z: 0.0
orientation: # Orientation (quaternion) in world frame to put robot 2
w: 1.0
x: 0.0
y: 0.0
z: 0.0
# More robots ...
# Absolute path to the usd file of the environment to load.
# If not provided, an empty environment with default ground plane will be used. You can also start with the example environment
# located at exts/isaacsim.robot.manipulators.examples/data/flexiv/example_env.usd
env_usd: "/path/to/environment.usd"
# Enable GPU dynamics. Use this argument if any object in the scene requires GPU for dynamics computation.
# For example, deformable body material and SDF mesh collider.
gpu_dynamics: false
# One or more cameras to add to the scene .
# NOTE: Add or remove [name] blocks to control which cameras are added to the scene.
# Remove or comment out the whole [cameras] section if no camera is needed.
cameras:
- name: "camera_1" # Unique name of camera 1
resolution: [1280, 720] # Resolution of camera 1
fps: 30 # Frames per second of camera 1
focal_length: 2.5 # Focal length in meter of camera 1
position: # Position in world frame to put camera 1
x: 0.0
y: 0.0
z: 0.0
orientation: # Orientation (quaternion) in USD frame to put camera 1
w: 1.0
x: 0.0
y: 0.0
z: 0.0
- name: "camera_2" # Unique name of camera 2
resolution: [1280, 720] # Resolution of camera 2
fps: 30 # Frames per second of camera 2
focal_length: 2.5 # Focal length in meter of camera 2
position: # Position in world frame to put camera 2
x: 0.0
y: 0.0
z: 0.0
orientation: # Orientation (quaternion) in USD frame to put camera 2
w: 1.0
x: 0.0
y: 0.0
z: 0.0
# More cameras ...
@@ -0,0 +1,352 @@
# Copyright (c) 2021-2023, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
# App version
APP_VERSION = "1.3"
# Compatible flexivsimplugin version
COMPATIBLE_SIM_PLUGIN_VER = "1.2.0"
import yaml
import spdlog
import numpy as np
from typing import List, Dict
from enum import Enum
from argparse import ArgumentParser
from dataclasses import dataclass
from isaacsim import SimulationApp
# Middleware plugin for connecting to Flexiv Elements Studio
import flexivsimplugin
# Check version
if flexivsimplugin.__version__ != COMPATIBLE_SIM_PLUGIN_VER:
raise ImportError(
f"flexivsimplugin=={COMPATIBLE_SIM_PLUGIN_VER} is required, but found {flexivsimplugin.__version__}"
)
# Load config file
argparser = ArgumentParser()
argparser.add_argument("--config", required=True, help="Path to YAML config file")
args = argparser.parse_args()
# Start simulation main window
simulation_app = SimulationApp({"headless": False, "width": 1920, "height": 1080})
# Import isaac modules after SimulationApp is started
from isaacsim.core.api import World
from isaacsim.core.utils.stage import add_reference_to_stage
from isaacsim.sensors.camera import Camera
from isaacsim.robot.manipulators.examples.flexiv import FlexivSerial
from isaacsim.robot.manipulators.grippers.parallel_gripper import ParallelGripper
# Physics and render loop period [sec]
RENDER_FREQ = 60.0
PHYSICS_FREQ = 2000.0
# Gripper status
class GripperStatus(Enum):
INIT = 0
OPENED = 1
CLOSED = 2
class BridgeRunner(object):
"""
Set up world and run joint impedance control.
Params:
physics_dt (float): Physics loop period of the scene [sec].
render_dt (float): Render loop period of the scene [sec].
config (Dict): Configurations parsed from the config file.
initial_q (List[float], optional): Initial joint positions [rad].
"""
# Data struct for a single robot
@dataclass
class SingleRobotData:
name: str
instance: FlexivSerial
sim_plugin: flexivsimplugin.UserNode
last_connected: bool
gripper_status: GripperStatus
# Robot degrees of freedom
ROBOT_DOF = 7
def __init__(
self,
physics_dt,
render_dt,
config: Dict,
initial_q: List[float] = [0.0] * ROBOT_DOF,
) -> None:
# Initialize logger
self._logger = spdlog.ConsoleLogger("Flexiv-Isaac Bridge App")
# fmt: off
self._logger.info("——————————————————————————————————————————————————————————")
self._logger.info(f"——— Flexiv-Isaac Bridge App v{APP_VERSION} ———")
self._logger.info("——————————————————————————————————————————————————————————")
# fmt: on
# Save initial q
self._initial_q = initial_q
# Create world
self._world = World(
stage_units_in_meters=1.0,
physics_dt=physics_dt,
rendering_dt=render_dt,
set_defaults=False,
)
# Enable GPU dynamics if specified
if config.get("gpu_dynamics", False):
self._world.get_physics_context().enable_gpu_dynamics(True)
# Load environment and reset world
env_usd = config.get("env_usd", "")
if env_usd:
# Add user-provided environment to stage
add_reference_to_stage(usd_path=env_usd, prim_path="/World")
else:
# Add empty environment to stage
self._world.scene.add_default_ground_plane()
self._world.reset()
# Add cameras
self._cameras = []
for c in config.get("cameras", []):
cam_name = c["name"]
pos_in_world = [float(c["position"][i]) for i in ["x", "y", "z"]]
ori_in_world = [float(c["orientation"][i]) for i in ["w", "x", "y", "z"]]
camera = Camera(
prim_path="/World/" + cam_name,
frequency=c["fps"],
resolution=tuple(c["resolution"]),
position=pos_in_world,
orientation=ori_in_world,
)
camera.set_focal_length(c["focal_length"])
# Use the same camera axes as the Isaac Sim UI
camera.set_world_pose(
position=pos_in_world, orientation=ori_in_world, camera_axes="usd"
)
self._cameras.append(camera)
self._logger.info(
f"Added camera [/World/{cam_name}] located at {pos_in_world} {ori_in_world} in world"
)
# Create data struct for all robots and add them to stage
self._robots = []
for r in config.get("robots", []):
# Parse config of this robot
serial_num = r["serial_number"]
usd_path = r["usd"]
pos_in_world = [float(r["position"][i]) for i in ["x", "y", "z"]]
ori_in_world = [float(r["orientation"][i]) for i in ["w", "x", "y", "z"]]
# Replace dash with underscore in serial number to avoid prim path error
serial_num = serial_num.replace("-", "_")
# Add this robot to stage
prim_path = "/World/Flexiv/" + serial_num
self._logger.info(
f"Adding robot usd [{usd_path}] to stage at prim path [{prim_path}]"
)
add_reference_to_stage(usd_path=usd_path, prim_path=prim_path)
# Configure gripper if the usd name suggests a gripper exists in the model
gripper = None
end_effector_prim_name = "flange"
if "Grav" in usd_path:
# This gripper has only one actuation joint, but the API requires two,
# thus providing a non-actuation joint (gains = 0) as a place holder
end_effector_prim_name = "Grav_gripper/right_finger_tip"
gripper = ParallelGripper(
end_effector_prim_path=prim_path + "/" + end_effector_prim_name,
joint_prim_names=["finger_joint", "right_outer_knuckle_joint"],
joint_opened_positions=np.array([45.0, 0]),
joint_closed_positions=np.array([-8.88, 0]),
)
self._logger.info(
"The usd name suggests a Grav gripper exists in the model, gripper control will be enabled"
)
elif "Robotiq" in usd_path:
# This gripper has only one actuation joint, but the API requires two,
# thus providing a non-actuation joint (gains = 0) as a place holder
end_effector_prim_name = (
"Robotiq_2F_85_flattened/Robotiq_2F_85/right_inner_finger"
)
gripper = ParallelGripper(
end_effector_prim_path=prim_path + "/" + end_effector_prim_name,
joint_prim_names=["finger_joint", "right_inner_finger_joint"],
joint_opened_positions=np.array([0, 0]),
joint_closed_positions=np.array([45, 0]),
)
self._logger.info(
"The usd name suggests a Robotiq gripper exists in the model, gripper control will be enabled"
)
else:
self._logger.info("Gripper control is not enabled")
# Add robot to stage
robot = self._world.scene.add(
FlexivSerial(
prim_path=prim_path,
name=serial_num,
end_effector_prim_name=end_effector_prim_name,
arm_dof=BridgeRunner.ROBOT_DOF,
pos_in_world=pos_in_world,
ori_in_world=ori_in_world,
gripper=gripper,
)
)
self._logger.info(
f"Added robot [/World/Flexiv/{serial_num}] located at {pos_in_world} {ori_in_world} in world"
)
# Append single robot data struct
self._robots.append(
self.SingleRobotData(
name=serial_num,
instance=robot,
sim_plugin=flexivsimplugin.UserNode(serial_num),
last_connected=False,
gripper_status=GripperStatus.INIT,
)
)
# Add physics callback
self._world.add_physics_callback("robot_step", callback_fn=self.on_physics_step)
# Reset world once
self._world.reset()
# Initialize cameras
for cam in self._cameras:
cam.initialize()
# Initialize other members
self._reset_needed = False
self._servo_cycle = 0
# Put robot to initial pose
for robot in self._robots:
robot.instance.teleport_to(self._initial_q)
def on_physics_step(self, dt) -> None:
"""
Physics call back to host the real-time joint control loop. The loop period of this callback is provided by [dt].
Params:
dt (float): Loop period, same as [physics_dt] [sec].
"""
for robot in self._robots:
# Publish fresh robot states to all Flexiv Nodes before doing anything else
robot.sim_plugin.SendRobotStates(
flexivsimplugin.SimRobotStates(
self._servo_cycle,
robot.instance.q,
robot.instance.dq,
)
)
for robot in self._robots:
if robot.sim_plugin.connected():
# Upon reconnection, set joint torque control mode
if not robot.last_connected:
self._logger.info(f"Connected to robot [{robot.name}]")
robot.instance.switch_control_mode("effort")
# Wait for new commands to arrive before proceeding current cycle
timeout_ms = 100
if robot.sim_plugin.WaitForRobotCommands(timeout_ms):
# Apply joint torques
robot.instance.apply_torques(
robot.sim_plugin.robot_commands().target_drives
)
else:
self._logger.warn(f"Missed 1 message from [{robot.name}]")
# Gripper control based on digital output signal
dout_list = list(
robot.sim_plugin.robot_commands().digital_outputs
) # Convert map to list
if dout_list:
# DOUT[0] high = open gripper
if dout_list[0]:
# Ignore if already opened
if robot.gripper_status != GripperStatus.OPENED:
self._logger.info("Opening gripper")
robot.instance.gripper.open()
robot.gripper_status = GripperStatus.OPENED
# DOUT[1] high = close gripper
if dout_list[1]:
# Ignore if already closed
if robot.gripper_status != GripperStatus.CLOSED:
self._logger.info("Closing gripper")
robot.instance.gripper.close()
robot.gripper_status = GripperStatus.CLOSED
# Set last connected status
robot.last_connected = True
else:
if robot.last_connected:
# Upon disconnection, transit this robot from torque control to position control to hold its current pose
self._logger.error(f"Disconnected from robot [{robot.name}]")
robot.instance.switch_control_mode("position")
robot.instance.teleport_to(robot.instance.q)
robot.gripper_status = GripperStatus.INIT
# Set last connected status
robot.last_connected = False
# Increment server cycle
self._servo_cycle += 1
def run(self) -> None:
"""
Poll world step, which will step physics and rendering with specified physics_dt and render_dt.
"""
while simulation_app.is_running():
self._world.step(render=True)
# Reset world if needed
if self._world.is_stopped() and not self._reset_needed:
self._reset_needed = True
for robot in self._robots:
robot.last_connected = False
if self._world.is_playing():
if self._reset_needed:
self._world.reset()
self._reset_needed = False
# Put robot to initial pose
for robot in self._robots:
robot.instance.switch_control_mode("position")
robot.instance.teleport_to(self._initial_q)
def main():
# Create runner to handle everything
runner = BridgeRunner(
physics_dt=1.0 / PHYSICS_FREQ,
render_dt=1.0 / RENDER_FREQ,
config=yaml.safe_load(open(args.config)),
initial_q=[0.0, -0.698132, 0.0, 1.5708, 0.0, 0.698132, 0.0],
)
runner.run()
simulation_app.close()
if __name__ == "__main__":
main()
@@ -0,0 +1,54 @@
# Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA CORPORATION and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA CORPORATION is strictly prohibited.
#
# Start simulation
from isaacsim import SimulationApp
simulation_app = SimulationApp({"headless": False})
from isaacsim.core.api import World
from isaacsim.robot.manipulators.examples.flexiv.controllers.rmpflow_controller import (
RMPFlowController,
)
from isaacsim.robot.manipulators.examples.flexiv.tasks import FollowTarget
from isaacsim.storage.native import get_assets_root_path
# Use Rizon4 usd stored in Isaac Sim assets
usd_path = get_assets_root_path() + "/Isaac/Robots/Flexiv/Rizon4/flexiv_rizon4.usd"
my_world = World(stage_units_in_meters=1.0)
my_task = FollowTarget(name="flexiv_follow_target", usd_path=usd_path)
my_world.add_task(my_task)
my_world.reset()
task_params = my_world.get_task("flexiv_follow_target").get_params()
flexiv_name = task_params["robot_name"]["value"]
target_name = task_params["target_name"]["value"]
my_flexiv = my_world.scene.get_object(flexiv_name)
my_controller = RMPFlowController(
name="target_follower_controller", robot_articulation=my_flexiv
)
articulation_controller = my_flexiv.get_articulation_controller()
reset_needed = False
while simulation_app.is_running():
my_world.step(render=True)
if my_world.is_stopped() and not reset_needed:
reset_needed = True
if my_world.is_playing():
if reset_needed:
my_world.reset()
my_controller.reset()
reset_needed = False
observations = my_world.get_observations()
actions = my_controller.forward(
target_end_effector_position=observations[target_name]["position"],
target_end_effector_orientation=observations[target_name]["orientation"],
)
articulation_controller.apply_action(actions)
simulation_app.close()
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
# Uninstall Flexiv's Isaac Sim workspace from the NVIDIA Isaac Sim installation directory.
# Absolute path of this script
SCRIPT_PATH="$(dirname $(readlink -f $0))"
set -e
# Check script arguments
if [ "$#" -lt 1 ]; then
echo "Error: invalid script argument"
echo "Required argument: [isaac_sim_root]"
echo " isaac_sim_root: absolute path to Isaac Sim installation root directory"
exit 1
fi
ISAAC_ROOT=$1
# Uninstalled files
rm -rf $ISAAC_ROOT/exts/isaacsim.robot.manipulators.examples/isaacsim/robot/manipulators/examples/flexiv
rm -rf $ISAAC_ROOT/exts/isaacsim.robot.manipulators.examples/data/flexiv
rm -rf $ISAAC_ROOT/standalone_examples/api/isaacsim.robot.manipulators/flexiv