Skip to content

Commit

Permalink
Create Isaac extensions for Recording and Replaying trajectories (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
apockill authored Dec 20, 2024
1 parent 718a242 commit 91f8587
Show file tree
Hide file tree
Showing 47 changed files with 1,609 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/UrbanMachine/create-ros-app.git",
"commit": "93e541631403e2c2c091c65d6583d61bd85a472c",
"commit": "46f618667950a47275d2976e91c99dd4bd15764b",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
2 changes: 1 addition & 1 deletion isaac_src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ To get good code completion, add a `Docker compose interpreter`, then
point it towards `/isaac-sim/python.sh`. That should
work, and pycharm should discover all the relevant libraries.

![img.png](docs/img.png)
![pycharm.png](docs/static/pycharm.png)
3 changes: 3 additions & 0 deletions isaac_src/assets/materials/AluminumShaft.usd
Git LFS file not shown
3 changes: 3 additions & 0 deletions isaac_src/assets/materials/Gripper.usd
Git LFS file not shown
3 changes: 3 additions & 0 deletions isaac_src/assets/materials/PlasticRobotBase.usd
Git LFS file not shown
3 changes: 3 additions & 0 deletions isaac_src/assets/materials/Printed3d.usd
Git LFS file not shown
3 changes: 3 additions & 0 deletions isaac_src/assets/myarm_c.usd
Git LFS file not shown
3 changes: 0 additions & 3 deletions isaac_src/assets/myarm_c650.usd

This file was deleted.

4 changes: 2 additions & 2 deletions isaac_src/assets/myarm_m.usd
Git LFS file not shown
3 changes: 3 additions & 0 deletions isaac_src/assets/omnigraphs/controller_actiongraph.usd
Git LFS file not shown
3 changes: 3 additions & 0 deletions isaac_src/assets/omnigraphs/mover_actiongraph.usd
Git LFS file not shown
12 changes: 12 additions & 0 deletions isaac_src/extensions/trajectory_synth/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# all folders starting with _ are local
_*/

.DS_Store
**/.vscode/ipch

# byte-compiled python files
*.py[cod]

/.vs

/app
52 changes: 52 additions & 0 deletions isaac_src/extensions/trajectory_synth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Extension Project Template

This project was automatically generated.

- `app` - It is a folder link to the location of your *Omniverse Kit* based app.
- `exts` - It is a folder where you can add new extensions. It was automatically added to extension search path. (Extension Manager -> Gear Icon -> Extension Search Path).

Open this folder using Visual Studio Code. It will suggest you to install few extensions that will make python experience better.

Look for "trajectory_synth" extension in extension manager and enable it. Try applying changes to any python files, it will hot-reload and you can observe results immediately.

Alternatively, you can launch your app from console with this folder added to search path and your extension enabled, e.g.:

```
> app\omni.code.bat --ext-folder exts --enable company.hello.world
```

# App Link Setup

If `app` folder link doesn't exist or broken it can be created again. For better developer experience it is recommended to create a folder link named `app` to the *Omniverse Kit* app installed from *Omniverse Launcher*. Convenience script to use is included.

Run:

```
> link_app.bat
```

If successful you should see `app` folder link in the root of this repo.

If multiple Omniverse apps is installed script will select recommended one. Or you can explicitly pass an app:

```
> link_app.bat --app create
```

You can also just pass a path to create link to:

```
> link_app.bat --path "C:/Users/bob/AppData/Local/ov/pkg/create-2021.3.4"
```


# Sharing Your Extensions

This folder is ready to be pushed to any git repository. Once pushed direct link to a git repository can be added to *Omniverse Kit* extension search paths.

Link might look like this: `git://github.com/[user]/[your_repo].git?branch=main&dir=exts`

Notice `exts` is repo subfolder with extensions. More information can be found in "Git URL as Extension Search Paths" section of developers manual.

To add a link to your *Omniverse Kit* based app go into: Extension Manager -> Gear Icon -> Extension Search Path

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[package]
# Semantic Versioning is used: https://semver.org/
version = "1.0.0"

# Lists people or organizations that are considered the "authors" of the package.
authors = ["NVIDIA"]

# The title and description fields are primarily for displaying extension info in UI
title = "trajectory_synth"
description="An extension for recording and augmenting robot trajectories"

# Path (relative to the root) or content of readme markdown file for UI.
readme = "docs/README.md"

# URL of the extension source repository.
repository = ""

# One of categories for UI.
category = "Synthetic Trajectories"

# Keywords for the extension
keywords = ["trajectory", "synthesis", "robotics", "simulation"]

# Location of change log file in target (final) folder of extension, relative to the root.
# More info on writing changelog: https://keepachangelog.com/en/1.0.0/
changelog="docs/CHANGELOG.md"

# Preview image and icon. Folder named "data" automatically goes in git lfs (see .gitattributes file).
# Preview image is shown in "Overview" of Extensions window. Screenshot of an extension might be a good preview image.
preview_image = "data/preview.png"

# Icon is shown in Extensions window, it is recommended to be square, of size 256x256.
icon = "data/icon.png"

# Use omni.ui to build simple UI
[dependencies]
"omni.kit.uiapp" = {}

# Main python module this extension provides, it will be publicly available as "import trajectory_synth".
[[python.module]]
name = "trajectory_synth"

[[test]]
# Extra dependencies only to be used during test run
dependencies = [
"omni.kit.ui_test" # UI testing extension
]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


## [1.0.0] - 2021-04-26
- Initial version of extension UI template with a window

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Python Extension Example [trajectory_synth]

This is my (Alex) first extension. It serves as an interface for starting & stopping
trajectory recording, playback, and augmentation.

The core purpose is to generate thousands of trajectories from a single human demonstration.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
trajectory_synth
#############################

Example of Python only extension


.. toctree::
:maxdepth: 1

README
CHANGELOG


.. automodule::"trajectory_synth"
:platform: Windows-x86_64, Linux-x86_64
:members:
:undoc-members:
:show-inheritance:
:imported-members:
:exclude-members: contextmanager
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .traj_recorder import TrajectoryRecorderExtension
from .traj_replayer import TrajectoryReplayerExtension
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
TIMESTEPS_FILENAME = "timesteps"
SCENE_FILENAME = "scene"
DEFAULT_RECORDINGS_DIR = "/robot/synthetic-output/recordings/"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .test_hello_world import *
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# NOTE:
# omni.kit.test - std python's unittest module with additional wrapping to add suport for async/await tests
# For most things refer to unittest docs: https://docs.python.org/3/library/unittest.html
import omni.kit.test

# Extnsion for writing UI tests (simulate UI interaction)
from omni.kit import ui_test

# Import extension python module we are testing with absolute import path, as if we are external user (other extension)
import trajectory_synth


# Having a test class dervived from omni.kit.test.AsyncTestCase declared on the root of module will make it auto-discoverable by omni.kit.test
class Test(omni.kit.test.AsyncTestCase):
# Before running each test
async def setUp(self):
pass

# After running each test
async def tearDown(self):
pass

# Actual test, notice it is "async" function, so "await" can be used if needed
async def test_hello_public_function(self):
result = trajectory_synth.some_public_function(4)
self.assertEqual(result, 256)

async def test_window_button(self):
# Find a label in our window
label = ui_test.find("My Window//Frame/**/Label[*]")

# Find buttons in our window
add_button = ui_test.find("My Window//Frame/**/Button[*].text=='Add'")
reset_button = ui_test.find("My Window//Frame/**/Button[*].text=='Reset'")

# Click reset button
await reset_button.click()
self.assertEqual(label.widget.text, "empty")

await add_button.click()
self.assertEqual(label.widget.text, "count: 1")

await add_button.click()
self.assertEqual(label.widget.text, "count: 2")
Loading

0 comments on commit 91f8587

Please sign in to comment.