Skip to content

Commit

Permalink
Add colab docker and make some scripts more amenable to a quick demo
Browse files Browse the repository at this point in the history
  • Loading branch information
cgokmen committed Mar 20, 2024
1 parent b35ef56 commit 054a8f0
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 64 deletions.
3 changes: 1 addition & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
omnigibson/data
docker
omnigibson/data
7 changes: 3 additions & 4 deletions docker/build_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
set -e -o pipefail

docker build \
-t stanfordvl/omnigibson:latest \
-t stanfordvl/omnigibson:$(sed -ne "s/.*version= *['\"]\([^'\"]*\)['\"] *.*/\1/p" setup.py) \
-t stanfordvl/omnigibson:colab-docker \
-f docker/prod.Dockerfile \
.

docker build \
-t stanfordvl/omnigibson-vscode:latest \
-f docker/vscode.Dockerfile \
-t stanfordvl/omnigibson-colab \
-f docker/colab.Dockerfile \
.
21 changes: 21 additions & 0 deletions docker/colab.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM stanfordvl/omnigibson:colab-docker

# environment settings
ARG DEBIAN_FRONTEND="noninteractive"
ENV OMNIGIBSON_HEADLESS="1"
ENV OMNIGIBSON_REMOTE_STREAMING="webrtc"

# Fix the JS file to allow for remote streaming on the same port (80)
RUN sed -i "s/49100/80/g" /isaac-sim/extscache/omni.services.streamclient.webrtc-1.3.8/web/js/kit-player.js && \
sed -i -E 's/IsValidIPv4=.*test\(e\)/IsValidIPv4=function(e){return true/g' /isaac-sim/extscache/omni.services.streamclient.webrtc-1.3.8/web/js/kit-player.js

# Install nginx
RUN apt-get update && apt-get install -y nginx && apt-get clean

# Download the demo dataset and the assets
RUN python -m omnigibson.utils.asset_utils --download_assets --download_demo_data --accept_license

# Add the nginx configuration file
ADD docker/nginx.conf /etc/nginx/sites-available/default

CMD nginx && python -m omnigibson.examples.robots.robot_control_example --quickstart
24 changes: 24 additions & 0 deletions docker/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

server {
listen 8123;

location /streaming/ {
proxy_pass http://127.0.0.1:8211/streaming/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
}

location / {
proxy_pass http://127.0.0.1:49100/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
}
}
38 changes: 30 additions & 8 deletions omnigibson/examples/robots/robot_control_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,24 @@ def choose_controllers(robot, random_selection=False):
return controller_choices


def main(random_selection=False, headless=False, short_exec=False):
def main(random_selection=False, headless=False, short_exec=False, quickstart=False):
"""
Robot control demo with selection
Queries the user to select a robot, the controllers, a scene and a type of input (random actions or teleop)
"""
og.log.info(f"Demo {__file__}\n " + "*" * 80 + "\n Description:\n" + main.__doc__ + "*" * 80)

# Choose scene to load
scene_model = choose_from_options(options=SCENES, name="scene", random_selection=random_selection)
scene_model = "Rs_int"
if not quickstart:
scene_model = choose_from_options(options=SCENES, name="scene", random_selection=random_selection)

# Choose robot to create
robot_name = choose_from_options(
options=list(sorted(REGISTERED_ROBOTS.keys())), name="robot", random_selection=random_selection
)
robot_name = "Fetch"
if not quickstart:
robot_name = choose_from_options(
options=list(sorted(REGISTERED_ROBOTS.keys())), name="robot", random_selection=random_selection
)

scene_cfg = dict()
if scene_model == "empty":
Expand All @@ -82,7 +86,7 @@ def main(random_selection=False, headless=False, short_exec=False):
# Add the robot we want to load
robot0_cfg = dict()
robot0_cfg["type"] = robot_name
robot0_cfg["obs_modalities"] = ["rgb", "depth", "seg_instance", "normal", "scan", "occupancy_grid"]
robot0_cfg["obs_modalities"] = ["rgb"]
robot0_cfg["action_type"] = "continuous"
robot0_cfg["action_normalize"] = True

Expand All @@ -94,11 +98,20 @@ def main(random_selection=False, headless=False, short_exec=False):

# Choose robot controller to use
robot = env.robots[0]
controller_choices = choose_controllers(robot=robot, random_selection=random_selection)
controller_choices = {
"base": "DifferentialDriveController",
"arm_0": "InverseKinematicsController",
"gripper_0": "MultiFingerGripperController",
"camera": "JointController"
}
if not quickstart:
controller_choices = choose_controllers(robot=robot, random_selection=random_selection)

# Choose control mode
if random_selection:
control_mode = "random"
elif quickstart:
control_mode = "teleop"
else:
control_mode = choose_from_options(options=CONTROL_MODES, name="control mode")

Expand Down Expand Up @@ -151,4 +164,13 @@ def main(random_selection=False, headless=False, short_exec=False):


if __name__ == "__main__":
main()
import argparse
parser = argparse.ArgumentParser(description="Teleoperate a robot in a BEHAVIOR scene.")

parser.add_argument(
"--quickstart",
action="store_true",
help="Whether the example should be loaded with default settings for a quick start.",
)
args = parser.parse_args()
main(quickstart=args.quickstart)
77 changes: 27 additions & 50 deletions omnigibson/utils/asset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,23 +394,24 @@ def download_assets():
# These datasets come as folders; in these folder there are scenes, so --strip-components are needed.


def download_demo_data():
def download_demo_data(accept_license=False):
"""
Download OmniGibson demo dataset
"""
# Print user agreement
if os.path.exists(gm.KEY_PATH):
print("OmniGibson dataset encryption key already installed.")
else:
print("\n")
print_user_agreement()
while (
input(
"Do you agree to the above terms for using OmniGibson dataset? [y/n]"
)
!= "y"
):
print("You need to agree to the terms for using OmniGibson dataset.")
if not accept_license:
print("\n")
print_user_agreement()
while (
input(
"Do you agree to the above terms for using OmniGibson dataset? [y/n]"
)
!= "y"
):
print("You need to agree to the terms for using OmniGibson dataset.")

download_key()

Expand Down Expand Up @@ -445,23 +446,24 @@ def download_key():
assert urlretrieve(path, gm.KEY_PATH, show_progress), "Key download failed."


def download_og_dataset():
def download_og_dataset(accept_license=False):
"""
Download OmniGibson dataset
"""
# Print user agreement
if os.path.exists(gm.KEY_PATH):
print("OmniGibson dataset encryption key already installed.")
else:
print("\n")
print_user_agreement()
while (
input(
"Do you agree to the above terms for using OmniGibson dataset? [y/n]"
)
!= "y"
):
print("You need to agree to the terms for using OmniGibson dataset.")
if not accept_license:
print("\n")
print_user_agreement()
while (
input(
"Do you agree to the above terms for using OmniGibson dataset? [y/n]"
)
!= "y"
):
print("You need to agree to the terms for using OmniGibson dataset.")

download_key()

Expand All @@ -477,28 +479,6 @@ def download_og_dataset():
# These datasets come as folders; in these folder there are scenes, so --strip-components are needed.


def change_data_path():
"""
Changes the data paths for this repo
"""
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "global_config.yaml")) as f:
global_config = yaml.load(f, Loader=yaml.FullLoader)
print("Current dataset path:")
for k, v in global_config.items():
print("{}: {}".format(k, v))
for k, v in global_config.items():
new_path = input("Change {} from {} to: ".format(k, v))
global_config[k] = new_path

print("New dataset path:")
for k, v in global_config.items():
print("{}: {}".format(k, v))
response = input("Save? [y/n]")
if response == "y":
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "global_config.yaml"), "w") as f:
yaml.dump(global_config, f)


def decrypt_file(encrypted_filename, decrypted_filename):
with open(gm.KEY_PATH, "rb") as filekey:
key = filekey.read()
Expand Down Expand Up @@ -543,17 +523,14 @@ def decrypted(encrypted_filename):
parser.add_argument("--download_assets", action="store_true", help="download assets file")
parser.add_argument("--download_demo_data", action="store_true", help="download demo data Rs")
parser.add_argument("--download_og_dataset", action="store_true", help="download OmniGibson Dataset")
parser.add_argument("--change_data_path", action="store_true", help="change the path to store assets and datasets")

parser.add_argument("--accept_license", action="store_true", help="pre-accept the OmniGibson dataset license")
args = parser.parse_args()

if args.download_assets:
download_assets()
elif args.download_demo_data:
download_demo_data()
elif args.download_og_dataset:
download_og_dataset()
elif args.change_data_path:
change_data_path()
if args.download_demo_data:
download_demo_data(accept_license=args.accept_license)
if args.download_og_dataset:
download_og_dataset(accept_license=args.accept_license)

og.shutdown()

0 comments on commit 054a8f0

Please sign in to comment.