file_path
stringlengths 21
202
| content
stringlengths 19
1.02M
| size
int64 19
1.02M
| lang
stringclasses 8
values | avg_line_length
float64 5.88
100
| max_line_length
int64 12
993
| alphanum_fraction
float64 0.27
0.93
|
---|---|---|---|---|---|---|
NVIDIA-Omniverse/orbit/source/standalone/workflows/robomimic/collect_demonstrations.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Script to collect demonstrations with Orbit environments."""
from __future__ import annotations
"""Launch Isaac Sim Simulator first."""
import argparse
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser(description="Collect demonstrations for Orbit environments.")
parser.add_argument("--cpu", action="store_true", default=False, help="Use CPU pipeline.")
parser.add_argument("--num_envs", type=int, default=1, help="Number of environments to simulate.")
parser.add_argument("--task", type=str, default=None, help="Name of the task.")
parser.add_argument("--device", type=str, default="keyboard", help="Device for interacting with environment")
parser.add_argument("--num_demos", type=int, default=1, help="Number of episodes to store in the dataset.")
parser.add_argument("--filename", type=str, default="hdf_dataset", help="Basename of output file.")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()
# launch the simulator
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app
"""Rest everything follows."""
import contextlib
import gymnasium as gym
import os
import torch
from omni.isaac.orbit.devices import Se3Keyboard, Se3SpaceMouse
from omni.isaac.orbit.managers import TerminationTermCfg as DoneTerm
from omni.isaac.orbit.utils.io import dump_pickle, dump_yaml
import omni.isaac.orbit_tasks # noqa: F401
from omni.isaac.orbit_tasks.manipulation.lift import mdp
from omni.isaac.orbit_tasks.utils.data_collector import RobomimicDataCollector
from omni.isaac.orbit_tasks.utils.parse_cfg import parse_env_cfg
def pre_process_actions(delta_pose: torch.Tensor, gripper_command: bool) -> torch.Tensor:
"""Pre-process actions for the environment."""
# compute actions based on environment
if "Reach" in args_cli.task:
# note: reach is the only one that uses a different action space
# compute actions
return delta_pose
else:
# resolve gripper command
gripper_vel = torch.zeros((delta_pose.shape[0], 1), dtype=torch.float, device=delta_pose.device)
gripper_vel[:] = -1 if gripper_command else 1
# compute actions
return torch.concat([delta_pose, gripper_vel], dim=1)
def main():
"""Collect demonstrations from the environment using teleop interfaces."""
assert (
args_cli.task == "Isaac-Lift-Cube-Franka-IK-Rel-v0"
), "Only 'Isaac-Lift-Cube-Franka-IK-Rel-v0' is supported currently."
# parse configuration
env_cfg = parse_env_cfg(args_cli.task, use_gpu=not args_cli.cpu, num_envs=args_cli.num_envs)
# modify configuration such that the environment runs indefinitely
# until goal is reached
env_cfg.terminations.time_out = None
# set the resampling time range to large number to avoid resampling
env_cfg.commands.object_pose.resampling_time_range = (1.0e9, 1.0e9)
# we want to have the terms in the observations returned as a dictionary
# rather than a concatenated tensor
env_cfg.observations.policy.concatenate_terms = False
# add termination condition for reaching the goal otherwise the environment won't reset
env_cfg.terminations.object_reached_goal = DoneTerm(func=mdp.object_reached_goal)
# create environment
env = gym.make(args_cli.task, cfg=env_cfg)
# create controller
if args_cli.device.lower() == "keyboard":
teleop_interface = Se3Keyboard(pos_sensitivity=0.04, rot_sensitivity=0.08)
elif args_cli.device.lower() == "spacemouse":
teleop_interface = Se3SpaceMouse(pos_sensitivity=0.05, rot_sensitivity=0.005)
else:
raise ValueError(f"Invalid device interface '{args_cli.device}'. Supported: 'keyboard', 'spacemouse'.")
# add teleoperation key for env reset
teleop_interface.add_callback("L", env.reset)
# print helper
print(teleop_interface)
# specify directory for logging experiments
log_dir = os.path.join("./logs/robomimic", args_cli.task)
# dump the configuration into log-directory
dump_yaml(os.path.join(log_dir, "params", "env.yaml"), env_cfg)
dump_pickle(os.path.join(log_dir, "params", "env.pkl"), env_cfg)
# create data-collector
collector_interface = RobomimicDataCollector(
env_name=args_cli.task,
directory_path=log_dir,
filename=args_cli.filename,
num_demos=args_cli.num_demos,
flush_freq=env.num_envs,
env_config={"device": args_cli.device},
)
# reset environment
obs_dict, _ = env.reset()
# reset interfaces
teleop_interface.reset()
collector_interface.reset()
# simulate environment -- run everything in inference mode
with contextlib.suppress(KeyboardInterrupt) and torch.inference_mode():
while not collector_interface.is_stopped():
# get keyboard command
delta_pose, gripper_command = teleop_interface.advance()
# convert to torch
delta_pose = torch.tensor(delta_pose, dtype=torch.float, device=env.device).repeat(env.num_envs, 1)
# compute actions based on environment
actions = pre_process_actions(delta_pose, gripper_command)
# TODO: Deal with the case when reset is triggered by teleoperation device.
# The observations need to be recollected.
# store signals before stepping
# -- obs
for key, value in obs_dict["policy"].items():
collector_interface.add(f"obs/{key}", value)
# -- actions
collector_interface.add("actions", actions)
# perform action on environment
obs_dict, rewards, terminated, truncated, info = env.step(actions)
dones = terminated | truncated
# check that simulation is stopped or not
if env.unwrapped.sim.is_stopped():
break
# robomimic only cares about policy observations
# store signals from the environment
# -- next_obs
for key, value in obs_dict["policy"].items():
collector_interface.add(f"next_obs/{key}", value)
# -- rewards
collector_interface.add("rewards", rewards)
# -- dones
collector_interface.add("dones", dones)
# -- is success label
collector_interface.add("success", env.termination_manager.get_term("object_reached_goal"))
# flush data from collector for successful environments
reset_env_ids = dones.nonzero(as_tuple=False).squeeze(-1)
collector_interface.flush(reset_env_ids)
# check if enough data is collected
if collector_interface.is_stopped():
break
# close the simulator
collector_interface.close()
env.close()
if __name__ == "__main__":
# run the main function
main()
# close sim app
simulation_app.close()
| 7,116 | Python | 38.320442 | 111 | 0.676504 |
NVIDIA-Omniverse/orbit/source/standalone/workflows/robomimic/train.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
# MIT License
#
# Copyright (c) 2021 Stanford Vision and Learning Lab
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
The main entry point for training policies from pre-collected data.
Args:
algo: name of the algorithm to run.
task: name of the environment.
name: if provided, override the experiment name defined in the config
dataset: if provided, override the dataset path defined in the config
This file has been modified from the original version in the following ways:
* Added import of AppLauncher from omni.isaac.orbit.app to resolve the configuration to load for training.
"""
from __future__ import annotations
"""Launch Isaac Sim Simulator first."""
from omni.isaac.orbit.app import AppLauncher
# launch omniverse app
app_launcher = AppLauncher(headless=True)
simulation_app = app_launcher.app
"""Rest everything follows."""
import argparse
import gymnasium as gym
import json
import numpy as np
import os
import sys
import time
import torch
import traceback
from collections import OrderedDict
from torch.utils.data import DataLoader
import psutil
import robomimic.utils.env_utils as EnvUtils
import robomimic.utils.file_utils as FileUtils
import robomimic.utils.obs_utils as ObsUtils
import robomimic.utils.torch_utils as TorchUtils
import robomimic.utils.train_utils as TrainUtils
from robomimic.algo import RolloutPolicy, algo_factory
from robomimic.config import config_factory
from robomimic.utils.log_utils import DataLogger, PrintLogger
# Needed so that environment is registered
import omni.isaac.orbit_tasks # noqa: F401
def train(config, device):
"""Train a model using the algorithm."""
# first set seeds
np.random.seed(config.train.seed)
torch.manual_seed(config.train.seed)
print("\n============= New Training Run with Config =============")
print(config)
print("")
log_dir, ckpt_dir, video_dir = TrainUtils.get_exp_dir(config)
print(f">>> Saving logs into directory: {log_dir}")
print(f">>> Saving checkpoints into directory: {ckpt_dir}")
print(f">>> Saving videos into directory: {video_dir}")
if config.experiment.logging.terminal_output_to_txt:
# log stdout and stderr to a text file
logger = PrintLogger(os.path.join(log_dir, "log.txt"))
sys.stdout = logger
sys.stderr = logger
# read config to set up metadata for observation modalities (e.g. detecting rgb observations)
ObsUtils.initialize_obs_utils_with_config(config)
# make sure the dataset exists
dataset_path = os.path.expanduser(config.train.data)
if not os.path.exists(dataset_path):
raise FileNotFoundError(f"Dataset at provided path {dataset_path} not found!")
# load basic metadata from training file
print("\n============= Loaded Environment Metadata =============")
env_meta = FileUtils.get_env_metadata_from_dataset(dataset_path=config.train.data)
shape_meta = FileUtils.get_shape_metadata_from_dataset(
dataset_path=config.train.data, all_obs_keys=config.all_obs_keys, verbose=True
)
if config.experiment.env is not None:
env_meta["env_name"] = config.experiment.env
print("=" * 30 + "\n" + "Replacing Env to {}\n".format(env_meta["env_name"]) + "=" * 30)
# create environment
envs = OrderedDict()
if config.experiment.rollout.enabled:
# create environments for validation runs
env_names = [env_meta["env_name"]]
if config.experiment.additional_envs is not None:
for name in config.experiment.additional_envs:
env_names.append(name)
for env_name in env_names:
env = EnvUtils.create_env_from_metadata(
env_meta=env_meta,
env_name=env_name,
render=False,
render_offscreen=config.experiment.render_video,
use_image_obs=shape_meta["use_images"],
)
envs[env.name] = env
print(envs[env.name])
print("")
# setup for a new training run
data_logger = DataLogger(log_dir, config=config, log_tb=config.experiment.logging.log_tb)
model = algo_factory(
algo_name=config.algo_name,
config=config,
obs_key_shapes=shape_meta["all_shapes"],
ac_dim=shape_meta["ac_dim"],
device=device,
)
# save the config as a json file
with open(os.path.join(log_dir, "..", "config.json"), "w") as outfile:
json.dump(config, outfile, indent=4)
print("\n============= Model Summary =============")
print(model) # print model summary
print("")
# load training data
trainset, validset = TrainUtils.load_data_for_training(config, obs_keys=shape_meta["all_obs_keys"])
train_sampler = trainset.get_dataset_sampler()
print("\n============= Training Dataset =============")
print(trainset)
print("")
# maybe retrieve statistics for normalizing observations
obs_normalization_stats = None
if config.train.hdf5_normalize_obs:
obs_normalization_stats = trainset.get_obs_normalization_stats()
# initialize data loaders
train_loader = DataLoader(
dataset=trainset,
sampler=train_sampler,
batch_size=config.train.batch_size,
shuffle=(train_sampler is None),
num_workers=config.train.num_data_workers,
drop_last=True,
)
if config.experiment.validate:
# cap num workers for validation dataset at 1
num_workers = min(config.train.num_data_workers, 1)
valid_sampler = validset.get_dataset_sampler()
valid_loader = DataLoader(
dataset=validset,
sampler=valid_sampler,
batch_size=config.train.batch_size,
shuffle=(valid_sampler is None),
num_workers=num_workers,
drop_last=True,
)
else:
valid_loader = None
# main training loop
best_valid_loss = None
best_return = {k: -np.inf for k in envs} if config.experiment.rollout.enabled else None
best_success_rate = {k: -1.0 for k in envs} if config.experiment.rollout.enabled else None
last_ckpt_time = time.time()
# number of learning steps per epoch (defaults to a full dataset pass)
train_num_steps = config.experiment.epoch_every_n_steps
valid_num_steps = config.experiment.validation_epoch_every_n_steps
for epoch in range(1, config.train.num_epochs + 1): # epoch numbers start at 1
step_log = TrainUtils.run_epoch(model=model, data_loader=train_loader, epoch=epoch, num_steps=train_num_steps)
model.on_epoch_end(epoch)
# setup checkpoint path
epoch_ckpt_name = f"model_epoch_{epoch}"
# check for recurring checkpoint saving conditions
should_save_ckpt = False
if config.experiment.save.enabled:
time_check = (config.experiment.save.every_n_seconds is not None) and (
time.time() - last_ckpt_time > config.experiment.save.every_n_seconds
)
epoch_check = (
(config.experiment.save.every_n_epochs is not None)
and (epoch > 0)
and (epoch % config.experiment.save.every_n_epochs == 0)
)
epoch_list_check = epoch in config.experiment.save.epochs
should_save_ckpt = time_check or epoch_check or epoch_list_check
ckpt_reason = None
if should_save_ckpt:
last_ckpt_time = time.time()
ckpt_reason = "time"
print(f"Train Epoch {epoch}")
print(json.dumps(step_log, sort_keys=True, indent=4))
for k, v in step_log.items():
if k.startswith("Time_"):
data_logger.record(f"Timing_Stats/Train_{k[5:]}", v, epoch)
else:
data_logger.record(f"Train/{k}", v, epoch)
# Evaluate the model on validation set
if config.experiment.validate:
with torch.no_grad():
step_log = TrainUtils.run_epoch(
model=model, data_loader=valid_loader, epoch=epoch, validate=True, num_steps=valid_num_steps
)
for k, v in step_log.items():
if k.startswith("Time_"):
data_logger.record(f"Timing_Stats/Valid_{k[5:]}", v, epoch)
else:
data_logger.record(f"Valid/{k}", v, epoch)
print(f"Validation Epoch {epoch}")
print(json.dumps(step_log, sort_keys=True, indent=4))
# save checkpoint if achieve new best validation loss
valid_check = "Loss" in step_log
if valid_check and (best_valid_loss is None or (step_log["Loss"] <= best_valid_loss)):
best_valid_loss = step_log["Loss"]
if config.experiment.save.enabled and config.experiment.save.on_best_validation:
epoch_ckpt_name += f"_best_validation_{best_valid_loss}"
should_save_ckpt = True
ckpt_reason = "valid" if ckpt_reason is None else ckpt_reason
# Evaluate the model by by running rollouts
# do rollouts at fixed rate or if it's time to save a new ckpt
video_paths = None
rollout_check = (epoch % config.experiment.rollout.rate == 0) or (should_save_ckpt and ckpt_reason == "time")
if config.experiment.rollout.enabled and (epoch > config.experiment.rollout.warmstart) and rollout_check:
# wrap model as a RolloutPolicy to prepare for rollouts
rollout_model = RolloutPolicy(model, obs_normalization_stats=obs_normalization_stats)
num_episodes = config.experiment.rollout.n
all_rollout_logs, video_paths = TrainUtils.rollout_with_stats(
policy=rollout_model,
envs=envs,
horizon=config.experiment.rollout.horizon,
use_goals=config.use_goals,
num_episodes=num_episodes,
render=False,
video_dir=video_dir if config.experiment.render_video else None,
epoch=epoch,
video_skip=config.experiment.get("video_skip", 5),
terminate_on_success=config.experiment.rollout.terminate_on_success,
)
# summarize results from rollouts to tensorboard and terminal
for env_name in all_rollout_logs:
rollout_logs = all_rollout_logs[env_name]
for k, v in rollout_logs.items():
if k.startswith("Time_"):
data_logger.record(f"Timing_Stats/Rollout_{env_name}_{k[5:]}", v, epoch)
else:
data_logger.record(f"Rollout/{k}/{env_name}", v, epoch, log_stats=True)
print("\nEpoch {} Rollouts took {}s (avg) with results:".format(epoch, rollout_logs["time"]))
print(f"Env: {env_name}")
print(json.dumps(rollout_logs, sort_keys=True, indent=4))
# checkpoint and video saving logic
updated_stats = TrainUtils.should_save_from_rollout_logs(
all_rollout_logs=all_rollout_logs,
best_return=best_return,
best_success_rate=best_success_rate,
epoch_ckpt_name=epoch_ckpt_name,
save_on_best_rollout_return=config.experiment.save.on_best_rollout_return,
save_on_best_rollout_success_rate=config.experiment.save.on_best_rollout_success_rate,
)
best_return = updated_stats["best_return"]
best_success_rate = updated_stats["best_success_rate"]
epoch_ckpt_name = updated_stats["epoch_ckpt_name"]
should_save_ckpt = (
config.experiment.save.enabled and updated_stats["should_save_ckpt"]
) or should_save_ckpt
if updated_stats["ckpt_reason"] is not None:
ckpt_reason = updated_stats["ckpt_reason"]
# Only keep saved videos if the ckpt should be saved (but not because of validation score)
should_save_video = (should_save_ckpt and (ckpt_reason != "valid")) or config.experiment.keep_all_videos
if video_paths is not None and not should_save_video:
for env_name in video_paths:
os.remove(video_paths[env_name])
# Save model checkpoints based on conditions (success rate, validation loss, etc)
if should_save_ckpt:
TrainUtils.save_model(
model=model,
config=config,
env_meta=env_meta,
shape_meta=shape_meta,
ckpt_path=os.path.join(ckpt_dir, epoch_ckpt_name + ".pth"),
obs_normalization_stats=obs_normalization_stats,
)
# Finally, log memory usage in MB
process = psutil.Process(os.getpid())
mem_usage = int(process.memory_info().rss / 1000000)
data_logger.record("System/RAM Usage (MB)", mem_usage, epoch)
print(f"\nEpoch {epoch} Memory Usage: {mem_usage} MB\n")
# terminate logging
data_logger.close()
def main(args):
"""Train a model on a task using a specified algorithm."""
# load config
if args.task is not None:
# obtain the configuration entry point
cfg_entry_point_key = f"robomimic_{args.algo}_cfg_entry_point"
print(f"Loading configuration for task: {args.task}")
cfg_entry_point_file = gym.spec(args.task).kwargs.pop(cfg_entry_point_key)
# check if entry point exists
if cfg_entry_point_file is None:
raise ValueError(
f"Could not find configuration for the environment: '{args.task}'."
f" Please check that the gym registry has the entry point: '{cfg_entry_point_key}'."
)
# load config from json file
with open(cfg_entry_point_file) as f:
ext_cfg = json.load(f)
config = config_factory(ext_cfg["algo_name"])
# update config with external json - this will throw errors if
# the external config has keys not present in the base algo config
with config.values_unlocked():
config.update(ext_cfg)
else:
raise ValueError("Please provide a task name through CLI arguments.")
if args.dataset is not None:
config.train.data = args.dataset
if args.name is not None:
config.experiment.name = args.name
# change location of experiment directory
config.train.output_dir = os.path.abspath(os.path.join("./logs/robomimic", args.task))
# get torch device
device = TorchUtils.get_torch_device(try_to_use_cuda=config.train.cuda)
config.lock()
# catch error during training and print it
res_str = "finished run successfully!"
try:
train(config, device=device)
except Exception as e:
res_str = f"run failed with error:\n{e}\n\n{traceback.format_exc()}"
print(res_str)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
# Experiment Name (for tensorboard, saving models, etc.)
parser.add_argument(
"--name",
type=str,
default=None,
help="(optional) if provided, override the experiment name defined in the config",
)
# Dataset path, to override the one in the config
parser.add_argument(
"--dataset",
type=str,
default=None,
help="(optional) if provided, override the dataset path defined in the config",
)
parser.add_argument("--task", type=str, default=None, help="Name of the task.")
parser.add_argument("--algo", type=str, default=None, help="Name of the algorithm.")
args = parser.parse_args()
# run training
main(args)
# close sim app
simulation_app.close()
| 16,901 | Python | 38.957447 | 118 | 0.633809 |
NVIDIA-Omniverse/orbit/source/standalone/workflows/robomimic/tools/episode_merging.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Tool to merge multiple episodes with single trajectory into one episode with multiple trajectories."""
from __future__ import annotations
import argparse
import h5py
import json
import os
if __name__ == "__main__":
# parse arguments
parser = argparse.ArgumentParser(description="Merge multiple episodes with single trajectory into one episode.")
parser.add_argument(
"--dir", type=str, default=None, help="Path to directory that contains all single episode hdf5 files"
)
parser.add_argument("--task", type=str, default=None, help="Name of the task.")
parser.add_argument("--out", type=str, default="merged_dataset.hdf5", help="output hdf5 file")
args_cli = parser.parse_args()
# read arguments
parent_dir = args_cli.dir
merged_dataset_name = args_cli.out
task_name = args_cli.task
# check valid task name
if task_name is None:
raise ValueError("Please specify a valid task name.")
# get hdf5 entries from specified directory
entries = [i for i in os.listdir(parent_dir) if i.endswith(".hdf5")]
# create new hdf5 file for merging episodes
fp = h5py.File(parent_dir + merged_dataset_name, "a")
# initiate data group
f_grp = fp.create_group("data")
f_grp.attrs["num_samples"] = 0
# merge all episodes
for count, entry in enumerate(entries):
fc = h5py.File(parent_dir + entry, "r")
# find total number of samples in all demos
f_grp.attrs["num_samples"] = f_grp.attrs["num_samples"] + fc["data"]["demo_0"].attrs["num_samples"]
fc.copy("data/demo_0", fp["data"], "demo_" + str(count))
# This is needed to run env in robomimic
fp["data"].attrs["env_args"] = json.dumps({"env_name": task_name, "type": 2, "env_kwargs": {}})
fp.close()
print("merged")
| 1,934 | Python | 32.362068 | 116 | 0.661324 |
NVIDIA-Omniverse/orbit/source/standalone/workflows/robomimic/tools/inspect_demonstrations.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Tool to check structure of hdf5 files."""
from __future__ import annotations
import argparse
import h5py
def check_group(f, num: int):
"""Print the data from different keys in stored dictionary."""
# print name of the group first
for subs in f:
if isinstance(subs, str):
print("\t" * num, subs, ":", type(f[subs]))
check_group(f[subs], num + 1)
# print attributes of the group
print("\t" * num, "attributes", ":")
for attr in f.attrs:
print("\t" * (num + 1), attr, ":", type(f.attrs[attr]), ":", f.attrs[attr])
if __name__ == "__main__":
# parse arguments
parser = argparse.ArgumentParser(description="Check structure of hdf5 file.")
parser.add_argument("file", type=str, default=None, help="The path to HDF5 file to analyze.")
args_cli = parser.parse_args()
# open specified file
with h5py.File(args_cli.file, "r") as f:
# print name of the file first
print(f)
# print contents of file
check_group(f["data"], 1)
| 1,166 | Python | 28.923076 | 97 | 0.614923 |
NVIDIA-Omniverse/orbit/source/standalone/workflows/robomimic/tools/split_train_val.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
# MIT License
#
# Copyright (c) 2021 Stanford Vision and Learning Lab
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
"""
Script for splitting a dataset hdf5 file into training and validation trajectories.
Args:
dataset: path to hdf5 dataset
filter_key: if provided, split the subset of trajectories
in the file that correspond to this filter key into a training
and validation set of trajectories, instead of splitting the
full set of trajectories
ratio: validation ratio, in (0, 1). Defaults to 0.1, which is 10%.
Example usage:
python split_train_val.py --dataset /path/to/demo.hdf5 --ratio 0.1
"""
from __future__ import annotations
import argparse
import h5py
import numpy as np
from robomimic.utils.file_utils import create_hdf5_filter_key
def split_train_val_from_hdf5(hdf5_path: str, val_ratio=0.1, filter_key=None):
"""
Splits data into training set and validation set from HDF5 file.
Args:
hdf5_path: path to the hdf5 file to load the transitions from
val_ratio: ratio of validation demonstrations to all demonstrations
filter_key: if provided, split the subset of demonstration keys stored
under mask/@filter_key instead of the full set of demonstrations
"""
# retrieve number of demos
f = h5py.File(hdf5_path, "r")
if filter_key is not None:
print(f"Using filter key: {filter_key}")
demos = sorted(elem.decode("utf-8") for elem in np.array(f[f"mask/{filter_key}"]))
else:
demos = sorted(list(f["data"].keys()))
num_demos = len(demos)
f.close()
# get random split
num_demos = len(demos)
num_val = int(val_ratio * num_demos)
mask = np.zeros(num_demos)
mask[:num_val] = 1.0
np.random.shuffle(mask)
mask = mask.astype(int)
train_inds = (1 - mask).nonzero()[0]
valid_inds = mask.nonzero()[0]
train_keys = [demos[i] for i in train_inds]
valid_keys = [demos[i] for i in valid_inds]
print(f"{num_val} validation demonstrations out of {num_demos} total demonstrations.")
# pass mask to generate split
name_1 = "train"
name_2 = "valid"
if filter_key is not None:
name_1 = f"{filter_key}_{name_1}"
name_2 = f"{filter_key}_{name_2}"
train_lengths = create_hdf5_filter_key(hdf5_path=hdf5_path, demo_keys=train_keys, key_name=name_1)
valid_lengths = create_hdf5_filter_key(hdf5_path=hdf5_path, demo_keys=valid_keys, key_name=name_2)
print(f"Total number of train samples: {np.sum(train_lengths)}")
print(f"Average number of train samples {np.mean(train_lengths)}")
print(f"Total number of valid samples: {np.sum(valid_lengths)}")
print(f"Average number of valid samples {np.mean(valid_lengths)}")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("dataset", type=str, help="path to hdf5 dataset")
parser.add_argument(
"--filter_key",
type=str,
default=None,
help=(
"If provided, split the subset of trajectories in the file that correspond to this filter key"
" into a training and validation set of trajectories, instead of splitting the full set of"
" trajectories."
),
)
parser.add_argument("--ratio", type=float, default=0.1, help="validation ratio, in (0, 1)")
args = parser.parse_args()
# seed to make sure results are consistent
np.random.seed(0)
split_train_val_from_hdf5(args.dataset, val_ratio=args.ratio, filter_key=args.filter_key)
| 4,685 | Python | 36.190476 | 106 | 0.690288 |
NVIDIA-Omniverse/orbit/source/standalone/workflows/sb3/play.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Script to play a checkpoint if an RL agent from Stable-Baselines3."""
from __future__ import annotations
"""Launch Isaac Sim Simulator first."""
import argparse
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser(description="Play a checkpoint of an RL agent from Stable-Baselines3.")
parser.add_argument("--cpu", action="store_true", default=False, help="Use CPU pipeline.")
parser.add_argument(
"--disable_fabric", action="store_true", default=False, help="Disable fabric and use USD I/O operations."
)
parser.add_argument("--num_envs", type=int, default=None, help="Number of environments to simulate.")
parser.add_argument("--task", type=str, default=None, help="Name of the task.")
parser.add_argument("--checkpoint", type=str, default=None, help="Path to model checkpoint.")
parser.add_argument(
"--use_last_checkpoint",
action="store_true",
help="When no checkpoint provided, use the last saved model. Otherwise use the best saved model.",
)
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()
# launch omniverse app
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app
"""Rest everything follows."""
import gymnasium as gym
import numpy as np
import os
import torch
from stable_baselines3 import PPO
from stable_baselines3.common.vec_env import VecNormalize
import omni.isaac.orbit_tasks # noqa: F401
from omni.isaac.orbit_tasks.utils.parse_cfg import get_checkpoint_path, load_cfg_from_registry, parse_env_cfg
from omni.isaac.orbit_tasks.utils.wrappers.sb3 import Sb3VecEnvWrapper, process_sb3_cfg
def main():
"""Play with stable-baselines agent."""
# parse configuration
env_cfg = parse_env_cfg(
args_cli.task, use_gpu=not args_cli.cpu, num_envs=args_cli.num_envs, use_fabric=not args_cli.disable_fabric
)
agent_cfg = load_cfg_from_registry(args_cli.task, "sb3_cfg_entry_point")
# post-process agent configuration
agent_cfg = process_sb3_cfg(agent_cfg)
# create isaac environment
env = gym.make(args_cli.task, cfg=env_cfg)
# wrap around environment for stable baselines
env = Sb3VecEnvWrapper(env)
# normalize environment (if needed)
if "normalize_input" in agent_cfg:
env = VecNormalize(
env,
training=True,
norm_obs="normalize_input" in agent_cfg and agent_cfg.pop("normalize_input"),
norm_reward="normalize_value" in agent_cfg and agent_cfg.pop("normalize_value"),
clip_obs="clip_obs" in agent_cfg and agent_cfg.pop("clip_obs"),
gamma=agent_cfg["gamma"],
clip_reward=np.inf,
)
# directory for logging into
log_root_path = os.path.join("logs", "sb3", args_cli.task)
log_root_path = os.path.abspath(log_root_path)
# check checkpoint is valid
if args_cli.checkpoint is None:
if args_cli.use_last_checkpoint:
checkpoint = "model_.*.zip"
else:
checkpoint = "model.zip"
checkpoint_path = get_checkpoint_path(log_root_path, ".*", checkpoint)
else:
checkpoint_path = args_cli.checkpoint
# create agent from stable baselines
print(f"Loading checkpoint from: {checkpoint_path}")
agent = PPO.load(checkpoint_path, env, print_system_info=True)
# reset environment
obs = env.reset()
# simulate environment
while simulation_app.is_running():
# run everything in inference mode
with torch.inference_mode():
# agent stepping
actions, _ = agent.predict(obs, deterministic=True)
# env stepping
obs, _, _, _ = env.step(actions)
# close the simulator
env.close()
if __name__ == "__main__":
# run the main function
main()
# close sim app
simulation_app.close()
| 4,014 | Python | 33.025423 | 115 | 0.680867 |
NVIDIA-Omniverse/orbit/source/standalone/workflows/sb3/train.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Script to train RL agent with Stable Baselines3.
Since Stable-Baselines3 does not support buffers living on GPU directly,
we recommend using smaller number of environments. Otherwise,
there will be significant overhead in GPU->CPU transfer.
"""
from __future__ import annotations
"""Launch Isaac Sim Simulator first."""
import argparse
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser(description="Train an RL agent with Stable-Baselines3.")
parser.add_argument("--video", action="store_true", default=False, help="Record videos during training.")
parser.add_argument("--video_length", type=int, default=200, help="Length of the recorded video (in steps).")
parser.add_argument("--video_interval", type=int, default=2000, help="Interval between video recordings (in steps).")
parser.add_argument("--cpu", action="store_true", default=False, help="Use CPU pipeline.")
parser.add_argument(
"--disable_fabric", action="store_true", default=False, help="Disable fabric and use USD I/O operations."
)
parser.add_argument("--num_envs", type=int, default=None, help="Number of environments to simulate.")
parser.add_argument("--task", type=str, default=None, help="Name of the task.")
parser.add_argument("--seed", type=int, default=None, help="Seed used for the environment")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()
# launch omniverse app
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app
"""Rest everything follows."""
import gymnasium as gym
import numpy as np
import os
from datetime import datetime
from stable_baselines3 import PPO
from stable_baselines3.common.callbacks import CheckpointCallback
from stable_baselines3.common.logger import configure
from stable_baselines3.common.vec_env import VecNormalize
from omni.isaac.orbit.utils.dict import print_dict
from omni.isaac.orbit.utils.io import dump_pickle, dump_yaml
import omni.isaac.orbit_tasks # noqa: F401
from omni.isaac.orbit_tasks.utils import load_cfg_from_registry, parse_env_cfg
from omni.isaac.orbit_tasks.utils.wrappers.sb3 import Sb3VecEnvWrapper, process_sb3_cfg
def main():
"""Train with stable-baselines agent."""
# parse configuration
env_cfg = parse_env_cfg(
args_cli.task, use_gpu=not args_cli.cpu, num_envs=args_cli.num_envs, use_fabric=not args_cli.disable_fabric
)
agent_cfg = load_cfg_from_registry(args_cli.task, "sb3_cfg_entry_point")
# override configuration with command line arguments
if args_cli.seed is not None:
agent_cfg["seed"] = args_cli.seed
# directory for logging into
log_dir = os.path.join("logs", "sb3", args_cli.task, datetime.now().strftime("%Y-%m-%d_%H-%M-%S"))
# dump the configuration into log-directory
dump_yaml(os.path.join(log_dir, "params", "env.yaml"), env_cfg)
dump_yaml(os.path.join(log_dir, "params", "agent.yaml"), agent_cfg)
dump_pickle(os.path.join(log_dir, "params", "env.pkl"), env_cfg)
dump_pickle(os.path.join(log_dir, "params", "agent.pkl"), agent_cfg)
# post-process agent configuration
agent_cfg = process_sb3_cfg(agent_cfg)
# read configurations about the agent-training
policy_arch = agent_cfg.pop("policy")
n_timesteps = agent_cfg.pop("n_timesteps")
# create isaac environment
env = gym.make(args_cli.task, cfg=env_cfg, render_mode="rgb_array" if args_cli.video else None)
# wrap for video recording
if args_cli.video:
video_kwargs = {
"video_folder": os.path.join(log_dir, "videos"),
"step_trigger": lambda step: step % args_cli.video_interval == 0,
"video_length": args_cli.video_length,
"disable_logger": True,
}
print("[INFO] Recording videos during training.")
print_dict(video_kwargs, nesting=4)
env = gym.wrappers.RecordVideo(env, **video_kwargs)
# wrap around environment for stable baselines
env = Sb3VecEnvWrapper(env)
# set the seed
env.seed(seed=agent_cfg["seed"])
if "normalize_input" in agent_cfg:
env = VecNormalize(
env,
training=True,
norm_obs="normalize_input" in agent_cfg and agent_cfg.pop("normalize_input"),
norm_reward="normalize_value" in agent_cfg and agent_cfg.pop("normalize_value"),
clip_obs="clip_obs" in agent_cfg and agent_cfg.pop("clip_obs"),
gamma=agent_cfg["gamma"],
clip_reward=np.inf,
)
# create agent from stable baselines
agent = PPO(policy_arch, env, verbose=1, **agent_cfg)
# configure the logger
new_logger = configure(log_dir, ["stdout", "tensorboard"])
agent.set_logger(new_logger)
# callbacks for agent
checkpoint_callback = CheckpointCallback(save_freq=1000, save_path=log_dir, name_prefix="model", verbose=2)
# train the agent
agent.learn(total_timesteps=n_timesteps, callback=checkpoint_callback)
# save the final model
agent.save(os.path.join(log_dir, "model"))
# close the simulator
env.close()
if __name__ == "__main__":
# run the main function
main()
# close sim app
simulation_app.close()
| 5,362 | Python | 37.307143 | 117 | 0.696382 |
NVIDIA-Omniverse/orbit/source/standalone/workflows/rl_games/play.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Script to play a checkpoint if an RL agent from RL-Games."""
from __future__ import annotations
"""Launch Isaac Sim Simulator first."""
import argparse
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser(description="Play a checkpoint of an RL agent from RL-Games.")
parser.add_argument("--cpu", action="store_true", default=False, help="Use CPU pipeline.")
parser.add_argument(
"--disable_fabric", action="store_true", default=False, help="Disable fabric and use USD I/O operations."
)
parser.add_argument("--num_envs", type=int, default=None, help="Number of environments to simulate.")
parser.add_argument("--task", type=str, default=None, help="Name of the task.")
parser.add_argument("--checkpoint", type=str, default=None, help="Path to model checkpoint.")
parser.add_argument(
"--use_last_checkpoint",
action="store_true",
help="When no checkpoint provided, use the last saved model. Otherwise use the best saved model.",
)
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()
# launch omniverse app
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app
"""Rest everything follows."""
import gymnasium as gym
import math
import os
import torch
from rl_games.common import env_configurations, vecenv
from rl_games.common.player import BasePlayer
from rl_games.torch_runner import Runner
from omni.isaac.orbit.utils.assets import retrieve_file_path
import omni.isaac.orbit_tasks # noqa: F401
from omni.isaac.orbit_tasks.utils import get_checkpoint_path, load_cfg_from_registry, parse_env_cfg
from omni.isaac.orbit_tasks.utils.wrappers.rl_games import RlGamesGpuEnv, RlGamesVecEnvWrapper
def main():
"""Play with RL-Games agent."""
# parse env configuration
env_cfg = parse_env_cfg(
args_cli.task, use_gpu=not args_cli.cpu, num_envs=args_cli.num_envs, use_fabric=not args_cli.disable_fabric
)
agent_cfg = load_cfg_from_registry(args_cli.task, "rl_games_cfg_entry_point")
# wrap around environment for rl-games
rl_device = agent_cfg["params"]["config"]["device"]
clip_obs = agent_cfg["params"]["env"].get("clip_observations", math.inf)
clip_actions = agent_cfg["params"]["env"].get("clip_actions", math.inf)
# create isaac environment
env = gym.make(args_cli.task, cfg=env_cfg)
# wrap around environment for rl-games
env = RlGamesVecEnvWrapper(env, rl_device, clip_obs, clip_actions)
# register the environment to rl-games registry
# note: in agents configuration: environment name must be "rlgpu"
vecenv.register(
"IsaacRlgWrapper", lambda config_name, num_actors, **kwargs: RlGamesGpuEnv(config_name, num_actors, **kwargs)
)
env_configurations.register("rlgpu", {"vecenv_type": "IsaacRlgWrapper", "env_creator": lambda **kwargs: env})
# specify directory for logging experiments
log_root_path = os.path.join("logs", "rl_games", agent_cfg["params"]["config"]["name"])
log_root_path = os.path.abspath(log_root_path)
print(f"[INFO] Loading experiment from directory: {log_root_path}")
# find checkpoint
if args_cli.checkpoint is None:
# specify directory for logging runs
run_dir = agent_cfg["params"]["config"].get("full_experiment_name", ".*")
# specify name of checkpoint
if args_cli.use_last_checkpoint:
checkpoint_file = ".*"
else:
# this loads the best checkpoint
checkpoint_file = f"{agent_cfg['params']['config']['name']}.pth"
# get path to previous checkpoint
resume_path = get_checkpoint_path(log_root_path, run_dir, checkpoint_file, other_dirs=["nn"])
else:
resume_path = retrieve_file_path(args_cli.checkpoint)
# load previously trained model
agent_cfg["params"]["load_checkpoint"] = True
agent_cfg["params"]["load_path"] = resume_path
print(f"[INFO]: Loading model checkpoint from: {agent_cfg['params']['load_path']}")
# set number of actors into agent config
agent_cfg["params"]["config"]["num_actors"] = env.unwrapped.num_envs
# create runner from rl-games
runner = Runner()
runner.load(agent_cfg)
# obtain the agent from the runner
agent: BasePlayer = runner.create_player()
agent.restore(resume_path)
agent.reset()
# reset environment
obs = env.reset()
# required: enables the flag for batched observations
_ = agent.get_batch_size(obs, 1)
# simulate environment
# note: We simplified the logic in rl-games player.py (:func:`BasePlayer.run()`) function in an
# attempt to have complete control over environment stepping. However, this removes other
# operations such as masking that is used for multi-agent learning by RL-Games.
while simulation_app.is_running():
# run everything in inference mode
with torch.inference_mode():
# convert obs to agent format
obs = agent.obs_to_torch(obs)
# agent stepping
actions = agent.get_action(obs, is_deterministic=True)
# env stepping
obs, _, dones, _ = env.step(actions)
# perform operations for terminated episodes
if len(dones) > 0:
# reset rnn state for terminated episodes
if agent.is_rnn and agent.states is not None:
for s in agent.states:
s[:, dones, :] = 0.0
# close the simulator
env.close()
if __name__ == "__main__":
# run the main function
main()
# close sim app
simulation_app.close()
| 5,785 | Python | 37.573333 | 117 | 0.676059 |
NVIDIA-Omniverse/orbit/source/standalone/workflows/rl_games/train.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Script to train RL agent with RL-Games."""
from __future__ import annotations
"""Launch Isaac Sim Simulator first."""
import argparse
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser(description="Train an RL agent with RL-Games.")
parser.add_argument("--video", action="store_true", default=False, help="Record videos during training.")
parser.add_argument("--video_length", type=int, default=200, help="Length of the recorded video (in steps).")
parser.add_argument("--video_interval", type=int, default=2000, help="Interval between video recordings (in steps).")
parser.add_argument("--cpu", action="store_true", default=False, help="Use CPU pipeline.")
parser.add_argument(
"--disable_fabric", action="store_true", default=False, help="Disable fabric and use USD I/O operations."
)
parser.add_argument("--num_envs", type=int, default=None, help="Number of environments to simulate.")
parser.add_argument("--task", type=str, default=None, help="Name of the task.")
parser.add_argument("--seed", type=int, default=None, help="Seed used for the environment")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()
# launch omniverse app
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app
"""Rest everything follows."""
import gymnasium as gym
import math
import os
from datetime import datetime
from rl_games.common import env_configurations, vecenv
from rl_games.common.algo_observer import IsaacAlgoObserver
from rl_games.torch_runner import Runner
from omni.isaac.orbit.utils.dict import print_dict
from omni.isaac.orbit.utils.io import dump_pickle, dump_yaml
import omni.isaac.orbit_tasks # noqa: F401
from omni.isaac.orbit_tasks.utils import load_cfg_from_registry, parse_env_cfg
from omni.isaac.orbit_tasks.utils.wrappers.rl_games import RlGamesGpuEnv, RlGamesVecEnvWrapper
def main():
"""Train with RL-Games agent."""
# parse seed from command line
args_cli_seed = args_cli.seed
# parse configuration
env_cfg = parse_env_cfg(
args_cli.task, use_gpu=not args_cli.cpu, num_envs=args_cli.num_envs, use_fabric=not args_cli.disable_fabric
)
agent_cfg = load_cfg_from_registry(args_cli.task, "rl_games_cfg_entry_point")
# override from command line
if args_cli_seed is not None:
agent_cfg["params"]["seed"] = args_cli_seed
# specify directory for logging experiments
log_root_path = os.path.join("logs", "rl_games", agent_cfg["params"]["config"]["name"])
log_root_path = os.path.abspath(log_root_path)
print(f"[INFO] Logging experiment in directory: {log_root_path}")
# specify directory for logging runs
log_dir = agent_cfg["params"]["config"].get("full_experiment_name", datetime.now().strftime("%Y-%m-%d_%H-%M-%S"))
# set directory into agent config
# logging directory path: <train_dir>/<full_experiment_name>
agent_cfg["params"]["config"]["train_dir"] = log_root_path
agent_cfg["params"]["config"]["full_experiment_name"] = log_dir
# dump the configuration into log-directory
dump_yaml(os.path.join(log_root_path, log_dir, "params", "env.yaml"), env_cfg)
dump_yaml(os.path.join(log_root_path, log_dir, "params", "agent.yaml"), agent_cfg)
dump_pickle(os.path.join(log_root_path, log_dir, "params", "env.pkl"), env_cfg)
dump_pickle(os.path.join(log_root_path, log_dir, "params", "agent.pkl"), agent_cfg)
# read configurations about the agent-training
rl_device = agent_cfg["params"]["config"]["device"]
clip_obs = agent_cfg["params"]["env"].get("clip_observations", math.inf)
clip_actions = agent_cfg["params"]["env"].get("clip_actions", math.inf)
# create isaac environment
env = gym.make(args_cli.task, cfg=env_cfg, render_mode="rgb_array" if args_cli.video else None)
# wrap for video recording
if args_cli.video:
video_kwargs = {
"video_folder": os.path.join(log_dir, "videos"),
"step_trigger": lambda step: step % args_cli.video_interval == 0,
"video_length": args_cli.video_length,
"disable_logger": True,
}
print("[INFO] Recording videos during training.")
print_dict(video_kwargs, nesting=4)
env = gym.wrappers.RecordVideo(env, **video_kwargs)
# wrap around environment for rl-games
env = RlGamesVecEnvWrapper(env, rl_device, clip_obs, clip_actions)
# register the environment to rl-games registry
# note: in agents configuration: environment name must be "rlgpu"
vecenv.register(
"IsaacRlgWrapper", lambda config_name, num_actors, **kwargs: RlGamesGpuEnv(config_name, num_actors, **kwargs)
)
env_configurations.register("rlgpu", {"vecenv_type": "IsaacRlgWrapper", "env_creator": lambda **kwargs: env})
# set number of actors into agent config
agent_cfg["params"]["config"]["num_actors"] = env.unwrapped.num_envs
# create runner from rl-games
runner = Runner(IsaacAlgoObserver())
runner.load(agent_cfg)
# set seed of the env
env.seed(agent_cfg["params"]["seed"])
# reset the agent and env
runner.reset()
# train the agent
runner.run({"train": True, "play": False, "sigma": None})
# close the simulator
env.close()
if __name__ == "__main__":
# run the main function
main()
# close sim app
simulation_app.close()
| 5,558 | Python | 39.576642 | 117 | 0.692155 |
NVIDIA-Omniverse/orbit/docker/docker-compose.yaml | # Here we set the parts that would
# be re-used between services to an
# extension field
# https://docs.docker.com/compose/compose-file/compose-file-v3/#extension-fields
x-default-orbit-volumes:
&default-orbit-volumes
# These volumes follow from this page
# https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/install_faq.html#save-isaac-sim-configs-on-local-disk
- type: volume
source: isaac-cache-kit
target: ${DOCKER_ISAACSIM_ROOT_PATH}/kit/cache
- type: volume
source: isaac-cache-ov
target: ${DOCKER_USER_HOME}/.cache/ov
- type: volume
source: isaac-cache-pip
target: ${DOCKER_USER_HOME}/.cache/pip
- type: volume
source: isaac-cache-gl
target: ${DOCKER_USER_HOME}/.cache/nvidia/GLCache
- type: volume
source: isaac-cache-compute
target: ${DOCKER_USER_HOME}/.nv/ComputeCache
- type: volume
source: isaac-logs
target: ${DOCKER_USER_HOME}/.nvidia-omniverse/logs
- type: volume
source: isaac-carb-logs
target: ${DOCKER_ISAACSIM_ROOT_PATH}/kit/logs/Kit/Isaac-Sim
- type: volume
source: isaac-data
target: ${DOCKER_USER_HOME}/.local/share/ov/data
- type: volume
source: isaac-docs
target: ${DOCKER_USER_HOME}/Documents
# These volumes allow X11 Forwarding
# We currently comment these out because they can
# cause bugs and warnings for people uninterested in
# X11 Forwarding from within the docker. We keep them
# as comments as a convenience for those seeking X11
# forwarding until a scripted solution is developed
# - type: bind
# source: /tmp/.X11-unix
# target: /tmp/.X11-unix
# - type: bind
# source: ${HOME}/.Xauthority
# target: ${DOCKER_USER_HOME}/.Xauthority
# This overlay allows changes on the local files to
# be reflected within the container immediately
- type: bind
source: ../source
target: /workspace/orbit/source
- type: bind
source: ../docs
target: /workspace/orbit/docs
# The effect of these volumes is twofold:
# 1. Prevent root-owned files from flooding the _build and logs dir
# on the host machine
# 2. Preserve the artifacts in persistent volumes for later copying
# to the host machine
- type: volume
source: orbit-docs
target: /workspace/orbit/docs/_build
- type: volume
source: orbit-logs
target: /workspace/orbit/logs
- type: volume
source: orbit-data
target: /workspace/orbit/data_storage
x-default-orbit-deploy:
&default-orbit-deploy
resources:
reservations:
devices:
- driver: nvidia
count: all
capabilities: [ gpu ]
services:
# This service is the base Orbit image
orbit-base:
profiles: ["base"]
env_file: .env.base
build:
context: ../
dockerfile: docker/Dockerfile.base
args:
- ISAACSIM_VERSION=${ISAACSIM_VERSION}
- ISAACSIM_ROOT_PATH=${DOCKER_ISAACSIM_ROOT_PATH}
- ORBIT_PATH=${DOCKER_ORBIT_PATH}
- DOCKER_USER_HOME=${DOCKER_USER_HOME}
image: orbit-base
container_name: orbit-base
environment:
# We can't just define this in the .env file because shell envars take precedence
# https://docs.docker.com/compose/environment-variables/envvars-precedence/
- ISAACSIM_PATH=${DOCKER_ORBIT_PATH}/_isaac_sim
- ORBIT_PATH=${DOCKER_ORBIT_PATH}
# This should also be enabled for X11 forwarding
# - DISPLAY=${DISPLAY}
volumes: *default-orbit-volumes
network_mode: host
deploy: *default-orbit-deploy
# This is the entrypoint for the container
entrypoint: bash
stdin_open: true
tty: true
# This service adds a ROS2 Humble
# installation on top of the base image
orbit-ros2:
profiles: ["ros2"]
env_file:
- .env.base
- .env.ros2
build:
context: ../
dockerfile: docker/Dockerfile.ros2
args:
# ROS2_APT_PACKAGE will default to NONE. This is to
# avoid a warning message when building only the base profile
# with the .env.base file
- ROS2_APT_PACKAGE=${ROS2_APT_PACKAGE:-NONE}
- DOCKER_USER_HOME=${DOCKER_USER_HOME}
image: orbit-ros2
container_name: orbit-ros2
environment:
- ISAACSIM_PATH=${DOCKER_ORBIT_PATH}/_isaac_sim
- ORBIT_PATH=${DOCKER_ORBIT_PATH}
volumes: *default-orbit-volumes
network_mode: host
deploy: *default-orbit-deploy
# This is the entrypoint for the container
entrypoint: bash
stdin_open: true
tty: true
volumes:
# isaac-sim
isaac-cache-kit:
isaac-cache-ov:
isaac-cache-pip:
isaac-cache-gl:
isaac-cache-compute:
isaac-logs:
isaac-carb-logs:
isaac-data:
isaac-docs:
# orbit
orbit-docs:
orbit-logs:
orbit-data:
| 4,881 | YAML | 30.701299 | 119 | 0.646589 |
NVIDIA-Omniverse/orbit/docs/README.md | # Building Documentation
We use [Sphinx](https://www.sphinx-doc.org/en/master/) with the [Book Theme](https://sphinx-book-theme.readthedocs.io/en/stable/) for maintaining the documentation.
> **Note:** To build the documentation, we recommend creating a virtual environment to avoid any conflicts with system installed dependencies.
Execute the following instructions to build the documentation (assumed from the top of the repository):
1. Install the dependencies for [Sphinx](https://www.sphinx-doc.org/en/master/):
```bash
# enter the location where this readme exists
cd docs
# install dependencies
pip install -r requirements.txt
```
2. Generate the documentation file via:
```bash
# make the html version
make html
```
3. The documentation is now available at `docs/_build/html/index.html`:
```bash
# open on default browser
xdg-open _build/html/index.html
```
| 932 | Markdown | 29.096773 | 164 | 0.714592 |
NVIDIA-Omniverse/orbit/docs/index.rst | Overview
========
**Orbit** is a unified and modular framework for robot learning that aims to simplify common workflows
in robotics research (such as RL, learning from demonstrations, and motion planning). It is built upon
`NVIDIA Isaac Sim`_ to leverage the latest simulation capabilities for photo-realistic scenes, and fast
and efficient simulation. The core objectives of the framework are:
- **Modularity**: Easily customize and add new environments, robots, and sensors.
- **Agility**: Adapt to the changing needs of the community.
- **Openness**: Remain open-sourced to allow the community to contribute and extend the framework.
- **Battery-included**: Include a number of environments, sensors, and tasks that are ready to use.
For more information about the framework, please refer to the `paper <https://arxiv.org/abs/2301.04195>`_
:cite:`mittal2023orbit`. For clarifications on NVIDIA Isaac ecosystem, please check out the
:doc:`/source/setup/faq` section.
.. figure:: source/_static/tasks.jpg
:width: 100%
:alt: Example tasks created using orbit
Citing
======
If you use Orbit in your research, please use the following BibTeX entry:
.. code:: bibtex
@article{mittal2023orbit,
author={Mittal, Mayank and Yu, Calvin and Yu, Qinxi and Liu, Jingzhou and Rudin, Nikita and Hoeller, David and Yuan, Jia Lin and Singh, Ritvik and Guo, Yunrong and Mazhar, Hammad and Mandlekar, Ajay and Babich, Buck and State, Gavriel and Hutter, Marco and Garg, Animesh},
journal={IEEE Robotics and Automation Letters},
title={Orbit: A Unified Simulation Framework for Interactive Robot Learning Environments},
year={2023},
volume={8},
number={6},
pages={3740-3747},
doi={10.1109/LRA.2023.3270034}
}
License
=======
NVIDIA Isaac Sim is provided under the NVIDIA End User License Agreement. However, the
Orbit framework is open-sourced under the BSD-3-Clause license.
Please refer to :ref:`license` for more details.
Table of Contents
=================
.. toctree::
:maxdepth: 2
:caption: Getting Started
source/setup/installation
source/setup/developer
source/setup/sample
source/setup/template
source/setup/faq
.. toctree::
:maxdepth: 2
:caption: Features
source/features/environments
source/features/actuators
.. source/features/motion_generators
.. toctree::
:maxdepth: 1
:caption: Resources
:titlesonly:
source/tutorials/index
source/how-to/index
source/deployment/index
.. toctree::
:maxdepth: 1
:caption: Source API
source/api/index
.. toctree::
:maxdepth: 1
:caption: References
source/refs/migration
source/refs/contributing
source/refs/troubleshooting
source/refs/issues
source/refs/changelog
source/refs/license
source/refs/bibliography
.. toctree::
:hidden:
:caption: Project Links
GitHub <https://github.com/NVIDIA-Omniverse/orbit>
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
.. _NVIDIA Isaac Sim: https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/overview.html
| 3,113 | reStructuredText | 26.803571 | 278 | 0.716672 |
NVIDIA-Omniverse/orbit/docs/conf.py | # Copyright (c) 2022-2024, The ORBIT Project Developers.
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath("../source/extensions/omni.isaac.orbit"))
sys.path.insert(0, os.path.abspath("../source/extensions/omni.isaac.orbit/omni/isaac/orbit"))
sys.path.insert(0, os.path.abspath("../source/extensions/omni.isaac.orbit_tasks"))
sys.path.insert(0, os.path.abspath("../source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks"))
# -- Project information -----------------------------------------------------
project = "orbit"
copyright = "2022-2024, The ORBIT Project Developers."
author = "The ORBIT Project Developers."
version = "0.2.0"
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"autodocsumm",
"myst_parser",
"sphinx.ext.napoleon",
"sphinxemoji.sphinxemoji",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.githubpages",
"sphinx.ext.intersphinx",
"sphinx.ext.mathjax",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"sphinxcontrib.bibtex",
"sphinx_copybutton",
"sphinx_design",
]
# mathjax hacks
mathjax3_config = {
"tex": {
"inlineMath": [["\\(", "\\)"]],
"displayMath": [["\\[", "\\]"]],
},
}
# panels hacks
panels_add_bootstrap_css = False
panels_add_fontawesome_css = True
# supported file extensions for source files
source_suffix = {
".rst": "restructuredtext",
".md": "markdown",
}
# make sure we don't have any unknown references
# TODO: Enable this by default once we have fixed all the warnings
# nitpicky = True
# put type hints inside the signature instead of the description (easier to maintain)
autodoc_typehints = "signature"
# autodoc_typehints_format = "fully-qualified"
# document class *and* __init__ methods
autoclass_content = "class" #
# separate class docstring from __init__ docstring
autodoc_class_signature = "separated"
# sort members by source order
autodoc_member_order = "bysource"
# inherit docstrings from base classes
autodoc_inherit_docstrings = True
# BibTeX configuration
bibtex_bibfiles = ["source/_static/refs.bib"]
# generate autosummary even if no references
autosummary_generate = True
autosummary_generate_overwrite = False
# default autodoc settings
autodoc_default_options = {
"autosummary": True,
}
# generate links to the documentation of objects in external projects
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"numpy": ("https://numpy.org/doc/stable/", None),
"torch": ("https://pytorch.org/docs/stable/", None),
"isaac": ("https://docs.omniverse.nvidia.com/py/isaacsim", None),
"gymnasium": ("https://gymnasium.farama.org/", None),
"warp": ("https://nvidia.github.io/warp/", None),
}
# Add any paths that contain templates here, relative to this directory.
templates_path = []
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "README.md", "licenses/*"]
# Mock out modules that are not available on RTD
autodoc_mock_imports = [
"torch",
"numpy",
"matplotlib",
"scipy",
"carb",
"warp",
"pxr",
"omni.kit",
"omni.usd",
"omni.client",
"omni.physx",
"omni.physics",
"pxr.PhysxSchema",
"pxr.PhysicsSchemaTools",
"omni.replicator",
"omni.isaac.core",
"omni.isaac.kit",
"omni.isaac.cloner",
"omni.isaac.urdf",
"omni.isaac.version",
"omni.isaac.motion_generation",
"omni.isaac.ui",
"omni.syntheticdata",
"omni.timeline",
"omni.ui",
"gym",
"skrl",
"stable_baselines3",
"rsl_rl",
"rl_games",
"ray",
"h5py",
"hid",
"prettytable",
"tqdm",
"tensordict",
"trimesh",
"toml",
]
# List of zero or more Sphinx-specific warning categories to be squelched (i.e.,
# suppressed, ignored).
suppress_warnings = [
# FIXME: *THIS IS TERRIBLE.* Generally speaking, we do want Sphinx to inform
# us about cross-referencing failures. Remove this hack entirely after Sphinx
# resolves this open issue:
# https://github.com/sphinx-doc/sphinx/issues/4961
# Squelch mostly ignorable warnings resembling:
# WARNING: more than one target found for cross-reference 'TypeHint':
# beartype.door._doorcls.TypeHint, beartype.door.TypeHint
#
# Sphinx currently emits *MANY* of these warnings against our
# documentation. All of these warnings appear to be ignorable. Although we
# could explicitly squelch *SOME* of these warnings by canonicalizing
# relative to absolute references in docstrings, Sphinx emits still others
# of these warnings when parsing PEP-compliant type hints via static
# analysis. Since those hints are actual hints that *CANNOT* by definition
# by canonicalized, our only recourse is to squelch warnings altogether.
"ref.python",
]
# -- Internationalization ----------------------------------------------------
# specifying the natural language populates some key tags
language = "en"
# -- Options for HTML output -------------------------------------------------
import sphinx_book_theme
html_title = "orbit documentation"
html_theme_path = [sphinx_book_theme.get_html_theme_path()]
html_theme = "sphinx_book_theme"
html_favicon = "source/_static/favicon.ico"
html_show_copyright = True
html_show_sphinx = False
html_last_updated_fmt = "" # to reveal the build date in the pages meta
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["source/_static/css"]
html_css_files = ["custom.css"]
html_theme_options = {
"collapse_navigation": True,
"repository_url": "https://github.com/NVIDIA-Omniverse/Orbit",
"announcement": "We have now released v0.2.0! Please use the latest version for the best experience.",
"use_repository_button": True,
"use_issues_button": True,
"use_edit_page_button": True,
"show_toc_level": 1,
"use_sidenotes": True,
"logo": {
"text": "orbit documentation",
"image_light": "source/_static/NVIDIA-logo-white.png",
"image_dark": "source/_static/NVIDIA-logo-black.png",
},
"icon_links": [
{
"name": "GitHub",
"url": "https://github.com/NVIDIA-Omniverse/Orbit",
"icon": "fa-brands fa-square-github",
"type": "fontawesome",
},
{
"name": "Isaac Sim",
"url": "https://developer.nvidia.com/isaac-sim",
"icon": "https://img.shields.io/badge/IsaacSim-2023.1.1-silver.svg",
"type": "url",
},
{
"name": "Stars",
"url": "https://img.shields.io/github/stars/NVIDIA-Omniverse/Orbit?color=fedcba",
"icon": "https://img.shields.io/github/stars/NVIDIA-Omniverse/Orbit?color=fedcba",
"type": "url",
},
],
"icon_links_label": "Quick Links",
}
html_sidebars = {"**": ["navbar-logo.html", "icon-links.html", "search-field.html", "sbt-sidebar-nav.html"]}
# -- Advanced configuration -------------------------------------------------
def skip_member(app, what, name, obj, skip, options):
# List the names of the functions you want to skip here
exclusions = ["from_dict", "to_dict", "replace", "copy", "__post_init__"]
if name in exclusions:
return True
return None
def setup(app):
app.connect("autodoc-skip-member", skip_member)
| 8,492 | Python | 32.175781 | 108 | 0.644842 |
NVIDIA-Omniverse/orbit/docs/source/how-to/save_camera_output.rst | .. _how-to-save-images-and-3d-reprojection:
Saving rendered images and 3D re-projection
===========================================
.. currentmodule:: omni.isaac.orbit
This guide accompanied with the ``run_usd_camera.py`` script in the ``orbit/source/standalone/tutorials/04_sensors``
directory.
.. dropdown:: Code for run_usd_camera.py
:icon: code
.. literalinclude:: ../../../source/standalone/tutorials/04_sensors/run_usd_camera.py
:language: python
:emphasize-lines: 171-179, 229-247, 251-264
:linenos:
Saving using Replicator Basic Writer
------------------------------------
To save camera outputs, we use the basic write class from Omniverse Replicator. This class allows us to save the
images in a numpy format. For more information on the basic writer, please check the
`documentation <https://docs.omniverse.nvidia.com/extensions/latest/ext_replicator/writer_examples.html>`_.
.. literalinclude:: ../../../source/standalone/tutorials/04_sensors/run_usd_camera.py
:language: python
:start-at: rep_writer = rep.BasicWriter(
:end-before: # Camera positions, targets, orientations
While stepping the simulator, the images can be saved to the defined folder. Since the BasicWriter only supports
saving data using NumPy format, we first need to convert the PyTorch sensors to NumPy arrays before packing
them in a dictionary.
.. literalinclude:: ../../../source/standalone/tutorials/04_sensors/run_usd_camera.py
:language: python
:start-at: # Save images from camera at camera_index
:end-at: single_cam_info = camera.data.info[camera_index]
After this step, we can save the images using the BasicWriter.
.. literalinclude:: ../../../source/standalone/tutorials/04_sensors/run_usd_camera.py
:language: python
:start-at: # Pack data back into replicator format to save them using its writer
:end-at: rep_writer.write(rep_output)
Projection into 3D Space
------------------------
We include utilities to project the depth image into 3D Space. The re-projection operations are done using
PyTorch operations which allows faster computation.
.. code-block:: python
from omni.isaac.orbit.utils.math import transform_points, unproject_depth
# Pointcloud in world frame
points_3d_cam = unproject_depth(
camera.data.output["distance_to_image_plane"], camera.data.intrinsic_matrices
)
points_3d_world = transform_points(points_3d_cam, camera.data.pos_w, camera.data.quat_w_ros)
Alternately, we can use the :meth:`omni.isaac.orbit.sensors.camera.utils.create_pointcloud_from_depth` function
to create a point cloud from the depth image and transform it to the world frame.
.. literalinclude:: ../../../source/standalone/tutorials/04_sensors/run_usd_camera.py
:language: python
:start-at: # Derive pointcloud from camera at camera_index
:end-before: # In the first few steps, things are still being instanced and Camera.data
The resulting point cloud can be visualized using the :mod:`omni.isaac.debug_draw` extension from Isaac Sim.
This makes it easy to visualize the point cloud in the 3D space.
.. literalinclude:: ../../../source/standalone/tutorials/04_sensors/run_usd_camera.py
:language: python
:start-at: # In the first few steps, things are still being instanced and Camera.data
:end-at: pc_markers.visualize(translations=pointcloud)
Executing the script
--------------------
To run the accompanying script, execute the following command:
.. code-block:: bash
# Usage with saving and drawing
./orbit.sh -p source/standalone/tutorials/04_sensors/run_usd_camera.py --save --draw
# Usage with saving only in headless mode
./orbit.sh -p source/standalone/tutorials/04_sensors/run_usd_camera.py --save --headless --offscreen_render
The simulation should start, and you can observe different objects falling down. An output folder will be created
in the ``orbit/source/standalone/tutorials/04_sensors`` directory, where the images will be saved. Additionally,
you should see the point cloud in the 3D space drawn on the viewport.
To stop the simulation, close the window, press the ``STOP`` button in the UI, or use ``Ctrl+C`` in the terminal.
| 4,175 | reStructuredText | 39.543689 | 116 | 0.728383 |
NVIDIA-Omniverse/orbit/docs/source/how-to/wrap_rl_env.rst | .. _how-to-env-wrappers:
Wrapping environments
=====================
.. currentmodule:: omni.isaac.orbit
Environment wrappers are a way to modify the behavior of an environment without modifying the environment itself.
This can be used to apply functions to modify observations or rewards, record videos, enforce time limits, etc.
A detailed description of the API is available in the :class:`gymnasium.Wrapper` class.
At present, all RL environments inheriting from the :class:`~envs.RLTaskEnv` class
are compatible with :class:`gymnasium.Wrapper`, since the base class implements the :class:`gymnasium.Env` interface.
In order to wrap an environment, you need to first initialize the base environment. After that, you can
wrap it with as many wrappers as you want by calling ``env = wrapper(env, *args, **kwargs)`` repeatedly.
For example, here is how you would wrap an environment to enforce that reset is called before step or render:
.. code-block:: python
"""Launch Isaac Sim Simulator first."""
from omni.isaac.orbit.app import AppLauncher
# launch omniverse app in headless mode
app_launcher = AppLauncher(headless=True)
simulation_app = app_launcher.app
"""Rest everything follows."""
import gymnasium as gym
import omni.isaac.orbit_tasks # noqa: F401
from omni.isaac.orbit_tasks.utils import load_cfg_from_registry
# create base environment
cfg = load_cfg_from_registry("Isaac-Reach-Franka-v0", "env_cfg_entry_point")
env = gym.make("Isaac-Reach-Franka-v0", cfg=cfg)
# wrap environment to enforce that reset is called before step
env = gym.wrappers.OrderEnforcing(env)
Wrapper for recording videos
----------------------------
The :class:`gymnasium.wrappers.RecordVideo` wrapper can be used to record videos of the environment.
The wrapper takes a ``video_dir`` argument, which specifies where to save the videos. The videos are saved in
`mp4 <https://en.wikipedia.org/wiki/MP4_file_format>`__ format at specified intervals for specified
number of environment steps or episodes.
To use the wrapper, you need to first install ``ffmpeg``. On Ubuntu, you can install it by running:
.. code-block:: bash
sudo apt-get install ffmpeg
.. attention::
By default, when running an environment in headless mode, the Omniverse viewport is disabled. This is done to
improve performance by avoiding unnecessary rendering.
We notice the following performance in different rendering modes with the ``Isaac-Reach-Franka-v0`` environment
using an RTX 3090 GPU:
* No GUI execution without off-screen rendering enabled: ~65,000 FPS
* No GUI execution with off-screen enabled: ~57,000 FPS
* GUI execution with full rendering: ~13,000 FPS
The viewport camera used for rendering is the default camera in the scene called ``"/OmniverseKit_Persp"``.
The camera's pose and image resolution can be configured through the
:class:`~envs.ViewerCfg` class.
.. dropdown:: Default parameters of the ViewerCfg class:
:icon: code
.. literalinclude:: ../../../source/extensions/omni.isaac.orbit/omni/isaac/orbit/envs/base_env_cfg.py
:language: python
:pyobject: ViewerCfg
After adjusting the parameters, you can record videos by wrapping the environment with the
:class:`gymnasium.wrappers.RecordVideo` wrapper and enabling the off-screen rendering
flag. Additionally, you need to specify the render mode of the environment as ``"rgb_array"``.
As an example, the following code records a video of the ``Isaac-Reach-Franka-v0`` environment
for 200 steps, and saves it in the ``videos`` folder at a step interval of 1500 steps.
.. code:: python
"""Launch Isaac Sim Simulator first."""
from omni.isaac.orbit.app import AppLauncher
# launch omniverse app in headless mode with off-screen rendering
app_launcher = AppLauncher(headless=True, offscreen_render=True)
simulation_app = app_launcher.app
"""Rest everything follows."""
import gymnasium as gym
# adjust camera resolution and pose
env_cfg.viewer.resolution = (640, 480)
env_cfg.viewer.eye = (1.0, 1.0, 1.0)
env_cfg.viewer.lookat = (0.0, 0.0, 0.0)
# create isaac-env instance
# set render mode to rgb_array to obtain images on render calls
env = gym.make(task_name, cfg=env_cfg, render_mode="rgb_array")
# wrap for video recording
video_kwargs = {
"video_folder": "videos",
"step_trigger": lambda step: step % 1500 == 0,
"video_length": 200,
}
env = gym.wrappers.RecordVideo(env, **video_kwargs)
Wrapper for learning frameworks
-------------------------------
Every learning framework has its own API for interacting with environments. For example, the
`Stable-Baselines3`_ library uses the `gym.Env <https://gymnasium.farama.org/api/env/>`_
interface to interact with environments. However, libraries like `RL-Games`_ or `RSL-RL`_
use their own API for interfacing with a learning environments. Since there is no one-size-fits-all
solution, we do not base the :class:`~envs.RLTaskEnv` class on any particular learning framework's
environment definition. Instead, we implement wrappers to make it compatible with the learning
framework's environment definition.
As an example of how to use the RL task environment with Stable-Baselines3:
.. code:: python
from omni.isaac.orbit_tasks.utils.wrappers.sb3 import Sb3VecEnvWrapper
# create isaac-env instance
env = gym.make(task_name, cfg=env_cfg)
# wrap around environment for stable baselines
env = Sb3VecEnvWrapper(env)
.. caution::
Wrapping the environment with the respective learning framework's wrapper should happen in the end,
i.e. after all other wrappers have been applied. This is because the learning framework's wrapper
modifies the interpretation of environment's APIs which may no longer be compatible with :class:`gymnasium.Env`.
Adding new wrappers
-------------------
All new wrappers should be added to the :mod:`omni.isaac.orbit_tasks.utils.wrappers` module.
They should check that the underlying environment is an instance of :class:`omni.isaac.orbit.envs.RLTaskEnv`
before applying the wrapper. This can be done by using the :func:`unwrapped` property.
We include a set of wrappers in this module that can be used as a reference to implement your own wrappers.
If you implement a new wrapper, please consider contributing it to the framework by opening a pull request.
.. _Stable-Baselines3: https://stable-baselines3.readthedocs.io/en/master/
.. _RL-Games: https://github.com/Denys88/rl_games
.. _RSL-RL: https://github.com/leggedrobotics/rsl_rl
| 6,619 | reStructuredText | 38.879518 | 117 | 0.735005 |
NVIDIA-Omniverse/orbit/docs/source/how-to/draw_markers.rst | Creating Visualization Markers
==============================
.. currentmodule:: omni.isaac.orbit
Visualization markers are useful to debug the state of the environment. They can be used to visualize
the frames, commands, and other information in the simulation.
While Isaac Sim provides its own :mod:`omni.isaac.debug_draw` extension, it is limited to rendering only
points, lines and splines. For cases, where you need to render more complex shapes, you can use the
:class:`markers.VisualizationMarkers` class.
This guide is accompanied by a sample script ``markers.py`` in the ``orbit/source/standalone/demos`` directory.
.. dropdown:: Code for markers.py
:icon: code
.. literalinclude:: ../../../source/standalone/demos/markers.py
:language: python
:emphasize-lines: 49-97, 112-113, 142-148
:linenos:
Configuring the markers
-----------------------
The :class:`~markers.VisualizationMarkersCfg` class provides a simple interface to configure
different types of markers. It takes in the following parameters:
- :attr:`~markers.VisualizationMarkersCfg.prim_path`: The corresponding prim path for the marker class.
- :attr:`~markers.VisualizationMarkersCfg.markers`: A dictionary specifying the different marker prototypes
handled by the class. The key is the name of the marker prototype and the value is its spawn configuration.
.. note::
In case the marker prototype specifies a configuration with physics properties, these are removed.
This is because the markers are not meant to be simulated.
Here we show all the different types of markers that can be configured. These range from simple shapes like
cones and spheres to more complex geometries like a frame or arrows. The marker prototypes can also be
configured from USD files.
.. literalinclude:: ../../../source/standalone/demos/markers.py
:language: python
:lines: 49-97
:dedent:
Drawing the markers
-------------------
To draw the markers, we call the :class:`~markers.VisualizationMarkers.visualize` method. This method takes in
as arguments the pose of the markers and the corresponding marker prototypes to draw.
.. literalinclude:: ../../../source/standalone/demos/markers.py
:language: python
:lines: 142-148
:dedent:
Executing the Script
--------------------
To run the accompanying script, execute the following command:
.. code-block:: bash
./orbit.sh -p source/standalone/demos/markers.py
The simulation should start, and you can observe the different types of markers arranged in a grid pattern.
The markers will rotating around their respective axes. Additionally every few rotations, they will
roll forward on the grid.
To stop the simulation, close the window, or use ``Ctrl+C`` in the terminal.
| 2,751 | reStructuredText | 35.210526 | 111 | 0.739731 |
NVIDIA-Omniverse/orbit/docs/source/how-to/import_new_asset.rst | Importing a New Asset
=====================
.. currentmodule:: omni.isaac.orbit
NVIDIA Omniverse relies on the Universal Scene Description (USD) file format to
import and export assets. USD is an open source file format developed by Pixar
Animation Studios. It is a scene description format optimized for large-scale,
complex data sets. While this format is widely used in the film and animation
industry, it is less common in the robotics community.
To this end, NVIDIA has developed various importers that allow you to import
assets from other file formats into USD. These importers are available as
extensions to Omniverse Kit:
* **URDF Importer** - Import assets from URDF files.
* **MJCF Importer** - Import assets from MJCF files.
* **Asset Importer** - Import assets from various file formats, including
OBJ, FBX, STL, and glTF.
The recommended workflow from NVIDIA is to use the above importers to convert
the asset into its USD representation. Once the asset is in USD format, you can
use the Omniverse Kit to edit the asset and export it to other file formats.
An important note to use assets for large-scale simulation is to ensure that they
are in `instanceable`_ format. This allows the asset to be efficiently loaded
into memory and used multiple times in a scene. Otherwise, the asset will be
loaded into memory multiple times, which can cause performance issues.
For more details on instanceable assets, please check the Isaac Sim `documentation`_.
Using URDF Importer
-------------------
Isaac Sim includes the URDF and MJCF importers by default. These importers support the
option to import assets as instanceable assets. By selecting this option, the
importer will create two USD files: one for all the mesh data and one for
all the non-mesh data (e.g. joints, rigid bodies, etc.). The prims in the mesh data file are
referenced in the non-mesh data file. This allows the mesh data (which is often bulky) to be
loaded into memory only once and used multiple times in a scene.
For using these importers from the GUI, please check the documentation for `MJCF importer`_ and
`URDF importer`_ respectively.
For using the URDF importers from Python scripts, we include a utility tool called ``convert_urdf.py``.
Internally, this script creates an instance of :class:`~sim.converters.UrdfConverterCfg` which
is then passed to the :class:`~sim.converters.UrdfConverter` class. The configuration class specifies
the default values for the importer. The important settings are:
* :attr:`~sim.converters.UrdfConverterCfg.fix_base` - Whether to fix the base of the robot.
This depends on whether you have a floating-base or fixed-base robot.
* :attr:`~sim.converters.UrdfConverterCfg.make_instanceable` - Whether to create instanceable assets.
Usually, this should be set to ``True``.
* :attr:`~sim.converters.UrdfConverterCfg.merge_fixed_joints` - Whether to merge the fixed joints.
Usually, this should be set to ``True`` to reduce the asset complexity.
* :attr:`~sim.converters.UrdfConverterCfg.default_drive_type` - The drive-type for the joints.
We recommend this to always be ``"none"``. This allows changing the drive configuration using the
actuator models.
* :attr:`~sim.converters.UrdfConverterCfg.default_drive_stiffness` - The drive stiffness for the joints.
We recommend this to always be ``0.0``. This allows changing the drive configuration using the
actuator models.
* :attr:`~sim.converters.UrdfConverterCfg.default_drive_damping` - The drive damping for the joints.
Similar to the stiffness, we recommend this to always be ``0.0``.
Example Usage
~~~~~~~~~~~~~
In this example, we use the pre-processed URDF file of the ANYmal-D robot. To check the
pre-process URDF, please check the file the `anymal.urdf`_. The main difference between the
pre-processed URDF and the original URDF are:
* We removed the ``<gazebo>`` tag from the URDF. This tag is not supported by the URDF importer.
* We removed the ``<transmission>`` tag from the URDF. This tag is not supported by the URDF importer.
* We removed various collision bodies from the URDF to reduce the complexity of the asset.
* We changed all the joint's damping and friction parameters to ``0.0``. This ensures that we can perform
effort-control on the joints without PhysX adding additional damping.
* We added the ``<dont_collapse>`` tag to fixed joints. This ensures that the importer does
not merge these fixed joints.
The following shows the steps to clone the repository and run the converter:
.. code-block:: bash
# create a directory to clone
mkdir ~/git && cd ~/git
# clone a repository with URDF files
git clone [email protected]:isaac-orbit/anymal_d_simple_description.git
# go to top of the repository
cd /path/to/orbit
# run the converter
./orbit.sh -p source/standalone/tools/convert_urdf.py \
~/git/anymal_d_simple_description/urdf/anymal.urdf \
source/extensions/omni.isaac.orbit_assets/data/Robots/ANYbotics/anymal_d.usd \
--merge-joints \
--make-instanceable
Executing the above script will create two USD files inside the
``source/extensions/omni.isaac.orbit_assets/data/Robots/ANYbotics/`` directory:
* ``anymal_d.usd`` - This is the main asset file. It contains all the non-mesh data.
* ``Props/instanceable_assets.usd`` - This is the mesh data file.
.. note::
Since Isaac Sim 2023.1.1, the URDF importer behavior has changed and it stores the mesh data inside the
main asset file even if the ``--make-instanceable`` flag is set. This means that the
``Props/instanceable_assets.usd`` file is created but not used anymore.
You can press play on the opened window to see the asset in the scene. The asset should "collapse"
if everything is working correctly. If it blows up, then it might be that you have self-collisions
present in the URDF.
To run the script headless, you can add the ``--headless`` flag. This will not open the GUI and
exit the script after the conversion is complete.
Using Mesh Importer
-------------------
Omniverse Kit includes the mesh converter tool that uses the ASSIMP library to import assets
from various mesh formats (e.g. OBJ, FBX, STL, glTF, etc.). The asset converter tool is available
as an extension to Omniverse Kit. Please check the `asset converter`_ documentation for more details.
However, unlike Isaac Sim's URDF and MJCF importers, the asset converter tool does not support
creating instanceable assets. This means that the asset will be loaded into memory multiple times
if it is used multiple times in a scene.
Thus, we include a utility tool called ``convert_mesh.py`` that uses the asset converter tool to
import the asset and then converts it into an instanceable asset. Internally, this script creates
an instance of :class:`~sim.converters.MeshConverterCfg` which is then passed to the
:class:`~sim.converters.MeshConverter` class. Since the mesh file does not contain any physics
information, the configuration class accepts different physics properties (such as mass, collision
shape, etc.) as input. Please check the documentation for :class:`~sim.converters.MeshConverterCfg`
for more details.
Example Usage
~~~~~~~~~~~~~
We use an OBJ file of a cube to demonstrate the usage of the mesh converter. The following shows
the steps to clone the repository and run the converter:
.. code-block:: bash
# create a directory to clone
mkdir ~/git && cd ~/git
# clone a repository with URDF files
git clone [email protected]:NVIDIA-Omniverse/IsaacGymEnvs.git
# go to top of the repository
cd /path/to/orbit
# run the converter
./orbit.sh -p source/standalone/tools/convert_mesh.py \
~/git/IsaacGymEnvs/assets/trifinger/objects/meshes/cube_multicolor.obj \
source/extensions/omni.isaac.orbit_assets/data/Props/CubeMultiColor/cube_multicolor.usd \
--make-instanceable \
--collision-approximation convexDecomposition \
--mass 1.0
Similar to the URDF converter, executing the above script will create two USD files inside the
``source/extensions/omni.isaac.orbit_assets/data/Props/CubeMultiColor/`` directory. Additionally,
if you press play on the opened window, you should see the asset fall down under the influence
of gravity.
* If you do not set the ``--mass`` flag, then no rigid body properties will be added to the asset.
It will be imported as a static asset.
* If you also do not set the ``--collision-approximation`` flag, then the asset will not have any collider
properties as well and will be imported as a visual asset.
.. _instanceable: https://openusd.org/dev/api/_usd__page__scenegraph_instancing.html
.. _documentation: https://docs.omniverse.nvidia.com/isaacsim/latest/isaac_gym_tutorials/tutorial_gym_instanceable_assets.html
.. _MJCF importer: https://docs.omniverse.nvidia.com/isaacsim/latest/advanced_tutorials/tutorial_advanced_import_mjcf.html
.. _URDF importer: https://docs.omniverse.nvidia.com/isaacsim/latest/advanced_tutorials/tutorial_advanced_import_urdf.html
.. _anymal.urdf: https://github.com/isaac-orbit/anymal_d_simple_description/blob/master/urdf/anymal.urdf
.. _asset converter: https://docs.omniverse.nvidia.com/extensions/latest/ext_asset-converter.html
| 9,167 | reStructuredText | 50.79661 | 126 | 0.765245 |
NVIDIA-Omniverse/orbit/docs/source/how-to/master_omniverse.rst | Mastering Omniverse for Robotics
================================
NVIDIA Omniverse offers a large suite of tools for 3D content workflows.
There are three main components (relevant to robotics) in Omniverse:
- **USD Composer**: This is based on a novel file format (Universal Scene
Description) from the animation (originally Pixar) community that is
used in Omniverse
- **PhysX SDK**: This is the main physics engine behind Omniverse that
leverages GPU-based parallelization for massive scenes
- **RTX-enabled Renderer**: This uses ray-tracing kernels in NVIDIA RTX
GPUs for real-time physically-based rendering
Of these, the first two require a deeper understanding to start working
with Omniverse and its constituent applications (Isaac Sim and Orbit).
The main things to learn:
- How to use the Composer GUI efficiently?
- What are USD prims and schemas?
- How do you compose a USD scene?
- What is the difference between references and payloads in USD?
- What is meant by scene-graph instancing?
- How to apply PhysX schemas on prims? What all schemas are possible?
- How to write basic operations in USD for creating prims and modifying
their attributes?
Part 1: Using USD Composer
--------------------------
While several `video
tutorials <https://www.youtube.com/@NVIDIA-Studio>`__ and
`documentation <https://docs.omniverse.nvidia.com/>`__ exist
out there on NVIDIA Omniverse, going through all of them would take an
extensive amount of time and effort. Thus, we have curated these
resources to guide you through using Omniverse, specifically for
robotics.
Introduction to Omniverse and USD
- `What is NVIDIA Omniverse? <https://youtu.be/dvdB-ndYJBM>`__
- `What is the USD File Type? \| Getting Started in NVIDIA Omniverse <https://youtu.be/GOdyx-oSs2M>`__
- `What Makes USD Unique in NVIDIA Omniverse <https://youtu.be/o2x-30-PTkw>`__
Using Omniverse USD Composer
- `Introduction to Omniverse USD Composer <https://youtu.be/_30Pf3nccuE>`__
- `Navigation Basics in Omniverse USD Composer <https://youtu.be/kb4ZA3TyMak>`__
- `Lighting Basics in NVIDIA Omniverse USD Composer <https://youtu.be/c7qyI8pZvF4>`__
- `Rendering Overview in NVIDIA Omniverse USD Composer <https://youtu.be/dCvq2ZyYmu4>`__
Materials and MDL
- `Five Things to Know About Materials in NVIDIA Omniverse <https://youtu.be/C0HmcQXaENc>`__
- `How to apply materials? <https://docs.omniverse.nvidia.com/materials-and-rendering/latest/materials.html%23applying-materials>`__
Omniverse Physics and PhysX SDK
- `Basics - Setting Up Physics and Toolbar Overview <https://youtu.be/nsJ0S9MycJI>`__
- `Basics - Demos Overview <https://youtu.be/-y0-EVTj10s>`__
- `Rigid Bodies - Mass Editing <https://youtu.be/GHl2RwWeRuM>`__
- `Materials - Friction Restitution and Defaults <https://youtu.be/oTW81DltNiE>`__
- `Overview of Simulation Ready Assets Physics in Omniverse <https://youtu.be/lFtEMg86lJc>`__
Importing assets
- `Omniverse Create - Importing FBX Files \| NVIDIA Omniverse Tutorials <https://youtu.be/dQI0OpzfVHw>`__
- `Omniverse Asset Importer <https://docs.omniverse.nvidia.com/extensions/latest/ext_asset-importer.html>`__
- `Isaac Sim URDF impoter <https://docs.omniverse.nvidia.com/isaacsim/latest/ext_omni_isaac_urdf.html>`__
Part 2: Scripting in Omniverse
------------------------------
The above links mainly introduced how to use the USD Composer and its
functionalities through UI operations. However, often developers
need to write scripts to perform operations. This is especially true
when you want to automate certain tasks or create custom applications
that use Omniverse as a backend. This section will introduce you to
scripting in Omniverse.
USD is the main file format Omniverse operates with. So naturally, the
APIs (from OpenUSD) for modifying USD are at the core of Omniverse.
Most of the APIs are in C++ and Python bindings are provided for them.
Thus, to script in Omniverse, you need to understand the USD APIs.
.. note::
While Isaac Sim and Orbit try to "relieve" users from understanding
the core USD concepts and APIs, understanding these basics still
help a lot once you start diving inside the codebase and modifying
it for your own application.
Before diving into USD scripting, it is good to get acquainted with the
terminologies used in USD. We recommend the following `introduction to
USD basics <https://www.sidefx.com/docs/houdini/solaris/usd.html>`__ by
Houdini, which is a 3D animation software.
Make sure to go through the following sections:
- `Quick example <https://www.sidefx.com/docs/houdini/solaris/usd.html%23quick-example>`__
- `Attributes and primvars <https://www.sidefx.com/docs/houdini/solaris/usd.html%23attrs>`__
- `Composition <https://www.sidefx.com/docs/houdini/solaris/usd.html%23compose>`__
- `Schemas <https://www.sidefx.com/docs/houdini/solaris/usd.html%23schemas>`__
- `Instances <https://www.sidefx.com/docs/houdini/solaris/usd.html%23instancing>`__
and `Scene-graph Instancing <https://openusd.org/dev/api/_usd__page__scenegraph_instancing.html>`__
As a test of understanding, make sure you can answer the following:
- What are prims? What is meant by a prim path in a stage?
- How are attributes related to prims?
- How are schemas related to prims?
- What is the difference between attributes and schemas?
- What is asset instancing?
Part 3: More Resources
----------------------
- `Omniverse Glossary of Terms <https://docs.omniverse.nvidia.com/isaacsim/latest/common/glossary-of-terms.html>`__
- `Omniverse Code Samples <https://docs.omniverse.nvidia.com/dev-guide/latest/programmer_ref.html>`__
- `PhysX Collider Compatibility <https://docs.omniverse.nvidia.com/extensions/latest/ext_physics/rigid-bodies.html#collidercompatibility>`__
- `PhysX Limitations <https://docs.omniverse.nvidia.com/isaacsim/latest/features/physics/physX_limitations.html>`__
- `PhysX Documentation <https://nvidia-omniverse.github.io/PhysX/physx/>`__.
| 5,971 | reStructuredText | 46.776 | 140 | 0.748786 |
NVIDIA-Omniverse/orbit/docs/source/how-to/write_articulation_cfg.rst | .. _how-to-write-articulation-config:
Writing an Asset Configuration
==============================
.. currentmodule:: omni.isaac.orbit
This guide walks through the process of creating an :class:`~assets.ArticulationCfg`.
The :class:`~assets.ArticulationCfg` is a configuration object that defines the
properties of an :class:`~assets.Articulation` in Orbit.
.. note::
While we only cover the creation of an :class:`~assets.ArticulationCfg` in this guide,
the process is similar for creating any other asset configuration object.
We will use the Cartpole example to demonstrate how to create an :class:`~assets.ArticulationCfg`.
The Cartpole is a simple robot that consists of a cart with a pole attached to it. The cart
is free to move along a rail, and the pole is free to rotate about the cart.
.. dropdown:: Code for Cartpole configuration
:icon: code
.. literalinclude:: ../../../source/extensions/omni.isaac.orbit_assets/omni/isaac/orbit_assets/cartpole.py
:language: python
:linenos:
Defining the spawn configuration
--------------------------------
As explained in :ref:`tutorial-spawn-prims` tutorials, the spawn configuration defines
the properties of the assets to be spawned. This spawning may happen procedurally, or
through an existing asset file (e.g. USD or URDF). In this example, we will spawn the
Cartpole from a USD file.
When spawning an asset from a USD file, we define its :class:`~sim.spawners.from_files.UsdFileCfg`.
This configuration object takes in the following parameters:
* :class:`~sim.spawners.from_files.UsdFileCfg.usd_path`: The USD file path to spawn from
* :class:`~sim.spawners.from_files.UsdFileCfg.rigid_props`: The properties of the articulation's root
* :class:`~sim.spawners.from_files.UsdFileCfg.articulation_props`: The properties of all the articulation's links
The last two parameters are optional. If not specified, they are kept at their default values in the USD file.
.. literalinclude:: ../../../source/extensions/omni.isaac.orbit_assets/omni/isaac/orbit_assets/cartpole.py
:language: python
:lines: 17-33
:dedent:
To import articulation from a URDF file instead of a USD file, you can replace the
:class:`~sim.spawners.from_files.UsdFileCfg` with a :class:`~sim.spawners.from_files.UrdfFileCfg`.
For more details, please check the API documentation.
Defining the initial state
--------------------------
Every asset requires defining their initial or *default* state in the simulation through its configuration.
This configuration is stored into the asset's default state buffers that can be accessed when the asset's
state needs to be reset.
.. note::
The initial state of an asset is defined w.r.t. its local environment frame. This then needs to
be transformed into the global simulation frame when resetting the asset's state. For more
details, please check the :ref:`tutorial-interact-articulation` tutorial.
For an articulation, the :class:`~assets.ArticulationCfg.InitialStateCfg` object defines the
initial state of the root of the articulation and the initial state of all its joints. In this
example, we will spawn the Cartpole at the origin of the XY plane at a Z height of 2.0 meters.
Meanwhile, the joint positions and velocities are set to 0.0.
.. literalinclude:: ../../../source/extensions/omni.isaac.orbit_assets/omni/isaac/orbit_assets/cartpole.py
:language: python
:lines: 34-36
:dedent:
Defining the actuator configuration
-----------------------------------
Actuators are a crucial component of an articulation. Through this configuration, it is possible
to define the type of actuator model to use. We can use the internal actuator model provided by
the physics engine (i.e. the implicit actuator model), or use a custom actuator model which is
governed by a user-defined system of equations (i.e. the explicit actuator model).
For more details on actuators, see :ref:`feature-actuators`.
The cartpole's articulation has two actuators, one corresponding to its each joint:
``cart_to_pole`` and ``slider_to_cart``. We use two different actuator models for these actuators as
an example. However, since they are both using the same actuator model, it is possible
to combine them into a single actuator model.
.. dropdown:: Actuator model configuration with separate actuator models
:icon: code
.. literalinclude:: ../../../source/extensions/omni.isaac.orbit_assets/omni/isaac/orbit_assets/cartpole.py
:language: python
:lines: 37-47
:dedent:
.. dropdown:: Actuator model configuration with a single actuator model
:icon: code
.. code-block:: python
actuators={
"all_joints": ImplicitActuatorCfg(
joint_names_expr=[".*"],
effort_limit=400.0,
velocity_limit=100.0,
stiffness={"slider_to_cart": 0.0, "cart_to_pole": 0.0},
damping={"slider_to_cart": 10.0, "cart_to_pole": 0.0},
),
},
| 4,957 | reStructuredText | 41.376068 | 113 | 0.727053 |
NVIDIA-Omniverse/orbit/docs/source/how-to/record_animation.rst | Recording Animations of Simulations
===================================
.. currentmodule:: omni.isaac.orbit
Omniverse includes tools to record animations of physics simulations. The `Stage Recorder`_ extension
listens to all the motion and USD property changes within a USD stage and records them to a USD file.
This file contains the time samples of the changes, which can be played back to render the animation.
The timeSampled USD file only contains the changes to the stage. It uses the same hierarchy as the original
stage at the time of recording. This allows adding the animation to the original stage, or to a different
stage with the same hierarchy. The timeSampled file can be directly added as a sublayer to the original stage
to play back the animation.
.. note::
Omniverse only supports playing animation or playing physics on a USD prim at the same time. If you want to
play back the animation of a USD prim, you need to disable the physics simulation on the prim.
In Orbit, we directly use the `Stage Recorder`_ extension to record the animation of the physics simulation.
This is available as a feature in the :class:`~omni.isaac.orbit.envs.ui.BaseEnvWindow` class.
However, to record the animation of a simulation, you need to disable `Fabric`_ to allow reading and writing
all the changes (such as motion and USD properties) to the USD stage.
Stage Recorder Settings
~~~~~~~~~~~~~~~~~~~~~~~
Orbit integration of the `Stage Recorder`_ extension assumes certain default settings. If you want to change the
settings, you can directly use the `Stage Recorder`_ extension in the Omniverse Create application.
.. dropdown:: Settings used in base_env_window.py
:icon: code
.. literalinclude:: ../../../source/extensions/omni.isaac.orbit/omni/isaac/orbit/envs/ui/base_env_window.py
:language: python
:linenos:
:pyobject: BaseEnvWindow._toggle_recording_animation_fn
Example Usage
~~~~~~~~~~~~~
In all environment standalone scripts, Fabric can be disabled by passing the ``--disable_fabric`` flag to the script.
Here we run the state-machine example and record the animation of the simulation.
.. code-block:: bash
./orbit.sh -p source/standalone/environments/state_machine/lift_cube_sm.py --num_envs 8 --cpu --disable_fabric
On running the script, the Orbit UI window opens with the button "Record Animation" in the toolbar.
Clicking this button starts recording the animation of the simulation. On clicking the button again, the
recording stops. The recorded animation and the original stage (with all physics disabled) are saved
to the ``recordings`` folder in the current working directory. The files are stored in the ``usd`` format:
- ``Stage.usd``: The original stage with all physics disabled
- ``TimeSample_tk001.usd``: The timeSampled file containing the recorded animation
You can open Omniverse Isaac Sim application to play back the animation. There are many ways to launch
the application (such as from terminal or `Omniverse Launcher`_). Here we use the terminal to open the
application and play the animation.
.. code-block:: bash
./orbit.sh -s # Opens Isaac Sim application through _isaac_sim/isaac-sim.sh
On a new stage, add the ``Stage.usd`` as a sublayer and then add the ``TimeSample_tk001.usd`` as a sublayer.
You can do this by dragging and dropping the files from the file explorer to the stage. Please check out
the `tutorial on layering in Omniverse`_ for more details.
You can then play the animation by pressing the play button.
.. _Stage Recorder: https://docs.omniverse.nvidia.com/extensions/latest/ext_animation_stage-recorder.html
.. _Fabric: https://docs.omniverse.nvidia.com/kit/docs/usdrt/latest/docs/usd_fabric_usdrt.html
.. _Omniverse Launcher: https://docs.omniverse.nvidia.com/launcher/latest/index.html
.. _tutorial on layering in Omniverse: https://www.youtube.com/watch?v=LTwmNkSDh-c&ab_channel=NVIDIAOmniverse
| 3,914 | reStructuredText | 48.556961 | 117 | 0.762902 |
NVIDIA-Omniverse/orbit/docs/source/how-to/index.rst | How-to Guides
=============
This section includes guides that help you use Orbit. These are intended for users who
have already worked through the tutorials and are looking for more information on how to
use Orbit. If you are new to Orbit, we recommend you start with the tutorials.
.. note::
This section is a work in progress. If you have a question that is not answered here,
please open an issue on our `GitHub page <https://github.com/NVIDIA-Omniverse/Orbit>`_.
.. toctree::
:maxdepth: 1
import_new_asset
write_articulation_cfg
save_camera_output
draw_markers
wrap_rl_env
master_omniverse
record_animation
| 656 | reStructuredText | 27.565216 | 91 | 0.716463 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/index.rst | Tutorials
=========
Welcome to the Orbit tutorials! These tutorials provide a step-by-step guide to help you understand
and use various features of the framework. All the tutorials are written as Python scripts. You can
find the source code for each tutorial in the ``source/standalone/tutorials`` directory of the Orbit
repository.
.. note::
We would love to extend the tutorials to cover more topics and use cases, so please let us know if
you have any suggestions.
We recommend that you go through the tutorials in the order they are listed here.
.. toctree::
:maxdepth: 2
00_sim/index
01_assets/index
02_scene/index
03_envs/index
04_sensors/index
05_controllers/index
| 714 | reStructuredText | 27.599999 | 102 | 0.736695 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/01_assets/run_articulation.rst | .. _tutorial-interact-articulation:
Interacting with an articulation
================================
.. currentmodule:: omni.isaac.orbit
This tutorial shows how to interact with an articulated robot in the simulation. It is a continuation of the
:ref:`tutorial-interact-rigid-object` tutorial, where we learned how to interact with a rigid object.
On top of setting the root state, we will see how to set the joint state and apply commands to the articulated
robot.
The Code
~~~~~~~~
The tutorial corresponds to the ``run_articulation.py`` script in the ``orbit/source/standalone/tutorials/01_assets``
directory.
.. dropdown:: Code for run_articulation.py
:icon: code
.. literalinclude:: ../../../../source/standalone/tutorials/01_assets/run_articulation.py
:language: python
:emphasize-lines: 60-71, 93-106, 110-113, 118-119
:linenos:
The Code Explained
~~~~~~~~~~~~~~~~~~
Designing the scene
-------------------
Similar to the previous tutorial, we populate the scene with a ground plane and a distant light. Instead of
spawning rigid objects, we now spawn a cart-pole articulation from its USD file. The cart-pole is a simple robot
consisting of a cart and a pole attached to it. The cart is free to move along the x-axis, and the pole is free to
rotate about the cart. The USD file for the cart-pole contains the robot's geometry, joints, and other physical
properties.
For the cart-pole, we use its pre-defined configuration object, which is an instance of the
:class:`assets.ArticulationCfg` class. This class contains information about the articulation's spawning strategy,
default initial state, actuator models for different joints, and other meta-information. A deeper-dive into how to
create this configuration object is provided in the :ref:`how-to-write-articulation-config` tutorial.
As seen in the previous tutorial, we can spawn the articulation into the scene in a similar fashion by creating
an instance of the :class:`assets.Articulation` class by passing the configuration object to its constructor.
.. literalinclude:: ../../../../source/standalone/tutorials/01_assets/run_articulation.py
:language: python
:start-at: # Create separate groups called "Origin1", "Origin2", "Origin3"
:end-at: cartpole = Articulation(cfg=cartpole_cfg)
Running the simulation loop
---------------------------
Continuing from the previous tutorial, we reset the simulation at regular intervals, set commands to the articulation,
step the simulation, and update the articulation's internal buffers.
Resetting the simulation
""""""""""""""""""""""""
Similar to a rigid object, an articulation also has a root state. This state corresponds to the root body in the
articulation tree. On top of the root state, an articulation also has joint states. These states correspond to the
joint positions and velocities.
To reset the articulation, we first set the root state by calling the :meth:`Articulation.write_root_state_to_sim`
method. Similarly, we set the joint states by calling the :meth:`Articulation.write_joint_state_to_sim` method.
Finally, we call the :meth:`Articulation.reset` method to reset any internal buffers and caches.
.. literalinclude:: ../../../../source/standalone/tutorials/01_assets/run_articulation.py
:language: python
:start-at: # reset the scene entities
:end-at: robot.reset()
Stepping the simulation
"""""""""""""""""""""""
Applying commands to the articulation involves two steps:
1. *Setting the joint targets*: This sets the desired joint position, velocity, or effort targets for the articulation.
2. *Writing the data to the simulation*: Based on the articulation's configuration, this step handles any
:ref:`actuation conversions <feature-actuators>` and writes the converted values to the PhysX buffer.
In this tutorial, we control the articulation using joint effort commands. For this to work, we need to set the
articulation's stiffness and damping parameters to zero. This is done a-priori inside the cart-pole's pre-defined
configuration object.
At every step, we randomly sample joint efforts and set them to the articulation by calling the
:meth:`Articulation.set_joint_effort_target` method. After setting the targets, we call the
:meth:`Articulation.write_data_to_sim` method to write the data to the PhysX buffer. Finally, we step
the simulation.
.. literalinclude:: ../../../../source/standalone/tutorials/01_assets/run_articulation.py
:language: python
:start-at: # Apply random action
:end-at: robot.write_data_to_sim()
Updating the state
""""""""""""""""""
Every articulation class contains a :class:`assets.ArticulationData` object. This stores the state of the
articulation. To update the state inside the buffer, we call the :meth:`assets.Articulation.update` method.
.. literalinclude:: ../../../../source/standalone/tutorials/01_assets/run_articulation.py
:language: python
:start-at: # Update buffers
:end-at: robot.update(sim_dt)
The Code Execution
~~~~~~~~~~~~~~~~~~
To run the code and see the results, let's run the script from the terminal:
.. code-block:: bash
./orbit.sh -p source/standalone/tutorials/01_assets/run_articulation.py
This command should open a stage with a ground plane, lights, and two cart-poles that are moving around randomly.
To stop the simulation, you can either close the window, press the ``STOP`` button in the UI, or press ``Ctrl+C``
in the terminal.
In this tutorial, we learned how to create and interact with a simple articulation. We saw how to set the state
of an articulation (its root and joint state) and how to apply commands to it. We also saw how to update its
buffers to read the latest state from the simulation.
In addition to this tutorial, we also provide a few other scripts that spawn different robots.These are included
in the ``orbit/source/standalone/demos`` directory. You can run these scripts as:
.. code-block:: bash
# Spawn many different single-arm manipulators
./orbit.sh -p source/standalone/demos/arms.py
# Spawn many different quadrupeds
./orbit.sh -p source/standalone/demos/quadrupeds.py
| 6,130 | reStructuredText | 42.176056 | 119 | 0.745351 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/01_assets/run_rigid_object.rst | .. _tutorial-interact-rigid-object:
Interacting with a rigid object
===============================
.. currentmodule:: omni.isaac.orbit
In the previous tutorials, we learned the essential workings of the standalone script and how to
spawn different objects (or *prims*) into the simulation. This tutorial shows how to create and interact
with a rigid object. For this, we will use the :class:`assets.RigidObject` class provided in Orbit.
The Code
~~~~~~~~
The tutorial corresponds to the ``run_rigid_object.py`` script in the ``orbit/source/standalone/tutorials/01_assets`` directory.
.. dropdown:: Code for run_rigid_object.py
:icon: code
.. literalinclude:: ../../../../source/standalone/tutorials/01_assets/run_rigid_object.py
:language: python
:emphasize-lines: 57-76, 78-80, 100-110, 113-114, 120-121, 134-136, 141-142
:linenos:
The Code Explained
~~~~~~~~~~~~~~~~~~
In this script, we split the ``main`` function into two separate functions, which highlight the two main
steps of setting up any simulation in the simulator:
1. **Design scene**: As the name suggests, this part is responsible for adding all the prims to the scene.
2. **Run simulation**: This part is responsible for stepping the simulator, interacting with the prims
in the scene, e.g., changing their poses, and applying any commands to them.
A distinction between these two steps is necessary because the second step only happens after the first step
is complete and the simulator is reset. Once the simulator is reset (which automatically plays the simulation),
no new (physics-enabled) prims should be added to the scene as it may lead to unexpected behaviors. However,
the prims can be interacted with through their respective handles.
Designing the scene
-------------------
Similar to the previous tutorial, we populate the scene with a ground plane and a light source. In addition,
we add a rigid object to the scene using the :class:`assets.RigidObject` class. This class is responsible for
spawning the prims at the input path and initializes their corresponding rigid body physics handles.
In this tutorial, we create a conical rigid object using the spawn configuration similar to the rigid cone
in the :ref:`Spawn Objects <tutorial-spawn-prims>` tutorial. The only difference is that now we wrap
the spawning configuration into the :class:`assets.RigidObjectCfg` class. This class contains information about
the asset's spawning strategy, default initial state, and other meta-information. When this class is passed to
the :class:`assets.RigidObject` class, it spawns the object and initializes the corresponding physics handles
when the simulation is played.
As an example on spawning the rigid object prim multiple times, we create its parent Xform prims,
``/World/Origin{i}``, that correspond to different spawn locations. When the regex expression
``/World/Origin*/Cone`` is passed to the :class:`assets.RigidObject` class, it spawns the rigid object prim at
each of the ``/World/Origin{i}`` locations. For instance, if ``/World/Origin1`` and ``/World/Origin2`` are
present in the scene, the rigid object prims are spawned at the locations ``/World/Origin1/Cone`` and
``/World/Origin2/Cone`` respectively.
.. literalinclude:: ../../../../source/standalone/tutorials/01_assets/run_rigid_object.py
:language: python
:start-at: # Create separate groups called "Origin1", "Origin2", "Origin3"
:end-at: cone_object = RigidObject(cfg=cone_cfg)
Since we want to interact with the rigid object, we pass this entity back to the main function. This entity
is then used to interact with the rigid object in the simulation loop. In later tutorials, we will see a more
convenient way to handle multiple scene entities using the :class:`scene.InteractiveScene` class.
.. literalinclude:: ../../../../source/standalone/tutorials/01_assets/run_rigid_object.py
:language: python
:start-at: # return the scene information
:end-at: return scene_entities, origins
Running the simulation loop
---------------------------
We modify the simulation loop to interact with the rigid object to include three steps -- resetting the
simulation state at fixed intervals, stepping the simulation, and updating the internal buffers of the
rigid object. For the convenience of this tutorial, we extract the rigid object's entity from the scene
dictionary and store it in a variable.
Resetting the simulation state
""""""""""""""""""""""""""""""
To reset the simulation state of the spawned rigid object prims, we need to set their pose and velocity.
Together they define the root state of the spawned rigid objects. It is important to note that this state
is defined in the **simulation world frame**, and not of their parent Xform prim. This is because the physics
engine only understands the world frame and not the parent Xform prim's frame. Thus, we need to transform
desired state of the rigid object prim into the world frame before setting it.
We use the :attr:`assets.RigidObject.data.default_root_state` attribute to get the default root state of the
spawned rigid object prims. This default state can be configured from the :attr:`assets.RigidObjectCfg.init_state`
attribute, which we left as identity in this tutorial. We then randomize the translation of the root state and
set the desired state of the rigid object prim using the :meth:`assets.RigidObject.write_root_state_to_sim` method.
As the name suggests, this method writes the root state of the rigid object prim into the simulation buffer.
.. literalinclude:: ../../../../source/standalone/tutorials/01_assets/run_rigid_object.py
:language: python
:start-at: # reset root state
:end-at: cone_object.reset()
Stepping the simulation
"""""""""""""""""""""""
Before stepping the simulation, we perform the :meth:`assets.RigidObject.write_data_to_sim` method. This method
writes other data, such as external forces, into the simulation buffer. In this tutorial, we do not apply any
external forces to the rigid object, so this method is not necessary. However, it is included for completeness.
.. literalinclude:: ../../../../source/standalone/tutorials/01_assets/run_rigid_object.py
:language: python
:start-at: # apply sim data
:end-at: cone_object.write_data_to_sim()
Updating the state
""""""""""""""""""
After stepping the simulation, we update the internal buffers of the rigid object prims to reflect their new state
inside the :class:`assets.RigidObject.data` attribute. This is done using the :meth:`assets.RigidObject.update` method.
.. literalinclude:: ../../../../source/standalone/tutorials/01_assets/run_rigid_object.py
:language: python
:start-at: # update buffers
:end-at: cone_object.update(sim_dt)
The Code Execution
~~~~~~~~~~~~~~~~~~
Now that we have gone through the code, let's run the script and see the result:
.. code-block:: bash
./orbit.sh -p source/standalone/tutorials/01_assets/run_rigid_object.py
This should open a stage with a ground plane, lights, and several green cones. The cones must be dropping from
a random height and settling on to the ground. To stop the simulation, you can either close the window, or press
the ``STOP`` button in the UI, or press ``Ctrl+C`` in the terminal
This tutorial showed how to spawn rigid objects and wrap them in a :class:`RigidObject` class to initialize their
physics handles which allows setting and obtaining their state. In the next tutorial, we will see how to interact
with an articulated object which is a collection of rigid objects connected by joints.
| 7,574 | reStructuredText | 50.182432 | 128 | 0.750594 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/01_assets/index.rst | Interacting with Assets
=======================
Having spawned objects in the scene, these tutorials show you how to create physics handles for these
objects and interact with them. These revolve around the :class:`~omni.isaac.orbit.assets.AssetBase`
class and its derivatives such as :class:`~omni.isaac.orbit.assets.RigidObject` and
:class:`~omni.isaac.orbit.assets.Articulation`.
.. toctree::
:maxdepth: 1
:titlesonly:
run_rigid_object
run_articulation
| 475 | reStructuredText | 30.733331 | 101 | 0.726316 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/02_scene/create_scene.rst | .. _tutorial-interactive-scene:
Using the Interactive Scene
===========================
.. currentmodule:: omni.isaac.orbit
So far in the tutorials, we manually spawned assets into the simulation and created
object instances to interact with them. However, as the complexity of the scene
increases, it becomes tedious to perform these tasks manually. In this tutorial,
we will introduce the :class:`scene.InteractiveScene` class, which provides a convenient
interface for spawning prims and managing them in the simulation.
At a high-level, the interactive scene is a collection of scene entities. Each entity
can be either a non-interactive prim (e.g. ground plane, light source), an interactive
prim (e.g. articulation, rigid object), or a sensor (e.g. camera, lidar). The interactive
scene provides a convenient interface for spawning these entities and managing them
in the simulation.
Compared the manual approach, it provides the following benefits:
* Alleviates the user needing to spawn each asset separately as this is handled implicitly.
* Enables user-friendly cloning of scene prims for multiple environments.
* Collects all the scene entities into a single object, which makes them easier to manage.
In this tutorial, we take the cartpole example from the :ref:`tutorial-interact-articulation`
tutorial and replace the ``design_scene`` function with an :class:`scene.InteractiveScene` object.
While it may seem like overkill to use the interactive scene for this simple example, it will
become more useful in the future as more assets and sensors are added to the scene.
The Code
~~~~~~~~
This tutorial corresponds to the ``create_scene.py`` script within
``orbit/source/standalone/tutorials/02_scene``.
.. dropdown:: Code for create_scene.py
:icon: code
.. literalinclude:: ../../../../source/standalone/tutorials/02_scene/create_scene.py
:language: python
:emphasize-lines: 52-65, 70-72, 93-94, 101-102, 107-108, 118-120
:linenos:
The Code Explained
~~~~~~~~~~~~~~~~~~
While the code is similar to the previous tutorial, there are a few key differences
that we will go over in detail.
Scene configuration
-------------------
The scene is composed of a collection of entities, each with their own configuration.
These are specified in a configuration class that inherits from :class:`scene.InteractiveSceneCfg`.
The configuration class is then passed to the :class:`scene.InteractiveScene` constructor
to create the scene.
For the cartpole example, we specify the same scene as in the previous tutorial, but list
them now in the configuration class :class:`CartpoleSceneCfg` instead of manually spawning them.
.. literalinclude:: ../../../../source/standalone/tutorials/02_scene/create_scene.py
:language: python
:pyobject: CartpoleSceneCfg
The variable names in the configuration class are used as keys to access the corresponding
entity from the :class:`scene.InteractiveScene` object. For example, the cartpole can
be accessed via ``scene["cartpole"]``. However, we will get to that later. First, let's
look at how individual scene entities are configured.
Similar to how a rigid object and articulation were configured in the previous tutorials,
the configurations are specified using a configuration class. However, there is a key
difference between the configurations for the ground plane and light source and the
configuration for the cartpole. The ground plane and light source are non-interactive
prims, while the cartpole is an interactive prim. This distinction is reflected in the
configuration classes used to specify them. The configurations for the ground plane and
light source are specified using an instance of the :class:`assets.AssetBaseCfg` class
while the cartpole is configured using an instance of the :class:`assets.ArticulationCfg`.
Anything that is not an interactive prim (i.e., neither an asset nor a sensor) is not
*handled* by the scene during simulation steps.
Another key difference to note is in the specification of the prim paths for the
different prims:
* Ground plane: ``/World/defaultGroundPlane``
* Light source: ``/World/Light``
* Cartpole: ``{ENV_REGEX_NS}/Robot``
As we learned earlier, Omniverse creates a graph of prims in the USD stage. The prim
paths are used to specify the location of the prim in the graph. The ground plane and
light source are specified using absolute paths, while the cartpole is specified using
a relative path. The relative path is specified using the ``ENV_REGEX_NS`` variable,
which is a special variable that is replaced with the environment name during scene creation.
Any entity that has the ``ENV_REGEX_NS`` variable in its prim path will be cloned for each
environment. This path is replaced by the scene object with ``/World/envs/env_{i}`` where
``i`` is the environment index.
Scene instantiation
-------------------
Unlike before where we called the ``design_scene`` function to create the scene, we now
create an instance of the :class:`scene.InteractiveScene` class and pass in the configuration
object to its constructor. While creating the configuration instance of ``CartpoleSceneCfg``
we specify how many environment copies we want to create using the ``num_envs`` argument.
This will be used to clone the scene for each environment.
.. literalinclude:: ../../../../source/standalone/tutorials/02_scene/create_scene.py
:language: python
:start-at: # Design scene
:end-at: scene = InteractiveScene(scene_cfg)
Accessing scene elements
------------------------
Similar to how entities were accessed from a dictionary in the previous tutorials, the
scene elements can be accessed from the :class:`InteractiveScene` object using the
``[]`` operator. The operator takes in a string key and returns the corresponding
entity. The key is specified through the configuration class for each entity. For example,
the cartpole is specified using the key ``"cartpole"`` in the configuration class.
.. literalinclude:: ../../../../source/standalone/tutorials/02_scene/create_scene.py
:language: python
:start-at: # Extract scene entities
:end-at: robot = scene["cartpole"]
Running the simulation loop
---------------------------
The rest of the script looks similar to previous scripts that interfaced with :class:`assets.Articulation`,
with a few small differences in the methods called:
* :meth:`assets.Articulation.reset` ⟶ :meth:`scene.InteractiveScene.reset`
* :meth:`assets.Articulation.write_data_to_sim` ⟶ :meth:`scene.InteractiveScene.write_data_to_sim`
* :meth:`assets.Articulation.update` ⟶ :meth:`scene.InteractiveScene.update`
Under the hood, the methods of :class:`scene.InteractiveScene` call the corresponding
methods of the entities in the scene.
The Code Execution
~~~~~~~~~~~~~~~~~~
Let's run the script to simulate 32 cartpoles in the scene. We can do this by passing
the ``--num_envs`` argument to the script.
.. code-block:: bash
./orbit.sh -p source/standalone/tutorials/02_scene/create_scene.py --num_envs 32
This should open a stage with 32 cartpoles swinging around randomly. You can use the
mouse to rotate the camera and the arrow keys to move around the scene.
In this tutorial, we saw how to use :class:`scene.InteractiveScene` to create a
scene with multiple assets. We also saw how to use the ``num_envs`` argument
to clone the scene for multiple environments.
There are many more example usages of the :class:`scene.InteractiveSceneCfg` in the tasks found
under the ``omni.isaac.orbit_tasks`` extension. Please check out the source code to see
how they are used for more complex scenes.
| 7,600 | reStructuredText | 45.919753 | 107 | 0.761974 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/02_scene/index.rst | Creating a Scene
================
With the basic concepts of the framework covered, the tutorials move to a more intuitive scene
interface that uses the :class:`~omni.isaac.orbit.scene.InteractiveScene` class. This class
provides a higher level abstraction for creating scenes easily.
.. toctree::
:maxdepth: 1
:titlesonly:
create_scene
| 352 | reStructuredText | 26.153844 | 94 | 0.730114 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/03_envs/run_rl_training.rst | Training with an RL Agent
=========================
.. currentmodule:: omni.isaac.orbit
In the previous tutorials, we covered how to define an RL task environment, register
it into the ``gym`` registry, and interact with it using a random agent. We now move
on to the next step: training an RL agent to solve the task.
Although the :class:`envs.RLTaskEnv` conforms to the :class:`gymnasium.Env` interface,
it is not exactly a ``gym`` environment. The input and outputs of the environment are
not numpy arrays, but rather based on torch tensors with the first dimension being the
number of environment instances.
Additionally, most RL libraries expect their own variation of an environment interface.
For example, `Stable-Baselines3`_ expects the environment to conform to its
`VecEnv API`_ which expects a list of numpy arrays instead of a single tensor. Similarly,
`RSL-RL`_ and `RL-Games`_ expect a different interface. Since there is no one-size-fits-all
solution, we do not base the :class:`envs.RLTaskEnv` on any particular learning library.
Instead, we implement wrappers to convert the environment into the expected interface.
These are specified in the :mod:`omni.isaac.orbit_tasks.utils.wrappers` module.
In this tutorial, we will use `Stable-Baselines3`_ to train an RL agent to solve the
cartpole balancing task.
.. caution::
Wrapping the environment with the respective learning framework's wrapper should happen in the end,
i.e. after all other wrappers have been applied. This is because the learning framework's wrapper
modifies the interpretation of environment's APIs which may no longer be compatible with :class:`gymnasium.Env`.
The Code
--------
For this tutorial, we use the training script from `Stable-Baselines3`_ workflow in the
``orbit/source/standalone/workflows/sb3`` directory.
.. dropdown:: Code for train.py
:icon: code
.. literalinclude:: ../../../../source/standalone/workflows/sb3/train.py
:language: python
:emphasize-lines: 58, 61, 67-69, 78, 92-96, 98-99, 102-110, 112, 117-125, 127-128, 135-138
:linenos:
The Code Explained
------------------
.. currentmodule:: omni.isaac.orbit_tasks.utils
Most of the code above is boilerplate code to create logging directories, saving the parsed configurations,
and setting up different Stable-Baselines3 components. For this tutorial, the important part is creating
the environment and wrapping it with the Stable-Baselines3 wrapper.
There are three wrappers used in the code above:
1. :class:`gymnasium.wrappers.RecordVideo`: This wrapper records a video of the environment
and saves it to the specified directory. This is useful for visualizing the agent's behavior
during training.
2. :class:`wrappers.sb3.Sb3VecEnvWrapper`: This wrapper converts the environment
into a Stable-Baselines3 compatible environment.
3. `stable_baselines3.common.vec_env.VecNormalize`_: This wrapper normalizes the
environment's observations and rewards.
Each of these wrappers wrap around the previous wrapper by following ``env = wrapper(env, *args, **kwargs)``
repeatedly. The final environment is then used to train the agent. For more information on how these
wrappers work, please refer to the :ref:`how-to-env-wrappers` documentation.
The Code Execution
------------------
We train a PPO agent from Stable-Baselines3 to solve the cartpole balancing task.
Training the agent
~~~~~~~~~~~~~~~~~~
There are three main ways to train the agent. Each of them has their own advantages and disadvantages.
It is up to you to decide which one you prefer based on your use case.
Headless execution
""""""""""""""""""
If the ``--headless`` flag is set, the simulation is not rendered during training. This is useful
when training on a remote server or when you do not want to see the simulation. Typically, it speeds
up the training process since only physics simulation step is performed.
.. code-block:: bash
./orbit.sh -p source/standalone/workflows/sb3/train.py --task Isaac-Cartpole-v0 --num_envs 64 --headless
Headless execution with off-screen render
"""""""""""""""""""""""""""""""""""""""""
Since the above command does not render the simulation, it is not possible to visualize the agent's
behavior during training. To visualize the agent's behavior, we pass the ``--offscreen_render`` which
enables off-screen rendering. Additionally, we pass the flag ``--video`` which records a video of the
agent's behavior during training.
.. code-block:: bash
./orbit.sh -p source/standalone/workflows/sb3/train.py --task Isaac-Cartpole-v0 --num_envs 64 --headless --offscreen_render --video
The videos are saved to the ``logs/sb3/Isaac-Cartpole-v0/<run-dir>/videos`` directory. You can open these videos
using any video player.
Interactive execution
"""""""""""""""""""""
.. currentmodule:: omni.isaac.orbit
While the above two methods are useful for training the agent, they don't allow you to interact with the
simulation to see what is happening. In this case, you can ignore the ``--headless`` flag and run the
training script as follows:
.. code-block:: bash
./orbit.sh -p source/standalone/workflows/sb3/train.py --task Isaac-Cartpole-v0 --num_envs 64
This will open the Isaac Sim window and you can see the agent training in the environment. However, this
will slow down the training process since the simulation is rendered on the screen. As a workaround, you
can switch between different render modes in the ``"Orbit"`` window that is docked on the bottom-right
corner of the screen. To learn more about these render modes, please check the
:class:`sim.SimulationContext.RenderMode` class.
Viewing the logs
~~~~~~~~~~~~~~~~
On a separate terminal, you can monitor the training progress by executing the following command:
.. code:: bash
# execute from the root directory of the repository
./orbit.sh -p -m tensorboard.main --logdir logs/sb3/Isaac-Cartpole-v0
Playing the trained agent
~~~~~~~~~~~~~~~~~~~~~~~~~
Once the training is complete, you can visualize the trained agent by executing the following command:
.. code:: bash
# execute from the root directory of the repository
./orbit.sh -p source/standalone/workflows/sb3/play.py --task Isaac-Cartpole-v0 --num_envs 32 --use_last_checkpoint
The above command will load the latest checkpoint from the ``logs/sb3/Isaac-Cartpole-v0``
directory. You can also specify a specific checkpoint by passing the ``--checkpoint`` flag.
.. _Stable-Baselines3: https://stable-baselines3.readthedocs.io/en/master/
.. _VecEnv API: https://stable-baselines3.readthedocs.io/en/master/guide/vec_envs.html#vecenv-api-vs-gym-api
.. _`stable_baselines3.common.vec_env.VecNormalize`: https://stable-baselines3.readthedocs.io/en/master/guide/vec_envs.html#vecnormalize
.. _RL-Games: https://github.com/Denys88/rl_games
.. _RSL-RL: https://github.com/leggedrobotics/rsl_rl
| 6,871 | reStructuredText | 43.623376 | 136 | 0.747781 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/03_envs/create_rl_env.rst | .. _tutorial-create-rl-env:
Creating an RL Environment
==========================
.. currentmodule:: omni.isaac.orbit
Having learnt how to create a base environment in :ref:`tutorial-create-base-env`, we will now look at how to create a
task environment for reinforcement learning.
The base environment is designed as an sense-act environment where the agent can send commands to the environment
and receive observations from the environment. This minimal interface is sufficient for many applications such as
traditional motion planning and controls. However, many applications require a task-specification which often
serves as the learning objective for the agent. For instance, in a navigation task, the agent may be required to
reach a goal location. To this end, we use the :class:`envs.RLTaskEnv` class which extends the base environment
to include a task specification.
Similar to other components in Orbit, instead of directly modifying the base class :class:`RLTaskEnv`, we
encourage users to simply implement a configuration :class:`RLTaskEnvCfg` for their task environment.
This practice allows us to separate the task specification from the environment implementation, making it easier
to reuse components of the same environment for different tasks.
In this tutorial, we will configure the cartpole environment using the :class:`RLTaskEnvCfg` to create a task
for balancing the pole upright. We will learn how to specify the task using reward terms, termination criteria,
curriculum and commands.
The Code
~~~~~~~~
For this tutorial, we use the cartpole environment defined in ``omni.isaac.orbit_tasks.classic.cartpole`` module.
.. dropdown:: Code for cartpole_env_cfg.py
:icon: code
.. literalinclude:: ../../../../source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/cartpole_env_cfg.py
:language: python
:emphasize-lines: 63-68, 124-149, 152-162, 165-169, 187-192
:linenos:
The script for running the environment ``run_cartpole_rl_env.py`` is present in the
``orbit/source/standalone/tutorials/03_envs`` directory. The script is similar to the
``cartpole_base_env.py`` script in the previous tutorial, except that it uses the
:class:`envs.RLTaskEnv` instead of the :class:`envs.BaseEnv`.
.. dropdown:: Code for run_cartpole_rl_env.py
:icon: code
.. literalinclude:: ../../../../source/standalone/tutorials/03_envs/run_cartpole_rl_env.py
:language: python
:emphasize-lines: 43-47, 61-62
:linenos:
The Code Explained
~~~~~~~~~~~~~~~~~~
We already went through parts of the above in the :ref:`tutorial-create-base-env` tutorial to learn
about how to specify the scene, observations, actions and events. Thus, in this tutorial, we
will focus only on the RL components of the environment.
In Orbit, we provide various implementations of different terms in the :mod:`envs.mdp` module. We will use
some of these terms in this tutorial, but users are free to define their own terms as well. These
are usually placed in their task-specific sub-package
(for instance, in :mod:`omni.isaac.orbit_tasks.classic.cartpole.mdp`).
Defining rewards
----------------
The :class:`managers.RewardManager` is used to compute the reward terms for the agent. Similar to the other
managers, its terms are configured using the :class:`managers.RewardTermCfg` class. The
:class:`managers.RewardTermCfg` class specifies the function or callable class that computes the reward
as well as the weighting associated with it. It also takes in dictionary of arguments, ``"params"``
that are passed to the reward function when it is called.
For the cartpole task, we will use the following reward terms:
* **Alive Reward**: Encourage the agent to stay alive for as long as possible.
* **Terminating Reward**: Similarly penalize the agent for terminating.
* **Pole Angle Reward**: Encourage the agent to keep the pole at the desired upright position.
* **Cart Velocity Reward**: Encourage the agent to keep the cart velocity as small as possible.
* **Pole Velocity Reward**: Encourage the agent to keep the pole velocity as small as possible.
.. literalinclude:: ../../../../source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/cartpole_env_cfg.py
:language: python
:pyobject: RewardsCfg
Defining termination criteria
-----------------------------
Most learning tasks happen over a finite number of steps that we call an episode. For instance, in the cartpole
task, we want the agent to balance the pole for as long as possible. However, if the agent reaches an unstable
or unsafe state, we want to terminate the episode. On the other hand, if the agent is able to balance the pole
for a long time, we want to terminate the episode and start a new one so that the agent can learn to balance the
pole from a different starting configuration.
The :class:`managers.TerminationsCfg` configures what constitutes for an episode to terminate. In this example,
we want the task to terminate when either of the following conditions is met:
* **Episode Length** The episode length is greater than the defined max_episode_length
* **Cart out of bounds** The cart goes outside of the bounds [-3, 3]
The flag :attr:`managers.TerminationsCfg.time_out` specifies whether the term is a time-out (truncation) term
or terminated term. These are used to indicate the two types of terminations as described in `Gymnasium's documentation
<https://gymnasium.farama.org/tutorials/gymnasium_basics/handling_time_limits/>`_.
.. literalinclude:: ../../../../source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/cartpole_env_cfg.py
:language: python
:pyobject: TerminationsCfg
Defining commands
-----------------
For various goal-conditioned tasks, it is useful to specify the goals or commands for the agent. These are
handled through the :class:`managers.CommandManager`. The command manager handles resampling and updating the
commands at each step. It can also be used to provide the commands as an observation to the agent.
For this simple task, we do not use any commands. This is specified by using a command term with the
:class:`envs.mdp.NullCommandCfg` configuration. However, you can see an example of command definitions in the
locomotion or manipulation tasks.
.. literalinclude:: ../../../../source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/cartpole_env_cfg.py
:language: python
:pyobject: CommandsCfg
Defining curriculum
-------------------
Often times when training a learning agent, it helps to start with a simple task and gradually increase the
tasks's difficulty as the agent training progresses. This is the idea behind curriculum learning. In Orbit,
we provide a :class:`managers.CurriculumManager` class that can be used to define a curriculum for your environment.
In this tutorial we don't implement a curriculum for simplicity, but you can see an example of a
curriculum definition in the other locomotion or manipulation tasks.
We use a simple pass-through curriculum to define a curriculum manager that does not modify the environment.
.. literalinclude:: ../../../../source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/cartpole_env_cfg.py
:language: python
:pyobject: CurriculumCfg
Tying it all together
---------------------
With all the above components defined, we can now create the :class:`RLTaskEnvCfg` configuration for the
cartpole environment. This is similar to the :class:`BaseEnvCfg` defined in :ref:`tutorial-create-base-env`,
only with the added RL components explained in the above sections.
.. literalinclude:: ../../../../source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/cartpole_env_cfg.py
:language: python
:pyobject: CartpoleEnvCfg
Running the simulation loop
---------------------------
Coming back to the ``run_cartpole_rl_env.py`` script, the simulation loop is similar to the previous tutorial.
The only difference is that we create an instance of :class:`envs.RLTaskEnv` instead of the
:class:`envs.BaseEnv`. Consequently, now the :meth:`envs.RLTaskEnv.step` method returns additional signals
such as the reward and termination status. The information dictionary also maintains logging of quantities
such as the reward contribution from individual terms, the termination status of each term, the episode length etc.
.. literalinclude:: ../../../../source/standalone/tutorials/03_envs/run_cartpole_rl_env.py
:language: python
:pyobject: main
The Code Execution
~~~~~~~~~~~~~~~~~~
Similar to the previous tutorial, we can run the environment by executing the ``run_cartpole_rl_env.py`` script.
.. code-block:: bash
./orbit.sh -p source/standalone/tutorials/03_envs/run_cartpole_rl_env.py --num_envs 32
This should open a similar simulation as in the previous tutorial. However, this time, the environment
returns more signals that specify the reward and termination status. Additionally, the individual
environments reset themselves when they terminate based on the termination criteria specified in the
configuration.
To stop the simulation, you can either close the window, or press ``Ctrl+C`` in the terminal
where you started the simulation.
In this tutorial, we learnt how to create a task environment for reinforcement learning. We do this
by extending the base environment to include the rewards, terminations, commands and curriculum terms.
We also learnt how to use the :class:`envs.RLTaskEnv` class to run the environment and receive various
signals from it.
While it is possible to manually create an instance of :class:`envs.RLTaskEnv` class for a desired task,
this is not scalable as it requires specialized scripts for each task. Thus, we exploit the
:meth:`gymnasium.make` function to create the environment with the gym interface. We will learn how to do this
in the next tutorial.
| 9,925 | reStructuredText | 49.902564 | 135 | 0.764131 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/03_envs/create_base_env.rst | .. _tutorial-create-base-env:
Creating a Base Environment
===========================
.. currentmodule:: omni.isaac.orbit
Environments bring together different aspects of the simulation such as
the scene, observations and actions spaces, reset events etc. to create a
coherent interface for various applications. In Orbit, environments are
implemented as :class:`envs.BaseEnv` and :class:`envs.RLTaskEnv` classes.
The two classes are very similar, but :class:`envs.RLTaskEnv` is useful for
reinforcement learning tasks and contains rewards, terminations, curriculum
and command generation. The :class:`envs.BaseEnv` class is useful for
traditional robot control and doesn't contain rewards and terminations.
In this tutorial, we will look at the base class :class:`envs.BaseEnv` and its
corresponding configuration class :class:`envs.BaseEnvCfg`. We will use the
cartpole environment from earlier to illustrate the different components
in creating a new :class:`envs.BaseEnv` environment.
The Code
~~~~~~~~
The tutorial corresponds to the ``create_cartpole_base_env`` script in the ``orbit/source/standalone/tutorials/03_envs``
directory.
.. dropdown:: Code for create_cartpole_base_env.py
:icon: code
.. literalinclude:: ../../../../source/standalone/tutorials/03_envs/create_cartpole_base_env.py
:language: python
:emphasize-lines: 49-53, 56-73, 76-109, 112-131, 136-140, 145, 149, 154-155, 161-162
:linenos:
The Code Explained
~~~~~~~~~~~~~~~~~~
The base class :class:`envs.BaseEnv` wraps around many intricacies of the simulation interaction
and provides a simple interface for the user to run the simulation and interact with it. It
is composed of the following components:
* :class:`scene.InteractiveScene` - The scene that is used for the simulation.
* :class:`managers.ActionManager` - The manager that handles actions.
* :class:`managers.ObservationManager` - The manager that handles observations.
* :class:`managers.EventManager` - The manager that schedules operations (such as domain randomization)
at specified simulation events. For instance, at startup, on resets, or periodic intervals.
By configuring these components, the user can create different variations of the same environment
with minimal effort. In this tutorial, we will go through the different components of the
:class:`envs.BaseEnv` class and how to configure them to create a new environment.
Designing the scene
-------------------
The first step in creating a new environment is to configure its scene. For the cartpole
environment, we will be using the scene from the previous tutorial. Thus, we omit the
scene configuration here. For more details on how to configure a scene, see
:ref:`tutorial-interactive-scene`.
Defining actions
----------------
In the previous tutorial, we directly input the action to the cartpole using
the :meth:`assets.Articulation.set_joint_effort_target` method. In this tutorial, we will
use the :class:`managers.ActionManager` to handle the actions.
The action manager can comprise of multiple :class:`managers.ActionTerm`. Each action term
is responsible for applying *control* over a specific aspect of the environment. For instance,
for robotic arm, we can have two action terms -- one for controlling the joints of the arm,
and the other for controlling the gripper. This composition allows the user to define
different control schemes for different aspects of the environment.
In the cartpole environment, we want to control the force applied to the cart to balance the pole.
Thus, we will create an action term that controls the force applied to the cart.
.. literalinclude:: ../../../../source/standalone/tutorials/03_envs/create_cartpole_base_env.py
:language: python
:pyobject: ActionsCfg
Defining observations
---------------------
While the scene defines the state of the environment, the observations define the states
that are observable by the agent. These observations are used by the agent to make decisions
on what actions to take. In Orbit, the observations are computed by the
:class:`managers.ObservationManager` class.
Similar to the action manager, the observation manager can comprise of multiple observation terms.
These are further grouped into observation groups which are used to define different observation
spaces for the environment. For instance, for hierarchical control, we may want to define
two observation groups -- one for the low level controller and the other for the high level
controller. It is assumed that all the observation terms in a group have the same dimensions.
For this tutorial, we will only define one observation group named ``"policy"``. While not completely
prescriptive, this group is a necessary requirement for various wrappers in Orbit.
We define a group by inheriting from the :class:`managers.ObservationGroupCfg` class. This class
collects different observation terms and help define common properties for the group, such
as enabling noise corruption or concatenating the observations into a single tensor.
The individual terms are defined by inheriting from the :class:`managers.ObservationTermCfg` class.
This class takes in the :attr:`managers.ObservationTermCfg.func` that specifies the function or
callable class that computes the observation for that term. It includes other parameters for
defining the noise model, clipping, scaling, etc. However, we leave these parameters to their
default values for this tutorial.
.. literalinclude:: ../../../../source/standalone/tutorials/03_envs/create_cartpole_base_env.py
:language: python
:pyobject: ObservationsCfg
Defining events
---------------
At this point, we have defined the scene, actions and observations for the cartpole environment.
The general idea for all these components is to define the configuration classes and then
pass them to the corresponding managers. The event manager is no different.
The :class:`managers.EventManager` class is responsible for events corresponding to changes
in the simulation state. This includes resetting (or randomizing) the scene, randomizing physical
properties (such as mass, friction, etc.), and varying visual properties (such as colors, textures, etc.).
Each of these are specified through the :class:`managers.EventTermCfg` class, which
takes in the :attr:`managers.EventTermCfg.func` that specifies the function or callable
class that performs the event.
Additionally, it expects the **mode** of the event. The mode specifies when the event term should be applied.
It is possible to specify your own mode. For this, you'll need to adapt the :class:`~envs.BaseEnv` class.
However, out of the box, Orbit provides three commonly used modes:
* ``"startup"`` - Event that takes place only once at environment startup.
* ``"reset"`` - Event that occurs on environment termination and reset.
* ``"interval"`` - Event that are executed at a given interval, i.e., periodically after a certain number of steps.
For this example, we define events that randomize the pole's mass on startup. This is done only once since this
operation is expensive and we don't want to do it on every reset. We also create an event to randomize the initial
joint state of the cartpole and the pole at every reset.
.. literalinclude:: ../../../../source/standalone/tutorials/03_envs/create_cartpole_base_env.py
:language: python
:pyobject: EventCfg
Tying it all together
---------------------
Having defined the scene and manager configurations, we can now define the environment configuration
through the :class:`envs.BaseEnvCfg` class. This class takes in the scene, action, observation and
event configurations.
In addition to these, it also takes in the :attr:`envs.BaseEnvCfg.sim` which defines the simulation
parameters such as the timestep, gravity, etc. This is initialized to the default values, but can
be modified as needed. We recommend doing so by defining the :meth:`__post_init__` method in the
:class:`envs.BaseEnvCfg` class, which is called after the configuration is initialized.
.. literalinclude:: ../../../../source/standalone/tutorials/03_envs/create_cartpole_base_env.py
:language: python
:pyobject: CartpoleEnvCfg
Running the simulation
----------------------
Lastly, we revisit the simulation execution loop. This is now much simpler since we have
abstracted away most of the details into the environment configuration. We only need to
call the :meth:`envs.BaseEnv.reset` method to reset the environment and :meth:`envs.BaseEnv.step`
method to step the environment. Both these functions return the observation and an info dictionary
which may contain additional information provided by the environment. These can be used by an
agent for decision-making.
The :class:`envs.BaseEnv` class does not have any notion of terminations since that concept is
specific for episodic tasks. Thus, the user is responsible for defining the termination condition
for the environment. In this tutorial, we reset the simulation at regular intervals.
.. literalinclude:: ../../../../source/standalone/tutorials/03_envs/create_cartpole_base_env.py
:language: python
:pyobject: main
An important thing to note above is that the entire simulation loop is wrapped inside the
:meth:`torch.inference_mode` context manager. This is because the environment uses PyTorch
operations under-the-hood and we want to ensure that the simulation is not slowed down by
the overhead of PyTorch's autograd engine and gradients are not computed for the simulation
operations.
The Code Execution
~~~~~~~~~~~~~~~~~~
To run the base environment made in this tutorial, you can use the following command:
.. code-block:: bash
./orbit.sh -p source/standalone/tutorials/03_envs/create_cartpole_base_env.py --num_envs 32
This should open a stage with a ground plane, light source, and cartpoles. The simulation should be
playing with random actions on the cartpole. Additionally, it opens a UI window on the bottom
right corner of the screen named ``"Orbit"``. This window contains different UI elements that
can be used for debugging and visualization.
To stop the simulation, you can either close the window, or press ``Ctrl+C`` in the terminal where you
started the simulation.
In this tutorial, we learned about the different managers that help define a base environment. We
include more examples of defining the base environment in the ``orbit/source/standalone/tutorials/03_envs``
directory. For completeness, they can be run using the following commands:
.. code-block:: bash
# Floating cube environment with custom action term for PD control
./orbit.sh -p source/standalone/tutorials/03_envs/create_cube_base_env.py --num_envs 32
# Quadrupedal locomotion environment with a policy that interacts with the environment
./orbit.sh -p source/standalone/tutorials/03_envs/create_quadruped_base_env.py --num_envs 32
In the following tutorial, we will look at the :class:`envs.RLTaskEnv` class and how to use it
to create a Markovian Decision Process (MDP).
| 11,020 | reStructuredText | 49.555046 | 121 | 0.773775 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/03_envs/register_rl_env_gym.rst | Registering an Environment
==========================
.. currentmodule:: omni.isaac.orbit
In the previous tutorial, we learned how to create a custom cartpole environment. We manually
created an instance of the environment by importing the environment class and its configuration
class.
.. dropdown:: Environment creation in the previous tutorial
:icon: code
.. literalinclude:: ../../../../source/standalone/tutorials/03_envs/run_cartpole_rl_env.py
:language: python
:start-at: # create environment configuration
:end-at: env = RLTaskEnv(cfg=env_cfg)
While straightforward, this approach is not scalable as we have a large suite of environments.
In this tutorial, we will show how to use the :meth:`gymnasium.register` method to register
environments with the ``gymnasium`` registry. This allows us to create the environment through
the :meth:`gymnasium.make` function.
.. dropdown:: Environment creation in this tutorial
:icon: code
.. literalinclude:: ../../../../source/standalone/environments/random_agent.py
:language: python
:lines: 40-51
The Code
~~~~~~~~
The tutorial corresponds to the ``random_agent.py`` script in the ``orbit/source/standalone/environments`` directory.
.. dropdown:: Code for random_agent.py
:icon: code
.. literalinclude:: ../../../../source/standalone/environments/random_agent.py
:language: python
:emphasize-lines: 39-41, 46-51
:linenos:
The Code Explained
~~~~~~~~~~~~~~~~~~
The :class:`envs.RLTaskEnv` class inherits from the :class:`gymnasium.Env` class to follow
a standard interface. However, unlike the traditional Gym environments, the :class:`envs.RLTaskEnv`
implements a *vectorized* environment. This means that multiple environment instances
are running simultaneously in the same process, and all the data is returned in a batched
fashion.
Using the gym registry
----------------------
To register an environment, we use the :meth:`gymnasium.register` method. This method takes
in the environment name, the entry point to the environment class, and the entry point to the
environment configuration class. For the cartpole environment, the following shows the registration
call in the ``omni.isaac.orbit_tasks.classic.cartpole`` sub-package:
.. literalinclude:: ../../../../source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/__init__.py
:language: python
:lines: 10-
:emphasize-lines: 11, 12, 15
The ``id`` argument is the name of the environment. As a convention, we name all the environments
with the prefix ``Isaac-`` to make it easier to search for them in the registry. The name of the
environment is typically followed by the name of the task, and then the name of the robot.
For instance, for legged locomotion with ANYmal C on flat terrain, the environment is called
``Isaac-Velocity-Flat-Anymal-C-v0``. The version number ``v<N>`` is typically used to specify different
variations of the same environment. Otherwise, the names of the environments can become too long
and difficult to read.
The ``entry_point`` argument is the entry point to the environment class. The entry point is a string
of the form ``<module>:<class>``. In the case of the cartpole environment, the entry point is
``omni.isaac.orbit.envs:RLTaskEnv``. The entry point is used to import the environment class
when creating the environment instance.
The ``env_cfg_entry_point`` argument specifies the default configuration for the environment. The default
configuration is loaded using the :meth:`omni.isaac.orbit_tasks.utils.parse_env_cfg` function.
It is then passed to the :meth:`gymnasium.make` function to create the environment instance.
The configuration entry point can be both a YAML file or a python configuration class.
.. note::
The ``gymnasium`` registry is a global registry. Hence, it is important to ensure that the
environment names are unique. Otherwise, the registry will throw an error when registering
the environment.
Creating the environment
------------------------
To inform the ``gym`` registry with all the environments provided by the ``omni.isaac.orbit_tasks``
extension, we must import the module at the start of the script. This will execute the ``__init__.py``
file which iterates over all the sub-packages and registers their respective environments.
.. literalinclude:: ../../../../source/standalone/environments/random_agent.py
:language: python
:start-at: import omni.isaac.orbit_tasks # noqa: F401
:end-at: import omni.isaac.orbit_tasks # noqa: F401
In this tutorial, the task name is read from the command line. The task name is used to parse
the default configuration as well as to create the environment instance. In addition, other
parsed command line arguments such as the number of environments, the simulation device,
and whether to render, are used to override the default configuration.
.. literalinclude:: ../../../../source/standalone/environments/random_agent.py
:language: python
:start-at: # create environment configuration
:end-at: env = gym.make(args_cli.task, cfg=env_cfg)
Once creating the environment, the rest of the execution follows the standard resetting and stepping.
The Code Execution
~~~~~~~~~~~~~~~~~~
Now that we have gone through the code, let's run the script and see the result:
.. code-block:: bash
./orbit.sh -p source/standalone/environments/random_agent.py --task Isaac-Cartpole-v0 --num_envs 32
This should open a stage with everything similar to the previous :ref:`tutorial-create-rl-env` tutorial.
To stop the simulation, you can either close the window, or press ``Ctrl+C`` in the terminal.
In addition, you can also change the simulation device from GPU to CPU by adding the ``--cpu`` flag:
.. code-block:: bash
./orbit.sh -p source/standalone/environments/random_agent.py --task Isaac-Cartpole-v0 --num_envs 32 --cpu
With the ``--cpu`` flag, the simulation will run on the CPU. This is useful for debugging the simulation.
However, the simulation will run much slower than on the GPU.
| 6,070 | reStructuredText | 43.313868 | 124 | 0.741516 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/03_envs/index.rst | Designing an Environment
========================
The following tutorials introduce the concept of environments: :class:`~omni.isaac.orbit.envs.BaseEnv`
and its derivative :class:`~omni.isaac.orbit.envs.RLTaskEnv`. These environments bring-in together
different aspects of the framework to create a simulation environment for agent interaction.
.. toctree::
:maxdepth: 1
:titlesonly:
create_base_env
create_rl_env
register_rl_env_gym
run_rl_training
| 477 | reStructuredText | 28.874998 | 102 | 0.721174 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/05_controllers/run_diff_ik.rst | Using a task-space controller
=============================
.. currentmodule:: omni.isaac.orbit
In the previous tutorials, we have joint-space controllers to control the robot. However, in many
cases, it is more intuitive to control the robot using a task-space controller. For example, if we
want to teleoperate the robot, it is easier to specify the desired end-effector pose rather than
the desired joint positions.
In this tutorial, we will learn how to use a task-space controller to control the robot.
We will use the :class:`controllers.DifferentialIKController` class to track a desired
end-effector pose command.
The Code
~~~~~~~~
The tutorial corresponds to the ``run_diff_ik.py`` script in the
``orbit/source/standalone/tutorials/05_controllers`` directory.
.. dropdown:: Code for run_diff_ik.py
:icon: code
.. literalinclude:: ../../../../source/standalone/tutorials/05_controllers/run_diff_ik.py
:language: python
:emphasize-lines: 100-102, 123-138, 157-159, 163-173
:linenos:
The Code Explained
~~~~~~~~~~~~~~~~~~
While using any task-space controller, it is important to ensure that the provided
quantities are in the correct frames. When parallelizing environment instances, they are
all existing in the same unique simulation world frame. However, typically, we want each
environment itself to have its own local frame. This is accessible through the
:attr:`scene.InteractiveScene.env_origins` attribute.
In our APIs, we use the following notation for frames:
- The simulation world frame (denoted as ``w``), which is the frame of the entire simulation.
- The local environment frame (denoted as ``e``), which is the frame of the local environment.
- The robot's base frame (denoted as ``b``), which is the frame of the robot's base link.
Since the asset instances are not "aware" of the local environment frame, they return
their states in the simulation world frame. Thus, we need to convert the obtained
quantities to the local environment frame. This is done by subtracting the local environment
origin from the obtained quantities.
Creating an IK controller
-------------------------
The :class:`~controllers.DifferentialIKController` class computes the desired joint
positions for a robot to reach a desired end-effector pose. The included implementation
performs the computation in a batched format and uses PyTorch operations. It supports
different types of inverse kinematics solvers, including the damped least-squares method
and the pseudo-inverse method. These solvers can be specified using the
:attr:`~controllers.DifferentialIKControllerCfg.ik_method` argument.
Additionally, the controller can handle commands as both relative and absolute poses.
In this tutorial, we will use the damped least-squares method to compute the desired
joint positions. Additionally, since we want to track desired end-effector poses, we
will use the absolute pose command mode.
.. literalinclude:: ../../../../source/standalone/tutorials/05_controllers/run_diff_ik.py
:language: python
:start-at: # Create controller
:end-at: diff_ik_controller = DifferentialIKController(diff_ik_cfg, num_envs=scene.num_envs, device=sim.device)
Obtaining the robot's joint and body indices
--------------------------------------------
The IK controller implementation is a computation-only class. Thus, it expects the
user to provide the necessary information about the robot. This includes the robot's
joint positions, current end-effector pose, and the Jacobian matrix.
While the attribute :attr:`assets.ArticulationData.joint_pos` provides the joint positions,
we only want the joint positions of the robot's arm, and not the gripper. Similarly, while
the attribute :attr:`assets.ArticulationData.body_state_w` provides the state of all the
robot's bodies, we only want the state of the robot's end-effector. Thus, we need to
index into these arrays to obtain the desired quantities.
For this, the articulation class provides the methods :meth:`~assets.Articulation.find_joints`
and :meth:`~assets.Articulation.find_bodies`. These methods take in the names of the joints
and bodies and return their corresponding indices.
While you may directly use these methods to obtain the indices, we recommend using the
:attr:`~managers.SceneEntityCfg` class to resolve the indices. This class is used in various
places in the APIs to extract certain information from a scene entity. Internally, it
calls the above methods to obtain the indices. However, it also performs some additional
checks to ensure that the provided names are valid. Thus, it is a safer option to use
this class.
.. literalinclude:: ../../../../source/standalone/tutorials/05_controllers/run_diff_ik.py
:language: python
:start-at: # Specify robot-specific parameters
:end-before: # Define simulation stepping
Computing robot command
-----------------------
The IK controller separates the operation of setting the desired command and
computing the desired joint positions. This is done to allow for the user to
run the IK controller at a different frequency than the robot's control frequency.
The :meth:`~controllers.DifferentialIKController.set_command` method takes in
the desired end-effector pose as a single batched array. The pose is specified in
the robot's base frame.
.. literalinclude:: ../../../../source/standalone/tutorials/05_controllers/run_diff_ik.py
:language: python
:start-at: # reset controller
:end-at: diff_ik_controller.set_command(ik_commands)
We can then compute the desired joint positions using the
:meth:`~controllers.DifferentialIKController.compute` method.
The method takes in the current end-effector pose (in base frame), Jacobian, and
current joint positions. We read the Jacobian matrix from the robot's data, which uses
its value computed from the physics engine.
.. literalinclude:: ../../../../source/standalone/tutorials/05_controllers/run_diff_ik.py
:language: python
:start-at: # obtain quantities from simulation
:end-at: joint_pos_des = diff_ik_controller.compute(ee_pos_b, ee_quat_b, jacobian, joint_pos)
The computed joint position targets can then be applied on the robot, as done in the
previous tutorials.
.. literalinclude:: ../../../../source/standalone/tutorials/05_controllers/run_diff_ik.py
:language: python
:start-at: # apply actions
:end-at: scene.write_data_to_sim()
The Code Execution
~~~~~~~~~~~~~~~~~~
Now that we have gone through the code, let's run the script and see the result:
.. code-block:: bash
./orbit.sh -p source/standalone/tutorials/05_controllers/run_diff_ik.py --robot franka_panda --num_envs 128
The script will start a simulation with 128 robots. The robots will be controlled using the IK controller.
The current and desired end-effector poses should be displayed using frame markers. When the robot reaches
the desired pose, the command should cycle through to the next pose specified in the script.
To stop the simulation, you can either close the window, or press the ``STOP`` button in the UI, or
press ``Ctrl+C`` in the terminal.
| 7,092 | reStructuredText | 44.76129 | 114 | 0.758319 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/05_controllers/index.rst | Using Motion Generators
=======================
While the robots in the simulation environment can be controlled at the joint-level, the following
tutorials show you how to use motion generators to control the robots at the task-level.
.. toctree::
:maxdepth: 1
:titlesonly:
run_diff_ik
| 302 | reStructuredText | 24.249998 | 98 | 0.695364 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/04_sensors/add_sensors_on_robot.rst | .. _tutorial-add-sensors-on-robot:
Adding sensors on a robot
=========================
.. currentmodule:: omni.isaac.orbit
While the asset classes allow us to create and simulate the physical embodiment of the robot,
sensors help in obtaining information about the environment. They typically update at a lower
frequency than the simulation and are useful for obtaining different proprioceptive and
exteroceptive information. For example, a camera sensor can be used to obtain the visual
information of the environment, and a contact sensor can be used to obtain the contact
information of the robot with the environment.
In this tutorial, we will see how to add different sensors to a robot. We will use the
ANYmal-C robot for this tutorial. The ANYmal-C robot is a quadrupedal robot with 12 degrees
of freedom. It has 4 legs, each with 3 degrees of freedom. The robot has the following
sensors:
- A camera sensor on the head of the robot which provides RGB-D images
- A height scanner sensor that provides terrain height information
- Contact sensors on the feet of the robot that provide contact information
We continue this tutorial from the previous tutorial on :ref:`tutorial-interactive-scene`,
where we learned about the :class:`scene.InteractiveScene` class.
The Code
~~~~~~~~
The tutorial corresponds to the ``add_sensors_on_robot.py`` script in the
``orbit/source/standalone/tutorials/04_sensors`` directory.
.. dropdown:: Code for add_sensors_on_robot.py
:icon: code
.. literalinclude:: ../../../../source/standalone/tutorials/04_sensors/add_sensors_on_robot.py
:language: python
:emphasize-lines: 74-97, 145-155, 169-170
:linenos:
The Code Explained
~~~~~~~~~~~~~~~~~~
Similar to the previous tutorials, where we added assets to the scene, the sensors are also added
to the scene using the scene configuration. All sensors inherit from the :class:`sensors.SensorBase` class
and are configured through their respective config classes. Each sensor instance can define its own
update period, which is the frequency at which the sensor is updated. The update period is specified
in seconds through the :attr:`sensors.SensorBaseCfg.update_period` attribute.
Depending on the specified path and the sensor type, the sensors are attached to the prims in the scene.
They may have an associated prim that is created in the scene or they may be attached to an existing prim.
For instance, the camera sensor has a corresponding prim that is created in the scene, whereas for the
contact sensor, the activating the contact reporting is a property on a rigid body prim.
In the following, we introduce the different sensors we use in this tutorial and how they are configured.
For more description about them, please check the :mod:`sensors` module.
Camera sensor
-------------
A camera is defined using the :class:`sensors.CameraCfg`. It is based on the USD Camera sensor and
the different data types are captured using Omniverse Replicator API. Since it has a corresponding prim
in the scene, the prims are created in the scene at the specified prim path.
The configuration of the camera sensor includes the following parameters:
* :attr:`~sensors.CameraCfg.spawn`: The type of USD camera to create. This can be either
:class:`~sim.spawners.sensors.PinholeCameraCfg` or :class:`~sim.spawners.sensors.FisheyeCameraCfg`.
* :attr:`~sensors.CameraCfg.offset`: The offset of the camera sensor from the parent prim.
* :attr:`~sensors.CameraCfg.data_types`: The data types to capture. This can be ``rgb``,
``distance_to_image_plane``, ``normals``, or other types supported by the USD Camera sensor.
To attach an RGB-D camera sensor to the head of the robot, we specify an offset relative to the base
frame of the robot. The offset is specified as a translation and rotation relative to the base frame,
and the :attr:`~sensors.CameraCfg.OffsetCfg.convention` in which the offset is specified.
In the following, we show the configuration of the camera sensor used in this tutorial. We set the
update period to 0.1s, which means that the camera sensor is updated at 10Hz. The prim path expression is
set to ``{ENV_REGEX_NS}/Robot/base/front_cam`` where the ``{ENV_REGEX_NS}`` is the environment namespace,
``"Robot"`` is the name of the robot, ``"base"`` is the name of the prim to which the camera is attached,
and ``"front_cam"`` is the name of the prim associated with the camera sensor.
.. literalinclude:: ../../../../source/standalone/tutorials/04_sensors/add_sensors_on_robot.py
:language: python
:start-at: camera = CameraCfg(
:end-before: height_scanner = RayCasterCfg(
Height scanner
--------------
The height-scanner is implemented as a virtual sensor using the NVIDIA Warp ray-casting kernels.
Through the :class:`sensors.RayCasterCfg`, we can specify the pattern of rays to cast and the
meshes against which to cast the rays. Since they are virtual sensors, there is no corresponding
prim created in the scene for them. Instead they are attached to a prim in the scene, which is
used to specify the location of the sensor.
For this tutorial, the ray-cast based height scanner is attached to the base frame of the robot.
The pattern of rays is specified using the :attr:`~sensors.RayCasterCfg.pattern` attribute. For
a uniform grid pattern, we specify the pattern using :class:`~sensors.patterns.GridPatternCfg`.
Since we only care about the height information, we do not need to consider the roll and pitch
of the robot. Hence, we set the :attr:`~sensors.RayCasterCfg.attach_yaw_only` to true.
For the height-scanner, you can visualize the points where the rays hit the mesh. This is done
by setting the :attr:`~sensors.SensorBaseCfg.debug_vis` attribute to true.
The entire configuration of the height-scanner is as follows:
.. literalinclude:: ../../../../source/standalone/tutorials/04_sensors/add_sensors_on_robot.py
:language: python
:start-at: height_scanner = RayCasterCfg(
:end-before: contact_forces = ContactSensorCfg(
Contact sensor
--------------
Contact sensors wrap around the PhysX contact reporting API to obtain the contact information of the robot
with the environment. Since it relies of PhysX, the contact sensor expects the contact reporting API
to be enabled on the rigid bodies of the robot. This can be done by setting the
:attr:`~sim.spawners.RigidObjectSpawnerCfg.activate_contact_sensors` to true in the asset configuration.
Through the :class:`sensors.ContactSensorCfg`, it is possible to specify the prims for which we want to
obtain the contact information. Additional flags can be set to obtain more information about
the contact, such as the contact air time, contact forces between filtered prims, etc.
In this tutorial, we attach the contact sensor to the feet of the robot. The feet of the robot are
named ``"LF_FOOT"``, ``"RF_FOOT"``, ``"LH_FOOT"``, and ``"RF_FOOT"``. We pass a Regex expression
``".*_FOOT"`` to simplify the prim path specification. This Regex expression matches all prims that
end with ``"_FOOT"``.
We set the update period to 0 to update the sensor at the same frequency as the simulation. Additionally,
for contact sensors, we can specify the history length of the contact information to store. For this
tutorial, we set the history length to 6, which means that the contact information for the last 6
simulation steps is stored.
The entire configuration of the contact sensor is as follows:
.. literalinclude:: ../../../../source/standalone/tutorials/04_sensors/add_sensors_on_robot.py
:language: python
:start-at: contact_forces = ContactSensorCfg(
:lines: 1-3
Running the simulation loop
---------------------------
Similar to when using assets, the buffers and physics handles for the sensors are initialized only
when the simulation is played, i.e., it is important to call ``sim.reset()`` after creating the scene.
.. literalinclude:: ../../../../source/standalone/tutorials/04_sensors/add_sensors_on_robot.py
:language: python
:start-at: # Play the simulator
:end-at: sim.reset()
Besides that, the simulation loop is similar to the previous tutorials. The sensors are updated as part
of the scene update and they internally handle the updating of their buffers based on their update
periods.
The data from the sensors can be accessed through their ``data`` attribute. As an example, we show how
to access the data for the different sensors created in this tutorial:
.. literalinclude:: ../../../../source/standalone/tutorials/04_sensors/add_sensors_on_robot.py
:language: python
:start-at: # print information from the sensors
:end-at: print("Received max contact force of: ", torch.max(scene["contact_forces"].data.net_forces_w).item())
The Code Execution
~~~~~~~~~~~~~~~~~~
Now that we have gone through the code, let's run the script and see the result:
.. code-block:: bash
./orbit.sh -p source/standalone/tutorials/04_sensors/add_sensors_on_robot.py --num_envs 2
This command should open a stage with a ground plane, lights, and two quadrupedal robots.
Around the robots, you should see red spheres that indicate the points where the rays hit the mesh.
Additionally, you can switch the viewport to the camera view to see the RGB image captured by the
camera sensor. Please check `here <https://youtu.be/htPbcKkNMPs?feature=shared>`_ for more information
on how to switch the viewport to the camera view.
To stop the simulation, you can either close the window, or press ``Ctrl+C`` in the terminal.
While in this tutorial, we went over creating and using different sensors, there are many more sensors
available in the :mod:`sensors` module. We include minimal examples of using these sensors in the
``source/standalone/tutorials/04_sensors`` directory. For completeness, these scripts can be run using the
following commands:
.. code-block:: bash
# Frame Transformer
./orbit.sh -p source/standalone/tutorials/04_sensors/run_frame_transformer.py
# Ray Caster
./orbit.sh -p source/standalone/tutorials/04_sensors/run_ray_caster.py
# Ray Caster Camera
./orbit.sh -p source/standalone/tutorials/04_sensors/run_ray_caster_camera.py
# USD Camera
./orbit.sh -p source/standalone/tutorials/04_sensors/run_usd_camera.py
| 10,241 | reStructuredText | 48.960975 | 113 | 0.759301 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/04_sensors/index.rst | Integrating Sensors
===================
The following tutorial shows you how to integrate sensors into the simulation environment. The
tutorials introduce the :class:`~omni.isaac.orbit.sensors.SensorBase` class and its derivatives
such as :class:`~omni.isaac.orbit.sensors.Camera` and :class:`~omni.isaac.orbit.sensors.RayCaster`.
.. toctree::
:maxdepth: 1
:titlesonly:
add_sensors_on_robot
| 406 | reStructuredText | 30.30769 | 99 | 0.729064 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/00_sim/spawn_prims.rst | .. _tutorial-spawn-prims:
Spawning prims into the scene
=============================
.. currentmodule:: omni.isaac.orbit
This tutorial explores how to spawn various objects (or prims) into the scene in Orbit from Python.
It builds upon the previous tutorial on running the simulator from a standalone script and
demonstrates how to spawn a ground plane, lights, primitive shapes, and meshes from USD files.
The Code
~~~~~~~~
The tutorial corresponds to the ``spawn_prims.py`` script in the ``orbit/source/standalone/tutorials/00_sim`` directory.
Let's take a look at the Python script:
.. dropdown:: Code for spawn_prims.py
:icon: code
.. literalinclude:: ../../../../source/standalone/tutorials/00_sim/spawn_prims.py
:language: python
:emphasize-lines: 40-79, 91-92
:linenos:
The Code Explained
~~~~~~~~~~~~~~~~~~
Scene designing in Omniverse is built around a software system and file format called USD (Universal Scene Description).
It allows describing 3D scenes in a hierarchical manner, similar to a file system. Since USD is a comprehensive framework,
we recommend reading the `USD documentation`_ to learn more about it.
For completeness, we introduce the must know concepts of USD in this tutorial.
* **Primitives (Prims)**: These are the basic building blocks of a USD scene. They can be thought of as nodes in a scene
graph. Each node can be a mesh, a light, a camera, or a transform. It can also be a group of other prims under it.
* **Attributes**: These are the properties of a prim. They can be thought of as key-value pairs. For example, a prim can
have an attribute called ``color`` with a value of ``red``.
* **Relationships**: These are the connections between prims. They can be thought of as pointers to other prims. For
example, a mesh prim can have a relationship to a material prim for shading.
A collection of these prims, with their attributes and relationships, is called a **USD stage**. It can be thought of
as a container for all prims in a scene. When we say we are designing a scene, we are actually designing a USD stage.
While working with direct USD APIs provides a lot of flexibility, it can be cumbersome to learn and use. To make it
easier to design scenes, Orbit builds on top of the USD APIs to provide a configuration-drive interface to spawn prims
into a scene. These are included in the :mod:`sim.spawners` module.
When spawning prims into the scene, each prim requires a configuration class instance that defines the prim's attributes
and relationships (through material and shading information). The configuration class is then passed to its respective
function where the prim name and transformation are specified. The function then spawns the prim into the scene.
At a high-level, this is how it works:
.. code-block:: python
# Create a configuration class instance
cfg = MyPrimCfg()
prim_path = "/path/to/prim"
# Spawn the prim into the scene using the corresponding spawner function
spawn_my_prim(prim_path, cfg, translation=[0, 0, 0], orientation=[1, 0, 0, 0], scale=[1, 1, 1])
# OR
# Use the spawner function directly from the configuration class
cfg.func(prim_path, cfg, translation=[0, 0, 0], orientation=[1, 0, 0, 0], scale=[1, 1, 1])
In this tutorial, we demonstrate the spawning of various different prims into the scene. For more
information on the available spawners, please refer to the :mod:`sim.spawners` module in Orbit.
.. attention::
All the scene designing must happen before the simulation starts. Once the simulation starts, we recommend keeping
the scene frozen and only altering the properties of the prim. This is particularly important for GPU simulation
as adding new prims during simulation may alter the physics simulation buffers on GPU and lead to unexpected
behaviors.
Spawning a ground plane
-----------------------
The :class:`~sim.spawners.from_files.GroundPlaneCfg` configures a grid-like ground plane with
modifiable properties such as its appearance and size.
.. literalinclude:: ../../../../source/standalone/tutorials/00_sim/spawn_prims.py
:language: python
:start-at: # Ground-plane
:end-at: cfg_ground.func("/World/defaultGroundPlane", cfg_ground)
Spawning lights
---------------
It is possible to spawn `different light prims`_ into the stage. These include distant lights, sphere lights, disk
lights, and cylinder lights. In this tutorial, we spawn a distant light which is a light that is infinitely far away
from the scene and shines in a single direction.
.. literalinclude:: ../../../../source/standalone/tutorials/00_sim/spawn_prims.py
:language: python
:start-at: # spawn distant light
:end-at: cfg_light_distant.func("/World/lightDistant", cfg_light_distant, translation=(1, 0, 10))
Spawning primitive shapes
-------------------------
Before spawning primitive shapes, we introduce the concept of a transform prim or Xform. A transform prim is a prim that
contains only transformation properties. It is used to group other prims under it and to transform them as a group.
Here we make an Xform prim to group all the primitive shapes under it.
.. literalinclude:: ../../../../source/standalone/tutorials/00_sim/spawn_prims.py
:language: python
:start-at: # create a new xform prim for all objects to be spawned under
:end-at: prim_utils.create_prim("/World/Objects", "Xform")
Next, we spawn a cone using the :class:`~sim.spawners.shapes.ConeCfg` class. It is possible to specify
the radius, height, physics properties, and material properties of the cone. By default, the physics and material
properties are disabled.
The first two cones we spawn ``Cone1`` and ``Cone2`` are visual elements and do not have physics enabled.
.. literalinclude:: ../../../../source/standalone/tutorials/00_sim/spawn_prims.py
:language: python
:start-at: # spawn a red cone
:end-at: cfg_cone.func("/World/Objects/Cone2", cfg_cone, translation=(-1.0, -1.0, 1.0))
For the third cone ``ConeRigid``, we add rigid body physics to it by setting the attributes for that in the configuration
class. Through these attributes, we can specify the mass, friction, and restitution of the cone. If unspecified, they
default to the default values set by USD Physics.
.. literalinclude:: ../../../../source/standalone/tutorials/00_sim/spawn_prims.py
:language: python
:start-at: # spawn a green cone with colliders and rigid body
:end-before: # spawn a usd file of a table into the scene
Spawning from another file
--------------------------
Lastly, it is possible to spawn prims from other file formats such as other USD, URDF, or OBJ files. In this tutorial,
we spawn a USD file of a table into the scene. The table is a mesh prim and has a material prim associated with it.
All of this information is stored in its USD file.
.. literalinclude:: ../../../../source/standalone/tutorials/00_sim/spawn_prims.py
:language: python
:start-at: # spawn a usd file of a table into the scene
:end-at: cfg.func("/World/Objects/Table", cfg, translation=(0.0, 0.0, 1.05))
The table above is added as a reference to the scene. In layman terms, this means that the table is not actually added
to the scene, but a ``pointer`` to the table asset is added. This allows us to modify the table asset and have the changes
reflected in the scene in a non-destructive manner. For example, we can change the material of the table without
actually modifying the underlying file for the table asset directly. Only the changes are stored in the USD stage.
Executing the Script
~~~~~~~~~~~~~~~~~~~~
Similar to the tutorial before, to run the script, execute the following command:
.. code-block:: bash
./orbit.sh -p source/standalone/tutorials/00_sim/spawn_prims.py
Once the simulation starts, you should see a window with a ground plane, a light, some cones, and a table.
The green cone, which has rigid body physics enabled, should fall and collide with the table and the ground
plane. The other cones are visual elements and should not move. To stop the simulation, you can close the window,
or press ``Ctrl+C`` in the terminal.
This tutorial provided a foundation for spawning various prims into the scene in Orbit. Although simple, it
demonstrates the basic concepts of scene designing in Orbit and how to use the spawners. In the coming tutorials,
we will now look at how to interact with the scene and the simulation.
.. _`USD documentation`: https://graphics.pixar.com/usd/docs/index.html
.. _`different light prims`: https://youtu.be/c7qyI8pZvF4?feature=shared
| 8,582 | reStructuredText | 46.94972 | 122 | 0.738989 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/00_sim/launch_app.rst | Deep-dive into AppLauncher
==========================
.. currentmodule:: omni.isaac.orbit
In this tutorial, we will dive into the :class:`app.AppLauncher` class to configure the simulator using
CLI arguments and environment variables (envars). Particularly, we will demonstrate how to use
:class:`~app.AppLauncher` to enable livestreaming and configure the :class:`omni.isaac.kit.SimulationApp`
instance it wraps, while also allowing user-provided options.
The :class:`~app.AppLauncher` is a wrapper for :class:`~omni.isaac.kit.SimulationApp` to simplify
its configuration. The :class:`~omni.isaac.kit.SimulationApp` has many extensions that must be
loaded to enable different capabilities, and some of these extensions are order- and inter-dependent.
Additionally, there are startup options such as ``headless`` which must be set at instantiation time,
and which have an implied relationship with some extensions, e.g. the livestreaming extensions.
The :class:`~app.AppLauncher` presents an interface that can handle these extensions and startup
options in a portable manner across a variety of use cases. To achieve this, we offer CLI and envar
flags which can be merged with user-defined CLI args, while passing forward arguments intended
for :class:`~omni.isaac.kit.SimulationApp`.
The Code
--------
The tutorial corresponds to the ``launch_app.py`` script in the
``orbit/source/standalone/tutorials/00_sim`` directory.
.. dropdown:: Code for launch_app.py
:icon: code
.. literalinclude:: ../../../../source/standalone/tutorials/00_sim/launch_app.py
:language: python
:emphasize-lines: 18-40
:linenos:
The Code Explained
------------------
Adding arguments to the argparser
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:class:`~app.AppLauncher` is designed to be compatible with custom CLI args that users need for
their own scripts, while still providing a portable CLI interface.
In this tutorial, a standard :class:`argparse.ArgumentParser` is instantiated and given the
script-specific ``--size`` argument, as well as the arguments ``--height`` and ``--width``.
The latter are ingested by :class:`~omni.isaac.kit.SimulationApp`.
The argument ``--size`` is not used by :class:`~app.AppLauncher`, but will merge seamlessly
with the :class:`~app.AppLauncher` interface. In-script arguments can be merged with the
:class:`~app.AppLauncher` interface via the :meth:`~app.AppLauncher.add_app_launcher_args` method,
which will return a modified :class:`~argparse.ArgumentParser` with the :class:`~app.AppLauncher`
arguments appended. This can then be processed into an :class:`argparse.Namespace` using the
standard :meth:`argparse.ArgumentParser.parse_args` method and passed directly to
:class:`~app.AppLauncher` for instantiation.
.. literalinclude:: ../../../../source/standalone/tutorials/00_sim/launch_app.py
:language: python
:start-at: import argparse
:end-at: simulation_app = app_launcher.app
The above only illustrates only one of several ways of passing arguments to :class:`~app.AppLauncher`.
Please consult its documentation page to see further options.
Understanding the output of --help
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
While executing the script, we can pass the ``--help`` argument and see the combined outputs of the
custom arguments and those from :class:`~app.AppLauncher`.
.. code-block:: console
./orbit.sh -p source/standalone/tutorials/00_sim/launch_app.py --help
[INFO] Using python from: /isaac-sim/python.sh
[INFO][AppLauncher]: The argument 'width' will be used to configure the SimulationApp.
[INFO][AppLauncher]: The argument 'height' will be used to configure the SimulationApp.
usage: launch_app.py [-h] [--size SIZE] [--width WIDTH] [--height HEIGHT] [--headless] [--livestream {0,1,2,3}]
[--offscreen_render] [--verbose] [--experience EXPERIENCE]
Tutorial on running IsaacSim via the AppLauncher.
options:
-h, --help show this help message and exit
--size SIZE Side-length of cuboid
--width WIDTH Width of the viewport and generated images. Defaults to 1280
--height HEIGHT Height of the viewport and generated images. Defaults to 720
app_launcher arguments:
--headless Force display off at all times.
--livestream {0,1,2,3}
Force enable livestreaming. Mapping corresponds to that for the "LIVESTREAM" environment variable.
--offscreen_render Enable offscreen rendering when running without a GUI.
--verbose Enable verbose terminal logging from the SimulationApp.
--experience EXPERIENCE
The experience file to load when launching the SimulationApp.
* If an empty string is provided, the experience file is determined based on the headless flag.
* If a relative path is provided, it is resolved relative to the `apps` folder in Isaac Sim and
Orbit (in that order).
This readout details the ``--size``, ``--height``, and ``--width`` arguments defined in the script directly,
as well as the :class:`~app.AppLauncher` arguments.
The ``[INFO]`` messages preceding the help output also reads out which of these arguments are going
to be interpreted as arguments to the :class:`~omni.isaac.kit.SimulationApp` instance which the
:class:`~app.AppLauncher` class wraps. In this case, it is ``--height`` and ``--width``. These
are classified as such because they match the name and type of an argument which can be processed
by :class:`~omni.isaac.kit.SimulationApp`. Please refer to the `specification`_ for such arguments
for more examples.
Using environment variables
^^^^^^^^^^^^^^^^^^^^^^^^^^^
As noted in the help message, the :class:`~app.AppLauncher` arguments (``--livestream``, ``--headless``)
have corresponding environment variables (envar) as well. These are detailed in :mod:`omni.isaac.orbit.app`
documentation. Providing any of these arguments through CLI is equivalent to running the script in a shell
environment where the corresponding envar is set.
The support for :class:`~app.AppLauncher` envars are simply a convenience to provide session-persistent
configurations, and can be set in the user's ``${HOME}/.bashrc`` for persistent settings between sessions.
In the case where these arguments are provided from the CLI, they will override their corresponding envar,
as we will demonstrate later in this tutorial.
These arguments can be used with any script that starts the simulation using :class:`~app.AppLauncher`,
with one exception, ``--offscreen_render``. This setting sets the rendering pipeline to use the
offscreen renderer. However, this setting is only compatible with the :class:`omni.isaac.orbit.sim.SimulationContext`.
It will not work with Isaac Sim's :class:`omni.isaac.core.simulation_context.SimulationContext` class.
For more information on this flag, please see the :class:`~app.AppLauncher` API documentation.
The Code Execution
------------------
We will now run the example script:
.. code-block:: console
LIVESTREAM=1 ./orbit.sh -p source/standalone/tutorials/00_sim/launch_app.py --size 0.5
This will spawn a 0.5m\ :sup:`3` volume cuboid in the simulation. No GUI will appear, equivalent
to if we had passed the ``--headless`` flag because headlessness is implied by our ``LIVESTREAM``
envar. If a visualization is desired, we could get one via Isaac's `Native Livestreaming`_. Streaming
is currently the only supported method of visualization from within the container. The
process can be killed by pressing ``Ctrl+C`` in the launching terminal.
Now, let's look at how :class:`~app.AppLauncher` handles conflicting commands:
.. code-block:: console
export LIVESTREAM=0
./orbit.sh -p source/standalone/tutorials/00_sim/launch_app.py --size 0.5 --livestream 1
This will cause the same behavior as in the previous run, because although we have set ``LIVESTREAM=0``
in our envars, CLI args such as ``--livestream`` take precedence in determining behavior. The process can
be killed by pressing ``Ctrl+C`` in the launching terminal.
Finally, we will examine passing arguments to :class:`~omni.isaac.kit.SimulationApp` through
:class:`~app.AppLauncher`:
.. code-block:: console
export LIVESTREAM=1
./orbit.sh -p source/standalone/tutorials/00_sim/launch_app.py --size 0.5 --width 1920 --height 1080
This will cause the same behavior as before, but now the viewport will be rendered at 1920x1080p resolution.
This can be useful when we want to gather high-resolution video, or we can specify a lower resolution if we
want our simulation to be more performant. The process can be killed by pressing ``Ctrl+C`` in the launching
terminal.
.. _specification: https://docs.omniverse.nvidia.com/py/isaacsim/source/extensions/omni.isaac.kit/docs/index.html#omni.isaac.kit.SimulationApp.DEFAULT_LAUNCHER_CONFIG
.. _Native Livestreaming: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/manual_livestream_clients.html#omniverse-streaming-client
| 9,065 | reStructuredText | 50.805714 | 166 | 0.734363 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/00_sim/create_empty.rst | Creating an empty scene
=======================
.. currentmodule:: omni.isaac.orbit
This tutorial shows how to launch and control Isaac Sim simulator from a standalone Python script. It sets up an
empty scene in Orbit and introduces the two main classes used in the framework, :class:`app.AppLauncher` and
:class:`sim.SimulationContext`.
Please review `Isaac Sim Interface`_ and `Isaac Sim Workflows`_ prior to beginning this tutorial to get
an initial understanding of working with the simulator.
The Code
~~~~~~~~
The tutorial corresponds to the ``create_empty.py`` script in the ``orbit/source/standalone/tutorials/00_sim`` directory.
.. dropdown:: Code for create_empty.py
:icon: code
.. literalinclude:: ../../../../source/standalone/tutorials/00_sim/create_empty.py
:language: python
:emphasize-lines: 18-30,34,40-44,46-47,51-54,60-61
:linenos:
The Code Explained
~~~~~~~~~~~~~~~~~~
Launching the simulator
-----------------------
The first step when working with standalone Python scripts is to launch the simulation application.
This is necessary to do at the start since various dependency modules of Isaac Sim are only available
after the simulation app is running.
This can be done by importing the :class:`app.AppLauncher` class. This utility class wraps around
:class:`omni.isaac.kit.SimulationApp` class to launch the simulator. It provides mechanisms to
configure the simulator using command-line arguments and environment variables.
For this tutorial, we mainly look at adding the command-line options to a user-defined
:class:`argparse.ArgumentParser`. This is done by passing the parser instance to the
:meth:`app.AppLauncher.add_app_launcher_args` method, which appends different parameters
to it. These include launching the app headless, configuring different Livestream options,
and enabling off-screen rendering.
.. literalinclude:: ../../../../source/standalone/tutorials/00_sim/create_empty.py
:language: python
:start-at: import argparse
:end-at: simulation_app = app_launcher.app
Importing python modules
------------------------
Once the simulation app is running, it is possible to import different Python modules from
Isaac Sim and other libraries. Here we import the following module:
* :mod:`omni.isaac.orbit.sim`: A sub-package in Orbit for all the core simulator-related operations.
.. literalinclude:: ../../../../source/standalone/tutorials/00_sim/create_empty.py
:language: python
:start-at: from omni.isaac.orbit.sim import SimulationCfg, SimulationContext
:end-at: from omni.isaac.orbit.sim import SimulationCfg, SimulationContext
Configuring the simulation context
----------------------------------
When launching the simulator from a standalone script, the user has complete control over playing,
pausing and stepping the simulator. All these operations are handled through the **simulation
context**. It takes care of various timeline events and also configures the `physics scene`_ for
simulation.
In Orbit, the :class:`sim.SimulationContext` class inherits from Isaac Sim's
:class:`omni.isaac.core.simulation_context.SimulationContext` to allow configuring the simulation
through Python's ``dataclass`` object and handle certain intricacies of the simulation stepping.
For this tutorial, we set the physics and rendering time step to 0.01 seconds. This is done
by passing these quantities to the :class:`sim.SimulationCfg`, which is then used to create an
instance of the simulation context.
.. literalinclude:: ../../../../source/standalone/tutorials/00_sim/create_empty.py
:language: python
:start-at: # Initialize the simulation context
:end-at: sim.set_camera_view([2.5, 2.5, 2.5], [0.0, 0.0, 0.0])
Following the creation of the simulation context, we have only configured the physics acting on the
simulated scene. This includes the device to use for simulation, the gravity vector, and other advanced
solver parameters. There are now two main steps remaining to run the simulation:
1. Designing the simulation scene: Adding sensors, robots and other simulated objects
2. Running the simulation loop: Stepping the simulator, and setting and getting data from the simulator
In this tutorial, we look at Step 2 first for an empty scene to focus on the simulation control first.
In the following tutorials, we will look into Step 1 and working with simulation handles for interacting
with the simulator.
Running the simulation
----------------------
The first thing, after setting up the simulation scene, is to call the :meth:`sim.SimulationContext.reset`
method. This method plays the timeline and initializes the physics handles in the simulator. It must always
be called the first time before stepping the simulator. Otherwise, the simulation handles are not initialized
properly.
.. note::
:meth:`sim.SimulationContext.reset` is different from :meth:`sim.SimulationContext.play` method as the latter
only plays the timeline and does not initializes the physics handles.
After playing the simulation timeline, we set up a simple simulation loop where the simulator is stepped repeatedly
while the simulation app is running. The method :meth:`sim.SimulationContext.step` takes in as argument :attr:`render`,
which dictates whether the step includes updating the rendering-related events or not. By default, this flag is
set to True.
.. literalinclude:: ../../../../source/standalone/tutorials/00_sim/create_empty.py
:language: python
:start-at: # Play the simulator
:end-at: sim.step()
Exiting the simulation
----------------------
Lastly, the simulation application is stopped and its window is closed by calling
:meth:`omni.isaac.kit.SimulationApp.close` method.
.. literalinclude:: ../../../../source/standalone/tutorials/00_sim/create_empty.py
:language: python
:start-at: # close sim app
:end-at: simulation_app.close()
The Code Execution
~~~~~~~~~~~~~~~~~~
Now that we have gone through the code, let's run the script and see the result:
.. code-block:: bash
./orbit.sh -p source/standalone/tutorials/00_sim/create_empty.py
The simulation should be playing, and the stage should be rendering. To stop the simulation,
you can either close the window, or press ``Ctrl+C`` in the terminal.
Passing ``--help`` to the above script will show the different command-line arguments added
earlier by the :class:`app.AppLauncher` class. To run the script headless, you can execute the
following:
.. code-block:: bash
./orbit.sh -p source/standalone/tutorials/00_sim/create_empty.py --headless
Now that we have a basic understanding of how to run a simulation, let's move on to the
following tutorial where we will learn how to add assets to the stage.
.. _`Isaac Sim Interface`: https://docs.omniverse.nvidia.com/isaacsim/latest/introductory_tutorials/tutorial_intro_interface.html#isaac-sim-app-tutorial-intro-interface
.. _`Isaac Sim Workflows`: https://docs.omniverse.nvidia.com/isaacsim/latest/introductory_tutorials/tutorial_intro_workflows.html
.. _carb: https://docs.omniverse.nvidia.com/kit/docs/carbonite/latest/index.html
.. _`physics scene`: https://docs.omniverse.nvidia.com/prod_extensions/prod_extensions/ext_physics.html#physics-scene
| 7,227 | reStructuredText | 43.07317 | 168 | 0.754117 |
NVIDIA-Omniverse/orbit/docs/source/tutorials/00_sim/index.rst | Setting up a Simple Simulation
==============================
These tutorials show you how to launch the simulation with different settings and spawn objects in the
simulated scene. They cover the following APIs: :class:`~omni.isaac.orbit.app.AppLauncher`,
:class:`~omni.isaac.orbit.sim.SimulationContext`, and :class:`~omni.isaac.orbit.sim.spawners`.
.. toctree::
:maxdepth: 1
:titlesonly:
create_empty
spawn_prims
launch_app
| 450 | reStructuredText | 29.066665 | 102 | 0.693333 |
NVIDIA-Omniverse/orbit/docs/source/setup/faq.rst | Frequently Asked Questions
==========================
Where does Orbit fit in the Isaac ecosystem?
--------------------------------------------
Over the years, NVIDIA has developed a number of tools for robotics and AI. These tools leverage
the power of GPUs to accelerate the simulation both in terms of speed and realism. They show great
promise in the field of simulation technology and are being used by many researchers and companies
worldwide.
`Isaac Gym`_ :cite:`makoviychuk2021isaac` provides a high performance GPU-based physics simulation
for robot learning. It is built on top of `PhysX`_ which supports GPU-accelerated simulation of rigid bodies
and a Python API to directly access physics simulation data. Through an end-to-end GPU pipeline, it is possible
to achieve high frame rates compared to CPU-based physics engines. The tool has been used successfully in a
number of research projects, including legged locomotion :cite:`rudin2022learning` :cite:`rudin2022advanced`,
in-hand manipulation :cite:`handa2022dextreme` :cite:`allshire2022transferring`, and industrial assembly
:cite:`narang2022factory`.
Despite the success of Isaac Gym, it is not designed to be a general purpose simulator for
robotics. For example, it does not include interaction between deformable and rigid objects, high-fidelity
rendering, and support for ROS. The tool has been primarily designed as a preview release to showcase the
capabilities of the underlying physics engine. With the release of `Isaac Sim`_, NVIDIA is building
a general purpose simulator for robotics and has integrated the functionalities of Isaac Gym into
Isaac Sim.
`Isaac Sim`_ is a robot simulation toolkit built on top of Omniverse, which is a general purpose platform
that aims to unite complex 3D workflows. Isaac Sim leverages the latest advances in graphics and
physics simulation to provide a high-fidelity simulation environment for robotics. It supports
ROS/ROS2, various sensor simulation, tools for domain randomization and synthetic data creation.
Overall, it is a powerful tool for roboticists and is a huge step forward in the field of robotics
simulation.
With the release of above two tools, NVIDIA also released an open-sourced set of environments called
`IsaacGymEnvs`_ and `OmniIsaacGymEnvs`_, that have been built on top of Isaac Gym and Isaac Sim respectively.
These environments have been designed to display the capabilities of the underlying simulators and provide
a starting point to understand what is possible with the simulators for robot learning. These environments
can be used for benchmarking but are not designed for developing and testing custom environments and algorithms.
This is where Orbit comes in.
Orbit :cite:`mittal2023orbit` is built on top of Isaac Sim to provide a unified and flexible framework
for robot learning that exploits latest simulation technologies. It is designed to be modular and extensible,
and aims to simplify common workflows in robotics research (such as RL, learning from demonstrations, and
motion planning). While it includes some pre-built environments, sensors, and tasks, its main goal is to
provide an open-sourced, unified, and easy-to-use interface for developing and testing custom environments
and robot learning algorithms. It not only inherits the capabilities of Isaac Sim, but also adds a number
of new features that pertain to robot learning research. For example, including actuator dynamics in the
simulation, procedural terrain generation, and support to collect data from human demonstrations.
Where does the name come from?
------------------------------
"Orbit" suggests a sense of movement circling around a central point. For us, this symbolizes bringing
together the different components and paradigms centered around robot learning, and making a unified
ecosystem for it.
The name further connotes modularity and flexibility. Similar to planets in a solar system at different speeds
and positions, the framework is designed to not be rigid or inflexible. Rather, it aims to provide the users
the ability to adjust and move around the different components to suit their needs.
Finally, the name "orbit" also suggests a sense of exploration and discovery. We hope that the framework will
provide a platform for researchers to explore and discover new ideas and paradigms in robot learning.
Why should I use Orbit?
-----------------------
Since Isaac Sim remains closed-sourced, it is difficult for users to contribute to the simulator and build a
common framework for research. On its current path, we see the community using the simulator will simply
develop their own frameworks that will result in scattered efforts with a lot of duplication of work.
This has happened in the past with other simulators, and we believe that it is not the best way to move
forward as a community.
Orbit provides an open-sourced platform for the community to drive progress with consolidated efforts
toward designing benchmarks and robot learning systems as a joint initiative. This allows us to reuse
existing components and algorithms, and to build on top of each other's work. Doing so not only saves
time and effort, but also allows us to focus on the more important aspects of research. Our hope with
Orbit is that it becomes the de-facto platform for robot learning research and an environment *zoo*
that leverages Isaac Sim. As the framework matures, we foresee it benefitting hugely from the latest
simulation developments (as part of internal developments at NVIDIA and collaborating partners)
and research in robotics.
We are already working with labs in universities and research institutions to integrate their work into Orbit
and hope that others in the community will join us too in this effort. If you are interested in contributing
to Orbit, please reach out to us at `email <mailto:[email protected]>`_.
.. _PhysX: https://developer.nvidia.com/physx-sdk
.. _Isaac Sim: https://developer.nvidia.com/isaac-sim
.. _Isaac Gym: https://developer.nvidia.com/isaac-gym
.. _IsaacGymEnvs: https://github.com/NVIDIA-Omniverse/IsaacGymEnvs
.. _OmniIsaacGymEnvs: https://github.com/NVIDIA-Omniverse/OmniIsaacGymEnvs
| 6,180 | reStructuredText | 64.755318 | 112 | 0.795793 |
NVIDIA-Omniverse/orbit/docs/source/setup/installation.rst | Installation Guide
===================
.. image:: https://img.shields.io/badge/IsaacSim-2023.1.1-silver.svg
:target: https://developer.nvidia.com/isaac-sim
:alt: IsaacSim 2023.1.1
.. image:: https://img.shields.io/badge/python-3.10-blue.svg
:target: https://www.python.org/downloads/release/python-31013/
:alt: Python 3.10
.. image:: https://img.shields.io/badge/platform-linux--64-orange.svg
:target: https://releases.ubuntu.com/20.04/
:alt: Ubuntu 20.04
Installing Isaac Sim
--------------------
.. caution::
We have dropped support for Isaac Sim versions 2022.2 and below. We recommend using the latest Isaac Sim
2023.1 releases (``2023.1.0-hotfix.1`` or ``2023.1.1``).
For more information, please refer to the
`Isaac Sim release notes <https://docs.omniverse.nvidia.com/isaacsim/latest/release_notes.html>`__.
Downloading pre-built binaries
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please follow the Isaac Sim
`documentation <https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_workstation.html>`__
to install the latest Isaac Sim release.
To check the minimum system requirements,refer to the documentation
`here <https://docs.omniverse.nvidia.com/isaacsim/latest/installation/requirements.html>`__.
.. note::
We have tested Orbit with Isaac Sim 2023.1.0-hotfix.1 release on Ubuntu
20.04LTS with NVIDIA driver 525.147.
Configuring the environment variables
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Isaac Sim is shipped with its own Python interpreter which bundles in
the extensions released with it. To simplify the setup, we recommend
using the same Python interpreter. Alternately, it is possible to setup
a virtual environment following the instructions
`here <https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/install_python.html>`__.
Please locate the `Python executable in Isaac
Sim <https://docs.omniverse.nvidia.com/isaacsim/latest/manual_standalone_python.html#isaac-sim-python-environment>`__
by navigating to Isaac Sim root folder. In the remaining of the
documentation, we will refer to its path as ``ISAACSIM_PYTHON_EXE``.
.. note::
On Linux systems, by default, this should be the executable ``python.sh`` in the directory
``${HOME}/.local/share/ov/pkg/isaac_sim-*``, with ``*`` corresponding to the Isaac Sim version.
To avoid the overhead of finding and locating the Isaac Sim installation
directory every time, we recommend exporting the following environment
variables to your terminal for the remaining of the installation instructions:
.. code:: bash
# Isaac Sim root directory
export ISAACSIM_PATH="${HOME}/.local/share/ov/pkg/isaac_sim-2023.1.0-hotfix.1"
# Isaac Sim python executable
export ISAACSIM_PYTHON_EXE="${ISAACSIM_PATH}/python.sh"
For more information on common paths, please check the Isaac Sim
`documentation <https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_faq.html#common-path-locations>`__.
Running the simulator
~~~~~~~~~~~~~~~~~~~~~
Once Isaac Sim is installed successfully, make sure that the simulator runs on your
system. For this, we encourage the user to try some of the introductory
tutorials on their `website <https://docs.omniverse.nvidia.com/isaacsim/latest/introductory_tutorials/index.html>`__.
For completeness, we specify the commands here to check that everything is configured correctly.
On a new terminal (**Ctrl+Alt+T**), run the following:
- Check that the simulator runs as expected:
.. code:: bash
# note: you can pass the argument "--help" to see all arguments possible.
${ISAACSIM_PATH}/isaac-sim.sh
- Check that the simulator runs from a standalone python script:
.. code:: bash
# checks that python path is set correctly
${ISAACSIM_PYTHON_EXE} -c "print('Isaac Sim configuration is now complete.')"
# checks that Isaac Sim can be launched from python
${ISAACSIM_PYTHON_EXE} ${ISAACSIM_PATH}/standalone_examples/api/omni.isaac.core/add_cubes.py
.. attention::
If you have been using a previous version of Isaac Sim, you
need to run the following command for the *first* time after
installation to remove all the old user data and cached variables:
.. code:: bash
${ISAACSIM_PATH}/isaac-sim.sh --reset-user
If the simulator does not run or crashes while following the above
instructions, it means that something is incorrectly configured. To
debug and troubleshoot, please check Isaac Sim
`documentation <https://docs.omniverse.nvidia.com/dev-guide/latest/linux-troubleshooting.html>`__
and the
`forums <https://docs.omniverse.nvidia.com/isaacsim/latest/isaac_sim_forums.html>`__.
Installing Orbit
----------------
Organizing the workspace
~~~~~~~~~~~~~~~~~~~~~~~~
.. note::
We recommend making a `fork <https://github.com/NVIDIA-Omniverse/Orbit/fork>`_ of the ``orbit`` repository to contribute
to the project. This is not mandatory to use the framework. If you
make a fork, please replace ``NVIDIA-Omniverse`` with your username
in the following instructions.
If you are not familiar with git, we recommend following the `git
tutorial <https://git-scm.com/book/en/v2/Getting-Started-Git-Basics>`__.
- Clone the ``orbit`` repository into your workspace:
.. code:: bash
# Option 1: With SSH
git clone [email protected]:NVIDIA-Omniverse/orbit.git
# Option 2: With HTTPS
git clone https://github.com/NVIDIA-Omniverse/orbit.git
- Set up a symbolic link between the installed Isaac Sim root folder
and ``_isaac_sim`` in the ``orbit``` directory. This makes it convenient
to index the python modules and look for extensions shipped with
Isaac Sim.
.. code:: bash
# enter the cloned repository
cd orbit
# create a symbolic link
ln -s ${ISAACSIM_PATH} _isaac_sim
We provide a helper executable `orbit.sh <https://github.com/NVIDIA-Omniverse/Orbit/blob/main/orbit.sh>`_ that provides
utilities to manage extensions:
.. code:: text
./orbit.sh --help
usage: orbit.sh [-h] [-i] [-e] [-f] [-p] [-s] [-t] [-o] [-v] [-d] [-c] -- Utility to manage Orbit.
optional arguments:
-h, --help Display the help content.
-i, --install Install the extensions inside Orbit.
-e, --extra [LIB] Install learning frameworks (rl_games, rsl_rl, sb3) as extra dependencies. Default is 'all'.
-f, --format Run pre-commit to format the code and check lints.
-p, --python Run the python executable provided by Isaac Sim or virtual environment (if active).
-s, --sim Run the simulator executable (isaac-sim.sh) provided by Isaac Sim.
-t, --test Run all python unittest tests.
-o, --docker Run the docker container helper script (docker/container.sh).
-v, --vscode Generate the VSCode settings file from template.
-d, --docs Build the documentation from source using sphinx.
-c, --conda [NAME] Create the conda environment for Orbit. Default name is 'orbit'.
Setting up the environment
~~~~~~~~~~~~~~~~~~~~~~~~~~
The executable ``orbit.sh`` automatically fetches the python bundled with Isaac
Sim, using ``./orbit.sh -p`` command (unless inside a virtual environment). This executable
behaves like a python executable, and can be used to run any python script or
module with the simulator. For more information, please refer to the
`documentation <https://docs.omniverse.nvidia.com/isaacsim/latest/manual_standalone_python.html#isaac-sim-python-environment>`__.
Although using a virtual environment is optional, we recommend using ``conda``. To install
``conda``, please follow the instructions `here <https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html>`__.
In case you want to use ``conda`` to create a virtual environment, you can
use the following command:
.. code:: bash
# Option 1: Default name for conda environment is 'orbit'
./orbit.sh --conda # or "./orbit.sh -c"
# Option 2: Custom name for conda environment
./orbit.sh --conda my_env # or "./orbit.sh -c my_env"
If you are using ``conda`` to create a virtual environment, make sure to
activate the environment before running any scripts. For example:
.. code:: bash
conda activate orbit # or "conda activate my_env"
Once you are in the virtual environment, you do not need to use ``./orbit.sh -p``
to run python scripts. You can use the default python executable in your environment
by running ``python`` or ``python3``. However, for the rest of the documentation,
we will assume that you are using ``./orbit.sh -p`` to run python scripts. This command
is equivalent to running ``python`` or ``python3`` in your virtual environment.
Building extensions
~~~~~~~~~~~~~~~~~~~
To build all the extensions, run the following commands:
- Install dependencies using ``apt`` (on Ubuntu):
.. code:: bash
sudo apt install cmake build-essential
- Run the install command that iterates over all the extensions in
``source/extensions`` directory and installs them using pip
(with ``--editable`` flag):
.. code:: bash
./orbit.sh --install # or "./orbit.sh -i"
- For installing all other dependencies (such as learning
frameworks), execute:
.. code:: bash
# Option 1: Install all dependencies
./orbit.sh --extra # or "./orbit.sh -e"
# Option 2: Install only a subset of dependencies
# note: valid options are 'rl_games', 'rsl_rl', 'sb3', 'robomimic', 'all'
./orbit.sh --extra rsl_rl # or "./orbit.sh -e rsl_r"
Verifying the installation
~~~~~~~~~~~~~~~~~~~~~~~~~~
To verify that the installation was successful, run the following command from the
top of the repository:
.. code:: bash
# Option 1: Using the orbit.sh executable
# note: this works for both the bundled python and the virtual environment
./orbit.sh -p source/standalone/tutorials/00_sim/create_empty.py
# Option 2: Using python in your virtual environment
python source/standalone/tutorials/00_sim/create_empty.py
The above command should launch the simulator and display a window with a black
ground plane. You can exit the script by pressing ``Ctrl+C`` on your terminal or
by pressing the ``STOP`` button on the simulator window.
If you see this, then the installation was successful! |:tada:|
| 10,318 | reStructuredText | 38.087121 | 130 | 0.705951 |
NVIDIA-Omniverse/orbit/docs/source/setup/sample.rst | Running Existing Scripts
========================
Showroom
--------
The main core interface extension in Orbit ``omni.isaac.orbit`` provides
the main modules for actuators, objects, robots and sensors. We provide
a list of demo scripts and tutorials. These showcase how to use the provided
interfaces within a code in a minimal way.
A few quick showroom scripts to run and checkout:
- Spawn different quadrupeds and make robots stand using position commands:
.. code:: bash
./orbit.sh -p source/standalone/demos/quadrupeds.py
- Spawn different arms and apply random joint position commands:
.. code:: bash
./orbit.sh -p source/standalone/demos/arms.py
- Spawn different hands and command them to open and close:
.. code:: bash
./orbit.sh -p source/standalone/demos/hands.py
- Spawn procedurally generated terrains with different configurations:
.. code:: bash
./orbit.sh -p source/standalone/demos/procedural_terrain.py
- Spawn multiple markers that are useful for visualizations:
.. code:: bash
./orbit.sh -p source/standalone/demos/markers.py
Workflows
---------
With Orbit, we also provide a suite of benchmark environments included
in the ``omni.isaac.orbit_tasks`` extension. We use the OpenAI Gym registry
to register these environments. For each environment, we provide a default
configuration file that defines the scene, observations, rewards and action spaces.
The list of environments available registered with OpenAI Gym can be found by running:
.. code:: bash
./orbit.sh -p source/standalone/environments/list_envs.py
Basic agents
~~~~~~~~~~~~
These include basic agents that output zero or random agents. They are
useful to ensure that the environments are configured correctly.
- Zero-action agent on the Cart-pole example
.. code:: bash
./orbit.sh -p source/standalone/environments/zero_agent.py --task Isaac-Cartpole-v0 --num_envs 32
- Random-action agent on the Cart-pole example:
.. code:: bash
./orbit.sh -p source/standalone/environments/random_agent.py --task Isaac-Cartpole-v0 --num_envs 32
State machine
~~~~~~~~~~~~~
We include examples on hand-crafted state machines for the environments. These
help in understanding the environment and how to use the provided interfaces.
The state machines are written in `warp <https://github.com/NVIDIA/warp>`__ which
allows efficient execution for large number of environments using CUDA kernels.
.. code:: bash
./orbit.sh -p source/standalone/environments/state_machine/lift_cube_sm.py --num_envs 32
Teleoperation
~~~~~~~~~~~~~
We provide interfaces for providing commands in SE(2) and SE(3) space
for robot control. In case of SE(2) teleoperation, the returned command
is the linear x-y velocity and yaw rate, while in SE(3), the returned
command is a 6-D vector representing the change in pose.
To play inverse kinematics (IK) control with a keyboard device:
.. code:: bash
./orbit.sh -p source/standalone/environments/teleoperation/teleop_se3_agent.py --task Isaac-Lift-Cube-Franka-IK-Rel-v0 --num_envs 1 --device keyboard
The script prints the teleoperation events configured. For keyboard,
these are as follows:
.. code:: text
Keyboard Controller for SE(3): Se3Keyboard
Reset all commands: L
Toggle gripper (open/close): K
Move arm along x-axis: W/S
Move arm along y-axis: A/D
Move arm along z-axis: Q/E
Rotate arm along x-axis: Z/X
Rotate arm along y-axis: T/G
Rotate arm along z-axis: C/V
Imitation Learning
~~~~~~~~~~~~~~~~~~
Using the teleoperation devices, it is also possible to collect data for
learning from demonstrations (LfD). For this, we support the learning
framework `Robomimic <https://robomimic.github.io/>`__ and allow saving
data in
`HDF5 <https://robomimic.github.io/docs/tutorials/dataset_contents.html#viewing-hdf5-dataset-structure>`__
format.
1. Collect demonstrations with teleoperation for the environment
``Isaac-Lift-Cube-Franka-IK-Rel-v0``:
.. code:: bash
# step a: collect data with keyboard
./orbit.sh -p source/standalone/workflows/robomimic/collect_demonstrations.py --task Isaac-Lift-Cube-Franka-IK-Rel-v0 --num_envs 1 --num_demos 10 --device keyboard
# step b: inspect the collected dataset
./orbit.sh -p source/standalone/workflows/robomimic/tools/inspect_demonstrations.py logs/robomimic/Isaac-Lift-Cube-Franka-IK-Rel-v0/hdf_dataset.hdf5
2. Split the dataset into train and validation set:
.. code:: bash
# install python module (for robomimic)
./orbit.sh -e robomimic
# split data
./orbit.sh -p source/standalone//workflows/robomimic/tools/split_train_val.py logs/robomimic/Isaac-Lift-Cube-Franka-IK-Rel-v0/hdf_dataset.hdf5 --ratio 0.2
3. Train a BC agent for ``Isaac-Lift-Cube-Franka-IK-Rel-v0`` with
`Robomimic <https://robomimic.github.io/>`__:
.. code:: bash
./orbit.sh -p source/standalone/workflows/robomimic/train.py --task Isaac-Lift-Cube-Franka-IK-Rel-v0 --algo bc --dataset logs/robomimic/Isaac-Lift-Cube-Franka-IK-Rel-v0/hdf_dataset.hdf5
4. Play the learned model to visualize results:
.. code:: bash
./orbit.sh -p source/standalone//workflows/robomimic/play.py --task Isaac-Lift-Cube-Franka-IK-Rel-v0 --checkpoint /PATH/TO/model.pth
Reinforcement Learning
~~~~~~~~~~~~~~~~~~~~~~
We provide wrappers to different reinforcement libraries. These wrappers convert the data
from the environments into the respective libraries function argument and return types.
- Training an agent with
`Stable-Baselines3 <https://stable-baselines3.readthedocs.io/en/master/index.html>`__
on ``Isaac-Cartpole-v0``:
.. code:: bash
# install python module (for stable-baselines3)
./orbit.sh -e sb3
# run script for training
# note: we enable cpu flag since SB3 doesn't optimize for GPU anyway
./orbit.sh -p source/standalone/workflows/sb3/train.py --task Isaac-Cartpole-v0 --headless --cpu
# run script for playing with 32 environments
./orbit.sh -p source/standalone/workflows/sb3/play.py --task Isaac-Cartpole-v0 --num_envs 32 --checkpoint /PATH/TO/model.zip
- Training an agent with
`SKRL <https://skrl.readthedocs.io>`__ on ``Isaac-Reach-Franka-v0``:
.. code:: bash
# install python module (for skrl)
./orbit.sh -e skrl
# run script for training
./orbit.sh -p source/standalone/workflows/skrl/train.py --task Isaac-Reach-Franka-v0 --headless
# run script for playing with 32 environments
./orbit.sh -p source/standalone/workflows/skrl/play.py --task Isaac-Reach-Franka-v0 --num_envs 32 --checkpoint /PATH/TO/model.pt
- Training an agent with
`RL-Games <https://github.com/Denys88/rl_games>`__ on ``Isaac-Ant-v0``:
.. code:: bash
# install python module (for rl-games)
./orbit.sh -e rl_games
# run script for training
./orbit.sh -p source/standalone/workflows/rl_games/train.py --task Isaac-Ant-v0 --headless
# run script for playing with 32 environments
./orbit.sh -p source/standalone/workflows/rl_games/play.py --task Isaac-Ant-v0 --num_envs 32 --checkpoint /PATH/TO/model.pth
- Training an agent with
`RSL-RL <https://github.com/leggedrobotics/rsl_rl>`__ on ``Isaac-Reach-Franka-v0``:
.. code:: bash
# install python module (for rsl-rl)
./orbit.sh -e rsl_rl
# run script for training
./orbit.sh -p source/standalone/workflows/rsl_rl/train.py --task Isaac-Reach-Franka-v0 --headless
# run script for playing with 32 environments
./orbit.sh -p source/standalone/workflows/rsl_rl/play.py --task Isaac-Reach-Franka-v0 --num_envs 32 --checkpoint /PATH/TO/model.pth
All the scripts above log the training progress to `Tensorboard`_ in the ``logs`` directory in the root of
the repository. The logs directory follows the pattern ``logs/<library>/<task>/<date-time>``, where ``<library>``
is the name of the learning framework, ``<task>`` is the task name, and ``<date-time>`` is the timestamp at
which the training script was executed.
To view the logs, run:
.. code:: bash
# execute from the root directory of the repository
./orbit.sh -p -m tensorboard.main --logdir=logs
.. _Tensorboard: https://www.tensorflow.org/tensorboard
| 8,309 | reStructuredText | 34.974026 | 191 | 0.711638 |
NVIDIA-Omniverse/orbit/docs/source/setup/developer.rst | Developer's Guide
=================
For development, we suggest using `Microsoft Visual Studio Code
(VSCode) <https://code.visualstudio.com/>`__. This is also suggested by
NVIDIA Omniverse and there exists tutorials on how to `debug Omniverse
extensions <https://www.youtube.com/watch?v=Vr1bLtF1f4U&ab_channel=NVIDIAOmniverse>`__
using VSCode.
Setting up Visual Studio Code
-----------------------------
The ``orbit`` repository includes the VSCode settings to easily allow setting
up your development environment. These are included in the ``.vscode`` directory
and include the following files:
.. code-block:: bash
.vscode
├── tools
│ ├── launch.template.json
│ ├── settings.template.json
│ └── setup_vscode.py
├── extensions.json
├── launch.json # <- this is generated by setup_vscode.py
├── settings.json # <- this is generated by setup_vscode.py
└── tasks.json
To setup the IDE, please follow these instructions:
1. Open the ``orbit`` directory on Visual Studio Code IDE
2. Run VSCode `Tasks <https://code.visualstudio.com/docs/editor/tasks>`__, by
pressing ``Ctrl+Shift+P``, selecting ``Tasks: Run Task`` and running the
``setup_python_env`` in the drop down menu.
.. image:: ../_static/vscode_tasks.png
:width: 600px
:align: center
:alt: VSCode Tasks
If everything executes correctly, it should create a file
``.python.env`` in the ``.vscode`` directory. The file contains the python
paths to all the extensions provided by Isaac Sim and Omniverse. This helps
in indexing all the python modules for intelligent suggestions while writing
code.
For more information on VSCode support for Omniverse, please refer to the
following links:
* `Isaac Sim VSCode support <https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/manual_standalone_python.html#isaac-sim-python-vscode>`__
* `Debugging with VSCode <https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/tutorial_advanced_python_debugging.html>`__
Configuring the python interpreter
----------------------------------
In the provided configuration, we set the default python interpreter to use the
python executable provided by Omniverse. This is specified in the
``.vscode/settings.json`` file:
.. code-block:: json
{
"python.defaultInterpreterPath": "${workspaceFolder}/_isaac_sim/kit/python/bin/python3",
"python.envFile": "${workspaceFolder}/.vscode/.python.env",
}
If you want to use a different python interpreter (for instance, from your conda environment),
you need to change the python interpreter used by selecting and activating the python interpreter
of your choice in the bottom left corner of VSCode, or opening the command palette (``Ctrl+Shift+P``)
and selecting ``Python: Select Interpreter``.
For more information on how to set python interpreter for VSCode, please
refer to the `VSCode documentation <https://code.visualstudio.com/docs/python/environments#_working-with-python-interpreters>`_.
Repository organization
-----------------------
The ``orbit`` repository is structured as follows:
.. code-block:: bash
orbit
├── .vscode
├── .flake8
├── LICENSE
├── orbit.sh
├── pyproject.toml
├── README.md
├── docs
├── source
│ ├── extensions
│ │ ├── omni.isaac.orbit
│ │ └── omni.isaac.orbit_tasks
│ ├── standalone
│ │ ├── demos
│ │ ├── environments
│ │ ├── tools
│ │ ├── tutorials
│ │ └── workflows
└── VERSION
The ``source`` directory contains the source code for all ``orbit`` *extensions*
and *standalone applications*. The two are the different development workflows
supported in `Isaac Sim <https://docs.omniverse.nvidia.com/isaacsim/latest/introductory_tutorials/tutorial_intro_workflows.html>`__.
These are described in the following sections.
Extensions
~~~~~~~~~~
Extensions are the recommended way to develop applications in Isaac Sim. They are
modularized packages that formulate the Omniverse ecosystem. Each extension
provides a set of functionalities that can be used by other extensions or
standalone applications. A folder is recognized as an extension if it contains
an ``extension.toml`` file in the ``config`` directory. More information on extensions can be found in the
`Omniverse documentation <https://docs.omniverse.nvidia.com/kit/docs/kit-manual/latest/guide/extensions_basic.html>`__.
Orbit in itself provides extensions for robot learning. These are written into the
``source/extensions`` directory. Each extension is written as a python package and
follows the following structure:
.. code:: bash
<extension-name>
├── config
│ └── extension.toml
├── docs
│ ├── CHANGELOG.md
│ └── README.md
├── <extension-name>
│ ├── __init__.py
│ ├── ....
│ └── scripts
├── setup.py
└── tests
The ``config/extension.toml`` file contains the metadata of the extension. This
includes the name, version, description, dependencies, etc. This information is used
by Omniverse to load the extension. The ``docs`` directory contains the documentation
for the extension with more detailed information about the extension and a CHANGELOG
file that contains the changes made to the extension in each version.
The ``<extension-name>`` directory contains the main python package for the extension.
It may also contains the ``scripts`` directory for keeping python-based applications
that are loaded into Omniverse when then extension is enabled using the
`Extension Manager <https://docs.omniverse.nvidia.com/kit/docs/kit-manual/latest/guide/extensions_basic.html>`__.
More specifically, when an extension is enabled, the python module specified in the
``config/extension.toml`` file is loaded and scripts that contains children of the
:class:`omni.ext.IExt` class are executed.
.. code:: python
import omni.ext
class MyExt(omni.ext.IExt):
"""My extension application."""
def on_startup(self, ext_id):
"""Called when the extension is loaded."""
pass
def on_shutdown(self):
"""Called when the extension is unloaded.
It releases all references to the extension and cleans up any resources.
"""
pass
While loading extensions into Omniverse happens automatically, using the python package
in standalone applications requires additional steps. To simplify the build process and
avoiding the need to understand the `premake <https://premake.github.io/>`__
build system used by Omniverse, we directly use the `setuptools <https://setuptools.readthedocs.io/en/latest/>`__
python package to build the python module provided by the extensions. This is done by the
``setup.py`` file in the extension directory.
.. note::
The ``setup.py`` file is not required for extensions that are only loaded into Omniverse
using the `Extension Manager <https://docs.omniverse.nvidia.com/prod_extensions/prod_extensions/ext_extension-manager.html>`__.
Lastly, the ``tests`` directory contains the unit tests for the extension. These are written
using the `unittest <https://docs.python.org/3/library/unittest.html>`__ framework. It is
important to note that Omniverse also provides a similar
`testing framework <https://docs.omniverse.nvidia.com/kit/docs/kit-manual/104.0/guide/testing_exts_python.html>`__.
However, it requires going through the build process and does not support testing of the python module in
standalone applications.
Standalone applications
~~~~~~~~~~~~~~~~~~~~~~~
In a typical Omniverse workflow, the simulator is launched first, after which the extensions are
enabled that load the python module and run the python application. While this is a recommended
workflow, it is not always possible to use this workflow. For example, for robot learning, it is
essential to have complete control over simulation stepping and all the other functionalities
instead of asynchronously waiting for the simulator to step. In such cases, it is necessary to
write a standalone application that launches the simulator using :class:`~omni.isaac.orbit.app.AppLauncher`
and allows complete control over the simulation through the :class:`~omni.isaac.orbit.sim.SimulationContext`
class.
.. code:: python
"""Launch Isaac Sim Simulator first."""
from omni.isaac.orbit.app import AppLauncher
# launch omniverse app
app_launcher = AppLauncher(headless=False)
simulation_app = app_launcher.app
"""Rest everything follows."""
from omni.isaac.orbit.sim import SimulationContext
if __name__ == "__main__":
# get simulation context
simulation_context = SimulationContext()
# reset and play simulation
simulation_context.reset()
# step simulation
simulation_context.step()
# stop simulation
simulation_context.stop()
# close the simulation
simulation_app.close()
The ``source/standalone`` directory contains various standalone applications designed using the extensions
provided by ``orbit``. These applications are written in python and are structured as follows:
* **demos**: Contains various demo applications that showcase the core framework ``omni.isaac.orbit``.
* **environments**: Contains applications for running environments defined in ``omni.isaac.orbit_tasks`` with different agents.
These include a random policy, zero-action policy, teleoperation or scripted state machines.
* **tools**: Contains applications for using the tools provided by the framework. These include converting assets, generating
datasets, etc.
* **tutorials**: Contains step-by-step tutorials for using the APIs provided by the framework.
* **workflows**: Contains applications for using environments with various learning-based frameworks. These include different
reinforcement learning or imitation learning libraries.
| 9,810 | reStructuredText | 39.374485 | 146 | 0.729664 |
NVIDIA-Omniverse/orbit/docs/source/setup/template.rst | Building your Own Project
=========================
Traditionally, building new projects that utilize Orbit's features required creating your own
extensions within the Orbit repository. However, this approach can obscure project visibility and
complicate updates from one version of Orbit to another. To circumvent these challenges, we now
provide a pre-configured and customizable `extension template <https://github.com/isaac-orbit/orbit.ext_template>`_
for creating projects in an isolated environment.
This template serves three distinct use cases:
* **Project Template**: Provides essential access to Isaac Sim and Orbit's features, making it ideal for projects
that require a standalone environment.
* **Python Package**: Facilitates integration with Isaac Sim's native or virtual Python environment, allowing for
the creation of Python packages that can be shared and reused across multiple projects.
* **Omniverse Extension**: Supports direct integration into Omniverse extension workflow.
.. note::
We recommend using the extension template for new projects, as it provides a more streamlined and
efficient workflow. Additionally it ensures that your project remains up-to-date with the latest
features and improvements in Orbit.
To get started, please follow the instructions in the `extension template repository <https://github.com/isaac-orbit/orbit.ext_template>`_.
| 1,396 | reStructuredText | 52.730767 | 139 | 0.790831 |
NVIDIA-Omniverse/orbit/docs/source/api/index.rst | API Reference
=============
This page gives an overview of all the modules and classes in the Orbit extensions.
omni.isaac.orbit extension
--------------------------
The following modules are available in the ``omni.isaac.orbit`` extension:
.. currentmodule:: omni.isaac.orbit
.. autosummary::
:toctree: orbit
app
actuators
assets
controllers
devices
envs
managers
markers
scene
sensors
sim
terrains
utils
.. toctree::
:hidden:
orbit/omni.isaac.orbit.envs.mdp
orbit/omni.isaac.orbit.envs.ui
orbit/omni.isaac.orbit.sensors.patterns
orbit/omni.isaac.orbit.sim.converters
orbit/omni.isaac.orbit.sim.schemas
orbit/omni.isaac.orbit.sim.spawners
omni.isaac.orbit_tasks extension
--------------------------------
The following modules are available in the ``omni.isaac.orbit_tasks`` extension:
.. currentmodule:: omni.isaac.orbit_tasks
.. autosummary::
:toctree: orbit_tasks
utils
.. toctree::
:hidden:
orbit_tasks/omni.isaac.orbit_tasks.utils.wrappers
orbit_tasks/omni.isaac.orbit_tasks.utils.data_collector
| 1,096 | reStructuredText | 17.913793 | 83 | 0.67792 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit_tasks/omni.isaac.orbit_tasks.utils.rst | orbit\_tasks.utils
==================
.. automodule:: omni.isaac.orbit_tasks.utils
:members:
:imported-members:
.. rubric:: Submodules
.. autosummary::
data_collector
wrappers
| 205 | reStructuredText | 13.714285 | 44 | 0.580488 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit_tasks/omni.isaac.orbit_tasks.utils.data_collector.rst | orbit\_tasks.utils.data\_collector
==================================
.. automodule:: omni.isaac.orbit_tasks.utils.data_collector
.. Rubric:: Classes
.. autosummary::
RobomimicDataCollector
Robomimic Data Collector
------------------------
.. autoclass:: RobomimicDataCollector
:members:
:show-inheritance:
| 338 | reStructuredText | 17.833332 | 59 | 0.579882 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit_tasks/omni.isaac.orbit_tasks.utils.wrappers.rst | orbit\_tasks.utils.wrappers
===========================
.. automodule:: omni.isaac.orbit_tasks.utils.wrappers
RL-Games Wrapper
----------------
.. automodule:: omni.isaac.orbit_tasks.utils.wrappers.rl_games
:members:
:show-inheritance:
RSL-RL Wrapper
--------------
.. automodule:: omni.isaac.orbit_tasks.utils.wrappers.rsl_rl
:members:
:imported-members:
:show-inheritance:
SKRL Wrapper
------------
.. automodule:: omni.isaac.orbit_tasks.utils.wrappers.skrl
:members:
:show-inheritance:
Stable-Baselines3 Wrapper
-------------------------
.. automodule:: omni.isaac.orbit_tasks.utils.wrappers.sb3
:members:
:show-inheritance:
| 665 | reStructuredText | 18.588235 | 62 | 0.62406 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.utils.rst | orbit.utils
===========
.. automodule:: omni.isaac.orbit.utils
.. Rubric:: Submodules
.. autosummary::
io
array
assets
dict
math
noise
string
timer
warp
.. Rubric:: Functions
.. autosummary::
configclass
Configuration class
~~~~~~~~~~~~~~~~~~~
.. automodule:: omni.isaac.orbit.utils.configclass
:members:
:show-inheritance:
IO operations
~~~~~~~~~~~~~
.. automodule:: omni.isaac.orbit.utils.io
:members:
:imported-members:
:show-inheritance:
Array operations
~~~~~~~~~~~~~~~~
.. automodule:: omni.isaac.orbit.utils.array
:members:
:show-inheritance:
Asset operations
~~~~~~~~~~~~~~~~
.. automodule:: omni.isaac.orbit.utils.assets
:members:
:show-inheritance:
Dictionary operations
~~~~~~~~~~~~~~~~~~~~~
.. automodule:: omni.isaac.orbit.utils.dict
:members:
:show-inheritance:
Math operations
~~~~~~~~~~~~~~~
.. automodule:: omni.isaac.orbit.utils.math
:members:
:inherited-members:
:show-inheritance:
Noise operations
~~~~~~~~~~~~~~~~
.. automodule:: omni.isaac.orbit.utils.noise
:members:
:imported-members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__, func
String operations
~~~~~~~~~~~~~~~~~
.. automodule:: omni.isaac.orbit.utils.string
:members:
:show-inheritance:
Timer operations
~~~~~~~~~~~~~~~~
.. automodule:: omni.isaac.orbit.utils.timer
:members:
:show-inheritance:
Warp operations
~~~~~~~~~~~~~~~
.. automodule:: omni.isaac.orbit.utils.warp
:members:
:imported-members:
:show-inheritance:
| 1,602 | reStructuredText | 14.871287 | 50 | 0.598627 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.terrains.rst | orbit.terrains
==============
.. automodule:: omni.isaac.orbit.terrains
.. rubric:: Classes
.. autosummary::
TerrainImporter
TerrainImporterCfg
TerrainGenerator
TerrainGeneratorCfg
SubTerrainBaseCfg
Terrain importer
----------------
.. autoclass:: TerrainImporter
:members:
:show-inheritance:
.. autoclass:: TerrainImporterCfg
:members:
:exclude-members: __init__, class_type
Terrain generator
-----------------
.. autoclass:: TerrainGenerator
:members:
.. autoclass:: TerrainGeneratorCfg
:members:
:exclude-members: __init__
.. autoclass:: SubTerrainBaseCfg
:members:
:exclude-members: __init__
Height fields
-------------
.. automodule:: omni.isaac.orbit.terrains.height_field
All sub-terrains must inherit from the :class:`HfTerrainBaseCfg` class which contains the common
parameters for all terrains generated from height fields.
.. autoclass:: omni.isaac.orbit.terrains.height_field.hf_terrains_cfg.HfTerrainBaseCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Random Uniform Terrain
^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.height_field.hf_terrains.random_uniform_terrain
.. autoclass:: omni.isaac.orbit.terrains.height_field.hf_terrains_cfg.HfRandomUniformTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Pyramid Sloped Terrain
^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.height_field.hf_terrains.pyramid_sloped_terrain
.. autoclass:: omni.isaac.orbit.terrains.height_field.hf_terrains_cfg.HfPyramidSlopedTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
.. autoclass:: omni.isaac.orbit.terrains.height_field.hf_terrains_cfg.HfInvertedPyramidSlopedTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Pyramid Stairs Terrain
^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.height_field.hf_terrains.pyramid_stairs_terrain
.. autoclass:: omni.isaac.orbit.terrains.height_field.hf_terrains_cfg.HfPyramidStairsTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
.. autoclass:: omni.isaac.orbit.terrains.height_field.hf_terrains_cfg.HfInvertedPyramidStairsTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Discrete Obstacles Terrain
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.height_field.hf_terrains.discrete_obstacles_terrain
.. autoclass:: omni.isaac.orbit.terrains.height_field.hf_terrains_cfg.HfDiscreteObstaclesTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Wave Terrain
^^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.height_field.hf_terrains.wave_terrain
.. autoclass:: omni.isaac.orbit.terrains.height_field.hf_terrains_cfg.HfWaveTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Stepping Stones Terrain
^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.height_field.hf_terrains.stepping_stones_terrain
.. autoclass:: omni.isaac.orbit.terrains.height_field.hf_terrains_cfg.HfSteppingStonesTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Trimesh terrains
----------------
.. automodule:: omni.isaac.orbit.terrains.trimesh
Flat terrain
^^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.trimesh.mesh_terrains.flat_terrain
.. autoclass:: omni.isaac.orbit.terrains.trimesh.mesh_terrains_cfg.MeshPlaneTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Pyramid terrain
^^^^^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.trimesh.mesh_terrains.pyramid_stairs_terrain
.. autoclass:: omni.isaac.orbit.terrains.trimesh.mesh_terrains_cfg.MeshPyramidStairsTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Inverted pyramid terrain
^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.trimesh.mesh_terrains.inverted_pyramid_stairs_terrain
.. autoclass:: omni.isaac.orbit.terrains.trimesh.mesh_terrains_cfg.MeshInvertedPyramidStairsTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Random grid terrain
^^^^^^^^^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.trimesh.mesh_terrains.random_grid_terrain
.. autoclass:: omni.isaac.orbit.terrains.trimesh.mesh_terrains_cfg.MeshRandomGridTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Rails terrain
^^^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.trimesh.mesh_terrains.rails_terrain
.. autoclass:: omni.isaac.orbit.terrains.trimesh.mesh_terrains_cfg.MeshRailsTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Pit terrain
^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.trimesh.mesh_terrains.pit_terrain
.. autoclass:: omni.isaac.orbit.terrains.trimesh.mesh_terrains_cfg.MeshPitTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Box terrain
^^^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.trimesh.mesh_terrains.box_terrain
.. autoclass:: omni.isaac.orbit.terrains.trimesh.mesh_terrains_cfg.MeshBoxTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Gap terrain
^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.trimesh.mesh_terrains.gap_terrain
.. autoclass:: omni.isaac.orbit.terrains.trimesh.mesh_terrains_cfg.MeshGapTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Floating ring terrain
^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.trimesh.mesh_terrains.floating_ring_terrain
.. autoclass:: omni.isaac.orbit.terrains.trimesh.mesh_terrains_cfg.MeshFloatingRingTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Star terrain
^^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.trimesh.mesh_terrains.star_terrain
.. autoclass:: omni.isaac.orbit.terrains.trimesh.mesh_terrains_cfg.MeshStarTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Repeated Objects Terrain
^^^^^^^^^^^^^^^^^^^^^^^^
.. autofunction:: omni.isaac.orbit.terrains.trimesh.mesh_terrains.repeated_objects_terrain
.. autoclass:: omni.isaac.orbit.terrains.trimesh.mesh_terrains_cfg.MeshRepeatedObjectsTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
.. autoclass:: omni.isaac.orbit.terrains.trimesh.mesh_terrains_cfg.MeshRepeatedPyramidsTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
.. autoclass:: omni.isaac.orbit.terrains.trimesh.mesh_terrains_cfg.MeshRepeatedBoxesTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
.. autoclass:: omni.isaac.orbit.terrains.trimesh.mesh_terrains_cfg.MeshRepeatedCylindersTerrainCfg
:members:
:show-inheritance:
:exclude-members: __init__, function
Utilities
---------
.. automodule:: omni.isaac.orbit.terrains.utils
:members:
:undoc-members:
| 7,214 | reStructuredText | 26.538168 | 103 | 0.708206 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.sim.rst | orbit.sim
=========
.. automodule:: omni.isaac.orbit.sim
.. rubric:: Submodules
.. autosummary::
converters
schemas
spawners
utils
.. rubric:: Classes
.. autosummary::
SimulationContext
SimulationCfg
PhysxCfg
.. rubric:: Functions
.. autosummary::
simulation_context.build_simulation_context
Simulation Context
------------------
.. autoclass:: SimulationContext
:members:
:show-inheritance:
Simulation Configuration
------------------------
.. autoclass:: SimulationCfg
:members:
:show-inheritance:
:exclude-members: __init__
.. autoclass:: PhysxCfg
:members:
:show-inheritance:
:exclude-members: __init__
Simulation Context Builder
--------------------------
.. automethod:: simulation_context.build_simulation_context
Utilities
---------
.. automodule:: omni.isaac.orbit.sim.utils
:members:
:show-inheritance:
| 897 | reStructuredText | 13.966666 | 59 | 0.626533 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.markers.rst | orbit.markers
=============
.. automodule:: omni.isaac.orbit.markers
.. rubric:: Classes
.. autosummary::
VisualizationMarkers
VisualizationMarkersCfg
Visualization Markers
---------------------
.. autoclass:: VisualizationMarkers
:members:
:undoc-members:
:show-inheritance:
.. autoclass:: VisualizationMarkersCfg
:members:
:exclude-members: __init__
| 392 | reStructuredText | 15.374999 | 40 | 0.637755 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.managers.rst | orbit.managers
==============
.. automodule:: omni.isaac.orbit.managers
.. rubric:: Classes
.. autosummary::
SceneEntityCfg
ManagerBase
ManagerTermBase
ManagerTermBaseCfg
ObservationManager
ObservationGroupCfg
ObservationTermCfg
ActionManager
ActionTerm
ActionTermCfg
EventManager
EventTermCfg
CommandManager
CommandTerm
CommandTermCfg
RewardManager
RewardTermCfg
TerminationManager
TerminationTermCfg
CurriculumManager
CurriculumTermCfg
Scene Entity
------------
.. autoclass:: SceneEntityCfg
:members:
:exclude-members: __init__
Manager Base
------------
.. autoclass:: ManagerBase
:members:
.. autoclass:: ManagerTermBase
:members:
.. autoclass:: ManagerTermBaseCfg
:members:
:exclude-members: __init__
Observation Manager
-------------------
.. autoclass:: ObservationManager
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: ObservationGroupCfg
:members:
:exclude-members: __init__
.. autoclass:: ObservationTermCfg
:members:
:exclude-members: __init__
Action Manager
--------------
.. autoclass:: ActionManager
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: ActionTerm
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: ActionTermCfg
:members:
:exclude-members: __init__
Event Manager
-------------
.. autoclass:: EventManager
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: EventTermCfg
:members:
:exclude-members: __init__
Randomization Manager
---------------------
.. deprecated:: v0.3
The Randomization Manager is deprecated and will be removed in v0.4.
Please use the :class:`EventManager` class instead.
.. autoclass:: RandomizationManager
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: RandomizationTermCfg
:members:
:exclude-members: __init__
Command Manager
---------------
.. autoclass:: CommandManager
:members:
.. autoclass:: CommandTerm
:members:
:exclude-members: __init__, class_type
.. autoclass:: CommandTermCfg
:members:
:exclude-members: __init__, class_type
Reward Manager
--------------
.. autoclass:: RewardManager
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: RewardTermCfg
:exclude-members: __init__
Termination Manager
-------------------
.. autoclass:: TerminationManager
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: TerminationTermCfg
:members:
:exclude-members: __init__
Curriculum Manager
------------------
.. autoclass:: CurriculumManager
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: CurriculumTermCfg
:members:
:exclude-members: __init__
| 2,846 | reStructuredText | 16.574074 | 72 | 0.641251 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.sensors.rst | orbit.sensors
=============
.. automodule:: omni.isaac.orbit.sensors
.. rubric:: Submodules
.. autosummary::
patterns
.. rubric:: Classes
.. autosummary::
SensorBase
SensorBaseCfg
Camera
CameraData
CameraCfg
ContactSensor
ContactSensorData
ContactSensorCfg
FrameTransformer
FrameTransformerData
FrameTransformerCfg
RayCaster
RayCasterData
RayCasterCfg
RayCasterCamera
RayCasterCameraCfg
Sensor Base
-----------
.. autoclass:: SensorBase
:members:
.. autoclass:: SensorBaseCfg
:members:
:exclude-members: __init__, class_type
USD Camera
----------
.. autoclass:: Camera
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: CameraData
:members:
:inherited-members:
:exclude-members: __init__
.. autoclass:: CameraCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__, class_type
Contact Sensor
--------------
.. autoclass:: ContactSensor
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: ContactSensorData
:members:
:inherited-members:
:exclude-members: __init__
.. autoclass:: ContactSensorCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__, class_type
Frame Transformer
-----------------
.. autoclass:: FrameTransformer
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: FrameTransformerData
:members:
:inherited-members:
:exclude-members: __init__
.. autoclass:: FrameTransformerCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__, class_type
.. autoclass:: OffsetCfg
:members:
:inherited-members:
:exclude-members: __init__
Ray-Cast Sensor
---------------
.. autoclass:: RayCaster
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: RayCasterData
:members:
:inherited-members:
:exclude-members: __init__
.. autoclass:: RayCasterCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__, class_type
Ray-Cast Camera
---------------
.. autoclass:: RayCasterCamera
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: RayCasterCameraCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__, class_type
| 2,409 | reStructuredText | 16.463768 | 42 | 0.635533 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.actuators.rst | orbit.actuators
===============
.. automodule:: omni.isaac.orbit.actuators
.. rubric:: Classes
.. autosummary::
ActuatorBase
ActuatorBaseCfg
ImplicitActuator
ImplicitActuatorCfg
IdealPDActuator
IdealPDActuatorCfg
DCMotor
DCMotorCfg
ActuatorNetMLP
ActuatorNetMLPCfg
ActuatorNetLSTM
ActuatorNetLSTMCfg
Actuator Base
-------------
.. autoclass:: ActuatorBase
:members:
:inherited-members:
.. autoclass:: ActuatorBaseCfg
:members:
:inherited-members:
:exclude-members: __init__, class_type
Implicit Actuator
-----------------
.. autoclass:: ImplicitActuator
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: ImplicitActuatorCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__, class_type
Ideal PD Actuator
-----------------
.. autoclass:: IdealPDActuator
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: IdealPDActuatorCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__, class_type
DC Motor Actuator
-----------------
.. autoclass:: DCMotor
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: DCMotorCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__, class_type
MLP Network Actuator
---------------------
.. autoclass:: ActuatorNetMLP
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: ActuatorNetMLPCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__, class_type
LSTM Network Actuator
---------------------
.. autoclass:: ActuatorNetLSTM
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: ActuatorNetLSTMCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__, class_type
| 1,831 | reStructuredText | 16.447619 | 42 | 0.663026 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.envs.ui.rst | orbit.envs.ui
=============
.. automodule:: omni.isaac.orbit.envs.ui
.. rubric:: Classes
.. autosummary::
BaseEnvWindow
RLTaskEnvWindow
ViewportCameraController
Base Environment UI
-------------------
.. autoclass:: BaseEnvWindow
:members:
RL Task Environment UI
----------------------
.. autoclass:: RLTaskEnvWindow
:members:
:show-inheritance:
Viewport Camera Controller
--------------------------
.. autoclass:: ViewportCameraController
:members:
| 509 | reStructuredText | 14.9375 | 40 | 0.573674 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.devices.rst | orbit.devices
=============
.. automodule:: omni.isaac.orbit.devices
.. rubric:: Classes
.. autosummary::
DeviceBase
Se2Gamepad
Se3Gamepad
Se2Keyboard
Se3Keyboard
Se3SpaceMouse
Se3SpaceMouse
Device Base
-----------
.. autoclass:: DeviceBase
:members:
Game Pad
--------
.. autoclass:: Se2Gamepad
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: Se3Gamepad
:members:
:inherited-members:
:show-inheritance:
Keyboard
--------
.. autoclass:: Se2Keyboard
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: Se3Keyboard
:members:
:inherited-members:
:show-inheritance:
Space Mouse
-----------
.. autoclass:: Se2SpaceMouse
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: Se3SpaceMouse
:members:
:inherited-members:
:show-inheritance:
| 893 | reStructuredText | 13.419355 | 40 | 0.62262 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.app.rst | orbit.app
=========
.. automodule:: omni.isaac.orbit.app
.. rubric:: Classes
.. autosummary::
AppLauncher
Environment variables
---------------------
The following details the behavior of the class based on the environment variables:
* **Headless mode**: If the environment variable ``HEADLESS=1``, then SimulationApp will be started in headless mode.
If ``LIVESTREAM={1,2,3}``, then it will supersede the ``HEADLESS`` envvar and force headlessness.
* ``HEADLESS=1`` causes the app to run in headless mode.
* **Livestreaming**: If the environment variable ``LIVESTREAM={1,2,3}`` , then `livestream`_ is enabled. Any
of the livestream modes being true forces the app to run in headless mode.
* ``LIVESTREAM=1`` enables streaming via the Isaac `Native Livestream`_ extension. This allows users to
connect through the Omniverse Streaming Client.
* ``LIVESTREAM=2`` enables streaming via the `Websocket Livestream`_ extension. This allows users to
connect in a browser using the WebSocket protocol.
* ``LIVESTREAM=3`` enables streaming via the `WebRTC Livestream`_ extension. This allows users to
connect in a browser using the WebRTC protocol.
* **Offscreen Render**: If the environment variable ``OFFSCREEN_RENDER`` is set to 1, then the
offscreen-render pipeline is enabled. This is useful for running the simulator without a GUI but
still rendering the viewport and camera images.
* ``OFFSCREEN_RENDER=1``: Enables the offscreen-render pipeline which allows users to render
the scene without launching a GUI.
.. note::
The off-screen rendering pipeline only works when used in conjunction with the
:class:`omni.isaac.orbit.sim.SimulationContext` class. This is because the off-screen rendering
pipeline enables flags that are internally used by the SimulationContext class.
To set the environment variables, one can use the following command in the terminal:
.. code:: bash
export REMOTE_DEPLOYMENT=3
export OFFSCREEN_RENDER=1
# run the python script
./orbit.sh -p source/standalone/demo/play_quadrupeds.py
Alternatively, one can set the environment variables to the python script directly:
.. code:: bash
REMOTE_DEPLOYMENT=3 OFFSCREEN_RENDER=1 ./orbit.sh -p source/standalone/demo/play_quadrupeds.py
Overriding the environment variables
------------------------------------
The environment variables can be overridden in the python script itself using the :class:`AppLauncher`.
These can be passed as a dictionary, a :class:`argparse.Namespace` object or as keyword arguments.
When the passed arguments are not the default values, then they override the environment variables.
The following snippet shows how use the :class:`AppLauncher` in different ways:
.. code:: python
import argparser
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser()
# add your own arguments
# ....
# add app launcher arguments for cli
AppLauncher.add_app_launcher_args(parser)
# parse arguments
args = parser.parse_args()
# launch omniverse isaac-sim app
# -- Option 1: Pass the settings as a Namespace object
app_launcher = AppLauncher(args).app
# -- Option 2: Pass the settings as keywords arguments
app_launcher = AppLauncher(headless=args.headless, livestream=args.livestream)
# -- Option 3: Pass the settings as a dictionary
app_launcher = AppLauncher(vars(args))
# -- Option 4: Pass no settings
app_launcher = AppLauncher()
# obtain the launched app
simulation_app = app_launcher.app
Simulation App Launcher
-----------------------
.. autoclass:: AppLauncher
:members:
.. _livestream: https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/manual_livestream_clients.html
.. _`Native Livestream`: https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/manual_livestream_clients.html#isaac-sim-setup-kit-remote
.. _`Websocket Livestream`: https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/manual_livestream_clients.html#isaac-sim-setup-livestream-webrtc
.. _`WebRTC Livestream`: https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/manual_livestream_clients.html#isaac-sim-setup-livestream-websocket
| 4,248 | reStructuredText | 36.9375 | 152 | 0.734228 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.sim.converters.rst | orbit.sim.converters
====================
.. automodule:: omni.isaac.orbit.sim.converters
.. rubric:: Classes
.. autosummary::
AssetConverterBase
AssetConverterBaseCfg
MeshConverter
MeshConverterCfg
UrdfConverter
UrdfConverterCfg
Asset Converter Base
--------------------
.. autoclass:: AssetConverterBase
:members:
.. autoclass:: AssetConverterBaseCfg
:members:
:exclude-members: __init__
Mesh Converter
--------------
.. autoclass:: MeshConverter
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: MeshConverterCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__
URDF Converter
--------------
.. autoclass:: UrdfConverter
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: UrdfConverterCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__
| 933 | reStructuredText | 15.981818 | 47 | 0.633441 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.sim.spawners.rst | orbit.sim.spawners
==================
.. automodule:: omni.isaac.orbit.sim.spawners
.. rubric:: Submodules
.. autosummary::
shapes
lights
sensors
from_files
materials
.. rubric:: Classes
.. autosummary::
SpawnerCfg
RigidObjectSpawnerCfg
Spawners
--------
.. autoclass:: SpawnerCfg
:members:
:exclude-members: __init__
.. autoclass:: RigidObjectSpawnerCfg
:members:
:show-inheritance:
:exclude-members: __init__
Shapes
------
.. automodule:: omni.isaac.orbit.sim.spawners.shapes
.. rubric:: Classes
.. autosummary::
ShapeCfg
CapsuleCfg
ConeCfg
CuboidCfg
CylinderCfg
SphereCfg
.. autoclass:: ShapeCfg
:members:
:exclude-members: __init__, func
.. autofunction:: spawn_capsule
.. autoclass:: CapsuleCfg
:members:
:show-inheritance:
:exclude-members: __init__, func
.. autofunction:: spawn_cone
.. autoclass:: ConeCfg
:members:
:show-inheritance:
:exclude-members: __init__, func
.. autofunction:: spawn_cuboid
.. autoclass:: CuboidCfg
:members:
:show-inheritance:
:exclude-members: __init__, func
.. autofunction:: spawn_cylinder
.. autoclass:: CylinderCfg
:members:
:show-inheritance:
:exclude-members: __init__, func
.. autofunction:: spawn_sphere
.. autoclass:: SphereCfg
:members:
:show-inheritance:
:exclude-members: __init__, func
Lights
------
.. automodule:: omni.isaac.orbit.sim.spawners.lights
.. rubric:: Classes
.. autosummary::
LightCfg
CylinderLightCfg
DiskLightCfg
DistantLightCfg
DomeLightCfg
SphereLightCfg
.. autofunction:: spawn_light
.. autoclass:: LightCfg
:members:
:exclude-members: __init__, func
.. autoclass:: CylinderLightCfg
:members:
:exclude-members: __init__, func
.. autoclass:: DiskLightCfg
:members:
:exclude-members: __init__, func
.. autoclass:: DistantLightCfg
:members:
:exclude-members: __init__, func
.. autoclass:: DomeLightCfg
:members:
:exclude-members: __init__, func
.. autoclass:: SphereLightCfg
:members:
:exclude-members: __init__, func
Sensors
-------
.. automodule:: omni.isaac.orbit.sim.spawners.sensors
.. rubric:: Classes
.. autosummary::
PinholeCameraCfg
FisheyeCameraCfg
.. autofunction:: spawn_camera
.. autoclass:: PinholeCameraCfg
:members:
:exclude-members: __init__, func
.. autoclass:: FisheyeCameraCfg
:members:
:exclude-members: __init__, func
From Files
----------
.. automodule:: omni.isaac.orbit.sim.spawners.from_files
.. rubric:: Classes
.. autosummary::
UrdfFileCfg
UsdFileCfg
GroundPlaneCfg
.. autofunction:: spawn_from_urdf
.. autoclass:: UrdfFileCfg
:members:
:exclude-members: __init__, func
.. autofunction:: spawn_from_usd
.. autoclass:: UsdFileCfg
:members:
:exclude-members: __init__, func
.. autofunction:: spawn_ground_plane
.. autoclass:: GroundPlaneCfg
:members:
:exclude-members: __init__, func
Materials
---------
.. automodule:: omni.isaac.orbit.sim.spawners.materials
.. rubric:: Classes
.. autosummary::
VisualMaterialCfg
PreviewSurfaceCfg
MdlFileCfg
GlassMdlCfg
PhysicsMaterialCfg
RigidBodyMaterialCfg
Visual Materials
~~~~~~~~~~~~~~~~
.. autoclass:: VisualMaterialCfg
:members:
:exclude-members: __init__, func
.. autofunction:: spawn_preview_surface
.. autoclass:: PreviewSurfaceCfg
:members:
:exclude-members: __init__, func
.. autofunction:: spawn_from_mdl_file
.. autoclass:: MdlFileCfg
:members:
:exclude-members: __init__, func
.. autoclass:: GlassMdlCfg
:members:
:exclude-members: __init__, func
Physical Materials
~~~~~~~~~~~~~~~~~~
.. autoclass:: PhysicsMaterialCfg
:members:
:exclude-members: __init__, func
.. autofunction:: spawn_rigid_body_material
.. autoclass:: RigidBodyMaterialCfg
:members:
:exclude-members: __init__, func
| 3,974 | reStructuredText | 15.772152 | 56 | 0.642929 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.controllers.rst | orbit.controllers
=================
.. automodule:: omni.isaac.orbit.controllers
.. rubric:: Classes
.. autosummary::
DifferentialIKController
DifferentialIKControllerCfg
Differential Inverse Kinematics
-------------------------------
.. autoclass:: DifferentialIKController
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: DifferentialIKControllerCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__, class_type
| 503 | reStructuredText | 18.384615 | 44 | 0.650099 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.envs.rst | orbit.envs
==========
.. automodule:: omni.isaac.orbit.envs
.. rubric:: Submodules
.. autosummary::
mdp
ui
.. rubric:: Classes
.. autosummary::
BaseEnv
BaseEnvCfg
ViewerCfg
RLTaskEnv
RLTaskEnvCfg
Base Environment
----------------
.. autoclass:: BaseEnv
:members:
.. autoclass:: BaseEnvCfg
:members:
:exclude-members: __init__, class_type
.. autoclass:: ViewerCfg
:members:
:exclude-members: __init__
RL Task Environment
-------------------
.. autoclass:: RLTaskEnv
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: RLTaskEnvCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__, class_type
| 729 | reStructuredText | 13.6 | 42 | 0.593964 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.scene.rst | orbit.scene
===========
.. automodule:: omni.isaac.orbit.scene
.. rubric:: Classes
.. autosummary::
InteractiveScene
InteractiveSceneCfg
interactive Scene
-----------------
.. autoclass:: InteractiveScene
:members:
:undoc-members:
:show-inheritance:
.. autoclass:: InteractiveSceneCfg
:members:
:exclude-members: __init__
| 362 | reStructuredText | 14.124999 | 38 | 0.624309 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.sensors.patterns.rst | orbit.sensors.patterns
======================
.. automodule:: omni.isaac.orbit.sensors.patterns
.. rubric:: Classes
.. autosummary::
PatternBaseCfg
GridPatternCfg
PinholeCameraPatternCfg
BpearlPatternCfg
Pattern Base
------------
.. autoclass:: PatternBaseCfg
:members:
:inherited-members:
:exclude-members: __init__
Grid Pattern
------------
.. autofunction:: omni.isaac.orbit.sensors.patterns.grid_pattern
.. autoclass:: GridPatternCfg
:members:
:inherited-members:
:exclude-members: __init__, func
Pinhole Camera Pattern
----------------------
.. autofunction:: omni.isaac.orbit.sensors.patterns.pinhole_camera_pattern
.. autoclass:: PinholeCameraPatternCfg
:members:
:inherited-members:
:exclude-members: __init__, func
RS-Bpearl Pattern
-----------------
.. autofunction:: omni.isaac.orbit.sensors.patterns.bpearl_pattern
.. autoclass:: BpearlPatternCfg
:members:
:inherited-members:
:exclude-members: __init__, func
| 1,006 | reStructuredText | 18.365384 | 74 | 0.649105 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.assets.rst | orbit.assets
============
.. automodule:: omni.isaac.orbit.assets
.. rubric:: Classes
.. autosummary::
AssetBase
AssetBaseCfg
RigidObject
RigidObjectData
RigidObjectCfg
Articulation
ArticulationData
ArticulationCfg
.. currentmodule:: omni.isaac.orbit.assets
Asset Base
----------
.. autoclass:: AssetBase
:members:
.. autoclass:: AssetBaseCfg
:members:
:exclude-members: __init__, class_type
Rigid Object
------------
.. autoclass:: RigidObject
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: RigidObjectData
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__
.. autoclass:: RigidObjectCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__, class_type
Articulation
------------
.. autoclass:: Articulation
:members:
:inherited-members:
:show-inheritance:
.. autoclass:: ArticulationData
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__
.. autoclass:: ArticulationCfg
:members:
:inherited-members:
:show-inheritance:
:exclude-members: __init__, class_type
| 1,202 | reStructuredText | 16.185714 | 42 | 0.639767 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.envs.mdp.rst | orbit.envs.mdp
==============
.. automodule:: omni.isaac.orbit.envs.mdp
Observations
------------
.. automodule:: omni.isaac.orbit.envs.mdp.observations
:members:
Actions
-------
.. automodule:: omni.isaac.orbit.envs.mdp.actions
.. automodule:: omni.isaac.orbit.envs.mdp.actions.actions_cfg
:members:
:show-inheritance:
:exclude-members: __init__, class_type
Events
------
.. automodule:: omni.isaac.orbit.envs.mdp.events
:members:
Commands
--------
.. automodule:: omni.isaac.orbit.envs.mdp.commands
.. automodule:: omni.isaac.orbit.envs.mdp.commands.commands_cfg
:members:
:show-inheritance:
:exclude-members: __init__, class_type
Rewards
-------
.. automodule:: omni.isaac.orbit.envs.mdp.rewards
:members:
Terminations
------------
.. automodule:: omni.isaac.orbit.envs.mdp.terminations
:members:
Curriculum
----------
.. automodule:: omni.isaac.orbit.envs.mdp.curriculums
:members:
| 948 | reStructuredText | 16.254545 | 63 | 0.649789 |
NVIDIA-Omniverse/orbit/docs/source/api/orbit/omni.isaac.orbit.sim.schemas.rst | orbit.sim.schemas
=================
.. automodule:: omni.isaac.orbit.sim.schemas
.. rubric:: Classes
.. autosummary::
ArticulationRootPropertiesCfg
RigidBodyPropertiesCfg
CollisionPropertiesCfg
MassPropertiesCfg
JointDrivePropertiesCfg
FixedTendonPropertiesCfg
.. rubric:: Functions
.. autosummary::
define_articulation_root_properties
modify_articulation_root_properties
define_rigid_body_properties
modify_rigid_body_properties
activate_contact_sensors
define_collision_properties
modify_collision_properties
define_mass_properties
modify_mass_properties
modify_joint_drive_properties
modify_fixed_tendon_properties
Articulation Root
-----------------
.. autoclass:: ArticulationRootPropertiesCfg
:members:
:exclude-members: __init__
.. autofunction:: define_articulation_root_properties
.. autofunction:: modify_articulation_root_properties
Rigid Body
----------
.. autoclass:: RigidBodyPropertiesCfg
:members:
:exclude-members: __init__
.. autofunction:: define_rigid_body_properties
.. autofunction:: modify_rigid_body_properties
.. autofunction:: activate_contact_sensors
Collision
---------
.. autoclass:: CollisionPropertiesCfg
:members:
:exclude-members: __init__
.. autofunction:: define_collision_properties
.. autofunction:: modify_collision_properties
Mass
----
.. autoclass:: MassPropertiesCfg
:members:
:exclude-members: __init__
.. autofunction:: define_mass_properties
.. autofunction:: modify_mass_properties
Joint Drive
-----------
.. autoclass:: JointDrivePropertiesCfg
:members:
:exclude-members: __init__
.. autofunction:: modify_joint_drive_properties
Fixed Tendon
------------
.. autoclass:: FixedTendonPropertiesCfg
:members:
:exclude-members: __init__
.. autofunction:: modify_fixed_tendon_properties
| 1,877 | reStructuredText | 19.637362 | 53 | 0.706446 |
NVIDIA-Omniverse/orbit/docs/source/features/actuators.rst | .. _feature-actuators:
Actuators
=========
An articulated system comprises of actuated joints, also called the degrees of freedom (DOF).
In a physical system, the actuation typically happens either through active components, such as
electric or hydraulic motors, or passive components, such as springs. These components can introduce
certain non-linear characteristics which includes delays or maximum producible velocity or torque.
In simulation, the joints are either position, velocity, or torque-controlled. For position and velocity
control, the physics engine internally implements a spring-damp (PD) controller which computes the torques
applied on the actuated joints. In torque-control, the commands are set directly as the joint efforts.
While this mimics an ideal behavior of the joint mechanism, it does not truly model how the drives work
in the physical world. Thus, we provide a mechanism to inject external models to compute the
joint commands that would represent the physical robot's behavior.
Actuator models
---------------
We name two different types of actuator models:
1. **implicit**: corresponds to the ideal simulation mechanism (provided by physics engine).
2. **explicit**: corresponds to external drive models (implemented by user).
The explicit actuator model performs two steps: 1) it computes the desired joint torques for tracking
the input commands, and 2) it clips the desired torques based on the motor capabilities. The clipped
torques are the desired actuation efforts that are set into the simulation.
As an example of an ideal explicit actuator model, we provide the :class:`omni.isaac.orbit.actuators.IdealPDActuator`
class, which implements a PD controller with feed-forward effort, and simple clipping based on the configured
maximum effort:
.. math::
\tau_{j, computed} & = k_p * (q - q_{des}) + k_d * (\dot{q} - \dot{q}_{des}) + \tau_{ff} \\
\tau_{j, applied} & = clip(\tau_{computed}, -\tau_{j, max}, \tau_{j, max})
where, :math:`k_p` and :math:`k_d` are joint stiffness and damping gains, :math:`q` and :math:`\dot{q}`
are the current joint positions and velocities, :math:`q_{des}`, :math:`\dot{q}_{des}` and :math:`\tau_{ff}`
are the desired joint positions, velocities and torques commands. The parameters :math:`\gamma` and
:math:`\tau_{motor, max}` are the gear box ratio and the maximum motor effort possible.
Actuator groups
---------------
The actuator models by themselves are computational blocks that take as inputs the desired joint commands
and output the the joint commands to apply into the simulator. They do not contain any knowledge about the
joints they are acting on themselves. These are handled by the :class:`omni.isaac.orbit.assets.Articulation`
class, which wraps around the physics engine's articulation class.
Actuator are collected as a set of actuated joints on an articulation that are using the same actuator model.
For instance, the quadruped, ANYmal-C, uses series elastic actuator, ANYdrive 3.0, for all its joints. This
grouping configures the actuator model for those joints, translates the input commands to the joint level
commands, and returns the articulation action to set into the simulator. Having an arm with a different
actuator model, such as a DC motor, would require configuring a different actuator group.
The following figure shows the actuator groups for a legged mobile manipulator:
.. image:: ../_static/actuator_groups.svg
:width: 600
:align: center
:alt: Actuator groups for a legged mobile manipulator
.. seealso::
We provide implementations for various explicit actuator models. These are detailed in
`omni.isaac.orbit.actuators <../api/orbit.actuators.html>`_ sub-package.
| 3,727 | reStructuredText | 51.507042 | 117 | 0.763885 |
NVIDIA-Omniverse/orbit/docs/source/features/motion_generators.rst | Motion Generators
=================
Robotic tasks are typically defined in task-space in terms of desired
end-effector trajectory, while control actions are executed in the
joint-space. This naturally leads to *joint-space* and *task-space*
(operational-space) control methods. However, successful execution of
interaction tasks using motion control often requires an accurate model
of both the robot manipulator as well as its environment. While a
sufficiently precise manipulator's model might be known, detailed
description of environment is hard to obtain :cite:p:`siciliano2009force`.
Planning errors caused by this mismatch can be overcome by introducing a
*compliant* behavior during interaction.
While compliance is achievable passively through robot's structure (such
as elastic actuators, soft robot arms), we are more interested in
controller designs that focus on active interaction control. These are
broadly categorized into:
1. **impedance control:** indirect control method where motion deviations
caused during interaction relates to contact force as a mass-spring-damper
system with adjustable parameters (stiffness and damping). A specialized case
of this is *stiffness* control where only the static relationship between
position error and contact force is considered.
2. **hybrid force/motion control:** active control method which controls motion
and force along unconstrained and constrained task directions respectively.
Among the various schemes for hybrid motion control, the provided implementation
is based on inverse dynamics control in the operational space :cite:p:`khatib1987osc`.
.. note::
To provide an even broader set of motion generators, we welcome contributions from the
community. If you are interested, please open an issue to start a discussion!
Joint-space controllers
-----------------------
Torque control
~~~~~~~~~~~~~~
Action dimensions: ``"n"`` (number of joints)
In torque control mode, the input actions are directly set as feed-forward
joint torque commands, i.e. at every time-step,
.. math::
\tau = \tau_{des}
Thus, this control mode is achievable by setting the command type for the actuator group, via
the :class:`ActuatorControlCfg` class, to ``"t_abs"``.
Velocity control
~~~~~~~~~~~~~~~~
Action dimensions: ``"n"`` (number of joints)
In velocity control mode, a proportional control law is required to reduce the error between the
current and desired joint velocities. Based on input actions, the joint torques commands are computed as:
.. math::
\tau = k_d (\dot{q}_{des} - \dot{q})
where :math:`k_d` are the gains parsed from configuration.
This control mode is achievable by setting the command type for the actuator group, via
the :class:`ActuatorControlCfg` class, to ``"v_abs"`` or ``"v_rel"``.
.. attention::
While performing velocity control, in many cases, gravity compensation is required to ensure better
tracking of the command. In this case, we suggest disabling gravity for the links in the articulation
in simulation.
Position control with fixed impedance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Action dimensions: ``"n"`` (number of joints)
In position control mode, a proportional-damping (PD) control law is employed to track the desired joint
positions and ensuring the articulation remains still at the desired location (i.e., desired joint velocities
are zero). Based on the input actions, the joint torque commands are computed as:
.. math::
\tau = k_p (q_{des} - q) - k_d \dot{q}
where :math:`k_p` and :math:`k_d` are the gains parsed from configuration.
In its simplest above form, the control mode is achievable by setting the command type for the actuator group,
via the :class:`ActuatorControlCfg` class, to ``"p_abs"`` or ``"p_rel"``.
However, a more complete formulation which considers the dynamics of the articulation would be:
.. math::
\tau = M \left( k_p (q_{des} - q) - k_d \dot{q} \right) + g
where :math:`M` is the joint-space inertia matrix of size :math:`n \times n`, and :math:`g` is the joint-space
gravity vector. This implementation is available through the :class:`JointImpedanceController` class by setting the
impedance mode to ``"fixed"``. The gains :math:`k_p` are parsed from the input configuration and :math:`k_d`
are computed while considering the system as a decoupled point-mass oscillator, i.e.,
.. math::
k_d = 2 \sqrt{k_p} \times D
where :math:`D` is the damping ratio of the system. Critical damping is achieved for :math:`D = 1`, overcritical
damping for :math:`D > 1` and undercritical damping for :math:`D < 1`.
Additionally, it is possible to disable the inertial or gravity compensation in the controller by setting the
flags :attr:`inertial_compensation` and :attr:`gravity_compensation` in the configuration to :obj:`False`,
respectively.
Position control with variable stiffness
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Action dimensions: ``"2n"`` (number of joints)
In stiffness control, the same formulation as above is employed, however, the gains :math:`k_p` are part of
the input commands. This implementation is available through the :class:`JointImpedanceController` class by
setting the impedance mode to ``"variable_kp"``.
Position control with variable impedance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Action dimensions: ``"3n"`` (number of joints)
In impedance control, the same formulation as above is employed, however, both :math:`k_p` and :math:`k_d`
are part of the input commands. This implementation is available through the :class:`JointImpedanceController`
class by setting the impedance mode to ``"variable"``.
Task-space controllers
----------------------
Differential inverse kinematics (IK)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Action dimensions: ``"3"`` (relative/absolute position), ``"6"`` (relative pose), or ``"7"`` (absolute pose)
Inverse kinematics converts the task-space tracking error to joint-space error. In its most typical implementation,
the pose error in the task-sace, :math:`\Delta \chi_e = (\Delta p_e, \Delta \phi_e)`, is computed as the cartesian
distance between the desired and current task-space positions, and the shortest distance in :math:`\mathbb{SO}(3)`
between the desired and current task-space orientations.
Using the geometric Jacobian :math:`J_{eO} \in \mathbb{R}^{6 \times n}`, that relates task-space velocity to joint-space velocities,
we design the control law to obtain the desired joint positions as:
.. math::
q_{des} = q + \eta J_{eO}^{-} \Delta \chi_e
where :math:`\eta` is a scaling parameter and :math:`J_{eO}^{-}` is the pseudo-inverse of the Jacobian.
It is possible to compute the pseudo-inverse of the Jacobian using different formulations:
* Moore-Penrose pseduo-inverse: :math:`A^{-} = A^T(AA^T)^{-1}`.
* Levenberg-Marquardt pseduo-inverse (damped least-squares): :math:`A^{-} = A^T (AA^T + \lambda \mathbb{I})^{-1}`.
* Tanspose pseudo-inverse: :math:`A^{-} = A^T`.
* Adaptive singular-vale decomposition (SVD) pseduo-inverse from :cite:t:`buss2004ik`.
These implementations are available through the :class:`DifferentialInverseKinematics` class.
Impedance controller
~~~~~~~~~~~~~~~~~~~~
It uses task-space pose error and Jacobian to compute join torques through mass-spring-damper system
with a) fixed stiffness, b) variable stiffness (stiffness control),
and c) variable stiffness and damping (impedance control).
Operational-space controller
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Similar to task-space impedance
control but uses the Equation of Motion (EoM) for computing the
task-space force
Closed-loop proportional force controller
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It uses a proportional term
to track the desired wrench command with respect to current wrench at
the end-effector.
Hybrid force-motion controller
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It combines closed-loop force control
and operational-space motion control to compute the desired wrench at
the end-effector. It uses selection matrices that define the
unconstrainted and constrained task directions.
Reactive planners
-----------------
Typical task-space controllers do not account for motion constraints
such as joint limits, self-collision and environment collision. Instead
they rely on high-level planners (such as RRT) to handle these
non-Euclidean constraints and give joint/task-space way-points to the
controller. However, these methods are often conservative and have
undesirable deceleration when close to an object. More recently,
different approaches combine the constraints directly into an
optimization problem, thereby providing a holistic solution for motion
generation and control.
We currently support the following planners:
- **RMPFlow (lula):** An acceleration-based policy that composes various Reimannian Motion Policies (RMPs) to
solve a hierarchy of tasks :cite:p:`cheng2021rmpflow`. It is capable of performing dynamic collision
avoidance while navigating the end-effector to a target.
- **MPC (OCS2):** A receding horizon control policy based on sequential linear-quadratic (SLQ) programming.
It formulates various constraints into a single optimization problem via soft-penalties and uses automatic
differentiation to compute derivatives of the system dynamics, constraints and costs. Currently, we support
the MPC formulation for end-effector trajectory tracking in fixed-arm and mobile manipulators. The formulation
considers a kinematic system model with joint limits and self-collision avoidance :cite:p:`mittal2021articulated`.
.. warning::
We wrap around the python bindings for these reactive planners to perform a batched computing of
robot actions. However, their current implementations are CPU-based which may cause certain
slowdown for learning.
| 9,828 | reStructuredText | 41.734782 | 132 | 0.737993 |
NVIDIA-Omniverse/orbit/docs/source/features/environments.rst | Environments
============
The following lists comprises of all the RL tasks implementations that are available in Orbit.
While we try to keep this list up-to-date, you can always get the latest list of environments by
running the following command:
.. code-block:: bash
./orbit.sh -p source/standalone/environments/list_envs.py
We are actively working on adding more environments to the list. If you have any environments that
you would like to add to Orbit, please feel free to open a pull request!
Classic
-------
Classic environments that are based on IsaacGymEnvs implementation of MuJoCo-style environments.
.. table::
:widths: 33 37 30
+------------------+-----------------------------+-------------------------------------------------------------------------+
| World | Environment ID | Description |
+==================+=============================+=========================================================================+
| |humanoid| | |humanoid-link| | Move towards a direction with the MuJoCo humanoid robot |
+------------------+-----------------------------+-------------------------------------------------------------------------+
| |ant| | |ant-link| | Move towards a direction with the MuJoCo ant robot |
+------------------+-----------------------------+-------------------------------------------------------------------------+
| |cartpole| | |cartpole-link| | Move the cart to keep the pole upwards in the classic cartpole control |
+------------------+-----------------------------+-------------------------------------------------------------------------+
.. |humanoid| image:: ../_static/tasks/classic/humanoid.jpg
.. |ant| image:: ../_static/tasks/classic/ant.jpg
.. |cartpole| image:: ../_static/tasks/classic/cartpole.jpg
.. |humanoid-link| replace:: `Isaac-Humanoid-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/humanoid/humanoid_env_cfg.py>`__
.. |ant-link| replace:: `Isaac-Ant-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/ant/ant_env_cfg.py>`__
.. |cartpole-link| replace:: `Isaac-Cartpole-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/classic/cartpole/cartpole_env_cfg.py>`__
Manipulation
------------
Environments based on fixed-arm manipulation tasks.
For many of these tasks, we include configurations with different arm action spaces. For example,
for the reach environment:
* |lift-cube-link|: Franka arm with joint position control
* |lift-cube-ik-abs-link|: Franka arm with absolute IK control
* |lift-cube-ik-rel-link|: Franka arm with relative IK control
.. table::
:widths: 33 37 30
+----------------+---------------------+-----------------------------------------------------------------------------+
| World | Environment ID | Description |
+================+=====================+=============================================================================+
| |reach-franka| | |reach-franka-link| | Move the end-effector to a sampled target pose with the Franka robot |
+----------------+---------------------+-----------------------------------------------------------------------------+
| |reach-ur10| | |reach-ur10-link| | Move the end-effector to a sampled target pose with the UR10 robot |
+----------------+---------------------+-----------------------------------------------------------------------------+
| |lift-cube| | |lift-cube-link| | Pick a cube and bring it to a sampled target position with the Franka robot |
+----------------+---------------------+-----------------------------------------------------------------------------+
| |cabi-franka| | |cabi-franka-link| | Grasp the handle of a cabinet's drawer and open it with the Franka robot |
+----------------+---------------------+-----------------------------------------------------------------------------+
.. |reach-franka| image:: ../_static/tasks/manipulation/franka_reach.jpg
.. |reach-ur10| image:: ../_static/tasks/manipulation/ur10_reach.jpg
.. |lift-cube| image:: ../_static/tasks/manipulation/franka_lift.jpg
.. |cabi-franka| image:: ../_static/tasks/manipulation/franka_open_drawer.jpg
.. |reach-franka-link| replace:: `Isaac-Reach-Franka-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/reach/config/franka/joint_pos_env_cfg.py>`__
.. |reach-ur10-link| replace:: `Isaac-Reach-UR10-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/reach/config/ur_10/joint_pos_env_cfg.py>`__
.. |lift-cube-link| replace:: `Isaac-Lift-Cube-Franka-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/lift/config/franka/joint_pos_env_cfg.py>`__
.. |lift-cube-ik-abs-link| replace:: `Isaac-Lift-Cube-Franka-IK-Abs-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/lift/config/franka/ik_abs_env_cfg.py>`__
.. |lift-cube-ik-rel-link| replace:: `Isaac-Lift-Cube-Franka-IK-Rel-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/lift/config/franka/ik_rel_env_cfg.py>`__
.. |cabi-franka-link| replace:: `Isaac-Open-Drawer-Franka-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/manipulation/cabinet/config/franka/joint_pos_env_cfg.py>`__
Locomotion
----------
Environments based on legged locomotion tasks.
.. table::
:widths: 33 37 30
+------------------------------+----------------------------------------------+-------------------------------------------------------------------------+
| World | Environment ID | Description |
+==============================+==============================================+=========================================================================+
| |velocity-flat-anymal-b| | |velocity-flat-anymal-b-link| | Track a velocity command on flat terrain with the Anymal B robot |
+------------------------------+----------------------------------------------+-------------------------------------------------------------------------+
| |velocity-rough-anymal-b| | |velocity-rough-anymal-b-link| | Track a velocity command on rough terrain with the Anymal B robot |
+------------------------------+----------------------------------------------+-------------------------------------------------------------------------+
| |velocity-flat-anymal-c| | |velocity-flat-anymal-c-link| | Track a velocity command on flat terrain with the Anymal C robot |
+------------------------------+----------------------------------------------+-------------------------------------------------------------------------+
| |velocity-rough-anymal-c| | |velocity-rough-anymal-c-link| | Track a velocity command on rough terrain with the Anymal C robot |
+------------------------------+----------------------------------------------+-------------------------------------------------------------------------+
| |velocity-flat-anymal-d| | |velocity-flat-anymal-d-link| | Track a velocity command on flat terrain with the Anymal D robot |
+------------------------------+----------------------------------------------+-------------------------------------------------------------------------+
| |velocity-rough-anymal-d| | |velocity-rough-anymal-d-link| | Track a velocity command on rough terrain with the Anymal D robot |
+------------------------------+----------------------------------------------+-------------------------------------------------------------------------+
| |velocity-flat-unitree-a1| | |velocity-flat-unitree-a1-link| | Track a velocity command on flat terrain with the Unitree A1 robot |
+------------------------------+----------------------------------------------+-------------------------------------------------------------------------+
| |velocity-rough-unitree-a1| | |velocity-rough-unitree-a1-link| | Track a velocity command on rough terrain with the Unitree A1 robot |
+------------------------------+----------------------------------------------+-------------------------------------------------------------------------+
| |velocity-flat-unitree-go1| | |velocity-flat-unitree-go1-link| | Track a velocity command on flat terrain with the Unitree Go1 robot |
+------------------------------+----------------------------------------------+-------------------------------------------------------------------------+
| |velocity-rough-unitree-go1| | |velocity-rough-unitree-go1-link| | Track a velocity command on rough terrain with the Unitree Go1 robot |
+------------------------------+----------------------------------------------+-------------------------------------------------------------------------+
| |velocity-flat-unitree-go2| | |velocity-flat-unitree-go2-link| | Track a velocity command on flat terrain with the Unitree Go2 robot |
+------------------------------+----------------------------------------------+-------------------------------------------------------------------------+
| |velocity-rough-unitree-go2| | |velocity-rough-unitree-go2-link| | Track a velocity command on rough terrain with the Unitree Go2 robot |
+------------------------------+----------------------------------------------+-------------------------------------------------------------------------+
.. |velocity-flat-anymal-b-link| replace:: `Isaac-Velocity-Flat-Anymal-B-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/locomotion/velocity/config/anymal_b/flat_env_cfg.py>`__
.. |velocity-rough-anymal-b-link| replace:: `Isaac-Velocity-Rough-Anymal-B-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/locomotion/velocity/config/anymal_b/rough_env_cfg.py>`__
.. |velocity-flat-anymal-c-link| replace:: `Isaac-Velocity-Flat-Anymal-C-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/locomotion/velocity/config/anymal_c/flat_env_cfg.py>`__
.. |velocity-rough-anymal-c-link| replace:: `Isaac-Velocity-Rough-Anymal-C-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/locomotion/velocity/config/anymal_c/rough_env_cfg.py>`__
.. |velocity-flat-anymal-d-link| replace:: `Isaac-Velocity-Flat-Anymal-D-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/locomotion/velocity/config/anymal_d/flat_env_cfg.py>`__
.. |velocity-rough-anymal-d-link| replace:: `Isaac-Velocity-Rough-Anymal-D-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/locomotion/velocity/config/anymal_d/rough_env_cfg.py>`__
.. |velocity-flat-unitree-a1-link| replace:: `Isaac-Velocity-Flat-Unitree-A1-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/locomotion/velocity/config/unitree_a1/flat_env_cfg.py>`__
.. |velocity-rough-unitree-a1-link| replace:: `Isaac-Velocity-Rough-Unitree-A1-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/locomotion/velocity/config/unitree_a1/rough_env_cfg.py>`__
.. |velocity-flat-unitree-go1-link| replace:: `Isaac-Velocity-Flat-Unitree-Go1-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/locomotion/velocity/config/unitree_go1/flat_env_cfg.py>`__
.. |velocity-rough-unitree-go1-link| replace:: `Isaac-Velocity-Rough-Unitree-Go1-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/locomotion/velocity/config/unitree_go1/rough_env_cfg.py>`__
.. |velocity-flat-unitree-go2-link| replace:: `Isaac-Velocity-Flat-Unitree-Go2-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/locomotion/velocity/config/unitree_go2/flat_env_cfg.py>`__
.. |velocity-rough-unitree-go2-link| replace:: `Isaac-Velocity-Rough-Unitree-Go2-v0 <https://github.com/NVIDIA-Omniverse/orbit/blob/main/source/extensions/omni.isaac.orbit_tasks/omni/isaac/orbit_tasks/locomotion/velocity/config/unitree_go2/rough_env_cfg.py>`__
.. |velocity-flat-anymal-b| image:: ../_static/tasks/locomotion/anymal_b_flat.jpg
.. |velocity-rough-anymal-b| image:: ../_static/tasks/locomotion/anymal_b_rough.jpg
.. |velocity-flat-anymal-c| image:: ../_static/tasks/locomotion/anymal_c_flat.jpg
.. |velocity-rough-anymal-c| image:: ../_static/tasks/locomotion/anymal_c_rough.jpg
.. |velocity-flat-anymal-d| image:: ../_static/tasks/locomotion/anymal_d_flat.jpg
.. |velocity-rough-anymal-d| image:: ../_static/tasks/locomotion/anymal_d_rough.jpg
.. |velocity-flat-unitree-a1| image:: ../_static/tasks/locomotion/a1_flat.jpg
.. |velocity-rough-unitree-a1| image:: ../_static/tasks/locomotion/a1_rough.jpg
.. |velocity-flat-unitree-go1| image:: ../_static/tasks/locomotion/go1_flat.jpg
.. |velocity-rough-unitree-go1| image:: ../_static/tasks/locomotion/go1_rough.jpg
.. |velocity-flat-unitree-go2| image:: ../_static/tasks/locomotion/go2_flat.jpg
.. |velocity-rough-unitree-go2| image:: ../_static/tasks/locomotion/go2_rough.jpg
| 14,487 | reStructuredText | 95.586666 | 260 | 0.530752 |
NVIDIA-Omniverse/orbit/docs/source/deployment/cluster.rst | .. _deployment-cluster:
Cluster Guide
=============
Clusters are a great way to speed up training and evaluation of learning algorithms.
While the Orbit Docker image can be used to run jobs on a cluster, many clusters only
support singularity images. This is because `singularity`_ is designed for
ease-of-use on shared multi-user systems and high performance computing (HPC) environments.
It does not require root privileges to run containers and can be used to run user-defined
containers.
Singularity is compatible with all Docker images. In this section, we describe how to
convert the Orbit Docker image into a singularity image and use it to submit jobs to a cluster.
.. attention::
Cluster setup varies across different institutions. The following instructions have been
tested on the `ETH Zurich Euler`_ cluster, which uses the SLURM workload manager.
The instructions may need to be adapted for other clusters. If you have successfully
adapted the instructions for another cluster, please consider contributing to the
documentation.
Setup Instructions
------------------
In order to export the Docker Image to a singularity image, `apptainer`_ is required.
A detailed overview of the installation procedure for ``apptainer`` can be found in its
`documentation`_. For convenience, we summarize the steps here for a local installation:
.. code:: bash
sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:apptainer/ppa
sudo apt update
sudo apt install -y apptainer
For simplicity, we recommend that an SSH connection is set up between the local
development machine and the cluster. Such a connection will simplify the file transfer and prevent
the user cluster password from being requested multiple times.
.. attention::
The workflow has been tested with ``apptainer version 1.2.5-1.el7`` and ``docker version 24.0.7``.
- ``apptainer``:
There have been reported binding issues with previous versions (such as ``apptainer version 1.1.3-1.el7``). Please
ensure that you are using the latest version.
- ``Docker``:
The latest versions (``25.x``) cannot be used as they are not compatible yet with apptainer/ singularity.
We are waiting for an update from the apptainer team. To track this issue, please check the `forum post`_.
Configuring the cluster parameters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
First, you need to configure the cluster-specific parameters in ``docker/.env.base`` file.
The following describes the parameters that need to be configured:
- ``CLUSTER_ISAAC_SIM_CACHE_DIR``:
The directory on the cluster where the Isaac Sim cache is stored. This directory
has to end on ``docker-isaac-sim``. This directory will be copied to the compute node
and mounted into the singularity container. It should increase the speed of starting
the simulation.
- ``CLUSTER_ORBIT_DIR``:
The directory on the cluster where the orbit code is stored. This directory has to
end on ``orbit``. This directory will be copied to the compute node and mounted into
the singularity container. When a job is submitted, the latest local changes will
be copied to the cluster.
- ``CLUSTER_LOGIN``:
The login to the cluster. Typically, this is the user and cluster names,
e.g., ``[email protected]``.
- ``CLUSTER_SIF_PATH``:
The path on the cluster where the singularity image will be stored. The image will be
copied to the compute node but not uploaded again to the cluster when a job is submitted.
- ``CLUSTER_PYTHON_EXECUTABLE``:
The path within orbit to the Python executable that should be executed in the submitted job.
Exporting to singularity image
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Next, we need to export the Docker image to a singularity image and upload
it to the cluster. This step is only required once when the first job is submitted
or when the Docker image is updated. For instance, due to an upgrade of the Isaac Sim
version, or additional requirements for your project.
To export to a singularity image, execute the following command:
.. code:: bash
./docker/container.sh push [profile]
This command will create a singularity image under ``docker/exports`` directory and
upload it to the defined location on the cluster. Be aware that creating the singularity
image can take a while.
``[profile]`` is an optional argument that specifies the container profile to be used. If no profile is
specified, the default profile ``base`` will be used.
.. note::
By default, the singularity image is created without root access by providing the ``--fakeroot`` flag to
the ``apptainer build`` command. In case the image creation fails, you can try to create it with root
access by removing the flag in ``docker/container.sh``.
Job Submission and Execution
----------------------------
Defining the job parameters
~~~~~~~~~~~~~~~~~~~~~~~~~~~
The job parameters are defined inside the ``docker/cluster/submit_job.sh``.
A typical SLURM operation requires specifying the number of CPUs and GPUs, the memory, and
the time limit. For more information, please check the `SLURM documentation`_.
The default configuration is as follows:
.. literalinclude:: ../../../docker/cluster/submit_job.sh
:language: bash
:lines: 12-19
:linenos:
:lineno-start: 12
An essential requirement for the cluster is that the compute node has access to the internet at all times.
This is required to load assets from the Nucleus server. For some cluster architectures, extra modules
must be loaded to allow internet access.
For instance, on ETH Zurich Euler cluster, the ``eth_proxy`` module needs to be loaded. This can be done
by adding the following line to the ``submit_job.sh`` script:
.. literalinclude:: ../../../docker/cluster/submit_job.sh
:language: bash
:lines: 3-5
:linenos:
:lineno-start: 3
Submitting a job
~~~~~~~~~~~~~~~~
To submit a job on the cluster, the following command can be used:
.. code:: bash
./docker/container.sh job [profile] "argument1" "argument2" ...
This command will copy the latest changes in your code to the cluster and submit a job. Please ensure that
your Python executable's output is stored under ``orbit/logs`` as this directory will be copied again
from the compute node to ``CLUSTER_ORBIT_DIR``.
``[profile]`` is an optional argument that specifies which singularity image corresponding to the container profile
will be used. If no profile is specified, the default profile ``base`` will be used. The profile has be defined
directlty after the ``job`` command. All other arguments are passed to the Python executable. If no profile is
defined, all arguments are passed to the Python executable.
The training arguments are passed to the Python executable. As an example, the standard
ANYmal rough terrain locomotion training can be executed with the following command:
.. code:: bash
./docker/container.sh job --task Isaac-Velocity-Rough-Anymal-C-v0 --headless --video --offscreen_render
The above will, in addition, also render videos of the training progress and store them under ``orbit/logs`` directory.
.. note::
The ``./docker/container.sh job`` command will copy the latest changes in your code to the cluster. However,
it will not delete any files that have been deleted locally. These files will still exist on the cluster
which can lead to issues. In this case, we recommend removing the ``CLUSTER_ORBIT_DIR`` directory on
the cluster and re-run the command.
.. _Singularity: https://docs.sylabs.io/guides/2.6/user-guide/index.html
.. _ETH Zurich Euler: https://scicomp.ethz.ch/wiki/Euler
.. _apptainer: https://apptainer.org/
.. _documentation: www.apptainer.org/docs/admin/main/installation.html#install-ubuntu-packages
.. _SLURM documentation: www.slurm.schedmd.com/sbatch.html
.. _forum post: https://forums.docker.com/t/trouble-after-upgrade-to-docker-ce-25-0-1-on-debian-12/139613
| 7,938 | reStructuredText | 43.105555 | 119 | 0.745528 |
NVIDIA-Omniverse/orbit/docs/source/deployment/run_docker_example.rst | Running an example with Docker
==============================
From the root of the ``orbit`` repository, the ``docker`` directory contains all the Docker relevant files. These include the three files
(**Dockerfile**, **docker-compose.yaml**, **.env**) which are used by Docker, and an additional script that we use to interface with them,
**container.sh**.
In this tutorial, we will learn how to use the Orbit Docker container for development. For a detailed description of the Docker setup,
including installation and obtaining access to an Isaac Sim image, please reference the :ref:`deployment-docker`. For a description
of Docker in general, please refer to `their official documentation <https://docs.docker.com/get-started/overview/>`_.
Building the Container
~~~~~~~~~~~~~~~~~~~~~~
To build the Orbit container from the root of the Orbit repository, we will run the following:
.. code-block:: console
./docker/container.sh start
The terminal will first pull the base IsaacSim image, build the Orbit image's additional layers on top of it, and run the Orbit container.
This should take several minutes upon the first build but will be shorter in subsequent runs as Docker's caching prevents repeated work.
If we run the command ``docker container ls`` on the terminal, the output will list the containers that are running on the system. If
everything has been set up correctly, a container with the ``NAME`` **orbit** should appear, similar to below:
.. code-block:: console
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
483d1d5e2def orbit "bash" 30 seconds ago Up 30 seconds orbit
Once the container is up and running, we can enter it from our terminal.
.. code-block:: console
./docker/container.sh enter
On entering the Orbit container, we are in the terminal as the superuser, ``root``. This environment contains a copy of the
Orbit repository, but also has access to the directories and libraries of Isaac Sim. We can run experiments from this environment
using a few convenient aliases that have been put into the ``root`` **.bashrc**. For instance, we have made the **orbit.sh** script
usable from anywhere by typing its alias ``orbit``.
Additionally in the container, we have `bind mounted`_ the ``orbit/source`` directory from the
host machine. This means that if we modify files under this directory from an editor on the host machine, the changes are
reflected immediately within the container without requiring us to rebuild the Docker image.
We will now run a sample script from within the container to demonstrate how to extract artifacts
from the Orbit Docker container.
The Code
~~~~~~~~
The tutorial corresponds to the ``log_time.py`` script in the ``orbit/source/standalone/tutorials/00_sim`` directory.
.. dropdown:: Code for log_time.py
:icon: code
.. literalinclude:: ../../../source/standalone/tutorials/00_sim/log_time.py
:language: python
:emphasize-lines: 46-55, 72-79
:linenos:
The Code Explained
~~~~~~~~~~~~~~~~~~
The Orbit Docker container has several `volumes`_ to facilitate persistent storage between the host computer and the
container. One such volume is the ``/workspace/orbit/logs`` directory.
The ``log_time.py`` script designates this directory as the location to which a ``log.txt`` should be written:
.. literalinclude:: ../../../source/standalone/tutorials/00_sim/log_time.py
:language: python
:start-at: # Specify that the logs must be in logs/docker_tutorial
:end-at: print(f"[INFO] Logging experiment to directory: {log_dir_path}")
As the comments note, :func:`os.path.abspath()` will prepend ``/workspace/orbit`` because in
the Docker container all python execution is done through ``/workspace/orbit/orbit.sh``.
The output will be a file, ``log.txt``, with the ``sim_time`` written on a newline at every simulation step:
.. literalinclude:: ../../../source/standalone/tutorials/00_sim/log_time.py
:language: python
:start-at: # Prepare to count sim_time
:end-at: sim_time += sim_dt
Executing the Script
~~~~~~~~~~~~~~~~~~~~
We will execute the script to produce a log, adding a ``--headless`` flag to our execution to prevent a GUI:
.. code-block:: bash
orbit -p source/standalone/tutorials/00_sim/log_time.py --headless
Now ``log.txt`` will have been produced at ``/workspace/orbit/logs/docker_tutorial``. If we exit the container
by typing ``exit``, we will return to ``orbit/docker`` in our host terminal environment. We can then enter
the following command to retrieve our logs from the Docker container and put them on our host machine:
.. code-block:: console
./container.sh copy
We will see a terminal readout reporting the artifacts we have retrieved from the container. If we navigate to
``/orbit/docker/artifacts/logs/docker_tutorial``, we will see a copy of the ``log.txt`` file which was produced
by the script above.
Each of the directories under ``artifacts`` corresponds to Docker `volumes`_ mapped to directories
within the container and the ``container.sh copy`` command copies them from those `volumes`_ to these directories.
We could return to the Orbit Docker terminal environment by running ``container.sh enter`` again,
but we have retrieved our logs and wish to go inspect them. We can stop the Orbit Docker container with the following command:
.. code-block:: console
./container.sh stop
This will bring down the Docker Orbit container. The image will persist and remain available for further use, as will
the contents of any `volumes`_. If we wish to free up the disk space taken by the image, (~20.1GB), and do not mind repeating
the build process when we next run ``./container.sh start``, we may enter the following command to delete the **orbit** image:
.. code-block:: console
docker image rm orbit
A subsequent run of ``docker image ls``` will show that the image tagged **orbit** is now gone. We can repeat the process for the
underlying NVIDIA container if we wish to free up more space. If a more powerful method of freeing resources from Docker is desired,
please consult the documentation for the `docker prune`_ commands.
.. _volumes: https://docs.docker.com/storage/volumes/
.. _bind mounted: https://docs.docker.com/storage/bind-mounts/
.. _docker prune: https://docs.docker.com/config/pruning/
| 6,373 | reStructuredText | 43.887324 | 138 | 0.73529 |
NVIDIA-Omniverse/orbit/docs/source/deployment/docker.rst | .. _deployment-docker:
Docker Guide
============
.. caution::
Due to the dependency on Isaac Sim docker image, by running this container you are implicitly
agreeing to the `NVIDIA Omniverse EULA`_. If you do not agree to the EULA, do not run this container.
Setup Instructions
------------------
.. note::
The following steps are taken from the NVIDIA Omniverse Isaac Sim documentation on `container installation`_.
They have been added here for the sake of completeness.
Docker and Docker Compose
~~~~~~~~~~~~~~~~~~~~~~~~~
We have tested the container using Docker Engine version 26.0.0 and Docker Compose version 2.25.0
We recommend using these versions or newer.
* To install Docker, please follow the instructions for your operating system on the `Docker website`_.
* To install Docker Compose, please follow the instructions for your operating system on the `docker compose`_ page.
* Follow the post-installation steps for Docker on the `post-installation steps`_ page. These steps allow you to run
Docker without using ``sudo``.
* To build and run GPU-accelerated containers, you also need install the `NVIDIA Container Toolkit`_.
Please follow the instructions on the `Container Toolkit website`_ for installation steps.
Obtaining the Isaac Sim Container
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Get access to the `Isaac Sim container`_ by joining the NVIDIA Developer Program credentials.
* Generate your `NGC API key`_ to access locked container images from NVIDIA GPU Cloud (NGC).
* This step requires you to create an NGC account if you do not already have one.
* You would also need to install the NGC CLI to perform operations from the command line.
* Once you have your generated API key and have installed the NGC CLI, you need to log in to NGC
from the terminal.
.. code:: bash
ngc config set
* Use the command line to pull the Isaac Sim container image from NGC.
.. code:: bash
docker login nvcr.io
* For the username, enter ``$oauthtoken`` exactly as shown. It is a special username that is used to
authenticate with NGC.
.. code:: text
Username: $oauthtoken
Password: <Your NGC API Key>
Directory Organization
----------------------
The root of the Orbit repository contains the ``docker`` directory that has various files and scripts
needed to run Orbit inside a Docker container. A subset of these are summarized below:
* ``Dockerfile.base``: Defines the orbit image by overlaying Orbit dependencies onto the Isaac Sim Docker image.
``Dockerfiles`` which end with something else, (i.e. ``Dockerfile.ros2``) build an `image_extension <#orbit-image-extensions>`_.
* ``docker-compose.yaml``: Creates mounts to allow direct editing of Orbit code from the host machine that runs
the container. It also creates several named volumes such as ``isaac-cache-kit`` to
store frequently re-used resources compiled by Isaac Sim, such as shaders, and to retain logs, data, and documents.
* ``base.env``: Stores environment variables required for the ``base`` build process and the container itself. ``.env``
files which end with something else (i.e. ``.env.ros2``) define these for `image_extension <#orbit-image-extensions>`_.
* ``container.sh``: A script that wraps the ``docker compose`` command to build the image and run the container.
Running the Container
---------------------
.. note::
The docker container copies all the files from the repository into the container at the
location ``/workspace/orbit`` at build time. This means that any changes made to the files in the container would not
normally be reflected in the repository after the image has been built, i.e. after ``./container.sh start`` is run.
For a faster development cycle, we mount the following directories in the Orbit repository into the container
so that you can edit their files from the host machine:
* ``source``: This is the directory that contains the Orbit source code.
* ``docs``: This is the directory that contains the source code for Orbit documentation. This is overlaid except
for the ``_build`` subdirectory where build artifacts are stored.
The script ``container.sh`` wraps around three basic ``docker compose`` commands. Each can accept an `image_extension argument <#orbit-image-extensions>`_,
or else they will default to image_extension ``base``:
1. ``start``: This builds the image and brings up the container in detached mode (i.e. in the background).
2. ``enter``: This begins a new bash process in an existing orbit container, and which can be exited
without bringing down the container.
3. ``copy``: This copies the ``logs``, ``data_storage`` and ``docs/_build`` artifacts, from the ``orbit-logs``, ``orbit-data`` and ``orbit-docs``
volumes respectively, to the ``docker/artifacts`` directory. These artifacts persist between docker
container instances and are shared between image extensions.
4. ``stop``: This brings down the container and removes it.
The following shows how to launch the container in a detached state and enter it:
.. code:: bash
# Launch the container in detached mode
# We don't pass an image extension arg, so it defaults to 'base'
./docker/container.sh start
# Enter the container
# We pass 'base' explicitly, but if we hadn't it would default to 'base'
./docker/container.sh enter base
To copy files from the base container to the host machine, you can use the following command:
.. code:: bash
# Copy the file /workspace/orbit/logs to the current directory
docker cp orbit-base:/workspace/orbit/logs .
The script ``container.sh`` provides a wrapper around this command to copy the ``logs`` , ``data_storage`` and ``docs/_build``
directories to the ``docker/artifacts`` directory. This is useful for copying the logs, data and documentation:
.. code::
# stop the container
./docker/container.sh stop
Python Interpreter
~~~~~~~~~~~~~~~~~~
The container uses the Python interpreter provided by Isaac Sim. This interpreter is located at
``/isaac-sim/python.sh``. We set aliases inside the container to make it easier to run the Python
interpreter. You can use the following commands to run the Python interpreter:
.. code:: bash
# Run the Python interpreter -> points to /isaac-sim/python.sh
python
Understanding the mounted volumes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The ``docker-compose.yaml`` file creates several named volumes that are mounted to the container.
These are summarized below:
* ``isaac-cache-kit``: This volume is used to store cached Kit resources (`/isaac-sim/kit/cache` in container)
* ``isaac-cache-ov``: This volume is used to store cached OV resources (`/root/.cache/ov` in container)
* ``isaac-cache-pip``: This volume is used to store cached pip resources (`/root/.cache/pip`` in container)
* ``isaac-cache-gl``: This volume is used to store cached GLCache resources (`/root/.cache/nvidia/GLCache` in container)
* ``isaac-cache-compute``: This volume is used to store cached compute resources (`/root/.nv/ComputeCache` in container)
* ``isaac-logs``: This volume is used to store logs generated by Omniverse. (`/root/.nvidia-omniverse/logs` in container)
* ``isaac-carb-logs``: This volume is used to store logs generated by carb. (`/isaac-sim/kit/logs/Kit/Isaac-Sim` in container)
* ``isaac-data``: This volume is used to store data generated by Omniverse. (`/root/.local/share/ov/data` in container)
* ``isaac-docs``: This volume is used to store documents generated by Omniverse. (`/root/Documents` in container)
* ``orbit-docs``: This volume is used to store documentation of Orbit when built inside the container. (`/workspace/orbit/docs/_build` in container)
* ``orbit-logs``: This volume is used to store logs generated by Orbit workflows when run inside the container. (`/workspace/orbit/logs` in container)
* ``orbit-data``: This volume is used to store whatever data users may want to preserve between container runs. (`/workspace/orbit/data_storage` in container)
To view the contents of these volumes, you can use the following command:
.. code:: bash
# list all volumes
docker volume ls
# inspect a specific volume, e.g. isaac-cache-kit
docker volume inspect isaac-cache-kit
Orbit Image Extensions
----------------------
The produced image depends upon the arguments passed to ``./container.sh start`` and ``./container.sh stop``. These
commands accept an ``image_extension`` as an additional argument. If no argument is passed, then these
commands default to ``base``. Currently, the only valid ``image_extension`` arguments are (``base``, ``ros2``).
Only one ``image_extension`` can be passed at a time, and the produced container will be named ``orbit``.
.. code:: bash
# start base by default
./container.sh start
# stop base explicitly
./container.sh stop base
# start ros2 container
./container.sh start ros2
# stop ros2 container
./container.sh stop ros2
The passed ``image_extension`` argument will build the image defined in ``Dockerfile.${image_extension}``,
with the corresponding `profile`_ in the ``docker-compose.yaml`` and the envars from ``.env.${image_extension}``
in addition to the ``.env.base``, if any.
ROS2 Image Extension
~~~~~~~~~~~~~~~~~~~~
In ``Dockerfile.ros2``, the container installs ROS2 Humble via an `apt package`_, and it is sourced in the ``.bashrc``.
The exact version is specified by the variable ``ROS_APT_PACKAGE`` in the ``.env.ros2`` file,
defaulting to ``ros-base``. Other relevant ROS2 variables are also specified in the ``.env.ros2`` file,
including variables defining the `various middleware`_ options. The container defaults to ``FastRTPS``, but ``CylconeDDS``
is also supported. Each of these middlewares can be `tuned`_ using their corresponding ``.xml`` files under ``docker/.ros``.
Known Issues
------------
Invalid mount config for type "bind"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you see the following error when building the container:
.. code:: text
⠋ Container orbit Creating 0.0s
Error response from daemon: invalid mount config for type "bind": bind source path does not exist: ${HOME}/.Xauthority
This means that the ``.Xauthority`` file is not present in the home directory of the host machine.
The portion of the docker-compose.yaml that enables this is commented out by default, so this shouldn't
happen unless it has been altered. This file is required for X11 forwarding to work. To fix this, you can
create an empty ``.Xauthority`` file in your home directory.
.. code:: bash
touch ${HOME}/.Xauthority
A similar error but requires a different fix:
.. code:: text
⠋ Container orbit Creating 0.0s
Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /tmp/.X11-unix
This means that the folder/files are either not present or not accessible on the host machine.
The portion of the docker-compose.yaml that enables this is commented out by default, so this
shouldn't happen unless it has been altered. This usually happens when you have multiple docker
versions installed on your machine. To fix this, you can try the following:
* Remove all docker versions from your machine.
.. code:: bash
sudo apt remove docker*
sudo apt remove docker docker-engine docker.io containerd runc docker-desktop docker-compose-plugin
sudo snap remove docker
sudo apt clean autoclean && sudo apt autoremove --yes
* Install the latest version of docker based on the instructions in the setup section.
WebRTC and WebSocket Streaming
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When streaming the GUI from Isaac Sim, there are `several streaming clients`_ available. There is a `known issue`_ when
attempting to use WebRTC streaming client on Google Chrome and Safari while running Isaac Sim inside a container.
To avoid this problem, we suggest using either the Native Streaming Client or WebSocket options, or using the
Mozilla Firefox browser on which WebRTC works.
Streaming is the only supported method for visualizing the Isaac GUI from within the container. The Omniverse Streaming Client
is freely available from the Omniverse app, and is easy to use. The other streaming methods similarly require only a web browser.
If users want to use X11 forwarding in order to have the apps behave as local GUI windows, they can uncomment the relevant portions
in docker-compose.yaml.
.. _`NVIDIA Omniverse EULA`: https://docs.omniverse.nvidia.com/platform/latest/common/NVIDIA_Omniverse_License_Agreement.html
.. _`container installation`: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_container.html
.. _`Docker website`: https://docs.docker.com/desktop/install/linux-install/
.. _`docker compose`: https://docs.docker.com/compose/install/linux/#install-using-the-repository
.. _`NVIDIA Container Toolkit`: https://github.com/NVIDIA/nvidia-container-toolkit
.. _`Container Toolkit website`: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html
.. _`post-installation steps`: https://docs.docker.com/engine/install/linux-postinstall/
.. _`Isaac Sim container`: https://catalog.ngc.nvidia.com/orgs/nvidia/containers/isaac-sim
.. _`NGC API key`: https://docs.nvidia.com/ngc/gpu-cloud/ngc-user-guide/index.html#generating-api-key
.. _`several streaming clients`: https://docs.omniverse.nvidia.com/isaacsim/latest/installation/manual_livestream_clients.html
.. _`known issue`: https://forums.developer.nvidia.com/t/unable-to-use-webrtc-when-i-run-runheadless-webrtc-sh-in-remote-headless-container/222916
.. _`profile`: https://docs.docker.com/compose/compose-file/15-profiles/
.. _`apt package`: https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html#install-ros-2-packages
.. _`various middleware`: https://docs.ros.org/en/humble/How-To-Guides/Working-with-multiple-RMW-implementations.html
.. _`tuned`: https://docs.ros.org/en/foxy/How-To-Guides/DDS-tuning.html
| 14,374 | reStructuredText | 49.438596 | 204 | 0.714693 |
NVIDIA-Omniverse/orbit/docs/source/deployment/index.rst | Container Deployment
====================
Docker is a tool that allows for the creation of containers, which are isolated environments that can
be used to run applications. They are useful for ensuring that an application can run on any machine
that has Docker installed, regardless of the host machine's operating system or installed libraries.
We include a Dockerfile and docker-compose.yaml file that can be used to build a Docker image that
contains Orbit and all of its dependencies. This image can then be used to run Orbit in a container.
The Dockerfile is based on the Isaac Sim image provided by NVIDIA, which includes the Omniverse
application launcher and the Isaac Sim application. The Dockerfile installs Orbit and its dependencies
on top of this image.
The following guides provide instructions for building the Docker image and running Orbit in a
container.
.. toctree::
:maxdepth: 1
docker
cluster
run_docker_example
| 946 | reStructuredText | 40.173911 | 102 | 0.788584 |
NVIDIA-Omniverse/orbit/docs/source/refs/migration.rst | Migration Guide (Isaac Sim)
===========================
Moving from Isaac Sim 2022.2.1 to 2023.1.0 brings in a number of changes to the
APIs and the way the application is built. This document outlines the changes
and how to migrate your code to the new APIs. Many of these changes attribute to
the underlying Omniverse Kit upgrade from 104.2 to 105.1. The new upgrade brings
the following notable changes:
* Update to USD 22.11
* Upgrading the Python from 3.7 to 3.10
.. warning::
This document is a work in progress and will be updated as we move closer
to the release of Isaac Sim 2023.1.0.
Renaming of PhysX Flatcache to PhysX Fabric
-------------------------------------------
The PhysX Flatcache has been renamed to PhysX Fabric. The new name is more
descriptive of the functionality and is consistent with the naming convention
used by Omniverse called `Fabric`_. Consequently, the Python module name has
also been changed from :mod:`omni.physxflatcache` to :mod:`omni.physxfabric`.
Following this, on the Isaac Sim side, various renaming have occurred:
* The parameter passed to :class:`SimulationContext` constructor via the keyword :obj:`sim_params`
now expects the key ``use_fabric`` instead of ``use_flatcache``.
* The Python attribute :attr:`SimulationContext.get_physics_context().use_flatcache` is now
:attr:`SimulationContext.get_physics_context().use_fabric`.
* The Python function :meth:`SimulationContext.get_physics_context().enable_flatcache` is now
:meth:`SimulationContext.get_physics_context().enable_fabric`.
Renaming of the URDF and MJCF Importers
---------------------------------------
Starting from Isaac Sim 2023.1, the URDF and MJCF importers have been renamed to be more consistent
with the other asset importers in Omniverse. The importers are now available on NVIDIA-Omniverse GitHub
as open source projects.
Due to the extension name change, the Python module names have also been changed:
* URDF Importer: :mod:`omni.importer.urdf` (previously :mod:`omni.isaac.urdf`)
* MJCF Importer: :mod:`omni.importer.mjcf` (previously :mod:`omni.isaac.mjcf`)
Deprecation of :class:`UsdLux.Light` API
----------------------------------------
As highlighted in the release notes of `USD 22.11`_, the ``UsdLux.Light`` API has
been deprecated in favor of the new ``UsdLuxLightAPI`` API. In the new API the attributes
are prefixed with ``inputs:``. For example, the ``intensity`` attribute is now available as
``inputs:intensity``.
The following example shows how to create a sphere light using the old API and
the new API.
.. dropdown:: Code for Isaac Sim 2022.2.1 and below
:icon: code
.. code-block:: python
import omni.isaac.core.utils.prims as prim_utils
prim_utils.create_prim(
"/World/Light/GreySphere",
"SphereLight",
translation=(4.5, 3.5, 10.0),
attributes={"radius": 2.5, "intensity": 600.0, "color": (0.75, 0.75, 0.75)},
)
.. dropdown:: Code for Isaac Sim 2023.1.0 and above
:icon: code
.. code-block:: python
import omni.isaac.core.utils.prims as prim_utils
prim_utils.create_prim(
"/World/Light/WhiteSphere",
"SphereLight",
translation=(-4.5, 3.5, 10.0),
attributes={
"inputs:radius": 2.5,
"inputs:intensity": 600.0,
"inputs:color": (1.0, 1.0, 1.0)
},
)
.. _Fabric: https://docs.omniverse.nvidia.com/kit/docs/usdrt/latest/docs/usd_fabric_usdrt.html
.. _`USD 22.11`: https://github.com/PixarAnimationStudios/OpenUSD/blob/release/CHANGELOG.md
| 3,578 | reStructuredText | 36.28125 | 103 | 0.686138 |
NVIDIA-Omniverse/orbit/docs/source/refs/changelog.rst | Extensions Changelog
====================
All notable changes to this project are documented in this file. The format is based on
`Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`__ and this project adheres to
`Semantic Versioning <https://semver.org/spec/v2.0.0.html>`__.
Each extension has its own changelog. The changelog for each extension is located in the
``docs`` directory of the extension. The changelog for each extension is also included in
this changelog to make it easier to find the changelog for a specific extension.
omni.isaac.orbit
-----------------
Extension containing the core framework of Orbit.
.. include:: ../../../source/extensions/omni.isaac.orbit/docs/CHANGELOG.rst
:start-line: 3
omni.isaac.orbit_assets
------------------------
Extension for configurations of various assets and sensors for Orbit.
.. include:: ../../../source/extensions/omni.isaac.orbit_assets/docs/CHANGELOG.rst
:start-line: 3
omni.isaac.orbit_tasks
----------------------
Extension containing the environments built using Orbit.
.. include:: ../../../source/extensions/omni.isaac.orbit_tasks/docs/CHANGELOG.rst
:start-line: 3
| 1,156 | reStructuredText | 30.270269 | 89 | 0.701557 |
NVIDIA-Omniverse/orbit/docs/source/refs/issues.rst | Known Issues
============
.. attention::
Please also refer to the `Omniverse Isaac Sim documentation`_ for known issues and workarounds.
Stale values after resetting the environment
--------------------------------------------
When resetting the environment, some of the data fields of assets and sensors are not updated.
These include the poses of links in a kinematic chain, the camera images, the contact sensor readings,
and the lidar point clouds. This is a known issue which has to do with the way the PhysX and
rendering engines work in Omniverse.
Many physics engines do a simulation step as a two-level call: ``forward()`` and ``simulate()``,
where the kinematic and dynamic states are updated, respectively. Unfortunately, PhysX has only a
single ``step()`` call where the two operations are combined. Due to computations through GPU
kernels, it is not so straightforward for them to split these operations. Thus, at the moment,
it is not possible to set the root and/or joint states and do a forward call to update the
kinematic states of links. This affects both initialization as well as episodic resets.
Similarly for RTX rendering related sensors (such as cameras), the sensor data is not updated
immediately after setting the state of the sensor. The rendering engine update is bundled with
the simulator's ``step()`` call which only gets called when the simulation is stepped forward.
This means that the sensor data is not updated immediately after a reset and it will hold
outdated values.
While the above is erroneous, there is currently no direct workaround for it. From our experience in
using IsaacGym, the reset values affect the agent learning critically depending on how frequently
the environment terminates. Eventually if the agent is learning successfully, this number drops
and does not affect the performance that critically.
We have made a feature request to the respective Omniverse teams to have complete control
over stepping different parts of the simulation app. However, at this point, there is no set
timeline for this feature request.
Non-determinism in physics simulation
-------------------------------------
Due to GPU work scheduling, there's a possibility that runtime changes to simulation parameters
may alter the order in which operations take place. This occurs because environment updates can
happen while the GPU is occupied with other tasks. Due to the inherent nature of floating-point
numeric storage, any modification to the execution ordering can result in minor changes in the
least significant bits of output data. These changes may lead to divergent execution over the
course of simulating thousands of environments and simulation frames.
An illustrative example of this issue is observed with the runtime domain randomization of object's
physics materials. This process can introduce both determinancy and simulation issues when executed
on the GPU due to the way these parameters are passed from the CPU to the GPU in the lower-level APIs.
Consequently, it is strongly advised to perform this operation only at setup time, before the
environment stepping commences.
For more information, please refer to the `PhysX Determinism documentation`_.
Blank initial frames from the camera
------------------------------------
When using the :class:`omni.isaac.orbit.sensors.Camera` sensor in standalone scripts, the first few frames
may be blank. This is a known issue with the simulator where it needs a few steps to load the material
textures properly and fill up the render targets.
A hack to work around this is to add the following after initializing the camera sensor and setting
its pose:
.. code-block:: python
from omni.isaac.orbit.sim import SimulationContext
sim = SimulationContext.instance()
# note: the number of steps might vary depending on how complicated the scene is.
for _ in range(12):
sim.render()
Using instanceable assets for markers
-------------------------------------
When using `instanceable assets`_ for markers, the markers do not work properly, since Omniverse does not support
instanceable assets when using the :class:`UsdGeom.PointInstancer` schema. This is a known issue and will hopefully
be fixed in a future release.
If you use an instanceable assets for markers, the marker class removes all the physics properties of the asset.
This is then replicated across other references of the same asset since physics properties of instanceable assets
are stored in the instanceable asset's USD file and not in its stage reference's USD file.
.. _instanceable assets: https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/tutorial_gym_instanceable_assets.html
.. _Omniverse Isaac Sim documentation: https://docs.omniverse.nvidia.com/isaacsim/latest/known_issues.html
.. _PhysX Determinism documentation: https://nvidia-omniverse.github.io/PhysX/physx/5.3.1/docs/BestPractices.html#determinism
| 4,937 | reStructuredText | 52.096774 | 125 | 0.774154 |
NVIDIA-Omniverse/orbit/docs/source/refs/troubleshooting.rst | Tricks and Troubleshooting
==========================
.. note::
The following lists some of the common tricks and troubleshooting methods that we use in our common workflows.
Please also check the `troubleshooting page on Omniverse
<https://docs.omniverse.nvidia.com/kit/docs/kit-manual/latest/guide/linux_troubleshooting.html>`__ for more
assistance.
Checking the internal logs from the simulator
---------------------------------------------
When running the simulator from a standalone script, it logs warnings and errors to the terminal. At the same time,
it also logs internal messages to a file. These are useful for debugging and understanding the internal state of the
simulator. Depending on your system, the log file can be found in the locations listed
`here <https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_faq.html#common-path-locations>`_.
To obtain the exact location of the log file, you need to check the first few lines of the terminal output when
you run the standalone script. The log file location is printed at the start of the terminal output. For example:
.. code:: bash
[INFO] Using python from: /home/${USER}/git/orbit/_isaac_sim/python.sh
...
Passing the following args to the base kit application: []
Loading user config located at: '.../data/Kit/Isaac-Sim/2023.1/user.config.json'
[Info] [carb] Logging to file: '.../logs/Kit/Isaac-Sim/2023.1/kit_20240328_183346.log'
In the above example, the log file is located at ``.../logs/Kit/Isaac-Sim/2023.1/kit_20240328_183346.log``,
``...`` is the path to the user's log directory. The log file is named ``kit_20240328_183346.log``
You can open this file to check the internal logs from the simulator. Also when reporting issues, please include
this log file to help us debug the issue.
Using CPU Scaling Governor for performance
------------------------------------------
By default on many systems, the CPU frequency governor is set to
“powersave” mode, which sets the CPU to lowest static frequency. To
increase the maximum performance, we recommend setting the CPU frequency
governor to “performance” mode. For more details, please check the the
link
`here <https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/power_management_guide/cpufreq_governors>`__.
.. warning::
We advice not to set the governor to “performance” mode on a system with poor
cooling (such as laptops), since it may cause the system to overheat.
- To view existing ``scaling_governor`` value per CPU:
.. code:: bash
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
- To change the governor to “performance” mode for each CPU:
.. code:: bash
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
Observing long load times at the start of the simulation
--------------------------------------------------------
The first time you run the simulator, it will take a long time to load up. This is because the
simulator is compiling shaders and loading assets. Subsequent runs should be faster to start up,
but may still take some time.
Please note that once the Isaac Sim app loads, the environment creation time may scale linearly with
the number of environments. Please expect a longer load time if running with thousands of
environments or if each environment contains a larger number of assets. We are continually working
on improving the time needed for this.
When an instance of Isaac Sim is already running, launching another Isaac Sim instance in a different
process may appear to hang at startup for the first time. Please be patient and give it some time as
the second process will take longer to start up due to slower shader compilation.
Receiving a “PhysX error” when running simulation on GPU
--------------------------------------------------------
When using the GPU pipeline, the buffers used for the physics simulation are allocated on the GPU only
once at the start of the simulation. This means that they do not grow dynamically as the number of
collisions or objects in the scene changes. If the number of collisions or objects in the scene
exceeds the size of the buffers, the simulation will fail with an error such as the following:
.. code:: bash
PhysX error: the application need to increase the PxgDynamicsMemoryConfig::foundLostPairsCapacity
parameter to 3072, otherwise the simulation will miss interactions
In this case, you need to increase the size of the buffers passed to the
:class:`~omni.isaac.orbit.sim.SimulationContext` class. The size of the buffers can be increased by setting
the :attr:`~omni.isaac.orbit.sim.PhysxCfg.gpu_found_lost_pairs_capacity` parameter in the
:class:`~omni.isaac.orbit.sim.PhysxCfg` class. For example, to increase the size of the buffers to
4096, you can use the following code:
.. code:: python
import omni.isaac.orbit.sim as sim_utils
sim_cfg = sim_utils.SimulationConfig()
sim_cfg.physx.gpu_found_lost_pairs_capacity = 4096
sim = SimulationContext(sim_params=sim_cfg)
Please see the documentation for :class:`~omni.isaac.orbit.sim.SimulationCfg` for more details
on the parameters that can be used to configure the simulation.
Preventing memory leaks in the simulator
----------------------------------------
Memory leaks in the Isaac Sim simulator can occur when C++ callbacks are registered with Python objects.
This happens when callback functions within classes maintain references to the Python objects they are
associated with. As a result, Python's garbage collection is unable to reclaim memory associated with
these objects, preventing the corresponding C++ objects from being destroyed. Over time, this can lead
to memory leaks and increased resource usage.
To prevent memory leaks in the Isaac Sim simulator, it is essential to use weak references when registering
callbacks with the simulator. This ensures that Python objects can be garbage collected when they are no
longer needed, thereby avoiding memory leaks. The `weakref <https://docs.python.org/3/library/weakref.html>`_
module from the Python standard library can be employed for this purpose.
For example, consider a class with a callback function ``on_event_callback`` that needs to be registered
with the simulator. If you use a strong reference to the ``MyClass`` object when passing the callback,
the reference count of the ``MyClass`` object will be incremented. This prevents the ``MyClass`` object
from being garbage collected when it is no longer needed, i.e., the ``__del__`` destructor will not be
called.
.. code:: python
import omni.kit
class MyClass:
def __init__(self):
app_interface = omni.kit.app.get_app_interface()
self._handle = app_interface.get_post_update_event_stream().create_subscription_to_pop(
self.on_event_callback
)
def __del__(self):
self._handle.unsubscribe()
self._handle = None
def on_event_callback(self, event):
# do something with the message
To fix this issue, it's crucial to employ weak references when registering the callback. While this approach
adds some verbosity to the code, it ensures that the ``MyClass`` object can be garbage collected when no longer
in use. Here's the modified code:
.. code:: python
import omni.kit
import weakref
class MyClass:
def __init__(self):
app_interface = omni.kit.app.get_app_interface()
self._handle = app_interface.get_post_update_event_stream().create_subscription_to_pop(
lambda event, obj=weakref.proxy(self): obj.on_event_callback(event)
)
def __del__(self):
self._handle.unsubscribe()
self._handle = None
def on_event_callback(self, event):
# do something with the message
In this revised code, the weak reference ``weakref.proxy(self)`` is used when registering the callback,
allowing the ``MyClass`` object to be properly garbage collected.
By following this pattern, you can prevent memory leaks and maintain a more efficient and stable simulation.
Understanding the error logs from crashes
-----------------------------------------
Many times the simulator crashes due to a bug in the implementation.
This swamps the terminal with exceptions, some of which are coming from
the python interpreter calling ``__del__()`` destructor of the
simulation application. These typically look like the following:
.. code:: bash
...
[INFO]: Completed setting up the environment...
Traceback (most recent call last):
File "source/standalone/workflows/robomimic/collect_demonstrations.py", line 166, in <module>
main()
File "source/standalone/workflows/robomimic/collect_demonstrations.py", line 126, in main
actions = pre_process_actions(delta_pose, gripper_command)
File "source/standalone/workflows/robomimic/collect_demonstrations.py", line 57, in pre_process_actions
return torch.concat([delta_pose, gripper_vel], dim=1)
TypeError: expected Tensor as element 1 in argument 0, but got int
Exception ignored in: <function _make_registry.<locals>._Registry.__del__ at 0x7f94ac097f80>
Traceback (most recent call last):
File "../orbit/_isaac_sim/kit/extscore/omni.kit.viewport.registry/omni/kit/viewport/registry/registry.py", line 103, in __del__
File "../orbit/_isaac_sim/kit/extscore/omni.kit.viewport.registry/omni/kit/viewport/registry/registry.py", line 98, in destroy
TypeError: 'NoneType' object is not callable
Exception ignored in: <function _make_registry.<locals>._Registry.__del__ at 0x7f94ac097f80>
Traceback (most recent call last):
File "../orbit/_isaac_sim/kit/extscore/omni.kit.viewport.registry/omni/kit/viewport/registry/registry.py", line 103, in __del__
File "../orbit/_isaac_sim/kit/extscore/omni.kit.viewport.registry/omni/kit/viewport/registry/registry.py", line 98, in destroy
TypeError: 'NoneType' object is not callable
Exception ignored in: <function SettingChangeSubscription.__del__ at 0x7fa2ea173e60>
Traceback (most recent call last):
File "../orbit/_isaac_sim/kit/kernel/py/omni/kit/app/_impl/__init__.py", line 114, in __del__
AttributeError: 'NoneType' object has no attribute 'get_settings'
Exception ignored in: <function RegisteredActions.__del__ at 0x7f935f5cae60>
Traceback (most recent call last):
File "../orbit/_isaac_sim/extscache/omni.kit.viewport.menubar.lighting-104.0.7/omni/kit/viewport/menubar/lighting/actions.py", line 345, in __del__
File "../orbit/_isaac_sim/extscache/omni.kit.viewport.menubar.lighting-104.0.7/omni/kit/viewport/menubar/lighting/actions.py", line 350, in destroy
TypeError: 'NoneType' object is not callable
2022-12-02 15:41:54 [18,514ms] [Warning] [carb.audio.context] 1 contexts were leaked
../orbit/_isaac_sim/python.sh: line 41: 414372 Segmentation fault (core dumped) $python_exe "$@" $args
There was an error running python
This is a known error with running standalone scripts with the Isaac Sim
simulator. Please scroll above the exceptions thrown with
``registry`` to see the actual error log.
In the above case, the actual error is:
.. code:: bash
Traceback (most recent call last):
File "source/standalone/workflows/robomimic/tools/collect_demonstrations.py", line 166, in <module>
main()
File "source/standalone/workflows/robomimic/tools/collect_demonstrations.py", line 126, in main
actions = pre_process_actions(delta_pose, gripper_command)
File "source/standalone/workflows/robomimic/tools/collect_demonstrations.py", line 57, in pre_process_actions
return torch.concat([delta_pose, gripper_vel], dim=1)
TypeError: expected Tensor as element 1 in argument 0, but got int
| 11,894 | reStructuredText | 47.55102 | 151 | 0.724567 |
NVIDIA-Omniverse/orbit/docs/source/refs/license.rst | .. _license:
License
========
NVIDIA Isaac Sim is available freely under `individual license
<https://www.nvidia.com/en-us/omniverse/download/>`_. For more information
about its license terms, please check `here <https://docs.omniverse.nvidia.com/app_isaacsim/common/NVIDIA_Omniverse_License_Agreement.html#software-support-supplement>`_.
The license files for all its dependencies and included assets are available in its
`documentation <https://docs.omniverse.nvidia.com/app_isaacsim/common/licenses.html>`_.
Orbit framework is open-sourced under the
`BSD-3-Clause license <https://opensource.org/licenses/BSD-3-Clause>`_.
.. code-block:: text
Copyright (c) 2022-2024, The ORBIT Project Developers.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
| 2,281 | reStructuredText | 46.541666 | 170 | 0.772907 |
NVIDIA-Omniverse/orbit/docs/source/refs/contributing.rst | Contribution Guidelines
=======================
We wholeheartedly welcome contributions to the project to make the framework more mature
and useful for everyone. These may happen in forms of:
* Bug reports: Please report any bugs you find in the `issue tracker <https://github.com/NVIDIA-Omniverse/orbit/issues>`__.
* Feature requests: Please suggest new features you would like to see in the `discussions <https://github.com/NVIDIA-Omniverse/Orbit/discussions>`__.
* Code contributions: Please submit a `pull request <https://github.com/NVIDIA-Omniverse/orbit/pulls>`__.
* Bug fixes
* New features
* Documentation improvements
* Tutorials and tutorial improvements
.. attention::
We prefer GitHub `discussions <https://github.com/NVIDIA-Omniverse/Orbit/discussions>`_ for discussing ideas,
asking questions, conversations and requests for new features.
Please use the
`issue tracker <https://github.com/NVIDIA-Omniverse/orbit/issues>`_ only to track executable pieces of work
with a definite scope and a clear deliverable. These can be fixing bugs, new features, or general updates.
Contributing Code
-----------------
We use `GitHub <https://github.com/NVIDIA-Omniverse/orbit>`__ for code hosting. Please
follow the following steps to contribute code:
1. Create an issue in the `issue tracker <https://github.com/NVIDIA-Omniverse/orbit/issues>`__ to discuss
the changes or additions you would like to make. This helps us to avoid duplicate work and to make
sure that the changes are aligned with the roadmap of the project.
2. Fork the repository.
3. Create a new branch for your changes.
4. Make your changes and commit them.
5. Push your changes to your fork.
6. Submit a pull request to the `main branch <https://github.com/NVIDIA-Omniverse/orbit/compare>`__.
7. Ensure all the checks on the pull request template are performed.
After sending a pull request, the maintainers will review your code and provide feedback.
Please ensure that your code is well-formatted, documented and passes all the tests.
.. tip::
It is important to keep the pull request as small as possible. This makes it easier for the
maintainers to review your code. If you are making multiple changes, please send multiple pull requests.
Large pull requests are difficult to review and may take a long time to merge.
Coding Style
------------
We follow the `Google Style
Guides <https://google.github.io/styleguide/pyguide.html>`__ for the
codebase. For Python code, the PEP guidelines are followed. Most
important ones are `PEP-8 <https://www.python.org/dev/peps/pep-0008/>`__
for code comments and layout,
`PEP-484 <http://www.python.org/dev/peps/pep-0484>`__ and
`PEP-585 <https://www.python.org/dev/peps/pep-0585/>`__ for
type-hinting.
For documentation, we adopt the `Google Style Guide <https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html>`__
for docstrings. We use `Sphinx <https://www.sphinx-doc.org/en/master/>`__ for generating the documentation.
Please make sure that your code is well-documented and follows the guidelines.
Circular Imports
^^^^^^^^^^^^^^^^
Circular imports happen when two modules import each other, which is a common issue in Python.
You can prevent circular imports by adhering to the best practices outlined in this
`StackOverflow post <https://stackoverflow.com/questions/744373/circular-or-cyclic-imports-in-python>`__.
In general, it is essential to avoid circular imports as they can lead to unpredictable behavior.
However, in our codebase, we encounter circular imports at a sub-package level. This situation arises
due to our specific code structure. We organize classes or functions and their corresponding configuration
objects into separate files. This separation enhances code readability and maintainability. Nevertheless,
it can result in circular imports because, in many configuration objects, we specify classes or functions
as default values using the attributes ``class_type`` and ``func`` respectively.
To address circular imports, we leverage the `typing.TYPE_CHECKING
<https://docs.python.org/3/library/typing.html#typing.TYPE_CHECKING>`_ variable. This special variable is
evaluated only during type-checking, allowing us to import classes or functions in the configuration objects
without triggering circular imports.
It is important to note that this is the sole instance within our codebase where circular imports are used
and are acceptable. In all other scenarios, we adhere to best practices and recommend that you do the same.
Type-hinting
^^^^^^^^^^^^
To make the code more readable, we use `type hints <https://docs.python.org/3/library/typing.html>`__ for
all the functions and classes. This helps in understanding the code and makes it easier to maintain. Following
this practice also helps in catching bugs early with static type checkers like `mypy <https://mypy.readthedocs.io/en/stable/>`__.
To avoid duplication of efforts, we do not specify type hints for the arguments and return values in the docstrings.
However, if your function or class is not self-explanatory, please add a docstring with the type hints.
Tools
^^^^^
We use the following tools for maintaining code quality:
* `pre-commit <https://pre-commit.com/>`__: Runs a list of formatters and linters over the codebase.
* `black <https://black.readthedocs.io/en/stable/>`__: The uncompromising code formatter.
* `flake8 <https://flake8.pycqa.org/en/latest/>`__: A wrapper around PyFlakes, pycodestyle and
McCabe complexity checker.
Please check `here <https://pre-commit.com/#install>`__ for instructions
to set these up. To run over the entire repository, please execute the
following command in the terminal:
.. code:: bash
./orbit.sh --format # or "./orbit.sh -f"
Contributing Documentation
--------------------------
Contributing to the documentation is as easy as contributing to the codebase. All the source files
for the documentation are located in the ``orbit/docs`` directory. The documentation is written in
`reStructuredText <https://docutils.sourceforge.io/rst.html>`__ format.
We use `Sphinx <https://www.sphinx-doc.org/en/master/>`__ with the
`Book Theme <https://sphinx-book-theme.readthedocs.io/en/stable/>`__
for maintaining the documentation.
Sending a pull request for the documentation is the same as sending a pull request for the codebase.
Please follow the steps mentioned in the `Contributing Code`_ section.
.. caution::
To build the documentation, we recommend creating a `virtual environment <https://docs.python.org/3/library/venv.html>`__
to install the dependencies. This can also be a `conda environment <https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html>`__.
To build the documentation, run the following command in the terminal which installs the required python packages and
builds the documentation using the ``docs/Makefile``:
.. code:: bash
./orbit.sh --docs # or "./orbit.sh -d"
The documentation is generated in the ``docs/_build`` directory. To view the documentation, open
the ``index.html`` file in the ``html`` directory. This can be done by running the following command
in the terminal:
.. code:: bash
xdg-open docs/_build/html/index.html
.. hint::
The ``xdg-open`` command is used to open the ``index.html`` file in the default browser. If you are
using a different operating system, you can use the appropriate command to open the file in the browser.
To do a clean build, run the following command in the terminal:
.. code:: bash
rm -rf docs/_build && ./orbit.sh --docs
Contributing assets
-------------------
Currently, we host the assets for the extensions on `NVIDIA Nucleus Server <https://docs.omniverse.nvidia.com/nucleus/latest/index.html>`__.
Nucleus is a cloud-based storage service that allows users to store and share large files. It is
integrated with the `NVIDIA Omniverse Platform <https://developer.nvidia.com/omniverse>`__.
Since all assets are hosted on Nucleus, we do not need to include them in the repository. However,
we need to include the links to the assets in the documentation.
The included assets are part of the `Isaac Sim Content <https://docs.omniverse.nvidia.com/isaacsim/latest/features/environment_setup/assets/usd_assets_overview.html>`__.
To use this content, you need to download the files to a Nucleus server or create an **Isaac** Mount on
a Nucleus server.
Please check the `Isaac Sim documentation <https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/install_faq.html#assets-and-nucleus>`__
for more information on how to download the assets.
.. attention::
We are currently working on a better way to contribute assets. We will update this section once we
have a solution. In the meantime, please follow the steps mentioned below.
To host your own assets, the current solution is:
1. Create a separate repository for the assets and add it over there
2. Make sure the assets are licensed for use and distribution
3. Include images of the assets in the README file of the repository
4. Send a pull request with a link to the repository
We will then verify the assets, its licensing, and include the assets into the Nucleus server for hosting.
In case you have any questions, please feel free to reach out to us through e-mail or by opening an issue
in the repository.
Maintaining a changelog
-----------------------
Each extension maintains a changelog in the ``CHANGELOG.rst`` file in the ``docs`` directory. The
file is written in `reStructuredText <https://docutils.sourceforge.io/rst.html>`__ format. It
contains a curated, chronologically ordered list of notable changes for each version of the extension.
The goal of this changelog is to help users and contributors see precisely what notable changes have
been made between each release (or version) of the extension. This is a *MUST* for every extension.
For updating the changelog, please follow the following guidelines:
* Each version should have a section with the version number and the release date.
* The version number is updated according to `Semantic Versioning <https://semver.org/>`__. The
release date is the date on which the version is released.
* Each version is divided into subsections based on the type of changes made.
* ``Added``: For new features.
* ``Changed``: For changes in existing functionality.
* ``Deprecated``: For soon-to-be removed features.
* ``Removed``: For now removed features.
* ``Fixed``: For any bug fixes.
* Each change is described in its corresponding sub-section with a bullet point.
* The bullet points are written in the past tense and in imperative mode.
For example, the following is a sample changelog:
.. code:: rst
Changelog
---------
0.1.0 (2021-02-01)
~~~~~~~~~~~~~~~~~~
Added
^^^^^
* Added a new feature.
Changed
^^^^^^^
* Changed an existing feature.
Deprecated
^^^^^^^^^^
* Deprecated an existing feature.
Removed
^^^^^^^
* Removed an existing feature.
Fixed
^^^^^
* Fixed a bug.
0.0.1 (2021-01-01)
~~~~~~~~~~~~~~~~~~
Added
^^^^^
* Added a new feature.
| 11,201 | reStructuredText | 40.335793 | 169 | 0.744933 |
NVIDIA-Omniverse/PhysX/README.md | # NVIDIA PhysX
Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of NVIDIA CORPORATION nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## Introduction
Welcome to the NVIDIA PhysX source code repository.
This repository contains source releases of the PhysX, Flow, and Blast SDKs used in NVIDIA Omniverse.
## Documentation
The user guide and API documentation are available on [GitHub Pages](https://nvidia-omniverse.github.io/PhysX). Please create an [Issue](https://github.com/NVIDIA-Omniverse/PhysX/issues/) if you find a documentation issue.
## Instructions
Please see instructions specific to each of the libraries in the respective subfolder.
## Community-Maintained Build Configuration Fork
Please see [the O3DE Fork](https://github.com/o3de/PhysX) for community-maintained additional build configurations.
## Support
* Please use GitHub [Discussions](https://github.com/NVIDIA-Omniverse/PhysX/discussions/) for questions and comments.
* GitHub [Issues](https://github.com/NVIDIA-Omniverse/PhysX/issues) should only be used for bug reports or documentation issues.
* You can also ask questions in the NVIDIA Omniverse #physics [Discord Channel](https://discord.com/invite/XWQNJDNuaC).
| 2,570 | Markdown | 48.442307 | 222 | 0.800389 |
NVIDIA-Omniverse/PhysX/LICENSE.md | BSD 3-Clause License
Copyright (c) 2023, NVIDIA Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of NVIDIA CORPORATION nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
| 1,512 | Markdown | 46.281249 | 71 | 0.803571 |
NVIDIA-Omniverse/PhysX/physx/README.md | # NVIDIA PhysX SDK 5
Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of NVIDIA CORPORATION nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## Introduction
Welcome to the NVIDIA PhysX SDK source code repository.
The NVIDIA PhysX SDK is a scalable multi-platform physics solution. PhysX is integrated into [NVIDIA Omniverse](https://developer.nvidia.com/omniverse). See also [PhysX SDK on developer.nvidia.com](https://developer.nvidia.com/physx-sdk).
Please see [Release Notes](./CHANGELOG.md) for updates pertaining to the latest version.
## CPU Source and GPU Binaries
The source made available in this repository is restricted to CPU code. GPU acceleration is made available through precompiled binaries.
## User Guide and API Documentation
The user guide and API documentation are available on [GitHub Pages](https://nvidia-omniverse.github.io/PhysX/physx/index.html). Please create an [Issue](https://github.com/NVIDIA-Omniverse/PhysX/issues/) if you find a documentation issue.
## Quick Start Instructions
Platform specific environment and build information can be found in [documentation/platformreadme](./documentation/platformreadme).
To begin, clone this repository onto your local drive. Then change directory to physx/, run ./generate_projects.[bat|sh] and follow on-screen prompts. This will let you select a platform specific solution to build. You can then build from the generated solution/make file in the platform- and configuration-specific folders in the ``compiler`` folder.
## Acknowledgements
This depot references packages of third party open source software copyright their respective owners.
For copyright details, please refer to the license files included in the packages.
| Software | Copyright Holder | Package |
|---------------------------|-------------------------------------------------------------------------------------|----------------------------------|
| CMake | Kitware, Inc. and Contributors | cmake |
| LLVM | University of Illinois at Urbana-Champaign | clang-physxmetadata |
| Visual Studio Locator | Microsoft Corporation | VsWhere |
| Freeglut | Pawel W. Olszta | freeglut-windows<br>opengl-linux |
| Mesa 3-D graphics library | Brian Paul | opengl-linux |
| RapidJSON | THL A29 Limited, a Tencent company, and Milo Yip<br>Alexander Chemeris (msinttypes) | rapidjson |
| OpenGL Ext Wrangler Lib | Nigel Stewart, Milan Ikits, Marcelo E. Magallon, Lev Povalahev | [SDK_ROOT]/snippets/graphics |
| 4,444 | Markdown | 66.348484 | 354 | 0.655491 |
NVIDIA-Omniverse/PhysX/physx/documentation/platformreadme/windows/README_WINDOWS.md | # NVIDIA PhysX SDK for Windows
## Location of Binaries:
* SDK DLLs/LIBs: bin/
* PhysX Device DLLs: bin/
## Required packages to generate projects:
* Windows OS + headers for at least Win7 (`_WIN32_WINNT = 0x0601`)
* CMake, minimum version 3.21
* Python, minimum version 3.5
## PhysX GPU Acceleration:
* Requires CUDA 11.8 compatible display driver. The corresponding driver version can be found [here](https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#cuda-major-component-versions__table-cuda-toolkit-driver-versions).
## Generating solutions for Visual Studio:
* Solutions are generated through a script in the physx root directory: generate_projects.bat
* The generate_projects.bat script expects a preset name as a parameter; if a parameter is not provided, it lists the available presets.
* The generated solutions are in the folder compiler/"preset name".
## Notes:
* The PhysXDevice/64.dll must be redistributed with GPU-enabled applications, and must live in the same directory as PhysXGpu.dll.
* The nvcuda.dll and PhysXUpdateLoader/64.dll are loaded and checked for the NVIDIA Corporation digital signature. The signature is expected on all NVIDIA Corporation provided dlls. The application will exit if the signature check failed.
| 1,269 | Markdown | 44.357141 | 238 | 0.78093 |
NVIDIA-Omniverse/PhysX/physx/documentation/platformreadme/linux/README_LINUX.md | # NVIDIA PhysX SDK for Linux
## Location of Binaries:
* SDK libraries: bin/linux.clang
## Required packages to generate projects:
* CMake, minimum version 3.14
* Python, minimum version 3.5
* curl
Compilers:
* For linux x86-64 builds we support Ubuntu LTS releases with their respective default compiler versions:
* Ubuntu 20.04 LTS with gcc 9 or clang 10
* Ubuntu 22.04 LTS with gcc 11 or clang 14
* For linux aarch64 builds we support gcc version 9
## Generating Makefiles:
* Makefiles are generated through a script in the physx root directory: generate_projects.sh
* The script generate_projects.sh expects a preset name as a parameter, if a parameter is not provided it does list the available presets and you can select one.
* Generated solutions are placed in the folders compiler/linux-debug, compiler/linux-checked, compiler/linux-profile, compiler/linux-release.
## Building SDK:
* Makefiles are in compiler/linux-debug etc
* Clean solution: make clean
* Build solution: make
* Install solution: make install
Note:
Compile errors on unsupported compilers or platforms are frequently caused by additional warnings that are treated as errors by default.
While we cannot offer support in this case we recommend removing all occurences of the `-Werror` flag in the file `physx/source/compiler/cmake/linux/CMakeLists.txt`.
## PhysX GPU Acceleration:
* Running GPU-accelerated simulations requires a CUDA 11.8 compatible display driver. The corresponding driver version can be found [here](https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#cuda-major-component-versions__table-cuda-toolkit-driver-versions).
* Note that CUDA is not required for building PhysX, it is only a runtime requirement for GPU-accelerated scenes.
## Required Packages for Building and Running PhysX Snippets:
* freeglut3
* libglu1
* libxdamage-dev
* libxmu6
## How to select the PhysX GPU Device:
* Set the environment variable PHYSX_GPU_DEVICE to the device ordinal on which GPU PhysX should run. Default is 0.
* Example: export PHYSX_GPU_DEVICE="1"
| 2,079 | Markdown | 36.142856 | 273 | 0.778259 |
NVIDIA-Omniverse/PhysX/physx/tools/physxmetadatagenerator/generateMetaData.py | ## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
import argparse
import os
import stat
import sys
import re
import platform
import shutil
from lib import utils
from lib import compare
# test mode: create copy of reference files
# update mode: try to open file in p4 if necessary
def setup_targetdir(metaDataDir, isTestMode):
if isTestMode:
targetDir = metaDataDir + "_test"
if os.path.isdir(targetDir):
print("deleting", targetDir)
shutil.rmtree(targetDir)
def ignore_non_autogen(dir, files):
return [f for f in files if not (os.path.isdir(os.path.join(dir, f))
or re.search(r"AutoGenerated", f))]
shutil.copytree(metaDataDir, targetDir, ignore=ignore_non_autogen)
#set write to new files:
for root, dirs, files in os.walk(targetDir):
for file in files:
os.chmod(os.path.join(root, file) , stat.S_IWRITE|stat.S_IREAD)
else:
targetDir = metaDataDir
if not utils.check_files_writable(utils.list_autogen_files(targetDir)):
utils.try_checkout_files(utils.list_autogen_files(targetDir))
if not utils.check_files_writable(utils.list_autogen_files(targetDir)):
print("auto generated meta data files not writable:", targetDir)
print("aborting")
sys.exit(1)
utils.clear_files(utils.list_autogen_files(targetDir))
return targetDir
# test mode: run perl script to compare reference and generated files
def test_targetdir(targetDir, metaDataDir, isTestMode):
if isTestMode:
print("compare generated meta data files with reference meta data files:")
result = compare.compareMetaDataDirectories(targetDir, metaDataDir)
if not result:
print("failed!")
sys.exit(1)
else:
print("passed.")
def get_osx_platform_path():
cmd = "xcodebuild -showsdks"
(stdout, stderr) = utils.run_cmd(cmd)
if stderr != "":
print(stderr)
sys.exit(1)
match = re.search(r"(-sdk macosx\d+.\d+)", stdout, flags=re.MULTILINE)
if not match:
print("coundn't parse output of:\n", cmd, "\naborting!")
sys.exit(1)
sdkparam = match.group(0)
cmd = "xcodebuild -version " + sdkparam + " Path"
(sdkPath, stderr) = utils.run_cmd(cmd)
if stderr != "":
print(stderr)
sys.exit(1)
print("using sdk path:", sdkPath.rstrip())
return sdkPath.rstrip()
def includeString(path):
return ' -I"' + path + '"'
###########################################################################################################
# main
###########################################################################################################
parser = argparse.ArgumentParser(description='Generates meta data source files.')
parser.add_argument('-test', help='enables testing mode, internal only', action='store_true')
args = parser.parse_args()
scriptDir = os.path.dirname(os.path.realpath(__file__))
try:
os.makedirs("temp")
except:
None
# find SDK_ROOT and PX_SHARED
sdkRoot = utils.find_root_path(scriptDir, "source")
clangRoot = os.path.normpath(os.environ['PM_clangMetadata_PATH'])
print("testmode:", args.test)
print("root sdk:", sdkRoot)
print("root clang:", clangRoot)
boilerPlateFile = os.path.join(sdkRoot, os.path.normpath("tools/physxmetadatagenerator/PxBoilerPlate.h"))
includes = ''
includes += includeString(sdkRoot + '/include')
includes += includeString(sdkRoot + '/tools/physxmetadatagenerator')
print("platform:", platform.system())
commonFlags = '-DNDEBUG -DPX_GENERATE_META_DATA -DPX_ENABLE_FEATURES_UNDER_CONSTRUCTION=0 -x c++-header -w -Wno-c++11-narrowing -fms-extensions '
if platform.system() == "Windows":
debugFile = open("temp/clangCommandLine_windows.txt", "a")
# read INCLUDE variable, set by calling batch script
sysIncludes = os.environ['INCLUDE']
sysIncludes = sysIncludes.rstrip(';')
sysIncludeList = sysIncludes.split(';')
sysIncludeFlags = ' -isystem"' + '" -isystem"'.join(sysIncludeList) + '"'
# for some reason -cc1 needs to go first in commonFlags
commonFlags = '-cc1 ' + commonFlags
platformFlags = '-DPX_VC=14 -D_WIN32 -std=c++14' + sysIncludeFlags
clangExe = os.path.join(clangRoot, os.path.normpath('win32/bin/clang.exe'))
elif platform.system() == "Linux":
debugFile = open("temp/clangCommandLine_linux.txt", "a")
platformFlags = '-std=c++0x'
clangExe = os.path.join(clangRoot, os.path.normpath('linux32/bin/clang'))
elif platform.system() == "Darwin":
debugFile = open("temp/clangCommandLine_osx.txt", "a")
platformFlags = '-std=c++0x -isysroot' + get_osx_platform_path()
clangExe = os.path.join(clangRoot, os.path.normpath('osx/bin/clang'))
else:
print("unsupported platform, aborting!")
sys.exit(1)
commonFlags += ' -boilerplate-file ' + boilerPlateFile
#some checks
if not os.path.isfile(clangExe):
print("didn't find,", clangExe, ", aborting!")
sys.exit(1)
clangExe = '"' + clangExe + '"'
# required for execution of clang.exe
os.environ["PWD"] = os.path.join(sdkRoot, os.path.normpath("tools/physxmetadatagenerator"))
###############################
# PxPhysicsWithExtensions #
###############################
print("PxPhysicsWithExtensions:")
srcPath = "PxPhysicsWithExtensionsAPI.h"
metaDataDir = os.path.join(sdkRoot, os.path.normpath("source/physxmetadata"))
targetDir = setup_targetdir(metaDataDir, args.test)
cmd = " ".join(["", clangExe, commonFlags, "", platformFlags, includes, srcPath, "-o", '"'+targetDir+'"'])
print(cmd, file=debugFile)
(stdout, stderr) = utils.run_cmd(cmd)
if (stderr != "" or stdout != ""):
print(stderr, "\n", stdout)
print("wrote meta data files in", targetDir)
test_targetdir(targetDir, metaDataDir, args.test)
###############################
# PxVehicleExtension #
###############################
print("PxVehicleExtension:")
srcPath = "PxVehicleExtensionAPI.h"
metaDataDir = os.path.join(sdkRoot, os.path.normpath("source/physxvehicle/src/physxmetadata"))
includes += includeString(sdkRoot + '/include/vehicle')
#TODO, get rid of source include
includes += includeString(sdkRoot + '/source/physxvehicle/src')
targetDir = setup_targetdir(metaDataDir, args.test)
cmd = " ".join(["", clangExe, commonFlags, "", platformFlags, includes, srcPath, "-o", '"'+targetDir+'"'])
print(cmd, file=debugFile)
(stdout, stderr) = utils.run_cmd(cmd)
if (stderr != "" or stdout != ""):
print(stderr, "\n", stdout)
print("wrote meta data files in", targetDir)
test_targetdir(targetDir, metaDataDir, args.test)
| 7,833 | Python | 33.511013 | 145 | 0.691944 |
NVIDIA-Omniverse/PhysX/physx/tools/physxmetadatagenerator/PxPhysicsWithExtensionsAPI.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PHYSICS_NXPHYSICSWITHEXTENSIONS_API
#define PX_PHYSICS_NXPHYSICSWITHEXTENSIONS_API
#include "PxExtensionsCommon.h"
//Property overrides will output this exact property name instead of the general
//property name that would be used. The properties need to have no template arguments
//and exactly the same initialization as the classes they are overriding.
static PropertyOverride gPropertyOverrides[] = {
PropertyOverride( "PxShape", "Materials", "PxShapeMaterialsProperty" ),
PropertyOverride( "PxRigidActor", "Shapes", "PxRigidActorShapeCollection" ),
PropertyOverride( "PxArticulationReducedCoordinate", "Links", "PxArticulationLinkCollectionProp" ),
};
//The meta data generator ignores properties that are marked as disabled. Note that in the declaration
//for properties that are defined via getter and setter methods, the 'get' and 'set' prefix can be dropped.
//For protected fields the "m" prefix can be dropped, however for public fields the whole field qualifier is expected.
static DisabledPropertyEntry gDisabledProperties[] = {
DisabledPropertyEntry( "PxSceneLimits", "IsValid" ),
DisabledPropertyEntry( "PxSceneDesc", "TolerancesScale" ),
DisabledPropertyEntry( "PxSceneDesc", "IsValid" ),
DisabledPropertyEntry( "PxSceneDesc", "SceneQuerySystem" ),
DisabledPropertyEntry( "PxShape", "Actor" ),
DisabledPropertyEntry( "PxShape", "Geometry" ),
DisabledPropertyEntry( "PxArticulationLink", "Articulation" ),
DisabledPropertyEntry("PxArticulationJointReducedCoordinate", "ParentArticulationLink"),
DisabledPropertyEntry("PxArticulationJointReducedCoordinate", "ChildArticulationLink"),
DisabledPropertyEntry("PxArticulationJointReducedCoordinate", "Limit"),
DisabledPropertyEntry( "PxArticulationReducedCoordinate", "LoopJoints"),
DisabledPropertyEntry("PxArticulationReducedCoordinate", "Dofs"),
DisabledPropertyEntry("PxArticulationReducedCoordinate", "CacheDataSize"),
DisabledPropertyEntry("PxArticulationReducedCoordinate", "CoefficientMatrixSize"),
DisabledPropertyEntry( "PxRigidActor", "IsRigidActor" ),
DisabledPropertyEntry( "PxRigidActor", "ClassName" ),
DisabledPropertyEntry( "PxRigidActor", "InternalActorIndex" ),
DisabledPropertyEntry( "PxRigidStatic", "ClassName" ),
DisabledPropertyEntry( "PxRigidDynamic", "ClassName" ),
DisabledPropertyEntry( "PxRigidBody", "IsRigidBody" ),
DisabledPropertyEntry( "PxRigidBody", "InternalIslandNodeIndex"),
DisabledPropertyEntry( "PxRigidBody", "LinearVelocity"),
DisabledPropertyEntry("PxRigidBody", "AngularVelocity"),
DisabledPropertyEntry( "PxActor", "IsRigidStatic" ),
DisabledPropertyEntry( "PxActor", "Type" ),
DisabledPropertyEntry( "PxActor", "ClassName" ),
DisabledPropertyEntry( "PxActor", "IsRigidDynamic" ),
DisabledPropertyEntry( "PxActor", "IsArticulationLink" ),
DisabledPropertyEntry( "PxActor", "IsRigidActor" ),
DisabledPropertyEntry( "PxActor", "IsRigidBody" ),
DisabledPropertyEntry( "PxMeshScale", "Inverse" ),
DisabledPropertyEntry( "PxMeshScale", "IsIdentity" ),
DisabledPropertyEntry( "PxMeshScale", "IsValidForTriangleMesh" ),
DisabledPropertyEntry( "PxMeshScale", "IsValidForConvexMesh" ),
DisabledPropertyEntry( "PxGeometry", "Type" ),
DisabledPropertyEntry( "PxGeometry", "MTypePadding" ),
DisabledPropertyEntry( "PxBoxGeometry", "IsValid" ),
DisabledPropertyEntry( "PxSphereGeometry", "IsValid" ),
DisabledPropertyEntry( "PxPlaneGeometry", "IsValid" ),
DisabledPropertyEntry( "PxCapsuleGeometry", "IsValid" ),
DisabledPropertyEntry( "PxConvexMeshGeometry", "IsValid" ),
DisabledPropertyEntry( "PxTetrahedronMeshGeometry", "IsValid"),
DisabledPropertyEntry( "PxTriangleMeshGeometry", "IsValid" ),
DisabledPropertyEntry( "PxHeightFieldGeometry", "IsValid" ),
DisabledPropertyEntry( "PxCustomGeometry", "IsValid" ),
DisabledPropertyEntry( "PxCustomGeometry", "Callbacks" ),
DisabledPropertyEntry( "PxJoint", "ClassName" ),
DisabledPropertyEntry( "PxDistanceJoint", "ClassName" ),
DisabledPropertyEntry( "PxContactJoint", "ClassName"),
DisabledPropertyEntry( "PxGearJoint", "ClassName"),
DisabledPropertyEntry( "PxRackAndPinionJoint", "ClassName"),
DisabledPropertyEntry( "PxFixedJoint", "ClassName" ),
DisabledPropertyEntry( "PxRevoluteJoint", "ClassName" ),
DisabledPropertyEntry( "PxPrismaticJoint", "ClassName" ),
DisabledPropertyEntry( "PxSphericalJoint", "ClassName" ),
DisabledPropertyEntry( "PxD6Joint", "ClassName" ),
DisabledPropertyEntry( "PxJointLimitParameters", "IsValid" ),
DisabledPropertyEntry( "PxJointLimitParameters", "IsSoft" ),
DisabledPropertyEntry( "PxJointLinearLimit", "IsValid" ),
DisabledPropertyEntry( "PxJointLinearLimitPair", "IsValid" ),
DisabledPropertyEntry( "PxJointAngularLimitPair", "IsValid" ),
DisabledPropertyEntry( "PxJointLimitCone", "IsValid" ),
DisabledPropertyEntry( "PxJointLimitPyramid", "IsValid" ),
DisabledPropertyEntry( "PxD6JointDrive", "IsValid" ),
DisabledPropertyEntry( "PxPhysics", "FLIPMaterials" ),
DisabledPropertyEntry( "PxPhysics", "MPMMaterials" ),
DisabledPropertyEntry( "PxScene", "ParticleSystems"),
DisabledPropertyEntry( "PxScene", "FEMCloths"),
DisabledPropertyEntry( "PxScene", "HairSystems"),
// PT: added this for PVD-315. It's a mystery to me why we don't need to do that here for PxConvexMeshDesc. Maybe because the convex desc is in the cooking lib.
DisabledPropertyEntry( "PxHeightFieldDesc", "IsValid" ),
// DisabledPropertyEntry( "PxConstraint", "IsValid" ),
// DisabledPropertyEntry( "PxTolerancesScale", "IsValid" ),
};
//Append these properties to this type.
static CustomProperty gCustomProperties[] = {
#define DEFINE_SIM_STATS_DUAL_INDEXED_PROPERTY( propName, propType, fieldName ) CustomProperty("PxSimulationStatistics", #propName, #propType, "PxU32 " #propName "[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT];", "PxMemCopy( "#propName ", inSource->"#fieldName", sizeof( "#propName" ) );" )
DEFINE_SIM_STATS_DUAL_INDEXED_PROPERTY( NbDiscreteContactPairs, NbDiscreteContactPairsProperty, nbDiscreteContactPairs ),
DEFINE_SIM_STATS_DUAL_INDEXED_PROPERTY( NbModifiedContactPairs, NbModifiedContactPairsProperty, nbModifiedContactPairs),
DEFINE_SIM_STATS_DUAL_INDEXED_PROPERTY( NbCCDPairs, NbCCDPairsProperty, nbCCDPairs),
DEFINE_SIM_STATS_DUAL_INDEXED_PROPERTY( NbTriggerPairs, NbTriggerPairsProperty, nbTriggerPairs),
#undef DEFINE_SIM_STATS_DUAL_INDEXED_PROPERTY
CustomProperty( "PxSimulationStatistics", "NbShapes", "NbShapesProperty", "PxU32 NbShapes[PxGeometryType::eGEOMETRY_COUNT];", "PxMemCopy( NbShapes, inSource->nbShapes, sizeof( NbShapes ) );" ),
CustomProperty( "PxScene", "SimulationStatistics", "SimulationStatisticsProperty", "PxSimulationStatistics SimulationStatistics;", "inSource->getSimulationStatistics(SimulationStatistics);" ),
CustomProperty( "PxShape", "Geom", "PxShapeGeomProperty", "PxGeometryHolder Geom;", "Geom = PxGeometryHolder(inSource->getGeometry());" ),
CustomProperty( "PxCustomGeometry", "CustomType", "PxCustomGeometryCustomTypeProperty", "PxU32 CustomType;", "PxCustomGeometry::Type t = inSource->callbacks->getCustomType(); CustomType = *reinterpret_cast<const PxU32*>(&t);" ),
};
static const char* gImportantPhysXTypes[] =
{
"PxRigidStatic",
"PxRigidDynamic",
"PxShape",
"PxArticulationReducedCoordinate",
"PxArticulationLink",
"PxMaterial",
"PxFEMSoftBodyMaterial",
"PxPBDMaterial",
"PxFLIPMaterial",
"PxMPMMaterial",
"PxArticulationJointReducedCoordinate",
"PxArticulationLimit",
"PxArticulationDrive",
"PxScene",
"PxPhysics",
"PxHeightFieldDesc",
"PxMeshScale",
"PxConstraint",
"PxTolerancesScale",
"PxSimulationStatistics",
"PxSceneDesc",
"PxSceneLimits",
"PxgDynamicsMemoryConfig",
"PxBroadPhaseDesc",
"PxGeometry",
"PxBoxGeometry",
"PxCapsuleGeometry",
"PxConvexMeshGeometry",
"PxSphereGeometry",
"PxPlaneGeometry",
"PxTetrahedronMeshGeometry",
"PxTriangleMeshGeometry",
"PxHeightFieldGeometry",
"PxCustomGeometry",
"PxAggregate",
"PxPruningStructure",
//The mesh and heightfield buffers will need to be
//handled by hand; they are very unorthodox compared
//to the rest of the objects.
#if PX_SUPPORT_GPU_PHYSX
"PxgDynamicsMemoryConfig",
#endif
};
static const char* gExtensionPhysXTypes[] =
{
"PxD6JointDrive",
"PxJointLinearLimit",
"PxJointLinearLimitPair",
"PxJointAngularLimitPair",
"PxJointLimitCone",
"PxJointLimitPyramid",
"PxD6Joint",
"PxDistanceJoint",
"PxGearJoint",
"PxRackAndPinionJoint",
"PxContactJoint",
"PxFixedJoint",
"PxPrismaticJoint",
"PxRevoluteJoint",
"PxSphericalJoint",
};
//We absolutely never generate information about these types, even if types
//we do care about are derived from these types.
static const char* gAvoidedPhysXTypes[] =
{
"PxSerializable",
"PxObservable",
"PxBase",
"PxBaseFlag::Enum",
"PxFLIPMaterial",
"PxMPMMaterial",
};
#include "PxPhysicsAPI.h"
#include "extensions/PxExtensionsAPI.h"
#endif
| 10,588 | C | 48.023148 | 310 | 0.776445 |
NVIDIA-Omniverse/PhysX/physx/tools/physxmetadatagenerator/PxVehicleExtensionAPI.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PHYSICS_NXPHYSICSWITHVEHICLEEXTENSIONS_API
#define PX_PHYSICS_NXPHYSICSWITHVEHICLEEXTENSIONS_API
#include "PxExtensionsCommon.h"
//The meta data generator ignores properties that are marked as disabled. Note that in the declaration
//for properties that are defined via getter and setter methods, the 'get' and 'set' prefix can be dropped.
//For protected fields the "m" prefix can be dropped, however for public fields the whole field qualifier is expected.
static DisabledPropertyEntry gDisabledProperties[] = {
DisabledPropertyEntry( "PxVehicleWheelsDynData", "MTireForceCalculators" ),
DisabledPropertyEntry( "PxVehicleWheelsDynData", "TireForceShaderData" ),
DisabledPropertyEntry( "PxVehicleWheelsDynData", "UserData" ),
DisabledPropertyEntry( "PxVehicleWheels", "MActor" ),
};
//Append these properties to this type.
static CustomProperty gCustomProperties[] = {
#define DEFINE_VEHICLETIREDATA_INDEXED_PROPERTY( propName, propType, fieldName ) CustomProperty("PxVehicleTireData", #propName, #propType, "PxReal " #propName "[3][2];", "PxMemCopy( "#propName ", inSource->"#fieldName", sizeof( "#propName" ) );" )
DEFINE_VEHICLETIREDATA_INDEXED_PROPERTY( MFrictionVsSlipGraph, MFrictionVsSlipGraphProperty, mFrictionVsSlipGraph),
#undef DEFINE_VEHICLETIREDATA_INDEXED_PROPERTY
CustomProperty( "PxVehicleEngineData", "MTorqueCurve", "MTorqueCurveProperty", "", "" ),
};
static const char* gUserPhysXTypes[] =
{
"PxVehicleWheels",
"PxVehicleWheelsSimData",
"PxVehicleWheelsDynData",
"PxVehicleDrive4W",
"PxVehicleWheels4SimData",
"PxVehicleDriveSimData4W",
"PxVehicleWheelData",
"PxVehicleSuspensionData",
"PxVehicleDriveDynData",
"PxVehicleDifferential4WData",
"PxVehicleDifferentialNWData",
"PxVehicleAckermannGeometryData",
"PxVehicleTireLoadFilterData",
"PxVehicleEngineData",
"PxVehicleGearsData",
"PxVehicleClutchData",
"PxVehicleAutoBoxData",
"PxVehicleTireData",
"PxVehicleChassisData",
"PxTorqueCurvePair",
"PxVehicleDriveTank",
"PxVehicleNoDrive",
"PxVehicleDriveSimDataNW",
"PxVehicleDriveNW",
"PxVehicleAntiRollBarData",
};
//We absolutely never generate information about these types, even if types
//we do care about are derived from these types.
static const char* gAvoidedPhysXTypes[] =
{
"PxSerializable",
"PxObservable",
"PxBase",
"PxBaseFlag::Enum",
};
#include "PxPhysicsAPI.h"
#include "PxVehicleSuspWheelTire4.h"
#endif
| 4,111 | C | 42.74468 | 247 | 0.775724 |
NVIDIA-Omniverse/PhysX/physx/tools/physxmetadatagenerator/lib/utils.py | ## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
# general utility module
import os
import sys
import re
import subprocess
def list_autogen_files(dirPath):
autogenFiles = []
for (root, subdirs, files) in os.walk(dirPath):
files = [f for f in files if re.search(r"AutoGenerated", f)]
autogenFiles.extend([os.path.join(root, f) for f in files])
return autogenFiles
#checkout files with p4 if available
def try_checkout_files(files):
print("checking p4 connection parameter...")
# checking p4
cmd = "p4"
(stdout, stderr) = run_cmd(cmd)
if stderr == "":
print("p4 available.")
else:
print("p4 unavailable.")
return
cmd = "p4 edit " + " " + " ".join(files)
(stdout, stderr) = run_cmd(cmd)
print(stderr)
print(stdout)
# check files writability
def check_files_writable(files):
for file in files:
if not os.access(file, os.W_OK):
return False
return True
# find a root directory containing a known directory (as a hint)
def find_root_path(startDir, containedDir):
currentDir = startDir
# search directory tree
mergedDir = os.path.join(currentDir, containedDir)
while not os.path.isdir(mergedDir):
(currentDir, dir) = os.path.split(currentDir)
if not dir:
return None
mergedDir = os.path.join(currentDir, containedDir)
return currentDir
def run_cmd(cmd, stdin = ""):
process = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(stdoutRaw, stderrRaw) = process.communicate(stdin.encode('utf-8'))
stdout = stdoutRaw.decode(encoding='utf-8')
stderr = stderrRaw.decode(encoding='utf-8')
return (stdout, stderr)
# clears content of files
def clear_files(files):
for file in files:
open(file, 'w').close()
##############################################################################
# internal functions
##############################################################################
| 3,425 | Python | 32.588235 | 115 | 0.703066 |
NVIDIA-Omniverse/PhysX/physx/tools/physxmetadatagenerator/lib/compare.py | ## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
# general utility module
import os
import sys
import re
from . import utils
def compareMetaDataDirectories(candidateDir, referenceDir):
print("reference dir:", referenceDir)
print("candidate dir:", candidateDir)
if not _checkFileExistence(candidateDir, referenceDir):
return False
referenceFiles = utils.list_autogen_files(referenceDir)
#get corresponding candidate files without relying on os.walk order
def mapRefToCand(refFile):
return os.path.join(candidateDir, os.path.relpath(refFile, referenceDir))
candidateFiles = [mapRefToCand(f) for f in referenceFiles]
for (fileCand, fileRef) in zip(candidateFiles, referenceFiles):
timeCand = os.path.getmtime(fileCand)
timeRef = os.path.getmtime(fileRef)
if timeCand <= timeRef:
print("last modified time of candidate is not later than last modified time of reference:")
print("candidate:", fileCand, "\n", "reference:", fileRef)
print("ref:", timeRef)
print("cand:", timeCand)
return False
#_read_file_content will remove line endings(windows/unix), but not ignore empty lines
candLines = _read_file_content(fileCand)
refLines = _read_file_content(fileRef)
if not (candLines and refLines):
return False
if len(candLines) != len(refLines):
print("files got different number of lines:")
print("candidate:", fileCand, "\n", "reference:", fileRef)
print("ref:", len(refLines))
print("cand:", len(candLines))
return False
for (i, (lineCand, lineRef)) in enumerate(zip(candLines, refLines)):
if (lineCand != lineRef):
print("candidate line is not equal to refence line:")
print("candidate:", fileCand, "\n", "reference:", fileRef)
print("@line number:", i)
print("ref:", lineRef)
print("cand:", lineCand)
return False
return True
##############################################################################
# internal functions
##############################################################################
#will remove line endings(windows/unix), but not ignore empty lines
def _read_file_content(filePath):
lines = []
try:
with open(filePath, "r") as file:
for line in file:
lines.append(line.rstrip())
except:
print("issue with reading file:", filePath)
return lines
def _checkFileExistence(candidateDir, referenceDir):
candidateSet = set([os.path.relpath(f, candidateDir) for f in utils.list_autogen_files(candidateDir)])
referenceSet = set([os.path.relpath(f, referenceDir) for f in utils.list_autogen_files(referenceDir)])
missingSet = referenceSet - candidateSet
if missingSet:
print("the following files are missing from the candidates:\n", "\n".join(missingSet))
return False
excessSet = candidateSet - referenceSet
if excessSet:
print("too many candidate files:\n", "\n".join(excessSet))
return False
return True
| 4,397 | Python | 36.271186 | 103 | 0.710257 |
NVIDIA-Omniverse/PhysX/physx/snippets/snippetcustomgeometry/VoxelMap.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef VOXEL_MAP_H
#define VOXEL_MAP_H
#include "PxPhysicsAPI.h"
/*
VoxelMap inherits physx::PxCustomGeometry::Callbacks interface and provides
implementations for 5 callback functions:
- getLocalBounds
- generateContacts
- raycast
- overlap
- sweep
It should be passed to PxCustomGeometry constructor.
*/
struct VoxelMap : physx::PxCustomGeometry::Callbacks, physx::PxUserAllocated
{
void setDimensions(int x, int y, int z);
int dimX() const;
int dimY() const;
int dimZ() const;
void setVoxelSize(float x, float y, float z);
const physx::PxVec3& voxelSize() const;
float voxelSizeX() const;
float voxelSizeY() const;
float voxelSizeZ() const;
physx::PxVec3 extents() const;
void setVoxel(int x, int y, int z, bool yes = true);
bool voxel(int x, int y, int z) const;
void clearVoxels();
void setFloorVoxels(int layers);
void setWaveVoxels();
void voxelize(const physx::PxGeometry& geom, const physx::PxTransform& pose, bool add = true);
physx::PxVec3 voxelPos(int x, int y, int z) const;
void pointCoords(const physx::PxVec3& p, int& x, int& y, int& z) const;
void getVoxelRegion(const physx::PxBounds3& b, int& sx, int& sy, int& sz, int& ex, int& ey, int& ez) const;
// physx::PxCustomGeometry::Callbacks overrides
DECLARE_CUSTOM_GEOMETRY_TYPE
virtual physx::PxBounds3 getLocalBounds(const physx::PxGeometry&) const;
virtual bool generateContacts(const physx::PxGeometry& geom0, const physx::PxGeometry& geom1, const physx::PxTransform& pose0, const physx::PxTransform& pose1,
const physx::PxReal contactDistance, const physx::PxReal meshContactMargin, const physx::PxReal toleranceLength,
physx::PxContactBuffer& contactBuffer) const;
virtual physx::PxU32 raycast(const physx::PxVec3& origin, const physx::PxVec3& unitDir, const physx::PxGeometry& geom, const physx::PxTransform& pose,
physx::PxReal maxDist, physx::PxHitFlags hitFlags, physx::PxU32 maxHits, physx::PxGeomRaycastHit* rayHits, physx::PxU32 stride, physx::PxRaycastThreadContext*) const;
virtual bool overlap(const physx::PxGeometry& geom0, const physx::PxTransform& pose0, const physx::PxGeometry& geom1, const physx::PxTransform& pose1, physx::PxOverlapThreadContext*) const;
virtual bool sweep(const physx::PxVec3& unitDir, const physx::PxReal maxDist,
const physx::PxGeometry& geom0, const physx::PxTransform& pose0, const physx::PxGeometry& geom1, const physx::PxTransform& pose1,
physx::PxGeomSweepHit& sweepHit, physx::PxHitFlags hitFlags, const physx::PxReal inflation, physx::PxSweepThreadContext*) const;
virtual void visualize(const physx::PxGeometry&, physx::PxRenderOutput&, const physx::PxTransform&, const physx::PxBounds3&) const;
virtual void computeMassProperties(const physx::PxGeometry&, physx::PxMassProperties&) const {}
virtual bool usePersistentContactManifold(const physx::PxGeometry&, physx::PxReal&) const { return true; }
private:
int pacsX() const;
int pacsY() const;
int pacsZ() const;
int m_dimensions[3];
physx::PxVec3 m_voxelSize;
physx::PxArray<physx::PxU64> m_packs;
};
#endif
| 4,745 | C | 42.541284 | 190 | 0.761644 |
NVIDIA-Omniverse/PhysX/physx/snippets/snippetcustomgeometry/VoxelMap.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "collision/PxCollisionDefs.h"
#include "PxImmediateMode.h"
#include "VoxelMap.h"
#include "common/PxRenderOutput.h"
#include "geomutils/PxContactBuffer.h"
using namespace physx;
void VoxelMap::setDimensions(int x, int y, int z)
{
m_dimensions[0] = x; m_dimensions[1] = y; m_dimensions[2] = z;
m_packs.resize(size_t(pacsX()) * size_t(pacsY()) * size_t(pacsZ()), 0U);
}
int VoxelMap::dimX() const
{
return m_dimensions[0];
}
int VoxelMap::dimY() const
{
return m_dimensions[1];
}
int VoxelMap::dimZ() const
{
return m_dimensions[2];
}
int VoxelMap::pacsX() const
{
return (dimX() + 3) / 4;
}
int VoxelMap::pacsY() const
{
return (dimY() + 3) / 4;
}
int VoxelMap::pacsZ() const
{
return (dimZ() + 3) / 4;
}
PxVec3 VoxelMap::extents() const
{
return PxVec3(dimX() * voxelSizeX(), dimY() * voxelSizeY(), dimZ() * voxelSizeZ());
}
void VoxelMap::setVoxelSize(float x, float y, float z)
{
m_voxelSize = PxVec3(x, y, z);
}
const PxVec3& VoxelMap::voxelSize() const
{
return m_voxelSize;
}
float VoxelMap::voxelSizeX() const
{
return m_voxelSize.x;
}
float VoxelMap::voxelSizeY() const
{
return m_voxelSize.y;
}
float VoxelMap::voxelSizeZ() const
{
return m_voxelSize.z;
}
void VoxelMap::setVoxel(int x, int y, int z, bool yes)
{
if (x < 0 || x >= int(dimX()) || y < 0 || y >= int(dimY()) || z < 0 || z >= int(dimZ()))
return;
int px = x / 4, py = y / 4, pz = z / 4;
int bx = x & 3, by = y & 3, bz = z & 3;
PxU64& p = m_packs[px + py * size_t(pacsX()) + pz * size_t(pacsX()) * size_t(pacsY())];
if (yes) p |= (PxU64(1) << (bx + by * 4 + bz * 16));
else p &= ~(PxU64(1) << (bx + by * 4 + bz * 16));
}
bool VoxelMap::voxel(int x, int y, int z) const
{
if (x < 0 || x >= int(dimX()) || y < 0 || y >= int(dimY()) || z < 0 || z >= int(dimZ()))
return false;
int px = x / 4, py = y / 4, pz = z / 4;
int bx = x & 3, by = y & 3, bz = z & 3;
PxU64 p = m_packs[px + py * size_t(pacsX()) + pz * size_t(pacsX()) * size_t(pacsY())];
return (p & (PxU64(1) << (bx + by * 4 + bz * 16))) != 0;
}
void VoxelMap::clearVoxels()
{
memset(&m_packs[0], 0, m_packs.size() * sizeof(PxU64));
}
void VoxelMap::setFloorVoxels(int layers)
{
for (int x = 0; x < dimX(); ++x)
for (int y = 0; y < layers; ++y)
for (int z = 0; z < dimZ(); ++z)
setVoxel(x, y, z);
}
void VoxelMap::setWaveVoxels()
{
PxVec3 ext = extents();
for (int x = 0; x < dimX(); ++x)
for (int y = 0; y < dimY(); ++y)
for (int z = 0; z < dimZ(); ++z)
{
PxVec3 pos = voxelPos(x, y, z);
float a = sqrtf((pos.x / ext.x) * (pos.x / ext.x) + (pos.z / ext.z) * (pos.z / ext.z));
if (a * 0.5f > pos.y / ext.y + 0.4f)
setVoxel(x, y, z);
}
}
void VoxelMap::voxelize(const PxGeometry& geom, const PxTransform& pose, bool add)
{
PxBounds3 bounds; PxGeometryQuery::computeGeomBounds(bounds, geom, pose);
int sx, sy, sz, ex, ey, ez;
getVoxelRegion(bounds, sx, sy, sz, ex, ey, ez);
for (int x = sx; x <= ex; ++x)
for (int y = sy; y <= ey; ++y)
for (int z = sz; z <= ez; ++z)
if (voxel(x, y, z))
{
if (!add && PxGeometryQuery::pointDistance(voxelPos(x, y, z), geom, pose) == 0)
setVoxel(x, y, z, false);
}
else
{
if (add && PxGeometryQuery::pointDistance(voxelPos(x, y, z), geom, pose) == 0)
setVoxel(x, y, z);
}
}
PxVec3 VoxelMap::voxelPos(int x, int y, int z) const
{
return PxVec3((x + 0.5f) * voxelSizeX(), (y + 0.5f) * voxelSizeY(), (z + 0.5f) * voxelSizeZ()) - extents() * 0.5f;
}
void VoxelMap::pointCoords(const PxVec3& p, int& x, int& y, int& z) const
{
PxVec3 l = p + extents() * 0.5f, s = voxelSize();
x = int(PxFloor(l.x / s.x));
y = int(PxFloor(l.y / s.y));
z = int(PxFloor(l.z / s.z));
}
void VoxelMap::getVoxelRegion(const PxBounds3& b, int& sx, int& sy, int& sz, int& ex, int& ey, int& ez) const
{
pointCoords(b.minimum, sx, sy, sz);
pointCoords(b.maximum, ex, ey, ez);
}
// physx::PxCustomGeometry::Callbacks overrides
IMPLEMENT_CUSTOM_GEOMETRY_TYPE(VoxelMap)
PxBounds3 VoxelMap::getLocalBounds(const PxGeometry&) const
{
return PxBounds3::centerExtents(PxVec3(0), extents());
}
bool VoxelMap::generateContacts(const PxGeometry& /*geom0*/, const PxGeometry& geom1, const PxTransform& pose0, const PxTransform& pose1,
const PxReal contactDistance, const PxReal meshContactMargin, const PxReal toleranceLength,
PxContactBuffer& contactBuffer) const
{
PxBoxGeometry voxelGeom(voxelSize() * 0.5f);
PxGeometry* pGeom0 = &voxelGeom;
const PxGeometry* pGeom1 = &geom1;
PxTransform pose1in0 = pose0.transformInv(pose1);
PxBounds3 bounds1; PxGeometryQuery::computeGeomBounds(bounds1, geom1, pose1in0, contactDistance);
struct ContactRecorder : immediate::PxContactRecorder
{
PxContactBuffer* contactBuffer;
ContactRecorder(PxContactBuffer& _contactBuffer) : contactBuffer(&_contactBuffer) {}
virtual bool recordContacts(const PxContactPoint* contactPoints, PxU32 nbContacts, PxU32 /*index*/)
{
for (PxU32 i = 0; i < nbContacts; ++i)
contactBuffer->contact(contactPoints[i]);
return true;
}
}
contactRecorder(contactBuffer);
PxCache contactCache;
struct ContactCacheAllocator : PxCacheAllocator
{
PxU8 buffer[1024];
ContactCacheAllocator() { memset(buffer, 0, sizeof(buffer)); }
virtual PxU8* allocateCacheData(const PxU32 /*byteSize*/) { return reinterpret_cast<PxU8*>(size_t(buffer + 0xf) & ~0xf); }
}
contactCacheAllocator;
int sx, sy, sz, ex, ey, ez;
getVoxelRegion(bounds1, sx, sy, sz, ex, ey, ez);
for (int x = sx; x <= ex; ++x)
for (int y = sy; y <= ey; ++y)
for (int z = sz; z <= ez; ++z)
if (voxel(x, y, z))
{
PxTransform p0 = pose0.transform(PxTransform(voxelPos(x, y, z)));
immediate::PxGenerateContacts(&pGeom0, &pGeom1, &p0, &pose1, &contactCache, 1, contactRecorder,
contactDistance, meshContactMargin, toleranceLength, contactCacheAllocator);
}
return true;
}
PxU32 VoxelMap::raycast(const PxVec3& origin, const PxVec3& unitDir, const PxGeometry& /*geom*/, const PxTransform& pose,
PxReal maxDist, PxHitFlags hitFlags, PxU32 maxHits, PxGeomRaycastHit* rayHits, PxU32 stride, PxRaycastThreadContext*) const
{
PxVec3 p = pose.transformInv(origin);
PxVec3 n = pose.rotateInv(unitDir);
PxVec3 s = voxelSize() * 0.5f;
int x, y, z; pointCoords(p, x, y, z);
int hitCount = 0;
PxU8* hitBuffer = reinterpret_cast<PxU8*>(rayHits);
float currDist = 0;
PxVec3 hitN(0);
while (currDist < maxDist)
{
PxVec3 v = voxelPos(x, y, z);
if (voxel(x, y, z))
{
PxGeomRaycastHit& h = *reinterpret_cast<PxGeomRaycastHit*>(hitBuffer + hitCount * stride);
h.distance = currDist;
if (hitFlags.isSet(PxHitFlag::ePOSITION))
h.position = origin + unitDir * currDist;
if (hitFlags.isSet(PxHitFlag::eNORMAL))
h.normal = hitN;
if (hitFlags.isSet(PxHitFlag::eFACE_INDEX))
h.faceIndex = (x) | (y << 10) | (z << 20);
hitCount += 1;
}
if (hitCount == int(maxHits))
break;
float step = FLT_MAX;
int dx = 0, dy = 0, dz = 0;
if (n.x > FLT_EPSILON)
{
float d = (v.x + s.x - p.x) / n.x;
if (d < step) { step = d; dx = 1; dy = 0; dz = 0; }
}
if (n.x < -FLT_EPSILON)
{
float d = (v.x - s.x - p.x) / n.x;
if (d < step) { step = d; dx = -1; dy = 0; dz = 0; }
}
if (n.y > FLT_EPSILON)
{
float d = (v.y + s.y - p.y) / n.y;
if (d < step) { step = d; dx = 0; dy = 1; dz = 0; }
}
if (n.y < -FLT_EPSILON)
{
float d = (v.y - s.y - p.y) / n.y;
if (d < step) { step = d; dx = 0; dy = -1; dz = 0; }
}
if (n.z > FLT_EPSILON)
{
float d = (v.z + s.z - p.z) / n.z;
if (d < step) { step = d; dx = 0; dy = 0; dz = 1; }
}
if (n.z < -FLT_EPSILON)
{
float d = (v.z - s.z - p.z) / n.z;
if (d < step) { step = d; dx = 0; dy = 0; dz = -1; }
}
x += dx; y += dy; z += dz;
hitN = PxVec3(float(-dx), float(-dy), float(-dz));
currDist = step;
}
return hitCount;
}
bool VoxelMap::overlap(const PxGeometry& /*geom0*/, const PxTransform& pose0, const PxGeometry& geom1, const PxTransform& pose1, PxOverlapThreadContext*) const
{
PxBoxGeometry voxelGeom(voxelSize() * 0.5f);
PxTransform pose1in0 = pose0.transformInv(pose1);
PxBounds3 bounds1; PxGeometryQuery::computeGeomBounds(bounds1, geom1, pose1in0);
int sx, sy, sz, ex, ey, ez;
getVoxelRegion(bounds1, sx, sy, sz, ex, ey, ez);
for (int x = sx; x <= ex; ++x)
for (int y = sy; y <= ey; ++y)
for (int z = sz; z <= ez; ++z)
if (voxel(x, y, z))
{
PxTransform p0 = pose0.transform(PxTransform(voxelPos(x, y, z)));
if (PxGeometryQuery::overlap(voxelGeom, p0, geom1, pose1, PxGeometryQueryFlags(0)))
return true;
}
return false;
}
bool VoxelMap::sweep(const PxVec3& unitDir, const PxReal maxDist,
const PxGeometry& /*geom0*/, const PxTransform& pose0, const PxGeometry& geom1, const PxTransform& pose1,
PxGeomSweepHit& sweepHit, PxHitFlags hitFlags, const PxReal inflation, PxSweepThreadContext*) const
{
PxBoxGeometry voxelGeom(voxelSize() * 0.5f);
PxTransform pose1in0 = pose0.transformInv(pose1);
PxBounds3 b; PxGeometryQuery::computeGeomBounds(b, geom1, pose1in0, 0, 1.0f, PxGeometryQueryFlags(0));
PxVec3 n = pose0.rotateInv(unitDir);
PxVec3 s = voxelSize();
int sx, sy, sz, ex, ey, ez;
getVoxelRegion(b, sx, sy, sz, ex, ey, ez);
int sx1, sy1, sz1, ex1, ey1, ez1;
sx1 = sy1 = sz1 = -1; ex1 = ey1 = ez1 = 0;
float currDist = 0;
sweepHit.distance = FLT_MAX;
while (currDist < maxDist && currDist < sweepHit.distance)
{
for (int x = sx; x <= ex; ++x)
for (int y = sy; y <= ey; ++y)
for (int z = sz; z <= ez; ++z)
if (voxel(x, y, z))
{
if (x >= sx1 && x <= ex1 && y >= sy1 && y <= ey1 && z >= sz1 && z <= ez1)
continue;
PxGeomSweepHit hit;
PxTransform p0 = pose0.transform(PxTransform(voxelPos(x, y, z)));
if (PxGeometryQuery::sweep(unitDir, maxDist, geom1, pose1, voxelGeom, p0, hit, hitFlags, inflation, PxGeometryQueryFlags(0)))
if (hit.distance < sweepHit.distance)
sweepHit = hit;
}
PxVec3 mi = b.minimum, ma = b.maximum;
PxVec3 bs = voxelPos(sx, sy, sz) - s, be = voxelPos(ex, ey, ez) + s;
float dist = FLT_MAX;
if (n.x > FLT_EPSILON)
{
float d = (be.x - ma.x) / n.x;
if (d < dist) dist = d;
}
if (n.x < -FLT_EPSILON)
{
float d = (bs.x - mi.x) / n.x;
if (d < dist) dist = d;
}
if (n.y > FLT_EPSILON)
{
float d = (be.y - ma.y) / n.y;
if (d < dist) dist = d;
}
if (n.y < -FLT_EPSILON)
{
float d = (bs.y - mi.y) / n.y;
if (d < dist) dist = d;
}
if (n.z > FLT_EPSILON)
{
float d = (be.z - ma.z) / n.z;
if (d < dist) dist = d;
}
if (n.z < -FLT_EPSILON)
{
float d = (bs.z - mi.z) / n.z;
if (d < dist) dist = d;
}
sx1 = sx; sy1 = sy; sz1 = sz; ex1 = ex; ey1 = ey; ez1 = ez;
PxBounds3 b1 = b; b1.minimum += n * dist; b1.maximum += n * dist;
getVoxelRegion(b1, sx, sy, sz, ex, ey, ez);
currDist = dist;
}
return sweepHit.distance < FLT_MAX;
}
void VoxelMap::visualize(const physx::PxGeometry& /*geom*/, physx::PxRenderOutput& render, const physx::PxTransform& transform, const physx::PxBounds3& /*bound*/) const
{
PxVec3 extents = voxelSize() * 0.5f;
render << transform;
for (int x = 0; x < dimX(); ++x)
for (int y = 0; y < dimY(); ++y)
for (int z = 0; z < dimZ(); ++z)
if (voxel(x, y, z))
{
if (voxel(x + 1, y, z) &&
voxel(x - 1, y, z) &&
voxel(x, y + 1, z) &&
voxel(x, y - 1, z) &&
voxel(x, y, z + 1) &&
voxel(x, y, z - 1))
continue;
PxVec3 pos = voxelPos(x, y, z);
PxBounds3 bounds(pos - extents, pos + extents);
physx::PxDebugBox box(bounds, true);
render << box;
}
}
| 13,283 | C++ | 28.784753 | 168 | 0.621847 |
NVIDIA-Omniverse/PhysX/physx/snippets/snippetcustomgeometry/SnippetCustomGeometry.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
// ****************************************************************************
// This snippet shows how to use custom geometries in PhysX.
// ****************************************************************************
#include <ctype.h>
#include <vector>
#include "PxPhysicsAPI.h"
// temporary disable this snippet, cannot work without rendering we cannot include GL directly
#ifdef RENDER_SNIPPET
#include "../snippetcommon/SnippetPrint.h"
#include "../snippetcommon/SnippetPVD.h"
#include "../snippetutils/SnippetUtils.h"
#include "../snippetrender/SnippetRender.h"
#include "VoxelMap.h"
using namespace physx;
static PxDefaultAllocator gAllocator;
static PxDefaultErrorCallback gErrorCallback;
static PxFoundation* gFoundation = NULL;
static PxPhysics* gPhysics = NULL;
static PxDefaultCpuDispatcher* gDispatcher = NULL;
static PxScene* gScene = NULL;
static PxMaterial* gMaterial = NULL;
static PxPvd* gPvd = NULL;
static PxRigidStatic* gActor = NULL;
static const int gVoxelMapDim = 20;
static const float gVoxelMapSize = 80.0f;
static VoxelMap* gVoxelMap;
static PxArray<PxVec3> gVertices;
static PxArray<PxU32> gIndices;
static PxU32 gVertexCount;
static PxU32 gIndexCount;
static PxGeometryHolder gVoxelGeometryHolder;
static const PxU32 gVertexOrder[12] = {
0, 2, 1, 2, 3, 1,
0, 1, 2, 2, 1, 3
};
PX_INLINE void cookVoxelFace(bool reverseWinding) {
for (int i = 0; i < 6; ++i) {
gIndices[gIndexCount + i] = gVertexCount + gVertexOrder[i + (reverseWinding ? 6 : 0)];
}
gVertexCount += 4;
gIndexCount += 6;
}
void cookVoxelMesh() {
int faceCount = 0;
gVertexCount = 0;
gIndexCount = 0;
float vx[2] = {gVoxelMap->voxelSize().x * -0.5f, gVoxelMap->voxelSize().x * 0.5f};
float vy[2] = {gVoxelMap->voxelSize().y * -0.5f, gVoxelMap->voxelSize().y * 0.5f};
float vz[2] = {gVoxelMap->voxelSize().z * -0.5f, gVoxelMap->voxelSize().z * 0.5f};
for (int x = 0; x < gVoxelMap->dimX(); ++x)
for (int y = 0; y < gVoxelMap->dimY(); ++y)
for (int z = 0; z < gVoxelMap->dimZ(); ++z)
if (gVoxelMap->voxel(x, y, z))
{
if (!gVoxelMap->voxel(x+1, y, z)) {faceCount++;}
if (!gVoxelMap->voxel(x-1, y, z)) {faceCount++;}
if (!gVoxelMap->voxel(x, y+1, z)) {faceCount++;}
if (!gVoxelMap->voxel(x, y-1, z)) {faceCount++;}
if (!gVoxelMap->voxel(x, y, z+1)) {faceCount++;}
if (!gVoxelMap->voxel(x, y, z-1)) {faceCount++;}
}
gVertices.resize(faceCount*4);
gIndices.resize(faceCount*6);
for (int x = 0; x < gVoxelMap->dimX(); ++x)
{
for (int y = 0; y < gVoxelMap->dimY(); ++y)
{
for (int z = 0; z < gVoxelMap->dimZ(); ++z)
{
PxVec3 voxelPos = gVoxelMap->voxelPos(x, y, z);
if (gVoxelMap->voxel(x, y, z))
{
if (!gVoxelMap->voxel(x+1, y, z)) {
gVertices[gVertexCount + 0] = voxelPos + PxVec3(vx[1], vy[0], vz[0]);
gVertices[gVertexCount + 1] = voxelPos + PxVec3(vx[1], vy[0], vz[1]);
gVertices[gVertexCount + 2] = voxelPos + PxVec3(vx[1], vy[1], vz[0]);
gVertices[gVertexCount + 3] = voxelPos + PxVec3(vx[1], vy[1], vz[1]);
cookVoxelFace(false);
}
if (!gVoxelMap->voxel(x-1, y, z)) {
gVertices[gVertexCount + 0] = voxelPos + PxVec3(vx[0], vy[0], vz[0]);
gVertices[gVertexCount + 1] = voxelPos + PxVec3(vx[0], vy[0], vz[1]);
gVertices[gVertexCount + 2] = voxelPos + PxVec3(vx[0], vy[1], vz[0]);
gVertices[gVertexCount + 3] = voxelPos + PxVec3(vx[0], vy[1], vz[1]);
cookVoxelFace(true);
}
if (!gVoxelMap->voxel(x, y+1, z)) {
gVertices[gVertexCount + 0] = voxelPos + PxVec3(vx[0], vy[1], vz[0]);
gVertices[gVertexCount + 1] = voxelPos + PxVec3(vx[0], vy[1], vz[1]);
gVertices[gVertexCount + 2] = voxelPos + PxVec3(vx[1], vy[1], vz[0]);
gVertices[gVertexCount + 3] = voxelPos + PxVec3(vx[1], vy[1], vz[1]);
cookVoxelFace(true);
}
if (!gVoxelMap->voxel(x, y-1, z)) {
gVertices[gVertexCount + 0] = voxelPos + PxVec3(vx[0], vy[0], vz[0]);
gVertices[gVertexCount + 1] = voxelPos + PxVec3(vx[0], vy[0], vz[1]);
gVertices[gVertexCount + 2] = voxelPos + PxVec3(vx[1], vy[0], vz[0]);
gVertices[gVertexCount + 3] = voxelPos + PxVec3(vx[1], vy[0], vz[1]);
cookVoxelFace(false);
}
if (!gVoxelMap->voxel(x, y, z+1)) {
gVertices[gVertexCount + 0] = voxelPos + PxVec3(vx[0], vy[0], vz[1]);
gVertices[gVertexCount + 1] = voxelPos + PxVec3(vx[0], vy[1], vz[1]);
gVertices[gVertexCount + 2] = voxelPos + PxVec3(vx[1], vy[0], vz[1]);
gVertices[gVertexCount + 3] = voxelPos + PxVec3(vx[1], vy[1], vz[1]);
cookVoxelFace(false);
}
if (!gVoxelMap->voxel(x, y, z-1)) {
gVertices[gVertexCount + 0] = voxelPos + PxVec3(vx[0], vy[0], vz[0]);
gVertices[gVertexCount + 1] = voxelPos + PxVec3(vx[0], vy[1], vz[0]);
gVertices[gVertexCount + 2] = voxelPos + PxVec3(vx[1], vy[0], vz[0]);
gVertices[gVertexCount + 3] = voxelPos + PxVec3(vx[1], vy[1], vz[0]);
cookVoxelFace(true);
}
}
}
}
}
const PxTolerancesScale scale;
PxCookingParams params(scale);
params.midphaseDesc.setToDefault(PxMeshMidPhase::eBVH34);
params.meshPreprocessParams |= PxMeshPreprocessingFlag::eDISABLE_ACTIVE_EDGES_PRECOMPUTE;
params.meshPreprocessParams |= PxMeshPreprocessingFlag::eDISABLE_CLEAN_MESH;
PxTriangleMeshDesc triangleMeshDesc;
triangleMeshDesc.points.count = gVertexCount;
triangleMeshDesc.points.data = gVertices.begin();
triangleMeshDesc.points.stride = sizeof(PxVec3);
triangleMeshDesc.triangles.count = gIndexCount / 3;
triangleMeshDesc.triangles.data = gIndices.begin();
triangleMeshDesc.triangles.stride = 3 * sizeof(PxU32);
PxTriangleMesh* gTriangleMesh = PxCreateTriangleMesh(params, triangleMeshDesc);
gVoxelGeometryHolder.storeAny( PxTriangleMeshGeometry(gTriangleMesh) );
}
static PxRigidDynamic* createDynamic(const PxTransform& t, const PxGeometry& geometry, const PxVec3& velocity = PxVec3(0), PxReal density = 1.0f)
{
PxRigidDynamic* dynamic = PxCreateDynamic(*gPhysics, t, geometry, *gMaterial, density);
dynamic->setLinearVelocity(velocity);
gScene->addActor(*dynamic);
return dynamic;
}
static void createStack(const PxTransform& t, PxU32 size, PxReal halfExtent)
{
PxShape* shape = gPhysics->createShape(PxBoxGeometry(halfExtent, halfExtent, halfExtent), *gMaterial);
for (PxU32 i = 0; i < size; i++)
{
for (PxU32 j = 0; j < size - i; j++)
{
PxTransform localTm(PxVec3(PxReal(j * 2) - PxReal(size - i), PxReal(i * 2 + 1), 0) * halfExtent);
PxRigidDynamic* body = gPhysics->createRigidDynamic(t.transform(localTm));
body->attachShape(*shape);
PxRigidBodyExt::updateMassAndInertia(*body, 10.0f);
gScene->addActor(*body);
}
}
shape->release();
}
void initVoxelMap()
{
gVoxelMap = PX_NEW(VoxelMap);
gVoxelMap->setDimensions(gVoxelMapDim, gVoxelMapDim, gVoxelMapDim);
gVoxelMap->setVoxelSize(gVoxelMapSize / gVoxelMapDim, gVoxelMapSize / gVoxelMapDim, gVoxelMapSize / gVoxelMapDim);
gVoxelMap->setWaveVoxels();
}
void initPhysics(bool /*interactive*/)
{
gFoundation = PxCreateFoundation(PX_PHYSICS_VERSION, gAllocator, gErrorCallback);
gPvd = PxCreatePvd(*gFoundation);
PxPvdTransport* transport = PxDefaultPvdSocketTransportCreate(PVD_HOST, 5425, 10);
gPvd->connect(*transport, PxPvdInstrumentationFlag::eALL);
gPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *gFoundation, PxTolerancesScale(), true, gPvd);
PxSceneDesc sceneDesc(gPhysics->getTolerancesScale());
sceneDesc.gravity = PxVec3(0.0f, -9.81f, 0.0f);
gDispatcher = PxDefaultCpuDispatcherCreate(2);
sceneDesc.cpuDispatcher = gDispatcher;
sceneDesc.filterShader = PxDefaultSimulationFilterShader;
gScene = gPhysics->createScene(sceneDesc);
gScene->setVisualizationParameter(PxVisualizationParameter::eCOLLISION_SHAPES, 1.0f);
gScene->setVisualizationParameter(PxVisualizationParameter::eSCALE, 1.0f);
PxPvdSceneClient* pvdClient = gScene->getScenePvdClient();
if (pvdClient)
{
pvdClient->setScenePvdFlag(PxPvdSceneFlag::eTRANSMIT_CONSTRAINTS, true);
pvdClient->setScenePvdFlag(PxPvdSceneFlag::eTRANSMIT_CONTACTS, true);
pvdClient->setScenePvdFlag(PxPvdSceneFlag::eTRANSMIT_SCENEQUERIES, true);
}
gMaterial = gPhysics->createMaterial(0.5f, 0.5f, 0.6f);
// Create voxel map actor
initVoxelMap();
PxRigidStatic* voxelMapActor = gPhysics->createRigidStatic(PxTransform(PxVec3(0, gVoxelMapSize * 0.5f, 0)));
PxShape* shape = PxRigidActorExt::createExclusiveShape(*voxelMapActor, PxCustomGeometry(*gVoxelMap), *gMaterial);
shape->setFlag(PxShapeFlag::eVISUALIZATION, true);
gScene->addActor(*voxelMapActor);
gActor = voxelMapActor;
gActor->setActorFlag(PxActorFlag::eVISUALIZATION, true);
// Ground plane
PxRigidStatic* planeActor = gPhysics->createRigidStatic(PxTransform(PxQuat(PX_PIDIV2, PxVec3(0, 0, 1))));
PxRigidActorExt::createExclusiveShape(*planeActor, PxPlaneGeometry(), *gMaterial);
gScene->addActor(*planeActor);
gScene->setVisualizationParameter(PxVisualizationParameter::eSCALE, 1.f);
gScene->setVisualizationParameter(PxVisualizationParameter::eCOLLISION_SHAPES, 1.0f);
createStack(PxTransform(PxVec3(0, 22, 0)), 10, 2.0f);
cookVoxelMesh();
}
void debugRender()
{
PxTransform pose = gActor->getGlobalPose();
Snippets::renderGeoms(1, &gVoxelGeometryHolder, &pose, false, PxVec3(0.5f));
}
void stepPhysics(bool /*interactive*/)
{
gScene->simulate(1.0f / 60.0f);
gScene->fetchResults(true);
}
void cleanupPhysics(bool /*interactive*/)
{
PX_DELETE(gVoxelMap);
PX_RELEASE(gScene);
PX_RELEASE(gDispatcher);
PX_RELEASE(gPhysics);
gVertices.reset();
gIndices.reset();
if (gPvd)
{
PxPvdTransport* transport = gPvd->getTransport();
gPvd->release(); gPvd = NULL;
PX_RELEASE(transport);
}
PX_RELEASE(gFoundation);
printf("SnippetCustomGeometry done.\n");
}
void keyPress(unsigned char key, const PxTransform& camera)
{
switch (toupper(key))
{
case ' ': createDynamic(camera, PxSphereGeometry(3.0f), camera.rotate(PxVec3(0, 0, -1)) * 200, 3.0f); break;
}
}
int snippetMain(int, const char* const*)
{
#ifdef RENDER_SNIPPET
extern void renderLoop();
renderLoop();
#else
static const PxU32 frameCount = 100;
initPhysics(false);
for (PxU32 i = 0; i < frameCount; i++)
stepPhysics(false);
cleanupPhysics(false);
#endif
return 0;
}
#else
int snippetMain(int, const char* const*)
{
return 0;
}
#endif
| 11,989 | C++ | 35.554878 | 145 | 0.694553 |
NVIDIA-Omniverse/PhysX/physx/snippets/snippetrender/SnippetCamera.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PHYSX_SNIPPET_CAMERA_H
#define PHYSX_SNIPPET_CAMERA_H
#include "foundation/PxTransform.h"
namespace Snippets
{
class Camera
{
public:
Camera(const physx::PxVec3& eye, const physx::PxVec3& dir);
void handleMouse(int button, int state, int x, int y);
bool handleKey(unsigned char key, int x, int y, float speed = 0.5f);
void handleMotion(int x, int y);
void handleAnalogMove(float x, float y);
physx::PxVec3 getEye() const;
physx::PxVec3 getDir() const;
physx::PxTransform getTransform() const;
void setPose(const physx::PxVec3& eye, const physx::PxVec3& dir);
void setSpeed(float speed);
private:
physx::PxVec3 mEye;
physx::PxVec3 mDir;
int mMouseX;
int mMouseY;
float mSpeed;
};
}
#endif //PHYSX_SNIPPET_CAMERA_H
| 2,479 | C | 38.365079 | 74 | 0.743445 |
NVIDIA-Omniverse/PhysX/physx/snippets/snippetrender/SnippetCamera.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "SnippetCamera.h"
#include <ctype.h>
#include "foundation/PxMat33.h"
using namespace physx;
namespace Snippets
{
Camera::Camera(const PxVec3& eye, const PxVec3& dir) : mMouseX(0), mMouseY(0), mSpeed(2.0f)
{
mEye = eye;
mDir = dir.getNormalized();
}
void Camera::handleMouse(int button, int state, int x, int y)
{
PX_UNUSED(state);
PX_UNUSED(button);
mMouseX = x;
mMouseY = y;
}
bool Camera::handleKey(unsigned char key, int x, int y, float speed)
{
PX_UNUSED(x);
PX_UNUSED(y);
const PxVec3 viewY = mDir.cross(PxVec3(0,1,0)).getNormalized();
switch(toupper(key))
{
case 'W': mEye += mDir*mSpeed*speed; break;
case 'S': mEye -= mDir*mSpeed*speed; break;
case 'A': mEye -= viewY*mSpeed*speed; break;
case 'D': mEye += viewY*mSpeed*speed; break;
default: return false;
}
return true;
}
void Camera::handleAnalogMove(float x, float y)
{
PxVec3 viewY = mDir.cross(PxVec3(0,1,0)).getNormalized();
mEye += mDir*y;
mEye += viewY*x;
}
void Camera::handleMotion(int x, int y)
{
const int dx = mMouseX - x;
const int dy = mMouseY - y;
const PxVec3 viewY = mDir.cross(PxVec3(0,1,0)).getNormalized();
const float Sensitivity = PxPi * 0.5f / 180.0f;
const PxQuat qx(Sensitivity * dx, PxVec3(0,1,0));
mDir = qx.rotate(mDir);
const PxQuat qy(Sensitivity * dy, viewY);
mDir = qy.rotate(mDir);
mDir.normalize();
mMouseX = x;
mMouseY = y;
}
PxTransform Camera::getTransform() const
{
PxVec3 viewY = mDir.cross(PxVec3(0,1,0));
if(viewY.normalize()<1e-6f)
return PxTransform(mEye);
const PxMat33 m(mDir.cross(viewY), viewY, -mDir);
return PxTransform(mEye, PxQuat(m));
}
PxVec3 Camera::getEye() const
{
return mEye;
}
PxVec3 Camera::getDir() const
{
return mDir;
}
void Camera::setPose(const PxVec3& eye, const PxVec3& dir)
{
mEye = eye;
mDir = dir;
}
void Camera::setSpeed(float speed)
{
mSpeed = speed;
}
}
| 3,579 | C++ | 26.538461 | 91 | 0.715284 |
NVIDIA-Omniverse/PhysX/physx/snippets/snippetrender/SnippetRender.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PHYSX_SNIPPET_RENDER_H
#define PHYSX_SNIPPET_RENDER_H
#include "PxPhysicsAPI.h"
#include "foundation/PxPreprocessor.h"
#if PX_WINDOWS
#include <windows.h>
#pragma warning(disable: 4505)
#include <GL/glew.h>
#include <GL/freeglut.h>
#elif PX_LINUX_FAMILY
#if PX_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-identifier"
#endif
#include <GL/glew.h>
#include <GL/freeglut.h>
#if PX_CLANG
#pragma clang diagnostic pop
#endif
#elif PX_OSX
#include <GL/glew.h>
#include <GLUT/glut.h>
#else
#error platform not supported.
#endif
typedef void (*KeyboardCallback) (unsigned char key, const physx::PxTransform& camera);
typedef void (*RenderCallback) ();
typedef void (*ExitCallback) ();
namespace Snippets
{
class Camera;
void setupDefault(const char* name, Camera* camera, KeyboardCallback kbcb, RenderCallback rdcb, ExitCallback excb);
Camera* getCamera();
physx::PxVec3 computeWorldRayF(float xs, float ys, const physx::PxVec3& camDir);
PX_FORCE_INLINE physx::PxVec3 computeWorldRay(int xs, int ys, const physx::PxVec3& camDir)
{
return computeWorldRayF(float(xs), float(ys), camDir);
}
physx::PxU32 getScreenWidth();
physx::PxU32 getScreenHeight();
void enableVSync(bool vsync);
void startRender(const Camera* camera, float nearClip = 1.0f, float farClip = 10000.0f, float fov=60.0f, bool setupLighting=true);
void finishRender();
void print(const char* text);
class TriggerRender
{
public:
virtual bool isTrigger(physx::PxShape*) const = 0;
};
#if PX_SUPPORT_GPU_PHYSX
class SharedGLBuffer
{
public:
SharedGLBuffer();
~SharedGLBuffer();
void initialize(physx::PxCudaContextManager* contextManager);
void allocate(physx::PxU32 sizeInBytes);
void release();
void* map();
void unmap();
private:
physx::PxCudaContextManager* cudaContextManager;
void* vbo_res;
void* devicePointer;
public:
GLuint vbo; //Opengl vertex buffer object
physx::PxU32 size;
};
#endif
void initFPS();
void showFPS(int updateIntervalMS = 30, const char* info = NULL);
void renderSoftBody(physx::PxSoftBody* softBody, const physx::PxVec4* deformedPositionsInvMass, bool shadows, const physx::PxVec3& color = physx::PxVec3(0.0f, 0.75f, 0.0f));
void renderActors(physx::PxRigidActor** actors, const physx::PxU32 numActors, bool shadows = false, const physx::PxVec3& color = physx::PxVec3(0.0f, 0.75f, 0.0f), TriggerRender* cb = NULL, bool changeColorForSleepingActors = true, bool wireframePass=true);
// void renderGeoms(const physx::PxU32 nbGeoms, const physx::PxGeometry* geoms, const physx::PxTransform* poses, bool shadows, const physx::PxVec3& color);
void renderGeoms(const physx::PxU32 nbGeoms, const physx::PxGeometryHolder* geoms, const physx::PxTransform* poses, bool shadows, const physx::PxVec3& color);
void renderMesh(physx::PxU32 nbVerts, const physx::PxVec3* verts, physx::PxU32 nbTris, const physx::PxU32* indices, const physx::PxVec3& color, const physx::PxVec3* normals = NULL, bool flipFaceOrientation = false);
void renderMesh(physx::PxU32 nbVerts, const physx::PxVec4* verts, physx::PxU32 nbTris, const physx::PxU32* indices, const physx::PxVec3& color, const physx::PxVec4* normals = NULL, bool flipFaceOrientation = false);
void renderMesh(physx::PxU32 nbVerts, const physx::PxVec4* verts, physx::PxU32 nbTris, const void* indices, bool hasSixteenBitIndices, const physx::PxVec3& color, const physx::PxVec4* normals = NULL, bool flipFaceOrientation = false, bool enableBackFaceCulling = true);
void renderHairSystem(physx::PxHairSystem* hairSystem, const physx::PxVec4* vertexPositionInvMass, physx::PxU32 numVertices);
void DrawLine(const physx::PxVec3& p0, const physx::PxVec3& p1, const physx::PxVec3& color);
void DrawPoints(const physx::PxArray<physx::PxVec3>& pts, const physx::PxVec3& color, float scale);
void DrawPoints(const physx::PxArray<physx::PxVec3>& pts, const physx::PxArray<physx::PxVec3>& colors, float scale);
void DrawPoints(const physx::PxArray<physx::PxVec4>& pts, const physx::PxVec3& color, float scale);
void DrawPoints(const physx::PxArray<physx::PxVec4>& pts, const physx::PxArray<physx::PxVec3>& colors, float scale);
void DrawPoints(GLuint vbo, physx::PxU32 numPoints, const physx::PxVec3& color, float scale, physx::PxU32 coordinatesPerPoint = 3, physx::PxU32 stride = 4 * sizeof(float), size_t offset = 0);
void DrawLines(GLuint vbo, physx::PxU32 numPoints, const physx::PxVec3& color, float scale, physx::PxU32 coordinatesPerPoint = 3, physx::PxU32 stride = 4 * sizeof(float), size_t offset = 0);
void DrawIcosahedraPoints(const physx::PxArray<physx::PxVec3>& pts, const physx::PxVec3& color, float radius);
void DrawFrame(const physx::PxVec3& pt, float scale=1.0f);
void DrawBounds(const physx::PxBounds3& box);
void DrawBounds(const physx::PxBounds3& box, const physx::PxVec3& color);
void DrawMeshIndexedNoNormals(GLuint vbo, GLuint elementbuffer, GLuint numTriangles, const physx::PxVec3& color, physx::PxU32 stride = 4 * sizeof(float));
void DrawMeshIndexed(GLuint vbo, GLuint elementbuffer, GLuint numTriangles, const physx::PxVec3& color, physx::PxU32 stride = 6 * sizeof(float));
GLuint CreateTexture(physx::PxU32 width, physx::PxU32 height, const GLubyte* buffer, bool createMipmaps);
void UpdateTexture(GLuint texId, physx::PxU32 width, physx::PxU32 height, const GLubyte* buffer, bool createMipmaps);
void ReleaseTexture(GLuint texId);
void DrawRectangle(float x_start, float x_end, float y_start, float y_end, const physx::PxVec3& color_top, const physx::PxVec3& color_bottom, float alpha, physx::PxU32 screen_width, physx::PxU32 screen_height, bool draw_outline, bool texturing);
void DisplayTexture(GLuint texId, physx::PxU32 size, physx::PxU32 margin);
}
#endif //PHYSX_SNIPPET_RENDER_H
| 7,484 | C | 50.620689 | 270 | 0.757215 |
NVIDIA-Omniverse/PhysX/physx/snippets/snippetrender/SnippetRender.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "foundation/PxPreprocessor.h"
#define USE_CUDA_INTEROP (!PX_PUBLIC_RELEASE)
#if (PX_SUPPORT_GPU_PHYSX && USE_CUDA_INTEROP)
#if PX_LINUX && PX_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdocumentation"
#endif
#include "cuda.h"
#include "SnippetRender.h"
#include "cudaGL.h"
#if PX_LINUX && PX_CLANG
#pragma clang diagnostic pop
#endif
#else
#include "SnippetRender.h"
#endif
#include "SnippetFontRenderer.h"
#include "SnippetCamera.h"
#include "foundation/PxArray.h"
#include "foundation/PxMathUtils.h"
#include <vector>
#define MAX_NUM_ACTOR_SHAPES 128
#define INITIAL_SCREEN_WIDTH 768
#define INITIAL_SCREEN_HEIGHT 768
using namespace physx;
static GLFontRenderer gTexter;
static float gCylinderData[]={
1.0f,0.0f,1.0f,1.0f,0.0f,1.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f,
0.866025f,0.500000f,1.0f,0.866025f,0.500000f,1.0f,0.866025f,0.500000f,0.0f,0.866025f,0.500000f,0.0f,
0.500000f,0.866025f,1.0f,0.500000f,0.866025f,1.0f,0.500000f,0.866025f,0.0f,0.500000f,0.866025f,0.0f,
-0.0f,1.0f,1.0f,-0.0f,1.0f,1.0f,-0.0f,1.0f,0.0f,-0.0f,1.0f,0.0f,
-0.500000f,0.866025f,1.0f,-0.500000f,0.866025f,1.0f,-0.500000f,0.866025f,0.0f,-0.500000f,0.866025f,0.0f,
-0.866025f,0.500000f,1.0f,-0.866025f,0.500000f,1.0f,-0.866025f,0.500000f,0.0f,-0.866025f,0.500000f,0.0f,
-1.0f,-0.0f,1.0f,-1.0f,-0.0f,1.0f,-1.0f,-0.0f,0.0f,-1.0f,-0.0f,0.0f,
-0.866025f,-0.500000f,1.0f,-0.866025f,-0.500000f,1.0f,-0.866025f,-0.500000f,0.0f,-0.866025f,-0.500000f,0.0f,
-0.500000f,-0.866025f,1.0f,-0.500000f,-0.866025f,1.0f,-0.500000f,-0.866025f,0.0f,-0.500000f,-0.866025f,0.0f,
0.0f,-1.0f,1.0f,0.0f,-1.0f,1.0f,0.0f,-1.0f,0.0f,0.0f,-1.0f,0.0f,
0.500000f,-0.866025f,1.0f,0.500000f,-0.866025f,1.0f,0.500000f,-0.866025f,0.0f,0.500000f,-0.866025f,0.0f,
0.866026f,-0.500000f,1.0f,0.866026f,-0.500000f,1.0f,0.866026f,-0.500000f,0.0f,0.866026f,-0.500000f,0.0f,
1.0f,0.0f,1.0f,1.0f,0.0f,1.0f,1.0f,0.0f,0.0f,1.0f,0.0f,0.0f
};
static std::vector<PxVec3>* gVertexBuffer = NULL;
static int gLastTime = 0;
static int gFrameCounter = 0;
static char gTitle[256];
static bool gWireFrame = false;
static PX_FORCE_INLINE void prepareVertexBuffer()
{
if(!gVertexBuffer)
gVertexBuffer = new std::vector<PxVec3>;
gVertexBuffer->clear();
}
static PX_FORCE_INLINE void pushVertex(const PxVec3& v0, const PxVec3& v1, const PxVec3& v2, const PxVec3& n)
{
PX_ASSERT(gVertexBuffer);
gVertexBuffer->push_back(n); gVertexBuffer->push_back(v0);
gVertexBuffer->push_back(n); gVertexBuffer->push_back(v1);
gVertexBuffer->push_back(n); gVertexBuffer->push_back(v2);
}
static PX_FORCE_INLINE void pushVertex(const PxVec3& v0, const PxVec3& v1, const PxVec3& v2, const PxVec3& n0, const PxVec3& n1, const PxVec3& n2, float normalSign = 1)
{
PX_ASSERT(gVertexBuffer);
gVertexBuffer->push_back(normalSign * n0); gVertexBuffer->push_back(v0);
gVertexBuffer->push_back(normalSign * n1); gVertexBuffer->push_back(v1);
gVertexBuffer->push_back(normalSign * n2); gVertexBuffer->push_back(v2);
}
static PX_FORCE_INLINE const PxVec3* getVertexBuffer()
{
PX_ASSERT(gVertexBuffer);
return &(*gVertexBuffer)[0];
}
static void releaseVertexBuffer()
{
if(gVertexBuffer)
{
delete gVertexBuffer;
gVertexBuffer = NULL;
}
}
static void renderSoftBodyGeometry(const PxTetrahedronMesh& mesh, const PxVec4* deformedPositionsInvMass)
{
const int tetFaces[4][3] = { {0,2,1}, {0,1,3}, {0,3,2}, {1,2,3} };
//Get the deformed vertices
//const PxVec3* vertices = mesh.getVertices();
const PxU32 tetCount = mesh.getNbTetrahedrons();
const PxU32 has16BitIndices = mesh.getTetrahedronMeshFlags() & PxTetrahedronMeshFlag::e16_BIT_INDICES;
const void* indexBuffer = mesh.getTetrahedrons();
prepareVertexBuffer();
const PxU32* intIndices = reinterpret_cast<const PxU32*>(indexBuffer);
const PxU16* shortIndices = reinterpret_cast<const PxU16*>(indexBuffer);
PxU32 numTotalTriangles = 0;
for (PxU32 i = 0; i < tetCount; ++i)
{
PxU32 vref[4];
if (has16BitIndices)
{
vref[0] = *shortIndices++;
vref[1] = *shortIndices++;
vref[2] = *shortIndices++;
vref[3] = *shortIndices++;
}
else
{
vref[0] = *intIndices++;
vref[1] = *intIndices++;
vref[2] = *intIndices++;
vref[3] = *intIndices++;
}
for (PxU32 j = 0; j < 4; ++j)
{
const PxVec4& v0 = deformedPositionsInvMass[vref[tetFaces[j][0]]];
const PxVec4& v1 = deformedPositionsInvMass[vref[tetFaces[j][1]]];
const PxVec4& v2 = deformedPositionsInvMass[vref[tetFaces[j][2]]];
PxVec3 fnormal = (v1.getXYZ() - v0.getXYZ()).cross(v2.getXYZ() - v0.getXYZ());
fnormal.normalize();
pushVertex(v0.getXYZ(), v1.getXYZ(), v2.getXYZ(), fnormal);
numTotalTriangles++;
}
}
glPushMatrix();
glScalef(1.0f, 1.0f, 1.0f);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
const PxVec3* vertexBuffer = getVertexBuffer();
glNormalPointer(GL_FLOAT, 2 * 3 * sizeof(float), vertexBuffer);
glVertexPointer(3, GL_FLOAT, 2 * 3 * sizeof(float), vertexBuffer + 1);
glDrawArrays(GL_TRIANGLES, 0, int(numTotalTriangles * 3));
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glPopMatrix();
}
static void renderGeometry(const PxGeometry& geom)
{
if (gWireFrame)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
switch(geom.getType())
{
case PxGeometryType::eBOX:
{
const PxBoxGeometry& boxGeom = static_cast<const PxBoxGeometry&>(geom);
glScalef(boxGeom.halfExtents.x, boxGeom.halfExtents.y, boxGeom.halfExtents.z);
glutSolidCube(2);
}
break;
case PxGeometryType::eSPHERE:
{
const PxSphereGeometry& sphereGeom = static_cast<const PxSphereGeometry&>(geom);
glutSolidSphere(GLdouble(sphereGeom.radius), 10, 10);
}
break;
case PxGeometryType::eCAPSULE:
{
const PxCapsuleGeometry& capsuleGeom = static_cast<const PxCapsuleGeometry&>(geom);
const PxF32 radius = capsuleGeom.radius;
const PxF32 halfHeight = capsuleGeom.halfHeight;
//Sphere
glPushMatrix();
glTranslatef(halfHeight, 0.0f, 0.0f);
glScalef(radius,radius,radius);
glutSolidSphere(1, 10, 10);
glPopMatrix();
//Sphere
glPushMatrix();
glTranslatef(-halfHeight, 0.0f, 0.0f);
glScalef(radius,radius,radius);
glutSolidSphere(1, 10, 10);
glPopMatrix();
//Cylinder
glPushMatrix();
glTranslatef(-halfHeight, 0.0f, 0.0f);
glScalef(2.0f*halfHeight, radius,radius);
glRotatef(90.0f,0.0f,1.0f,0.0f);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glVertexPointer(3, GL_FLOAT, 2*3*sizeof(float), gCylinderData);
glNormalPointer(GL_FLOAT, 2*3*sizeof(float), gCylinderData+3);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 13*2);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glPopMatrix();
}
break;
case PxGeometryType::eCONVEXMESH:
{
const PxConvexMeshGeometry& convexGeom = static_cast<const PxConvexMeshGeometry&>(geom);
//Compute triangles for each polygon.
const PxVec3& scale = convexGeom.scale.scale;
PxConvexMesh* mesh = convexGeom.convexMesh;
const PxU32 nbPolys = mesh->getNbPolygons();
const PxU8* polygons = mesh->getIndexBuffer();
const PxVec3* verts = mesh->getVertices();
PxU32 nbVerts = mesh->getNbVertices();
PX_UNUSED(nbVerts);
prepareVertexBuffer();
PxU32 numTotalTriangles = 0;
for(PxU32 i = 0; i < nbPolys; i++)
{
PxHullPolygon data;
mesh->getPolygonData(i, data);
const PxU32 nbTris = PxU32(data.mNbVerts - 2);
const PxU8 vref0 = polygons[data.mIndexBase + 0];
PX_ASSERT(vref0 < nbVerts);
for(PxU32 j=0;j<nbTris;j++)
{
const PxU32 vref1 = polygons[data.mIndexBase + 0 + j + 1];
const PxU32 vref2 = polygons[data.mIndexBase + 0 + j + 2];
//generate face normal:
PxVec3 e0 = verts[vref1] - verts[vref0];
PxVec3 e1 = verts[vref2] - verts[vref0];
PX_ASSERT(vref1 < nbVerts);
PX_ASSERT(vref2 < nbVerts);
PxVec3 fnormal = e0.cross(e1);
fnormal.normalize();
pushVertex(verts[vref0], verts[vref1], verts[vref2], fnormal);
numTotalTriangles++;
}
}
glPushMatrix();
glScalef(scale.x, scale.y, scale.z);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
const PxVec3* vertexBuffer = getVertexBuffer();
glNormalPointer(GL_FLOAT, 2*3*sizeof(float), vertexBuffer);
glVertexPointer(3, GL_FLOAT, 2*3*sizeof(float), vertexBuffer+1);
glDrawArrays(GL_TRIANGLES, 0, int(numTotalTriangles * 3));
glPopMatrix();
}
break;
case PxGeometryType::eTRIANGLEMESH:
{
const PxTriangleMeshGeometry& triGeom = static_cast<const PxTriangleMeshGeometry&>(geom);
const PxTriangleMesh& mesh = *triGeom.triangleMesh;
const PxVec3 scale = triGeom.scale.scale;
const PxU32 triangleCount = mesh.getNbTriangles();
const PxU32 has16BitIndices = mesh.getTriangleMeshFlags() & PxTriangleMeshFlag::e16_BIT_INDICES;
const void* indexBuffer = mesh.getTriangles();
const PxVec3* vertices = mesh.getVertices();
prepareVertexBuffer();
const PxU32* intIndices = reinterpret_cast<const PxU32*>(indexBuffer);
const PxU16* shortIndices = reinterpret_cast<const PxU16*>(indexBuffer);
PxU32 numTotalTriangles = 0;
for(PxU32 i=0; i < triangleCount; ++i)
{
PxU32 vref0, vref1, vref2;
if(has16BitIndices)
{
vref0 = *shortIndices++;
vref1 = *shortIndices++;
vref2 = *shortIndices++;
}
else
{
vref0 = *intIndices++;
vref1 = *intIndices++;
vref2 = *intIndices++;
}
const PxVec3& v0 = vertices[vref0];
const PxVec3& v1 = vertices[vref1];
const PxVec3& v2 = vertices[vref2];
PxVec3 fnormal = (v1 - v0).cross(v2 - v0);
fnormal.normalize();
pushVertex(v0, v1, v2, fnormal);
numTotalTriangles++;
}
glPushMatrix();
glScalef(scale.x, scale.y, scale.z);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
const PxVec3* vertexBuffer = getVertexBuffer();
glNormalPointer(GL_FLOAT, 2*3*sizeof(float), vertexBuffer);
glVertexPointer(3, GL_FLOAT, 2*3*sizeof(float), vertexBuffer+1);
glDrawArrays(GL_TRIANGLES, 0, int(numTotalTriangles * 3));
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glPopMatrix();
}
break;
case PxGeometryType::eTETRAHEDRONMESH:
{
const int tetFaces[4][3] = { {0,2,1}, {0,1,3}, {0,3,2}, {1,2,3} };
const PxTetrahedronMeshGeometry& tetGeom = static_cast<const PxTetrahedronMeshGeometry&>(geom);
const PxTetrahedronMesh& mesh = *tetGeom.tetrahedronMesh;
//Get the deformed vertices
const PxVec3* vertices = mesh.getVertices();
const PxU32 tetCount = mesh.getNbTetrahedrons();
const PxU32 has16BitIndices = mesh.getTetrahedronMeshFlags() & PxTetrahedronMeshFlag::e16_BIT_INDICES;
const void* indexBuffer = mesh.getTetrahedrons();
prepareVertexBuffer();
const PxU32* intIndices = reinterpret_cast<const PxU32*>(indexBuffer);
const PxU16* shortIndices = reinterpret_cast<const PxU16*>(indexBuffer);
PxU32 numTotalTriangles = 0;
for (PxU32 i = 0; i < tetCount; ++i)
{
PxU32 vref[4];
if (has16BitIndices)
{
vref[0] = *shortIndices++;
vref[1] = *shortIndices++;
vref[2] = *shortIndices++;
vref[3] = *shortIndices++;
}
else
{
vref[0] = *intIndices++;
vref[1] = *intIndices++;
vref[2] = *intIndices++;
vref[3] = *intIndices++;
}
for (PxU32 j = 0; j < 4; ++j)
{
const PxVec3& v0 = vertices[vref[tetFaces[j][0]]];
const PxVec3& v1 = vertices[vref[tetFaces[j][1]]];
const PxVec3& v2 = vertices[vref[tetFaces[j][2]]];
PxVec3 fnormal = (v1 - v0).cross(v2 - v0);
fnormal.normalize();
pushVertex(v0, v1, v2, fnormal);
numTotalTriangles++;
}
}
glPushMatrix();
glScalef(1.0f, 1.0f, 1.0f);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
const PxVec3* vertexBuffer = getVertexBuffer();
glNormalPointer(GL_FLOAT, 2 * 3 * sizeof(float), vertexBuffer);
glVertexPointer(3, GL_FLOAT, 2 * 3 * sizeof(float), vertexBuffer + 1);
glDrawArrays(GL_TRIANGLES, 0, int(numTotalTriangles * 3));
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glPopMatrix();
}
break;
default:
break;
}
if (gWireFrame)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
static Snippets::Camera* gCamera = NULL;
static KeyboardCallback gKbCb = NULL;
static PxU32 gScreenWidth = 0;
static PxU32 gScreenHeight = 0;
static void defaultReshapeCallback(int width, int height)
{
glViewport(0, 0, width, height);
gTexter.setScreenResolution(width, height);
gScreenWidth = width;
gScreenHeight = height;
}
static void defaultIdleCallback()
{
glutPostRedisplay();
}
static bool gMoveCamera = false;
static void defaultMotionCallback(int x, int y)
{
if(gCamera && gMoveCamera)
gCamera->handleMotion(x, y);
}
static void defaultMouseCallback(int button, int state, int x, int y)
{
if(button==0)
gMoveCamera = state==0;
if(gCamera)
gCamera->handleMouse(button, state, x, y);
}
static void defaultKeyboardCallback(unsigned char key, int x, int y)
{
if(key==27)
glutLeaveMainLoop();
if (key == 110) //n
gWireFrame = !gWireFrame;
const bool status = gCamera ? gCamera->handleKey(key, x, y) : false;
if(!status && gKbCb)
gKbCb(key, gCamera ? gCamera->getTransform() : PxTransform(PxIdentity));
}
static void defaultSpecialCallback(int key, int x, int y)
{
switch(key)
{
case GLUT_KEY_UP: key='W'; break;
case GLUT_KEY_DOWN: key='S'; break;
case GLUT_KEY_LEFT: key='A'; break;
case GLUT_KEY_RIGHT: key='D'; break;
}
const bool status = gCamera ? gCamera->handleKey((unsigned char)key, x, y) : false;
if(!status && gKbCb)
gKbCb((unsigned char)key, gCamera ? gCamera->getTransform() : PxTransform(PxIdentity));
}
static ExitCallback gUserExitCB = NULL;
static void defaultExitCallback()
{
releaseVertexBuffer();
if(gUserExitCB)
(gUserExitCB)();
}
static void setupDefaultWindow(const char* name, RenderCallback rdcb)
{
char* namestr = new char[strlen(name)+1];
strcpy(namestr, name);
int argc = 1;
char* argv[1] = { namestr };
glutInit(&argc, argv);
gScreenWidth = INITIAL_SCREEN_WIDTH;
gScreenHeight = INITIAL_SCREEN_HEIGHT;
gTexter.init();
gTexter.setScreenResolution(gScreenWidth, gScreenHeight);
gTexter.setColor(1.0f, 1.0f, 1.0f, 1.0f);
glutInitWindowSize(gScreenWidth, gScreenHeight);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE|GLUT_DEPTH);
int mainHandle = glutCreateWindow(name);
GLenum err = glewInit();
if (GLEW_OK != err)
{
fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
}
glutSetWindow(mainHandle);
glutReshapeFunc(defaultReshapeCallback);
glutIdleFunc(defaultIdleCallback);
glutKeyboardFunc(defaultKeyboardCallback);
glutSpecialFunc(defaultSpecialCallback);
glutMouseFunc(defaultMouseCallback);
glutMotionFunc(defaultMotionCallback);
if(rdcb)
glutDisplayFunc(rdcb);
defaultMotionCallback(0,0);
delete[] namestr;
}
static void setupDefaultRenderState()
{
// Setup default render states
// glClearColor(0.3f, 0.4f, 0.5f, 1.0);
glClearColor(0.2f, 0.2f, 0.2f, 1.0);
glEnable(GL_DEPTH_TEST);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
// Setup lighting
/* glEnable(GL_LIGHTING);
PxReal ambientColor[] = { 0.0f, 0.1f, 0.2f, 0.0f };
PxReal diffuseColor[] = { 1.0f, 1.0f, 1.0f, 0.0f };
PxReal specularColor[] = { 0.0f, 0.0f, 0.0f, 0.0f };
PxReal position[] = { 100.0f, 100.0f, 400.0f, 1.0f };
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientColor);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseColor);
glLightfv(GL_LIGHT0, GL_SPECULAR, specularColor);
glLightfv(GL_LIGHT0, GL_POSITION, position);
glEnable(GL_LIGHT0);*/
}
static void InitLighting()
{
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_NORMALIZE);
const float zero[] = { 0.0f, 0.0f, 0.0f, 0.0f };
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, zero);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, zero);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, zero);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, zero);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0f);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, zero);
glEnable(GL_LIGHTING);
PxVec3 Dir(-1.0f, 1.0f, 0.5f);
// PxVec3 Dir(0.0f, 1.0f, 0.0f);
Dir.normalize();
const float AmbientValue = 0.3f;
const float ambientColor0[] = { AmbientValue, AmbientValue, AmbientValue, 0.0f };
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientColor0);
const float specularColor0[] = { 0.0f, 0.0f, 0.0f, 0.0f };
glLightfv(GL_LIGHT0, GL_SPECULAR, specularColor0);
const float diffuseColor0[] = { 1.0f, 1.0f, 1.0f, 0.0f };
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseColor0);
const float position0[] = { Dir.x, Dir.y, Dir.z, 0.0f };
glLightfv(GL_LIGHT0, GL_POSITION, position0);
glEnable(GL_LIGHT0);
// glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
// glColor4f(0.0f, 0.0f, 0.0f, 0.0f);
/* glEnable(GL_LIGHTING);
PxReal ambientColor[] = { 0.0f, 0.1f, 0.2f, 0.0f };
PxReal diffuseColor[] = { 1.0f, 1.0f, 1.0f, 0.0f };
PxReal specularColor[] = { 0.0f, 0.0f, 0.0f, 0.0f };
PxReal position[] = { 100.0f, 100.0f, 400.0f, 1.0f };
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientColor);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseColor);
glLightfv(GL_LIGHT0, GL_SPECULAR, specularColor);
glLightfv(GL_LIGHT0, GL_POSITION, position);
glEnable(GL_LIGHT0);*/
if(0)
{
glEnable(GL_FOG);
glFogi(GL_FOG_MODE,GL_LINEAR);
//glFogi(GL_FOG_MODE,GL_EXP);
//glFogi(GL_FOG_MODE,GL_EXP2);
glFogf(GL_FOG_START, 0.0f);
glFogf(GL_FOG_END, 100.0f);
glFogf(GL_FOG_DENSITY, 0.005f);
// glClearColor(0.2f, 0.2f, 0.2f, 1.0);
// const PxVec3 FogColor(0.2f, 0.2f, 0.2f);
const PxVec3 FogColor(0.3f, 0.4f, 0.5f);
// const PxVec3 FogColor(1.0f);
glFogfv(GL_FOG_COLOR, &FogColor.x);
}
}
namespace Snippets
{
void initFPS()
{
gLastTime = glutGet(GLUT_ELAPSED_TIME);
}
void showFPS(int updateIntervalMS, const char* info)
{
++gFrameCounter;
int currentTime = glutGet(GLUT_ELAPSED_TIME);
if (currentTime - gLastTime > updateIntervalMS)
{
if (info)
sprintf(gTitle, " FPS : %4.0f%s", gFrameCounter * 1000.0 / (currentTime - gLastTime), info);
else
sprintf(gTitle, " FPS : %4.0f", gFrameCounter * 1000.0 / (currentTime - gLastTime));
glutSetWindowTitle(gTitle);
gLastTime = currentTime;
gFrameCounter = 0;
}
}
PxU32 getScreenWidth()
{
return gScreenWidth;
}
PxU32 getScreenHeight()
{
return gScreenHeight;
}
void enableVSync(bool vsync)
{
#if PX_WIN32 || PX_WIN64
typedef void (APIENTRY * PFNWGLSWAPINTERVALPROC) (GLenum interval);
PFNWGLSWAPINTERVALPROC wglSwapIntervalEXT = (PFNWGLSWAPINTERVALPROC)wglGetProcAddress("wglSwapIntervalEXT");
wglSwapIntervalEXT(vsync);
#else
PX_UNUSED(vsync);
#endif
}
void setupDefault(const char* name, Camera* camera, KeyboardCallback kbcb, RenderCallback rdcb, ExitCallback excb)
{
gCamera = camera;
gKbCb = kbcb;
setupDefaultWindow(name, rdcb);
setupDefaultRenderState();
enableVSync(true);
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
gUserExitCB = excb;
atexit(defaultExitCallback);
}
Camera* getCamera()
{
return gCamera;
}
static float gNearClip = 0.0f;
static float gFarClip = 0.0f;
static float gFOV = 60.0f;
static float gTextScale = 0.0f;
static float gTextY = 0.0f;
PxVec3 computeWorldRayF(float xs, float ys, const PxVec3& camDir)
{
const float Width = float(gScreenWidth);
const float Height = float(gScreenHeight);
// Recenter coordinates in camera space ([-1, 1])
const float u = ((xs - Width*0.5f)/Width)*2.0f;
const float v = -((ys - Height*0.5f)/Height)*2.0f;
// Adjust coordinates according to camera aspect ratio
const float HTan = tanf(0.25f * fabsf(PxDegToRad(gFOV * 2.0f)));
const float VTan = HTan*(Width/Height);
// Ray in camera space
const PxVec3 CamRay(VTan*u, HTan*v, 1.0f);
// Compute ray in world space
PxVec3 Right, Up;
PxComputeBasisVectors(camDir, Right, Up);
const PxMat33 invView(-Right, Up, camDir);
return invView.transform(CamRay).getNormalized();
}
void startRender(const Camera* camera, float clipNear, float clipFar, float fov, bool setupLighting)
{
const PxVec3 cameraEye = camera->getEye();
const PxVec3 cameraDir = camera->getDir();
gNearClip = clipNear;
gFarClip = clipFar;
gFOV = fov;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Setup camera
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(GLdouble(fov), GLdouble(glutGet(GLUT_WINDOW_WIDTH)) / GLdouble(glutGet(GLUT_WINDOW_HEIGHT)), GLdouble(clipNear), GLdouble(clipFar));
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(GLdouble(cameraEye.x), GLdouble(cameraEye.y), GLdouble(cameraEye.z), GLdouble(cameraEye.x + cameraDir.x), GLdouble(cameraEye.y + cameraDir.y), GLdouble(cameraEye.z + cameraDir.z), 0.0, 1.0, 0.0);
glColor4f(0.4f, 0.4f, 0.4f, 1.0f);
if(setupLighting)
InitLighting();
gTextScale = 0.0175f * float(INITIAL_SCREEN_HEIGHT) / float(gScreenHeight);
gTextY = 1.0f - gTextScale;
gTexter.setColor(1.0f, 1.0f, 1.0f, 1.0f);
}
void finishRender()
{
glutSwapBuffers();
}
void print(const char* text)
{
gTexter.print(0.0f, gTextY, gTextScale, text);
gTextY -= gTextScale;
}
const PxVec3 shadowDir(0.0f, -0.7071067f, -0.7071067f);
const PxReal shadowMat[] = { 1,0,0,0, -shadowDir.x / shadowDir.y,0,-shadowDir.z / shadowDir.y,0, 0,0,1,0, 0,0,0,1 };
void renderSoftBody(PxSoftBody* softBody, const PxVec4* deformedPositionsInvMass, bool shadows, const PxVec3& color)
{
PxShape* shape = softBody->getShape();
const PxMat44 shapePose(PxIdentity); // (PxShapeExt::getGlobalPose(*shapes[j], *actors[i]));
const PxGeometry& geom = shape->getGeometry();
const PxTetrahedronMeshGeometry& tetGeom = static_cast<const PxTetrahedronMeshGeometry&>(geom);
const PxTetrahedronMesh& mesh = *tetGeom.tetrahedronMesh;
glPushMatrix();
glMultMatrixf(&shapePose.column0.x);
glColor4f(color.x, color.y, color.z, 1.0f);
renderSoftBodyGeometry(mesh, deformedPositionsInvMass);
glPopMatrix();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
if (shadows)
{
glPushMatrix();
glMultMatrixf(shadowMat);
glMultMatrixf(&shapePose.column0.x);
glDisable(GL_LIGHTING);
//glColor4f(0.1f, 0.2f, 0.3f, 1.0f);
glColor4f(0.1f, 0.1f, 0.1f, 1.0f);
renderSoftBodyGeometry(mesh, deformedPositionsInvMass);
glEnable(GL_LIGHTING);
glPopMatrix();
}
}
void renderHairSystem(physx::PxHairSystem* /*hairSystem*/, const physx::PxVec4* vertexPositionInvMass, PxU32 numVertices)
{
const PxVec3 color{ 1.0f, 0.0f, 0.0f };
const PxSphereGeometry geom(0.05f);
// draw the volume
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
for(PxU32 j=0;j<numVertices;j++)
{
const PxMat44 shapePose(PxTransform(reinterpret_cast<const PxVec3&>(vertexPositionInvMass[j])));
glPushMatrix();
glMultMatrixf(&shapePose.column0.x);
glColor4f(color.x, color.y, color.z, 1.0f);
renderGeometry(geom);
glPopMatrix();
}
// draw the cage lines
const GLdouble aspect = GLdouble(glutGet(GLUT_WINDOW_WIDTH)) / GLdouble(glutGet(GLUT_WINDOW_HEIGHT));
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, aspect, GLdouble(gNearClip * 1.005f), GLdouble(gFarClip));
glMatrixMode(GL_MODELVIEW);
glDisable(GL_LIGHTING);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
for (PxU32 j = 0; j < numVertices; j++)
{
const PxMat44 shapePose(PxTransform(reinterpret_cast<const PxVec3&>(vertexPositionInvMass[j])));
glPushMatrix();
glMultMatrixf(&shapePose.column0.x);
renderGeometry(geom);
glPopMatrix();
}
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, aspect, GLdouble(gNearClip), GLdouble(gFarClip));
glMatrixMode(GL_MODELVIEW);
}
void renderActors(PxRigidActor** actors, const PxU32 numActors, bool shadows, const PxVec3& color, TriggerRender* cb,
bool changeColorForSleepingActors, bool wireframePass)
{
PxShape* shapes[MAX_NUM_ACTOR_SHAPES];
for(PxU32 i=0;i<numActors;i++)
{
const PxU32 nbShapes = actors[i]->getNbShapes();
PX_ASSERT(nbShapes <= MAX_NUM_ACTOR_SHAPES);
actors[i]->getShapes(shapes, nbShapes);
bool sleeping;
if (changeColorForSleepingActors)
sleeping = actors[i]->is<PxRigidDynamic>() ? actors[i]->is<PxRigidDynamic>()->isSleeping() : false;
else
sleeping = false;
for(PxU32 j=0;j<nbShapes;j++)
{
const PxMat44 shapePose(PxShapeExt::getGlobalPose(*shapes[j], *actors[i]));
const PxGeometry& geom = shapes[j]->getGeometry();
const bool isTrigger = cb ? cb->isTrigger(shapes[j]) : shapes[j]->getFlags() & PxShapeFlag::eTRIGGER_SHAPE;
if(isTrigger)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// render object
glPushMatrix();
glMultMatrixf(&shapePose.column0.x);
if(sleeping)
{
const PxVec3 darkColor = color * 0.25f;
glColor4f(darkColor.x, darkColor.y, darkColor.z, 1.0f);
}
else
glColor4f(color.x, color.y, color.z, 1.0f);
renderGeometry(geom);
glPopMatrix();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
if(shadows)
{
glPushMatrix();
glMultMatrixf(shadowMat);
glMultMatrixf(&shapePose.column0.x);
glDisable(GL_LIGHTING);
//glColor4f(0.1f, 0.2f, 0.3f, 1.0f);
glColor4f(0.1f, 0.1f, 0.1f, 1.0f);
renderGeometry(geom);
glEnable(GL_LIGHTING);
glPopMatrix();
}
}
}
if(wireframePass)
{
const GLdouble aspect = GLdouble(glutGet(GLUT_WINDOW_WIDTH)) / GLdouble(glutGet(GLUT_WINDOW_HEIGHT));
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, aspect, GLdouble(gNearClip*1.005f), GLdouble(gFarClip));
glMatrixMode(GL_MODELVIEW);
glDisable(GL_LIGHTING);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
for(PxU32 i=0;i<numActors;i++)
{
const PxU32 nbShapes = actors[i]->getNbShapes();
PX_ASSERT(nbShapes <= MAX_NUM_ACTOR_SHAPES);
actors[i]->getShapes(shapes, nbShapes);
for(PxU32 j=0;j<nbShapes;j++)
{
const PxMat44 shapePose(PxShapeExt::getGlobalPose(*shapes[j], *actors[i]));
glPushMatrix();
glMultMatrixf(&shapePose.column0.x);
renderGeometry(shapes[j]->getGeometry());
glPopMatrix();
}
}
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, aspect, GLdouble(gNearClip), GLdouble(gFarClip));
glMatrixMode(GL_MODELVIEW);
}
}
/*static const PxU32 gGeomSizes[] = {
sizeof(PxSphereGeometry),
sizeof(PxPlaneGeometry),
sizeof(PxCapsuleGeometry),
sizeof(PxBoxGeometry),
sizeof(PxConvexMeshGeometry),
sizeof(PxTriangleMeshGeometry),
sizeof(PxHeightFieldGeometry),
};
void renderGeoms(const PxU32 nbGeoms, const PxGeometry* geoms, const PxTransform* poses, bool shadows, const PxVec3& color)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
const PxVec3 shadowDir(0.0f, -0.7071067f, -0.7071067f);
const PxReal shadowMat[]={ 1,0,0,0, -shadowDir.x/shadowDir.y,0,-shadowDir.z/shadowDir.y,0, 0,0,1,0, 0,0,0,1 };
const PxU8* stream = reinterpret_cast<const PxU8*>(geoms);
for(PxU32 j=0;j<nbGeoms;j++)
{
const PxMat44 shapePose(poses[j]);
const PxGeometry& geom = *reinterpret_cast<const PxGeometry*>(stream);
stream += gGeomSizes[geom.getType()];
// render object
glPushMatrix();
glMultMatrixf(&shapePose.column0.x);
glColor4f(color.x, color.y, color.z, 1.0f);
renderGeometry(geom);
glPopMatrix();
if(shadows)
{
glPushMatrix();
glMultMatrixf(shadowMat);
glMultMatrixf(&shapePose.column0.x);
glDisable(GL_LIGHTING);
glColor4f(0.1f, 0.2f, 0.3f, 1.0f);
renderGeometry(geom);
glEnable(GL_LIGHTING);
glPopMatrix();
}
}
}*/
void renderGeoms(const PxU32 nbGeoms, const PxGeometryHolder* geoms, const PxTransform* poses, bool shadows, const PxVec3& color)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
// glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
//const PxVec3 shadowDir(0.0f, -0.7071067f, -0.7071067f);
//const PxReal shadowMat[]={ 1,0,0,0, -shadowDir.x/shadowDir.y,0,-shadowDir.z/shadowDir.y,0, 0,0,1,0, 0,0,0,1 };
for(PxU32 j=0;j<nbGeoms;j++)
{
const PxMat44 shapePose(poses[j]);
const PxGeometry& geom = geoms[j].any();
// render object
glPushMatrix();
glMultMatrixf(&shapePose.column0.x);
glColor4f(color.x, color.y, color.z, 1.0f);
renderGeometry(geom);
glPopMatrix();
if(shadows)
{
glPushMatrix();
glMultMatrixf(shadowMat);
glMultMatrixf(&shapePose.column0.x);
glDisable(GL_LIGHTING);
//glColor4f(0.1f, 0.2f, 0.3f, 1.0f);
glColor4f(0.1f, 0.1f, 0.1f, 1.0f);
renderGeometry(geom);
glEnable(GL_LIGHTING);
glPopMatrix();
}
}
if(1)
{
const GLdouble aspect = GLdouble(glutGet(GLUT_WINDOW_WIDTH)) / GLdouble(glutGet(GLUT_WINDOW_HEIGHT));
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, aspect, GLdouble(gNearClip*1.005f), GLdouble(gFarClip));
glMatrixMode(GL_MODELVIEW);
glDisable(GL_LIGHTING);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
for(PxU32 j=0;j<nbGeoms;j++)
{
const PxMat44 shapePose(poses[j]);
const PxGeometry& geom = geoms[j].any();
// render object
glPushMatrix();
glMultMatrixf(&shapePose.column0.x);
renderGeometry(geom);
glPopMatrix();
}
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, aspect, GLdouble(gNearClip), GLdouble(gFarClip));
glMatrixMode(GL_MODELVIEW);
}
}
PX_FORCE_INLINE PxVec3 getVec3(const physx::PxU8* data, const PxU32 index, const PxU32 sStrideInBytes)
{
return *reinterpret_cast<const PxVec3*>(data + index * sStrideInBytes);
}
void renderMesh(physx::PxU32 /*nbVerts*/, const physx::PxU8* verts, const PxU32 vertsStrideInBytes, physx::PxU32 nbTris, const void* indices, bool has16bitIndices, const physx::PxVec3& color,
const physx::PxU8* normals, const PxU32 normalsStrideInBytes, bool flipFaceOrientation, bool enableBackFaceCulling = true)
{
if (nbTris == 0)
return;
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
const PxMat44 idt(PxIdentity);
glPushMatrix();
glMultMatrixf(&idt.column0.x);
glColor4f(color.x, color.y, color.z, 1.0f);
if (!enableBackFaceCulling)
glDisable(GL_CULL_FACE);
{
prepareVertexBuffer();
PxU32 numTotalTriangles = 0;
for(PxU32 i=0; i <nbTris; ++i)
{
PxU32 vref0, vref1, vref2;
if (has16bitIndices)
{
vref0 = ((const PxU16*)indices)[i * 3 + 0];
vref1 = ((const PxU16*)indices)[i * 3 + 1];
vref2 = ((const PxU16*)indices)[i * 3 + 2];
}
else
{
vref0 = ((const PxU32*)indices)[i * 3 + 0];
vref1 = ((const PxU32*)indices)[i * 3 + 1];
vref2 = ((const PxU32*)indices)[i * 3 + 2];
}
const PxVec3& v0 = getVec3(verts, vref0, vertsStrideInBytes);
const PxVec3& v1 = flipFaceOrientation ? getVec3(verts, vref2, vertsStrideInBytes) : getVec3(verts, vref1, vertsStrideInBytes);
const PxVec3& v2 = flipFaceOrientation ? getVec3(verts, vref1, vertsStrideInBytes) : getVec3(verts, vref2, vertsStrideInBytes);
if (normals)
{
const PxVec3& n0 = getVec3(normals, vref0, normalsStrideInBytes);
const PxVec3& n1 = flipFaceOrientation ? getVec3(normals, vref2, normalsStrideInBytes) : getVec3(normals, vref1, normalsStrideInBytes);
const PxVec3& n2 = flipFaceOrientation ? getVec3(normals, vref1, normalsStrideInBytes) : getVec3(normals, vref2, normalsStrideInBytes);
pushVertex(v0, v1, v2, n0, n1, n2, flipFaceOrientation ? -1.0f : 1.0f);
}
else
{
PxVec3 fnormal = (v1 - v0).cross(v2 - v0);
fnormal.normalize();
pushVertex(v0, v1, v2, fnormal);
}
numTotalTriangles++;
}
glScalef(1.0f, 1.0f, 1.0f);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
const PxVec3* vertexBuffer = getVertexBuffer();
glNormalPointer(GL_FLOAT, 2*3*sizeof(float), vertexBuffer);
glVertexPointer(3, GL_FLOAT, 2*3*sizeof(float), vertexBuffer+1);
glDrawArrays(GL_TRIANGLES, 0, int(nbTris * 3));
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
}
glPopMatrix();
if (!enableBackFaceCulling)
glEnable(GL_CULL_FACE);
if(0)
{
const GLdouble aspect = GLdouble(glutGet(GLUT_WINDOW_WIDTH)) / GLdouble(glutGet(GLUT_WINDOW_HEIGHT));
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, aspect, GLdouble(gNearClip*1.005f), GLdouble(gFarClip));
glMatrixMode(GL_MODELVIEW);
glDisable(GL_LIGHTING);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
glPushMatrix();
glMultMatrixf(&idt.column0.x);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
const PxVec3* vertexBuffer = getVertexBuffer();
glNormalPointer(GL_FLOAT, 2*3*sizeof(float), vertexBuffer);
glVertexPointer(3, GL_FLOAT, 2*3*sizeof(float), vertexBuffer+1);
glDrawArrays(GL_TRIANGLES, 0, int(nbTris * 3));
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glPopMatrix();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_LIGHTING);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, aspect, GLdouble(gNearClip), GLdouble(gFarClip));
glMatrixMode(GL_MODELVIEW);
}
}
void renderMesh(physx::PxU32 nbVerts, const physx::PxVec3* verts, physx::PxU32 nbTris, const physx::PxU32* indices, const physx::PxVec3& color, const physx::PxVec3* normals, bool flipFaceOrientation)
{
renderMesh(nbVerts, reinterpret_cast<const PxU8*>(verts), sizeof(PxVec3), nbTris, indices, false, color, reinterpret_cast<const PxU8*>(normals), sizeof(PxVec3), flipFaceOrientation);
}
void renderMesh(physx::PxU32 nbVerts, const physx::PxVec4* verts, physx::PxU32 nbTris, const physx::PxU32* indices, const physx::PxVec3& color, const physx::PxVec4* normals, bool flipFaceOrientation)
{
renderMesh(nbVerts, reinterpret_cast<const PxU8*>(verts), sizeof(PxVec4), nbTris, indices, false, color, reinterpret_cast<const PxU8*>(normals), sizeof(PxVec4), flipFaceOrientation);
}
void renderMesh(physx::PxU32 nbVerts, const physx::PxVec4* verts, physx::PxU32 nbTris, const void* indices, bool hasSixteenBitIndices,
const physx::PxVec3& color, const physx::PxVec4* normals, bool flipFaceOrientation, bool enableBackFaceCulling)
{
renderMesh(nbVerts, reinterpret_cast<const PxU8*>(verts), sizeof(PxVec4), nbTris, indices, hasSixteenBitIndices,
color, reinterpret_cast<const PxU8*>(normals), sizeof(PxVec4), flipFaceOrientation, enableBackFaceCulling);
}
void DrawLine(const PxVec3& p0, const PxVec3& p1, const PxVec3& color)
{
glDisable(GL_LIGHTING);
glColor4f(color.x, color.y, color.z, 1.0f);
const PxVec3 Pts[] = { p0, p1 };
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(PxVec3), &Pts[0].x);
glDrawArrays(GL_LINES, 0, 2);
glDisableClientState(GL_VERTEX_ARRAY);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glEnable(GL_LIGHTING);
}
const physx::PxVec3 icosahedronPoints[12] = { PxVec3(0, -0.525731, 0.850651),
PxVec3(0.850651, 0, 0.525731),
PxVec3(0.850651, 0, -0.525731),
PxVec3(-0.850651, 0, -0.525731),
PxVec3(-0.850651, 0, 0.525731),
PxVec3(-0.525731, 0.850651, 0),
PxVec3(0.525731, 0.850651, 0),
PxVec3(0.525731, -0.850651, 0),
PxVec3(-0.525731, -0.850651, 0),
PxVec3(0, -0.525731, -0.850651),
PxVec3(0, 0.525731, -0.850651),
PxVec3(0, 0.525731, 0.850651) };
const PxU32 icosahedronIndices[3 * 20] = { 1 ,2 ,6 ,
1 ,7 ,2 ,
3 ,4 ,5 ,
4 ,3 ,8 ,
6 ,5 ,11 ,
5 ,6 ,10 ,
9 ,10 ,2 ,
10 ,9 ,3 ,
7 ,8 ,9 ,
8 ,7 ,0 ,
11 ,0 ,1 ,
0 ,11 ,4 ,
6 ,2 ,10 ,
1 ,6 ,11 ,
3 ,5 ,10 ,
5 ,4 ,11 ,
2 ,7 ,9 ,
7 ,1 ,0 ,
3 ,9 ,8 ,
4 ,8 ,0 };
void DrawIcosahedraPoints(const PxArray<PxVec3>& pts, const PxVec3& color, float radius)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
const PxMat44 idt(PxIdentity);
glPushMatrix();
glMultMatrixf(&idt.column0.x);
glColor4f(color.x, color.y, color.z, 1.0f);
PxU32 numTotalTriangles = 0;
{
prepareVertexBuffer();
for (PxU32 i = 0; i < pts.size(); ++i)
{
PxVec3 center = pts[i];
for (PxU32 j = 0; j < 20; ++j)
{
const PxVec3& v0 = icosahedronPoints[icosahedronIndices[3 * j + 0]] * radius + center;
const PxVec3& v1 = icosahedronPoints[icosahedronIndices[3 * j + 1]] * radius + center;
const PxVec3& v2 = icosahedronPoints[icosahedronIndices[3 * j + 2]] * radius + center;
{
PxVec3 fnormal = (v1 - v0).cross(v2 - v0);
fnormal.normalize();
pushVertex(v0, v1, v2, fnormal);
}
numTotalTriangles++;
}
}
glScalef(1.0f, 1.0f, 1.0f);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
const PxVec3* vertexBuffer = getVertexBuffer();
glNormalPointer(GL_FLOAT, 2 * 3 * sizeof(float), vertexBuffer);
glVertexPointer(3, GL_FLOAT, 2 * 3 * sizeof(float), vertexBuffer + 1);
glDrawArrays(GL_TRIANGLES, 0, int(numTotalTriangles * 3));
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
}
glPopMatrix();
}
void DrawPoints(const PxArray<PxVec3>& pts, const PxVec3& color, float scale)
{
glPointSize(scale);
glDisable(GL_LIGHTING);
glColor4f(color.x, color.y, color.z, 1.0f);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(PxVec3), pts.begin());
glDrawArrays(GL_POINTS, 0, pts.size());
glDisableClientState(GL_VERTEX_ARRAY);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glEnable(GL_LIGHTING);
}
void DrawPoints(const PxArray<PxVec4>& pts, const PxVec3& color, float scale)
{
glPointSize(scale);
glDisable(GL_LIGHTING);
glColor4f(color.x, color.y, color.z, 1.0f);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(PxVec4), pts.begin());
glDrawArrays(GL_POINTS, 0, pts.size());
glDisableClientState(GL_VERTEX_ARRAY);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glEnable(GL_LIGHTING);
}
void DrawPoints(const physx::PxArray<physx::PxVec3>& pts, const physx::PxArray<physx::PxVec3>& colors, float scale)
{
glPointSize(scale);
glDisable(GL_LIGHTING);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(PxVec3), pts.begin());
glColorPointer(3, GL_FLOAT, sizeof(PxVec3), colors.begin());
glDrawArrays(GL_POINTS, 0, pts.size());
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glEnable(GL_LIGHTING);
}
void DrawPoints(const physx::PxArray<physx::PxVec4>& pts, const physx::PxArray<physx::PxVec3>& colors, float scale)
{
glPointSize(scale);
glDisable(GL_LIGHTING);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(PxVec4), pts.begin());
glColorPointer(3, GL_FLOAT, sizeof(PxVec3), colors.begin());
glDrawArrays(GL_POINTS, 0, pts.size());
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glEnable(GL_LIGHTING);
}
#if PX_SUPPORT_GPU_PHYSX
namespace
{
void createVBO(GLuint* vbo, PxU32 size)
{
PX_ASSERT(vbo);
// create buffer object
glGenBuffers(1, vbo);
glBindBuffer(GL_ARRAY_BUFFER, *vbo);
// initialize buffer object
glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void deleteVBO(GLuint* vbo)
{
glBindBuffer(1, *vbo);
glDeleteBuffers(1, vbo);
*vbo = 0;
}
#if USE_CUDA_INTEROP
//Returns the pointer to the cuda buffer
void* mapCudaGraphicsResource(CUgraphicsResource* vbo_resource, size_t& numBytes, CUstream stream = 0)
{
CUresult result0 = cuGraphicsMapResources(1, vbo_resource, stream);
PX_UNUSED(result0);
void* dptr;
CUresult result1 = cuGraphicsResourceGetMappedPointer((CUdeviceptr*)&dptr, &numBytes, *vbo_resource);
PX_UNUSED(result1);
return dptr;
}
void unmapCudaGraphicsResource(CUgraphicsResource* vbo_resource, CUstream stream = 0)
{
CUresult result2 = cuGraphicsUnmapResources(1, vbo_resource, stream);
PX_UNUSED(result2);
}
#endif
} // namespace
SharedGLBuffer::SharedGLBuffer() : vbo_res(NULL), devicePointer(NULL), vbo(0), size(0)
{
}
void SharedGLBuffer::initialize(PxCudaContextManager* contextManager)
{
cudaContextManager = contextManager;
}
void SharedGLBuffer::allocate(PxU32 sizeInBytes)
{
release();
createVBO(&vbo, sizeInBytes);
#if USE_CUDA_INTEROP
physx::PxCudaInteropRegisterFlags flags = physx::PxCudaInteropRegisterFlags();
cudaContextManager->acquireContext();
CUresult result = cuGraphicsGLRegisterBuffer(reinterpret_cast<CUgraphicsResource*>(&vbo_res), vbo, flags);
PX_UNUSED(result);
cudaContextManager->releaseContext();
#endif
size = sizeInBytes;
}
void SharedGLBuffer::release()
{
if (vbo)
{
deleteVBO(&vbo);
vbo = 0;
}
#if USE_CUDA_INTEROP
if (vbo_res)
{
cudaContextManager->acquireContext();
CUresult result = cuGraphicsUnregisterResource(reinterpret_cast<CUgraphicsResource>(vbo_res));
PX_UNUSED(result);
cudaContextManager->releaseContext();
vbo_res = NULL;
}
#endif
}
SharedGLBuffer::~SharedGLBuffer()
{
//release();
}
void* SharedGLBuffer::map()
{
if (devicePointer)
return devicePointer;
#if USE_CUDA_INTEROP
size_t numBytes;
cudaContextManager->acquireContext();
devicePointer = mapCudaGraphicsResource(reinterpret_cast<CUgraphicsResource*>(&vbo_res), numBytes, 0);
cudaContextManager->releaseContext();
#else
glBindBuffer(GL_ARRAY_BUFFER, vbo);
devicePointer = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
#endif
return devicePointer;
}
void SharedGLBuffer::unmap()
{
if (!devicePointer)
return;
#if USE_CUDA_INTEROP
cudaContextManager->acquireContext();
unmapCudaGraphicsResource(reinterpret_cast<CUgraphicsResource*>(&vbo_res), 0);
cudaContextManager->releaseContext();
#else
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glUnmapBuffer(GL_ARRAY_BUFFER);
glBindBuffer(GL_ARRAY_BUFFER, 0);
#endif
devicePointer = NULL;
}
#endif // PX_SUPPORT_GPU_PHYSX
void DrawPoints(GLuint vbo, PxU32 numPoints, const PxVec3& color, float scale, PxU32 coordinatesPerPoint, PxU32 stride, size_t offset)
{
glPointSize(scale);
glDisable(GL_LIGHTING);
glColor4f(color.x, color.y, color.z, 1.0f);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(coordinatesPerPoint, GL_FLOAT, stride, (void*)offset /*offsetof(Vertex, pos)*/);
glDrawArrays(GL_POINTS, 0, numPoints);
glDisableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glEnable(GL_LIGHTING);
}
void DrawLines(GLuint vbo, PxU32 numPoints, const PxVec3& color, float scale, PxU32 coordinatesPerPoint, PxU32 stride, size_t offset)
{
PX_ASSERT(numPoints % 2 == 0);
glLineWidth(scale);
glDisable(GL_LIGHTING);
glColor4f(color.x, color.y, color.z, 1.0f);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(coordinatesPerPoint, GL_FLOAT, stride, (void*)offset /*offsetof(Vertex, pos)*/);
glDrawArrays(GL_LINES, 0, numPoints);
glDisableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glEnable(GL_LIGHTING);
}
void DrawMeshIndexed(GLuint vbo, GLuint elementbuffer, GLuint numTriangles, const physx::PxVec3& color, physx::PxU32 stride)
{
/*glPushMatrix();
glScalef(1.0f, 1.0f, 1.0f);*/
if(gWireFrame)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glColor4f(color.x, color.y, color.z, 1.0f);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, stride, (void*)0);
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, stride, (void*)(3 * sizeof(float)));
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementbuffer);
glDrawElements(GL_TRIANGLES, int(numTriangles * 3), GL_UNSIGNED_INT, (void*)0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
//glPopMatrix();
if (gWireFrame)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
void DrawMeshIndexedNoNormals(GLuint vbo, GLuint elementbuffer, GLuint numTriangles, const physx::PxVec3& color, physx::PxU32 stride)
{
/*glPushMatrix();
glScalef(1.0f, 1.0f, 1.0f);*/
glColor4f(color.x, color.y, color.z, 1.0f);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, stride, (void*)0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementbuffer);
glDrawElements(GL_TRIANGLES, int(numTriangles * 3), GL_UNSIGNED_INT, (void*)0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
//glPopMatrix();
}
void DrawFrame(const PxVec3& pt, float scale)
{
DrawLine(pt, pt + PxVec3(scale, 0.0f, 0.0f), PxVec3(1.0f, 0.0f, 0.0f));
DrawLine(pt, pt + PxVec3(0.0f, scale, 0.0f), PxVec3(0.0f, 1.0f, 0.0f));
DrawLine(pt, pt + PxVec3(0.0f, 0.0f, scale), PxVec3(0.0f, 0.0f, 1.0f));
}
void DrawBounds(const physx::PxBounds3& box, const physx::PxVec3& color)
{
DrawLine(PxVec3(box.minimum.x, box.minimum.y, box.minimum.z), PxVec3(box.maximum.x, box.minimum.y, box.minimum.z), color);
DrawLine(PxVec3(box.maximum.x, box.minimum.y, box.minimum.z), PxVec3(box.maximum.x, box.maximum.y, box.minimum.z), color);
DrawLine(PxVec3(box.maximum.x, box.maximum.y, box.minimum.z), PxVec3(box.minimum.x, box.maximum.y, box.minimum.z), color);
DrawLine(PxVec3(box.minimum.x, box.maximum.y, box.minimum.z), PxVec3(box.minimum.x, box.minimum.y, box.minimum.z), color);
DrawLine(PxVec3(box.minimum.x, box.minimum.y, box.minimum.z), PxVec3(box.minimum.x, box.minimum.y, box.maximum.z), color);
DrawLine(PxVec3(box.minimum.x, box.minimum.y, box.maximum.z), PxVec3(box.maximum.x, box.minimum.y, box.maximum.z), color);
DrawLine(PxVec3(box.maximum.x, box.minimum.y, box.maximum.z), PxVec3(box.maximum.x, box.maximum.y, box.maximum.z), color);
DrawLine(PxVec3(box.maximum.x, box.maximum.y, box.maximum.z), PxVec3(box.minimum.x, box.maximum.y, box.maximum.z), color);
DrawLine(PxVec3(box.minimum.x, box.maximum.y, box.maximum.z), PxVec3(box.minimum.x, box.minimum.y, box.maximum.z), color);
DrawLine(PxVec3(box.minimum.x, box.minimum.y, box.maximum.z), PxVec3(box.minimum.x, box.minimum.y, box.minimum.z), color);
DrawLine(PxVec3(box.maximum.x, box.minimum.y, box.minimum.z), PxVec3(box.maximum.x, box.minimum.y, box.maximum.z), color);
DrawLine(PxVec3(box.maximum.x, box.maximum.y, box.minimum.z), PxVec3(box.maximum.x, box.maximum.y, box.maximum.z), color);
DrawLine(PxVec3(box.minimum.x, box.maximum.y, box.minimum.z), PxVec3(box.minimum.x, box.maximum.y, box.maximum.z), color);
}
void DrawBounds(const PxBounds3& box)
{
const PxVec3 color(1.0f, 1.0f, 0.0f);
DrawBounds(box, color);
}
GLuint CreateTexture(PxU32 width, PxU32 height, const GLubyte* buffer, bool createMipmaps)
{
GLuint texId;
glGenTextures(1, &texId);
glBindTexture(GL_TEXTURE_2D, texId);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
if(buffer)
{
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
if(createMipmaps)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
}
}
glBindTexture(GL_TEXTURE_2D, 0);
return texId;
}
void UpdateTexture(GLuint texId, physx::PxU32 width, physx::PxU32 height, const GLubyte* buffer, bool createMipmaps)
{
glBindTexture(GL_TEXTURE_2D, texId);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
if(createMipmaps)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, width, height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
}
glBindTexture( GL_TEXTURE_2D, 0);
}
void ReleaseTexture(GLuint texId)
{
glDeleteTextures(1, &texId);
}
void DrawRectangle(float x_start, float x_end, float y_start, float y_end, const PxVec3& color_top, const PxVec3& color_bottom, float alpha, PxU32 screen_width, PxU32 screen_height, bool draw_outline, bool texturing)
{
if(alpha!=1.0f)
{
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
}
else
{
glDisable(GL_BLEND);
}
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_CULL_FACE);
if(texturing)
glEnable(GL_TEXTURE_2D);
else
glDisable(GL_TEXTURE_2D);
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, screen_width, 0, screen_height, -1, 1);
}
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
const float x0 = x_start * float(screen_width);
const float x1 = x_end * float(screen_width);
const float y0 = y_start * float(screen_height);
const float y1 = y_end * float(screen_height);
const PxVec3 p0(x0, y0, 0.0f);
const PxVec3 p1(x0, y1, 0.0f);
const PxVec3 p2(x1, y1, 0.0f);
const PxVec3 p3(x1, y0, 0.0f);
// const float u = (texture_flags & SQT_FLIP_U) ? 1.0f : 0.0f;
// const float v = (texture_flags & SQT_FLIP_V) ? 1.0f : 0.0f;
const float u = 0.0f;
const float v = 1.0f;
const PxVec3 t0(u, v, 0.0f);
const PxVec3 t1(u, 1.0f - v, 0.0f);
const PxVec3 t2(1.0f - u, 1.0f - v, 0.0f);
const PxVec3 t3(1.0f - u, v, 0.0f);
glBegin(GL_TRIANGLES);
glTexCoord2f(t0.x, t0.y);
glColor4f(color_top.x, color_top.y, color_top.z, alpha);
glVertex3f(p0.x, p0.y, p0.z);
glTexCoord2f(t1.x, t1.y);
glColor4f(color_bottom.x, color_bottom.y, color_bottom.z, alpha);
glVertex3f(p1.x, p1.y, p1.z);
glTexCoord2f(t2.x, t2.y);
glColor4f(color_bottom.x, color_bottom.y, color_bottom.z, alpha);
glVertex3f(p2.x, p2.y, p2.z);
glTexCoord2f(t0.x, t0.y);
glColor4f(color_top.x, color_top.y, color_top.z, alpha);
glVertex3f(p0.x, p0.y, p0.z);
glTexCoord2f(t2.x, t2.y);
glColor4f(color_bottom.x, color_bottom.y, color_bottom.z, alpha);
glVertex3f(p2.x, p2.y, p2.z);
glTexCoord2f(t3.x, t3.y);
glColor4f(color_top.x, color_top.y, color_top.z, alpha);
glVertex3f(p3.x, p3.y, p3.z);
glEnd();
if(draw_outline)
{
glDisable(GL_TEXTURE_2D);
glColor4f(1.0f, 1.0f, 1.0f, alpha);
glBegin(GL_LINES);
glVertex3f(p0.x, p0.y, p0.z);
glVertex3f(p1.x, p1.y, p1.z);
glVertex3f(p1.x, p1.y, p1.z);
glVertex3f(p2.x, p2.y, p2.z);
glVertex3f(p2.x, p2.y, p2.z);
glVertex3f(p3.x, p3.y, p3.z);
glVertex3f(p3.x, p3.y, p3.z);
glVertex3f(p0.x, p0.y, p0.z);
glEnd();
}
{
glMatrixMode(GL_PROJECTION);
glPopMatrix();
}
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glDisable(GL_BLEND);
}
void DisplayTexture(GLuint texId, PxU32 size, PxU32 margin)
{
const PxU32 screenWidth = gScreenWidth;
const PxU32 screenHeight = gScreenHeight;
glBindTexture(GL_TEXTURE_2D, texId);
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// glDisable(GL_CULL_FACE);
const PxVec3 color(1.0f, 1.0f, 1.0f);
// const float Alpha = 0.999f;
// const float Alpha = 0.5f;
const float Alpha = 1.0f;
PxU32 PixelSizeX = size;
PxU32 PixelSizeY = size;
if(!size)
{
PixelSizeX = gScreenWidth;
PixelSizeY = gScreenHeight;
margin = 0;
}
const float x0 = float(screenWidth-PixelSizeX-margin)/float(screenWidth);
const float y0 = float(screenHeight-PixelSizeY-margin)/float(screenHeight);
const float x1 = float(screenWidth-margin)/float(screenWidth);
const float y1 = float(screenHeight-margin)/float(screenHeight);
DrawRectangle(x0, x1, y0, y1, color, color, Alpha, screenWidth, screenHeight, false, true);
glDisable(GL_TEXTURE_2D);
}
} //namespace Snippets
| 53,539 | C++ | 29.734788 | 216 | 0.705915 |
NVIDIA-Omniverse/PhysX/physx/snippets/snippetrender/SnippetFontData.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
// auto generated don't touch
static const int OGL_FONT_TEXTURE_WIDTH=256;
static const int OGL_FONT_TEXTURE_HEIGHT=128;
static const int OGL_FONT_CHARS_PER_ROW=16;
static const int OGL_FONT_CHARS_PER_COL=8;
static const int OGL_FONT_CHAR_BASE=32;
int GLFontGlyphWidth[OGL_FONT_CHARS_PER_ROW*OGL_FONT_CHARS_PER_COL] = {
6,7,8,11,10,10,11,7,10,8,10,10,8,9,8,10,
11,11,11,11,11,11,11,11,11,11,8,8,10,10,10,10,
11,10,10,10,11,10,10,10,10,10,9,11,10,10,10,10,
10,11,11,10,10,10,10,10,10,10,10,10,10,7,10,10,
8,10,10,10,9,9,10,9,10,8,8,11,8,10,10,10,
10,9,10,10,9,10,10,10,10,10,9,9,6,9,10,10,
10,10,9,10,10,10,10,10,9,9,9,9,9,8,10,10,
10,11,10,10,10,10,10,10,10,10,10,10,9,10,10,10
};
unsigned char OGLFontData[OGL_FONT_TEXTURE_WIDTH * OGL_FONT_TEXTURE_HEIGHT] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,117,68,0,101,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,185,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,85,68,0,0,0,0,0,0,0,0,117,32,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,101,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,136,101,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,185,185,0,0,0,0,0,0,0,0,0,0,0,0,0,68,117,0,117,85,0,0,0,
0,0,0,0,0,0,0,68,169,254,185,136,48,0,0,0,0,0,0,0,16,152,185,85,0,0,0,117,169,0,0,0,
0,0,0,0,0,0,0,48,221,254,152,16,0,0,0,0,0,0,0,0,0,0,0,0,237,237,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,68,221,205,68,0,0,0,0,0,0,0,0,152,237,136,16,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,101,136,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,101,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,117,0,0,0,0,0,0,
0,0,0,0,0,0,221,101,0,152,152,0,0,0,0,0,0,0,0,0,0,0,0,0,152,101,0,221,32,0,0,0,
0,0,0,0,0,0,85,254,117,254,68,117,101,0,0,0,0,0,0,0,169,117,16,221,48,0,48,221,16,0,0,0,
0,0,0,0,0,0,0,221,169,48,254,117,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,68,254,101,0,0,0,0,0,0,0,0,0,0,0,16,205,205,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,101,152,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,221,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,117,0,0,0,0,0,0,
0,0,0,0,0,0,185,68,0,117,117,0,0,0,0,0,0,0,0,0,0,0,0,0,221,32,32,221,0,0,0,0,
0,0,0,0,0,0,169,205,0,254,0,0,0,0,0,0,0,0,0,0,254,0,0,117,117,0,205,68,0,0,0,0,
0,0,0,0,0,0,0,254,117,16,254,117,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,
0,0,0,0,0,0,0,16,237,117,0,0,0,0,0,0,0,0,0,0,0,0,0,16,237,117,0,0,0,0,0,0,
0,0,0,0,0,0,185,117,68,101,101,221,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,101,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,117,0,0,0,0,0,0,
0,0,0,0,0,0,101,32,0,68,68,0,0,0,0,0,0,0,0,0,0,32,117,117,254,117,169,205,117,32,0,0,
0,0,0,0,0,0,169,221,16,254,0,0,0,0,0,0,0,0,0,0,221,32,0,152,101,136,136,0,0,0,0,0,
0,0,0,0,0,0,0,205,205,117,237,32,0,0,0,0,0,0,0,0,0,0,0,0,117,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,117,254,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,136,237,0,0,0,0,0,0,
0,0,0,0,0,0,32,85,68,32,101,48,0,0,0,0,0,0,0,0,0,0,0,0,101,32,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,221,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,117,185,185,117,221,152,117,0,0,0,
0,0,0,0,0,0,48,237,205,254,0,0,0,0,0,0,0,0,0,0,101,205,136,205,85,205,0,0,0,0,0,0,
0,0,0,0,0,0,16,169,254,221,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,
0,0,0,0,0,0,0,101,205,136,152,0,0,0,0,0,0,0,0,0,0,0,0,0,185,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,101,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,169,85,0,237,16,0,0,0,0,
0,0,0,0,0,0,0,48,221,254,152,16,0,0,0,0,0,0,0,0,0,32,68,16,221,48,0,0,0,0,0,0,
0,0,0,0,0,48,221,169,221,185,0,0,136,136,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,237,101,32,254,48,0,0,0,0,0,0,0,0,0,0,0,0,185,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,221,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,68,254,68,117,205,68,32,0,0,0,
0,0,0,0,0,0,0,0,0,254,237,237,48,0,0,0,0,0,0,0,0,0,0,169,117,136,205,205,48,0,0,0,
0,0,0,0,0,185,185,0,101,254,68,0,185,152,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,32,0,0,32,0,0,0,0,0,0,0,0,0,0,68,68,68,205,117,68,68,32,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,254,254,254,254,254,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,101,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,48,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,169,205,237,185,237,205,185,85,0,0,0,
0,0,0,0,0,0,0,0,0,254,48,237,152,0,0,0,0,0,0,0,0,0,101,185,85,185,0,68,205,0,0,0,
0,0,0,0,0,254,117,0,0,185,237,16,221,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,237,136,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,185,185,237,205,185,185,101,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,221,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,136,117,0,205,48,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,0,185,185,0,0,0,0,0,0,0,0,32,221,16,117,117,0,0,254,0,0,0,
0,0,0,0,0,221,185,0,0,16,237,205,237,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,169,205,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,254,48,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,68,68,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,68,68,16,0,0,0,0,0,0,0,0,0,0,0,0,185,101,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,101,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,205,48,16,237,0,0,0,0,0,0,
0,0,0,0,0,0,136,68,0,254,48,254,101,0,0,0,0,0,0,0,0,185,85,0,85,185,0,68,205,0,0,0,
0,0,0,0,0,117,254,117,0,32,185,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,101,254,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,152,221,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,254,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,254,68,0,0,0,0,0,0,0,0,0,0,0,68,221,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,185,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,221,0,101,152,0,0,0,0,0,0,
0,0,0,0,0,0,152,221,254,254,237,117,0,0,0,0,0,0,0,0,117,152,0,0,0,136,205,205,48,0,0,0,
0,0,0,0,0,0,117,221,254,221,117,136,254,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,205,169,0,0,0,0,0,0,0,0,0,0,0,0,0,48,254,85,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,254,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,254,68,0,0,0,0,0,0,0,0,0,0,0,185,101,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,68,16,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,32,237,152,16,0,0,0,0,0,0,0,0,0,0,68,237,136,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,16,254,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,221,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,16,152,254,101,0,0,0,0,0,0,0,0,221,221,85,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,169,136,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,152,101,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,16,32,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,48,205,254,221,101,0,0,0,0,0,0,0,0,0,0,0,0,48,117,169,117,0,0,0,0,0,
0,0,0,0,0,0,117,205,254,254,169,32,0,0,0,0,0,0,0,0,0,0,185,254,254,237,136,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,136,185,0,0,0,0,0,0,0,0,0,0,0,136,185,185,185,185,48,0,0,0,0,
0,0,0,0,0,0,16,117,237,254,221,101,0,0,0,0,0,0,0,0,0,0,185,185,185,185,185,185,101,0,0,0,
0,0,0,0,0,0,85,221,254,254,169,16,0,0,0,0,0,0,0,0,0,0,101,221,254,205,85,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,169,221,254,254,221,117,16,0,0,0,
0,0,0,0,0,16,237,117,0,68,254,68,0,0,0,0,0,0,0,0,0,0,221,221,152,254,117,0,0,0,0,0,
0,0,0,0,0,0,117,48,0,32,205,221,0,0,0,0,0,0,0,0,0,0,101,32,0,68,254,117,0,0,0,0,
0,0,0,0,0,0,0,0,101,254,254,0,0,0,0,0,0,0,0,0,0,0,185,185,117,117,117,32,0,0,0,0,
0,0,0,0,0,0,185,152,32,0,48,68,0,0,0,0,0,0,0,0,0,0,117,117,117,117,136,254,117,0,0,0,
0,0,0,0,0,32,254,101,0,68,254,152,0,0,0,0,0,0,0,0,0,85,254,68,0,117,254,32,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,32,0,0,101,254,136,0,0,0,
0,0,0,0,0,117,221,0,0,0,152,169,0,0,0,0,0,0,0,0,0,0,32,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,85,254,68,0,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,
0,0,0,0,0,0,0,32,221,152,254,0,0,0,0,0,0,0,0,0,0,0,185,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,101,221,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,205,0,0,0,0,
0,0,0,0,0,117,254,0,0,0,185,185,0,0,0,0,0,0,0,0,0,205,152,0,0,0,169,152,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,0,0,0,0,185,185,0,0,0,
0,0,0,0,0,185,152,0,0,0,101,254,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,85,254,48,0,0,0,0,0,0,0,0,0,0,0,0,16,221,117,0,0,0,0,
0,0,0,0,0,0,0,185,117,117,254,0,0,0,0,0,0,0,0,0,0,0,185,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,169,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,237,68,0,0,0,0,
0,0,0,0,0,101,254,117,0,32,254,101,0,0,0,0,0,0,0,0,0,254,117,0,0,0,117,205,0,0,0,0,
0,0,0,0,0,0,0,0,254,254,68,0,0,0,0,0,0,0,0,0,0,0,0,0,254,254,68,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,32,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,254,85,0,0,0,
0,0,0,0,0,254,117,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,185,205,0,0,0,0,0,0,0,0,0,0,16,68,85,185,169,0,0,0,0,0,
0,0,0,0,0,0,117,185,0,117,254,0,0,0,0,0,0,0,0,0,0,0,185,185,117,32,0,0,0,0,0,0,
0,0,0,0,0,237,85,169,254,237,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,152,152,0,0,0,0,0,
0,0,0,0,0,0,152,254,152,205,117,0,0,0,0,0,0,0,0,0,0,237,152,0,0,0,136,254,0,0,0,0,
0,0,0,0,0,0,0,0,254,254,68,0,0,0,0,0,0,0,0,0,0,0,0,0,254,254,68,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,32,152,237,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,185,221,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,237,117,0,0,0,0,
0,0,0,0,0,254,117,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,152,237,48,0,0,0,0,0,0,0,0,0,0,48,185,205,237,117,0,0,0,0,0,
0,0,0,0,0,48,237,16,0,117,254,0,0,0,0,0,0,0,0,0,0,0,101,117,185,254,101,0,0,0,0,0,
0,0,0,0,0,254,221,68,0,117,254,117,0,0,0,0,0,0,0,0,0,0,0,0,68,254,32,0,0,0,0,0,
0,0,0,0,0,0,101,237,254,237,85,0,0,0,0,0,0,0,0,0,0,152,237,48,0,16,221,254,0,0,0,0,
0,0,0,0,0,0,0,0,68,68,16,0,0,0,0,0,0,0,0,0,0,0,0,0,68,68,16,0,0,0,0,0,
0,0,0,0,0,0,0,32,152,237,117,16,0,0,0,0,0,0,0,0,0,117,117,117,117,117,117,117,101,0,0,0,
0,0,0,0,0,0,68,185,221,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,254,85,0,0,0,0,0,
0,0,0,0,0,254,117,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,0,152,237,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,237,136,0,0,0,0,
0,0,0,0,0,205,85,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,254,48,0,0,0,0,
0,0,0,0,0,254,152,0,0,0,169,221,0,0,0,0,0,0,0,0,0,0,0,0,185,152,0,0,0,0,0,0,
0,0,0,0,0,85,237,48,32,205,254,101,0,0,0,0,0,0,0,0,0,16,185,254,185,221,117,254,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,32,152,237,117,16,0,0,0,0,0,0,0,0,0,0,0,117,117,117,117,117,117,117,101,0,0,0,
0,0,0,0,0,0,0,0,68,185,221,101,0,0,0,0,0,0,0,0,0,0,0,0,205,152,0,0,0,0,0,0,
0,0,0,0,0,205,136,0,0,0,101,254,16,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,117,237,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,136,237,0,0,0,0,
0,0,0,0,0,254,254,254,254,254,254,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,
0,0,0,0,0,221,117,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,68,254,32,0,0,0,0,0,0,
0,0,0,0,0,221,152,0,0,0,221,237,0,0,0,0,0,0,0,0,0,0,0,48,68,0,117,185,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,101,221,185,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,16,117,237,152,32,0,0,0,0,0,0,0,0,0,0,0,185,101,0,0,0,0,0,0,
0,0,0,0,0,136,205,0,0,0,136,205,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,136,254,0,0,0,0,
0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,254,117,0,0,0,0,
0,0,0,0,0,169,152,0,0,0,136,221,0,0,0,0,0,0,0,0,0,0,0,185,152,0,0,0,0,0,0,0,
0,0,0,0,0,254,117,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,117,0,0,0,0,
0,0,0,0,0,0,0,0,68,68,16,0,0,0,0,0,0,0,0,0,0,0,0,0,68,68,16,0,0,0,0,0,
0,0,0,0,0,0,0,101,221,185,68,0,0,0,0,0,0,0,0,0,0,254,254,254,254,254,254,254,185,0,0,0,
0,0,0,0,0,0,16,117,237,152,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,32,254,68,0,16,237,101,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,221,221,68,68,68,68,16,0,0,0,0,0,0,0,0,0,32,0,0,16,237,152,0,0,0,0,
0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,16,0,0,152,254,32,0,0,0,0,
0,0,0,0,0,68,237,48,0,16,237,117,0,0,0,0,0,0,0,0,0,0,48,254,85,0,0,0,0,0,0,0,
0,0,0,0,0,169,221,16,0,16,205,152,0,0,0,0,0,0,0,0,0,32,0,0,0,101,221,16,0,0,0,0,
0,0,0,0,0,0,0,0,254,254,68,0,0,0,0,0,0,0,0,0,0,0,0,0,254,254,68,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,101,221,185,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,117,237,152,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,117,68,0,0,0,0,0,0,
0,0,0,0,0,0,101,237,185,237,136,0,0,0,0,0,0,0,0,0,0,0,254,254,254,254,254,254,254,117,0,0,
0,0,0,0,0,0,254,254,254,254,254,254,68,0,0,0,0,0,0,0,0,0,254,205,185,254,185,16,0,0,0,0,
0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,254,185,205,237,85,0,0,0,0,0,
0,0,0,0,0,0,117,254,185,237,152,0,0,0,0,0,0,0,0,0,0,0,117,254,16,0,0,0,0,0,0,0,
0,0,0,0,0,16,205,237,185,237,185,16,0,0,0,0,0,0,0,0,0,117,237,185,221,185,48,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,254,68,0,0,0,0,0,0,0,0,0,0,0,0,0,254,254,68,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,101,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,152,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,16,68,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,68,68,32,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,68,68,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,16,68,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,48,68,32,0,0,0,0,0,0,0,0,0,0,0,0,32,68,48,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,254,32,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,169,136,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,117,221,254,221,85,0,0,0,0,0,0,0,0,0,0,0,85,185,85,0,0,0,0,0,0,
0,0,0,0,0,0,185,185,185,185,169,68,0,0,0,0,0,0,0,0,0,0,0,101,185,254,254,221,136,0,0,0,
0,0,0,0,0,0,185,185,185,185,117,32,0,0,0,0,0,0,0,0,0,0,185,185,185,185,185,185,101,0,0,0,
0,0,0,0,0,0,185,185,185,185,185,185,136,0,0,0,0,0,0,0,0,0,0,101,185,254,254,221,136,0,0,0,
0,0,0,0,0,0,185,101,0,0,0,185,101,0,0,0,0,0,0,0,0,0,185,185,185,185,185,185,101,0,0,0,
0,0,0,0,0,0,48,185,185,185,185,48,0,0,0,0,0,0,0,0,0,0,185,101,0,0,16,169,101,0,0,0,
0,0,0,0,0,0,185,101,0,0,0,0,0,0,0,0,0,0,0,0,0,185,169,0,0,0,32,185,136,0,0,0,
0,0,0,0,0,0,185,117,0,0,0,101,136,0,0,0,0,0,0,0,0,0,16,169,254,254,169,16,0,0,0,0,
0,0,0,0,0,0,152,205,32,0,68,237,0,0,0,0,0,0,0,0,0,0,0,169,254,169,0,0,0,0,0,0,
0,0,0,0,0,0,254,152,68,85,205,254,32,0,0,0,0,0,0,0,0,0,152,237,101,0,0,68,117,0,0,0,
0,0,0,0,0,0,254,152,68,101,185,237,48,0,0,0,0,0,0,0,0,0,254,152,68,68,68,68,32,0,0,0,
0,0,0,0,0,0,254,152,68,68,68,68,48,0,0,0,0,0,0,0,0,0,152,237,101,0,0,48,101,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,68,68,152,254,68,68,32,0,0,0,
0,0,0,0,0,0,16,68,68,117,254,68,0,0,0,0,0,0,0,0,0,0,254,117,0,0,152,205,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,254,48,0,0,117,254,185,0,0,0,
0,0,0,0,0,0,254,254,32,0,0,117,185,0,0,0,0,0,0,0,0,16,205,152,16,16,152,205,16,0,0,0,
0,0,0,0,0,68,221,16,0,117,185,221,68,0,0,0,0,0,0,0,0,0,16,254,205,254,16,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,16,254,117,0,0,0,0,0,0,0,0,68,254,85,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,16,221,169,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,68,254,85,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,254,117,0,85,237,48,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,205,136,0,0,205,205,185,0,0,0,
0,0,0,0,0,0,254,254,152,0,0,117,185,0,0,0,0,0,0,0,0,117,237,16,0,0,16,237,117,0,0,0,
0,0,0,0,0,152,117,0,136,117,0,205,68,0,0,0,0,0,0,0,0,0,101,237,48,254,101,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,32,254,101,0,0,0,0,0,0,0,0,169,221,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,117,254,16,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,169,221,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,254,117,32,237,117,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,221,0,32,237,117,185,0,0,0,
0,0,0,0,0,0,254,221,254,32,0,117,185,0,0,0,0,0,0,0,0,185,169,0,0,0,0,169,185,0,0,0,
0,0,0,0,0,221,32,16,221,0,0,205,68,0,0,0,0,0,0,0,0,0,169,136,0,221,169,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,48,205,185,0,0,0,0,0,0,0,0,0,237,152,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,68,254,68,0,0,0,0,0,0,0,0,254,152,68,68,68,48,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,237,152,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,254,117,185,169,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,16,254,68,117,169,117,185,0,0,0,
0,0,0,0,0,0,254,101,237,152,0,117,185,0,0,0,0,0,0,0,0,254,117,0,0,0,0,117,254,0,0,0,
0,0,0,0,0,254,0,68,185,0,32,254,68,0,0,0,0,0,0,0,0,32,254,48,0,117,254,32,0,0,0,0,
0,0,0,0,0,0,254,254,254,254,205,16,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,68,254,68,0,0,0,0,0,0,0,0,254,221,185,185,185,136,0,0,0,0,
0,0,0,0,0,0,254,221,185,185,185,185,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,254,254,254,254,254,117,0,0,0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,254,221,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,0,169,152,221,101,117,185,0,0,0,
0,0,0,0,0,0,254,68,117,254,68,117,185,0,0,0,0,0,0,0,0,254,117,0,0,0,0,117,254,0,0,0,
0,0,0,0,0,254,0,68,205,0,152,221,68,0,0,0,0,0,0,0,0,117,221,0,0,32,254,117,0,0,0,0,
0,0,0,0,0,0,254,117,0,48,185,237,32,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,68,254,68,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,152,68,68,68,68,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,136,136,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,254,117,185,237,48,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,0,101,237,254,16,117,185,0,0,0,
0,0,0,0,0,0,254,68,16,237,185,117,185,0,0,0,0,0,0,0,0,254,117,0,0,0,0,117,254,0,0,0,
0,0,0,0,0,205,68,0,237,152,152,185,152,32,0,0,0,0,0,0,0,205,254,254,254,254,254,205,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,16,237,152,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,117,254,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,185,185,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,254,117,16,237,205,16,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,0,16,237,169,0,117,185,0,0,0,
0,0,0,0,0,0,254,68,0,117,254,185,185,0,0,0,0,0,0,0,0,205,152,0,0,0,0,152,205,0,0,0,
0,0,0,0,0,117,169,0,48,117,16,101,117,32,0,0,0,0,0,0,32,254,48,0,0,0,117,254,32,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,185,185,0,0,0,0,0,0,0,0,117,254,48,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,221,169,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,101,254,48,0,0,0,185,185,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,68,254,48,0,0,0,0,0,0,0,0,0,0,254,117,0,68,254,152,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,0,0,0,0,0,117,185,0,0,0,
0,0,0,0,0,0,254,68,0,16,237,254,185,0,0,0,0,0,0,0,0,136,221,0,0,0,0,221,136,0,0,0,
0,0,0,0,0,16,205,152,16,0,85,32,0,0,0,0,0,0,0,0,117,221,0,0,0,0,32,254,117,0,0,0,
0,0,0,0,0,0,254,117,0,0,68,254,117,0,0,0,0,0,0,0,0,0,205,237,68,0,0,0,32,0,0,0,
0,0,0,0,0,0,254,117,0,32,169,237,32,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,205,237,68,0,0,185,185,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,
0,0,0,0,0,0,16,0,0,117,237,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,117,254,101,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,0,0,0,0,0,117,185,0,0,0,
0,0,0,0,0,0,254,68,0,0,117,254,185,0,0,0,0,0,0,0,0,32,237,117,0,0,117,237,32,0,0,0,
0,0,0,0,0,0,16,152,254,254,169,32,0,0,0,0,0,0,0,0,205,117,0,0,0,0,0,185,205,0,0,0,
0,0,0,0,0,0,254,254,254,254,237,117,0,0,0,0,0,0,0,0,0,0,16,152,254,221,185,221,169,0,0,0,
0,0,0,0,0,0,254,254,254,237,152,32,0,0,0,0,0,0,0,0,0,0,254,254,254,254,254,254,185,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,152,254,205,185,237,152,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,254,254,254,254,254,254,117,0,0,0,
0,0,0,0,0,0,254,205,205,237,85,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,185,237,48,0,0,
0,0,0,0,0,0,254,254,254,254,254,254,117,0,0,0,0,0,0,0,0,254,0,0,0,0,0,117,185,0,0,0,
0,0,0,0,0,0,254,68,0,0,0,221,185,0,0,0,0,0,0,0,0,0,48,237,205,205,237,48,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,68,68,32,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,68,68,32,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,68,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,117,117,117,101,0,0,0,
0,0,0,0,0,117,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,117,117,117,101,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,185,185,185,185,169,101,0,0,0,0,0,0,0,0,0,0,16,169,254,254,169,16,0,0,0,0,
0,0,0,0,0,0,185,185,185,185,152,48,0,0,0,0,0,0,0,0,0,0,16,152,254,254,237,169,0,0,0,0,
0,0,0,0,185,185,185,185,185,185,185,185,101,0,0,0,0,0,0,0,0,0,185,101,0,0,0,136,101,0,0,0,
0,0,0,0,152,117,0,0,0,0,0,85,152,0,0,0,0,0,0,0,185,48,0,0,0,0,0,48,136,0,0,0,
0,0,0,0,85,185,68,0,0,0,48,185,32,0,0,0,0,0,0,0,117,185,16,0,0,0,0,136,117,0,0,0,
0,0,0,0,0,136,185,185,185,185,185,185,101,0,0,0,0,0,0,0,0,0,0,0,254,185,117,117,101,0,0,0,
0,0,0,0,0,117,152,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,117,117,221,185,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,152,68,68,117,254,136,0,0,0,0,0,0,0,0,16,205,152,16,16,152,205,16,0,0,0,
0,0,0,0,0,0,254,152,68,85,169,237,32,0,0,0,0,0,0,0,0,0,152,169,16,0,48,117,0,0,0,0,
0,0,0,0,68,68,68,152,254,68,68,68,32,0,0,0,0,0,0,0,0,0,254,117,0,0,0,185,117,0,0,0,
0,0,0,0,136,254,16,0,0,0,0,169,136,0,0,0,0,0,0,0,205,117,0,0,0,0,0,117,136,0,0,0,
0,0,0,0,0,221,205,0,0,0,205,169,0,0,0,0,0,0,0,0,32,254,117,0,0,0,68,254,32,0,0,0,
0,0,0,0,0,48,68,68,68,68,152,254,85,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,
0,0,0,0,0,16,237,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,68,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,136,254,0,0,0,0,0,0,0,0,117,237,16,0,0,16,237,117,0,0,0,
0,0,0,0,0,0,254,117,0,0,16,254,117,0,0,0,0,0,0,0,0,0,254,68,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,185,117,0,0,0,
0,0,0,0,48,254,101,0,0,0,32,254,48,0,0,0,0,0,0,0,185,136,0,0,0,0,0,117,117,0,0,0,
0,0,0,0,0,68,254,117,0,117,237,16,0,0,0,0,0,0,0,0,0,136,254,32,0,0,205,136,0,0,0,0,
0,0,0,0,0,0,0,0,0,32,237,169,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,117,152,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,185,237,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,136,254,0,0,0,0,0,0,0,0,185,169,0,0,0,0,169,185,0,0,0,
0,0,0,0,0,0,254,117,0,0,16,254,117,0,0,0,0,0,0,0,0,0,237,169,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,185,117,0,0,0,
0,0,0,0,0,221,169,0,0,0,117,221,0,0,0,0,0,0,0,0,117,185,0,68,185,48,0,185,68,0,0,0,
0,0,0,0,0,0,169,237,48,237,85,0,0,0,0,0,0,0,0,0,0,16,237,185,0,117,237,16,0,0,0,0,
0,0,0,0,0,0,0,0,0,185,237,16,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,16,237,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,
0,0,0,0,0,0,0,68,221,152,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,16,221,169,0,0,0,0,0,0,0,0,254,117,0,0,0,0,117,254,0,0,0,
0,0,0,0,0,0,254,117,0,0,152,237,16,0,0,0,0,0,0,0,0,0,101,254,205,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,185,117,0,0,0,
0,0,0,0,0,136,254,16,0,0,205,136,0,0,0,0,0,0,0,0,117,205,0,117,254,117,0,205,48,0,0,0,
0,0,0,0,0,0,32,237,254,185,0,0,0,0,0,0,0,0,0,0,0,0,101,254,85,237,101,0,0,0,0,0,
0,0,0,0,0,0,0,0,117,254,85,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,117,152,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,
0,0,0,0,0,0,0,152,101,32,221,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,185,117,136,221,205,16,0,0,0,0,0,0,0,0,254,117,0,0,0,0,117,254,0,0,0,
0,0,0,0,0,0,254,221,185,237,185,32,0,0,0,0,0,0,0,0,0,0,0,68,221,254,185,48,0,0,0,0,
0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,185,117,0,0,0,
0,0,0,0,0,48,254,101,0,32,254,48,0,0,0,0,0,0,0,0,68,254,0,185,205,152,0,254,0,0,0,0,
0,0,0,0,0,0,0,136,254,85,0,0,0,0,0,0,0,0,0,0,0,0,0,205,254,205,0,0,0,0,0,0,
0,0,0,0,0,0,0,32,237,185,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,16,237,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,
0,0,0,0,0,0,32,221,0,0,152,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,185,117,117,48,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,117,254,0,0,0,
0,0,0,0,0,0,254,152,68,237,185,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,237,237,68,0,0,0,
0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,185,117,0,0,0,
0,0,0,0,0,0,205,185,0,117,205,0,0,0,0,0,0,0,0,0,32,254,32,221,117,205,32,221,0,0,0,0,
0,0,0,0,0,0,16,237,237,221,0,0,0,0,0,0,0,0,0,0,0,0,0,85,254,85,0,0,0,0,0,0,
0,0,0,0,0,0,0,169,237,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,117,152,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,
0,0,0,0,0,0,152,101,0,0,32,221,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,205,152,0,0,0,0,152,205,0,0,0,
0,0,0,0,0,0,254,117,0,85,254,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,237,169,0,0,0,
0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,185,117,0,0,0,
0,0,0,0,0,0,117,254,32,221,117,0,0,0,0,0,0,0,0,0,0,254,85,237,48,254,68,185,0,0,0,0,
0,0,0,0,0,0,169,205,68,254,117,0,0,0,0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,
0,0,0,0,0,0,85,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,16,237,32,0,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,
0,0,0,0,0,32,221,0,0,0,0,152,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,136,221,0,0,0,0,221,136,0,0,0,
0,0,0,0,0,0,254,117,0,0,185,237,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,
0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,0,237,117,0,0,0,205,117,0,0,0,
0,0,0,0,0,0,32,254,152,254,32,0,0,0,0,0,0,0,0,0,0,205,169,185,0,254,169,136,0,0,0,0,
0,0,0,0,0,68,254,48,0,152,237,32,0,0,0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,
0,0,0,0,0,16,237,185,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,117,152,0,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,
0,0,0,0,0,152,117,0,0,0,0,68,221,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,32,237,117,0,0,117,237,32,0,0,0,
0,0,0,0,0,0,254,117,0,0,32,237,169,0,0,0,0,0,0,0,0,0,101,16,0,0,48,254,101,0,0,0,
0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,0,152,221,16,0,48,254,32,0,0,0,
0,0,0,0,0,0,0,205,254,205,0,0,0,0,0,0,0,0,0,0,0,185,254,117,0,185,237,117,0,0,0,0,
0,0,0,0,16,221,117,0,0,16,237,185,0,0,0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,
0,0,0,0,0,169,237,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,16,237,32,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,237,205,205,237,85,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,117,254,85,0,0,0,0,0,0,0,0,221,254,185,185,254,136,0,0,0,0,
0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,0,16,205,237,185,254,101,0,0,0,0,
0,0,0,0,0,0,0,117,254,117,0,0,0,0,0,0,0,0,0,0,0,117,254,85,0,136,254,68,0,0,0,0,
0,0,0,0,136,221,16,0,0,0,101,254,85,0,0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,
0,0,0,0,0,254,254,254,254,254,254,254,117,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,117,152,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,85,237,152,48,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,68,68,16,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,68,16,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,16,237,32,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,254,254,254,254,254,254,254,254,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,185,254,101,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,221,185,185,136,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,117,152,0,0,0,0,0,0,0,0,185,185,185,237,185,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,68,68,68,48,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,16,68,0,0,0,0,0,0,0,0,68,68,68,68,48,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,136,169,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,117,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,101,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,32,117,117,117,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,117,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,185,48,0,0,0,0,0,
0,0,0,0,0,0,0,0,101,185,48,0,0,0,0,0,0,0,0,0,0,0,117,68,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,117,117,117,117,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,16,205,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,85,254,185,117,117,136,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,254,68,0,0,0,0,0,
0,0,0,0,0,0,0,0,117,254,68,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,117,117,117,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,32,117,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,169,205,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,169,237,254,237,117,0,0,0,0,0,
0,0,0,0,0,254,117,85,221,254,185,16,0,0,0,0,0,0,0,0,0,0,0,85,205,254,254,221,101,0,0,0,
0,0,0,0,0,0,117,237,254,136,185,185,0,0,0,0,0,0,0,0,0,0,68,205,254,237,152,16,0,0,0,0,
0,0,0,0,0,254,254,254,254,254,254,254,117,0,0,0,0,0,0,0,0,0,101,237,254,152,136,185,0,0,0,0,
0,0,0,0,0,0,254,117,85,221,254,136,0,0,0,0,0,0,0,0,0,0,254,254,254,254,68,0,0,0,0,0,
0,0,0,0,0,117,254,254,254,254,68,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,117,237,48,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,254,68,185,237,32,152,254,85,0,0,0,
0,0,0,0,0,0,254,117,85,221,254,136,0,0,0,0,0,0,0,0,0,0,85,205,254,237,152,16,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,101,16,0,136,254,32,0,0,0,0,
0,0,0,0,0,254,185,185,85,101,237,185,0,0,0,0,0,0,0,0,0,0,68,254,152,16,0,48,48,0,0,0,
0,0,0,0,0,85,254,101,0,117,254,185,0,0,0,0,0,0,0,0,0,48,254,117,0,48,237,152,0,0,0,0,
0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,0,0,0,0,0,0,85,254,68,0,117,254,185,0,0,0,0,
0,0,0,0,0,0,254,185,185,68,136,254,101,0,0,0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,
0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,0,254,117,0,101,237,48,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,254,185,101,221,185,152,169,185,0,0,0,
0,0,0,0,0,0,254,185,185,68,136,254,101,0,0,0,0,0,0,0,0,85,254,117,0,32,205,205,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,
0,0,0,0,0,254,169,0,0,0,117,254,32,0,0,0,0,0,0,0,0,0,205,205,0,0,0,0,0,0,0,0,
0,0,0,0,0,185,169,0,0,0,185,185,0,0,0,0,0,0,0,0,0,169,152,0,0,0,136,221,0,0,0,0,
0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,0,0,0,0,0,0,169,169,0,0,0,185,185,0,0,0,0,
0,0,0,0,0,0,254,185,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,
0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,0,254,117,85,254,101,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,254,117,0,185,185,0,117,185,0,0,0,
0,0,0,0,0,0,254,185,0,0,0,254,117,0,0,0,0,0,0,0,0,205,185,0,0,0,68,254,85,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,152,185,205,254,68,0,0,0,0,
0,0,0,0,0,254,117,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,254,117,0,0,0,185,185,0,0,0,0,0,0,0,0,0,254,221,185,185,185,221,254,0,0,0,0,
0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,185,185,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,
0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,0,254,169,237,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,254,68,0,185,117,0,117,185,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,254,117,0,0,0,0,254,117,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,237,85,0,68,254,68,0,0,0,0,
0,0,0,0,0,254,117,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,254,117,0,0,0,185,185,0,0,0,0,0,0,0,0,0,254,152,68,68,68,68,68,0,0,0,0,
0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,185,185,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,
0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,0,254,136,205,237,48,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,254,68,0,185,117,0,117,185,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,254,117,0,0,0,0,254,117,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,237,117,0,0,68,254,68,0,0,0,0,
0,0,0,0,0,254,117,0,0,0,117,237,0,0,0,0,0,0,0,0,0,0,205,205,0,0,0,0,0,0,0,0,
0,0,0,0,0,221,169,0,0,16,221,185,0,0,0,0,0,0,0,0,0,205,205,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,0,0,0,0,0,0,221,169,0,0,16,221,185,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,
0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,0,254,117,16,205,237,16,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,254,68,0,185,117,0,117,185,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,205,185,0,0,0,68,254,85,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,221,185,16,32,169,254,85,0,0,0,0,
0,0,0,0,0,254,237,85,0,68,237,117,0,0,0,0,0,0,0,0,0,0,68,254,152,32,0,32,68,0,0,0,
0,0,0,0,0,117,254,117,85,185,205,185,0,0,0,0,0,0,0,0,0,85,254,152,32,0,32,101,0,0,0,0,
0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,0,0,0,0,0,0,117,254,117,85,205,185,185,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,
0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,0,254,117,0,32,237,205,16,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,254,68,0,185,117,0,117,185,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,85,254,117,0,32,205,205,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,221,254,205,85,169,254,117,0,0,0,
0,0,0,0,0,254,117,169,254,237,117,0,0,0,0,0,0,0,0,0,0,0,0,68,185,254,254,221,136,0,0,0,
0,0,0,0,0,16,152,254,221,48,185,185,0,0,0,0,0,0,0,0,0,0,85,185,254,254,237,169,0,0,0,0,
0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,0,0,0,0,0,0,0,136,254,237,101,185,185,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,
0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,48,237,205,16,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,254,68,0,185,117,0,117,185,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,85,205,254,237,152,16,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,221,136,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,0,0,117,254,68,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,85,0,0,169,237,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,185,254,254,205,85,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,185,254,254,205,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,117,117,0,0,0,0,
0,0,0,0,0,0,0,0,117,0,0,0,0,0,0,0,0,0,0,0,0,0,117,117,85,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,136,221,117,117,0,0,0,0,
0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,0,0,0,117,117,221,136,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,185,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,254,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,254,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,101,237,254,136,0,0,0,0,0,0,0,0,0,0,85,221,254,185,101,254,0,0,0,0,
0,0,0,0,0,0,0,254,117,85,221,254,169,0,0,0,0,0,0,0,0,0,16,152,237,254,254,205,48,0,0,0,
0,0,0,0,0,254,254,254,254,254,254,185,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,
0,0,0,0,0,205,205,0,0,0,0,136,205,0,0,0,0,0,0,0,237,85,0,0,68,32,0,32,237,0,0,0,
0,0,0,0,0,152,254,48,0,0,85,254,48,0,0,0,0,0,0,0,0,152,221,0,0,0,0,117,221,0,0,0,
0,0,0,0,0,185,254,254,254,254,254,254,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,185,185,85,117,254,117,0,0,0,0,0,0,0,0,85,254,117,0,68,237,254,0,0,0,0,
0,0,0,0,0,0,0,254,185,205,101,117,185,0,0,0,0,0,0,0,0,0,152,221,32,0,0,68,32,0,0,0,
0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,
0,0,0,0,0,101,254,48,0,0,0,237,101,0,0,0,0,0,0,0,185,117,0,48,254,136,0,68,185,0,0,0,
0,0,0,0,0,16,205,221,16,16,237,117,0,0,0,0,0,0,0,0,0,68,254,101,0,0,0,221,117,0,0,0,
0,0,0,0,0,0,0,0,0,48,237,152,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,169,0,0,0,169,221,0,0,0,0,0,0,0,0,185,169,0,0,0,117,254,0,0,0,0,
0,0,0,0,0,0,0,254,205,16,0,32,101,0,0,0,0,0,0,0,0,0,185,221,32,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,
0,0,0,0,0,16,237,152,0,0,101,237,16,0,0,0,0,0,0,0,117,169,0,117,185,205,0,117,117,0,0,0,
0,0,0,0,0,0,48,237,169,185,185,0,0,0,0,0,0,0,0,0,0,0,221,185,0,0,85,237,16,0,0,0,
0,0,0,0,0,0,0,0,16,205,152,0,0,0,0,0,0,0,0,0,0,0,0,85,254,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,254,85,0,0,0,0,0,
0,0,0,0,0,0,48,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,117,254,0,0,0,0,0,0,0,0,254,117,0,0,0,117,254,0,0,0,0,
0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,68,237,254,205,117,16,0,0,0,0,
0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,
0,0,0,0,0,0,152,237,16,0,185,152,0,0,0,0,0,0,0,0,85,205,0,185,48,254,16,169,85,0,0,0,
0,0,0,0,0,0,0,101,254,237,32,0,0,0,0,0,0,0,0,0,0,0,101,254,32,0,185,152,0,0,0,0,
0,0,0,0,0,0,0,16,205,185,0,0,0,0,0,0,0,0,0,0,0,0,254,254,117,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,254,254,0,0,0,0,
0,0,0,0,0,117,221,221,185,32,0,48,136,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,117,254,0,0,0,0,0,0,0,0,254,117,0,0,0,117,254,0,0,0,0,
0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,117,205,254,237,32,0,0,0,
0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,
0,0,0,0,0,0,32,254,117,32,254,32,0,0,0,0,0,0,0,0,48,254,16,237,0,205,85,205,48,0,0,0,
0,0,0,0,0,0,0,117,254,237,48,0,0,0,0,0,0,0,0,0,0,0,16,237,136,48,254,32,0,0,0,0,
0,0,0,0,0,0,0,185,205,16,0,0,0,0,0,0,0,0,0,0,0,0,0,85,254,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,254,85,0,0,0,0,0,
0,0,0,0,0,237,16,0,117,237,136,205,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,169,185,0,0,0,0,0,0,0,0,221,169,0,0,0,169,254,0,0,0,0,
0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,254,117,0,0,0,
0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,68,254,117,0,0,0,
0,0,0,0,0,0,0,185,221,136,185,0,0,0,0,0,0,0,0,0,0,254,117,169,0,136,136,254,0,0,0,0,
0,0,0,0,0,0,48,254,101,221,205,16,0,0,0,0,0,0,0,0,0,0,0,152,237,169,169,0,0,0,0,0,
0,0,0,0,0,0,152,205,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,32,117,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,237,68,0,117,254,85,0,0,0,0,0,0,0,0,117,254,117,85,185,185,254,0,0,0,0,
0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,117,48,0,0,117,254,68,0,0,0,
0,0,0,0,0,0,0,221,205,32,0,0,0,0,0,0,0,0,0,0,0,0,221,221,85,117,169,254,117,0,0,0,
0,0,0,0,0,0,0,101,254,237,101,0,0,0,0,0,0,0,0,0,0,185,237,101,0,85,254,185,0,0,0,0,
0,0,0,0,0,16,221,136,0,48,254,152,0,0,0,0,0,0,0,0,0,0,0,48,254,254,68,0,0,0,0,0,
0,0,0,0,0,152,237,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,254,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,136,169,254,221,101,0,0,0,0,0,0,0,0,0,0,136,254,221,101,117,254,0,0,0,0,
0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,169,221,254,254,205,85,0,0,0,0,
0,0,0,0,0,0,0,48,205,254,254,254,0,0,0,0,0,0,0,0,0,0,48,221,254,152,16,254,117,0,0,0,
0,0,0,0,0,0,0,0,237,237,0,0,0,0,0,0,0,0,0,0,0,136,254,32,0,32,254,136,0,0,0,0,
0,0,0,0,0,152,205,0,0,0,117,254,101,0,0,0,0,0,0,0,0,0,0,0,205,221,0,0,0,0,0,0,
0,0,0,0,0,254,254,254,254,254,254,254,0,0,0,0,0,0,0,0,0,0,0,0,254,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,254,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,237,101,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,237,85,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,237,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,152,221,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,254,185,185,0,0,0,0,
0,0,0,0,0,0,0,0,254,0,0,0,0,0,0,0,0,0,0,0,0,0,185,185,254,101,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,254,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,254,205,48,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,68,68,0,0,0,0,
0,0,0,0,0,0,0,0,68,0,0,0,0,0,0,0,0,0,0,0,0,0,68,68,16,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,185,117,0,185,117,0,0,0,0,0,0,0,0,0,0,0,0,68,117,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,85,185,48,0,0,0,0,0,0,0,0,0,0,0,0,48,117,85,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,136,169,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,48,136,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,48,117,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,101,185,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,85,117,48,0,0,0,0,0,0,0,0,0,0,0,0,136,169,0,0,0,0,0,0,0,
0,0,0,0,0,0,48,32,0,48,32,0,0,0,0,0,0,0,0,0,0,0,0,117,0,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,101,185,254,254,221,136,0,0,0,0,0,0,0,0,0,0,185,48,0,185,48,0,0,0,0,
0,0,0,0,0,0,0,16,237,101,0,0,0,0,0,0,0,0,0,0,0,0,32,237,117,237,85,0,0,0,0,0,
0,0,0,0,0,0,101,136,0,101,136,0,0,0,0,0,0,0,0,0,0,0,0,16,205,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,117,16,136,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,32,237,117,237,85,0,0,0,0,0,0,0,0,0,0,0,48,185,0,48,185,0,0,0,0,0,
0,0,0,0,0,0,0,0,152,185,0,0,0,0,0,0,0,0,0,0,0,0,0,136,101,0,136,101,0,0,0,0,
0,0,0,0,0,0,0,85,237,117,237,32,0,0,0,0,0,0,0,0,0,0,0,16,205,117,0,0,0,0,0,0,
0,0,0,0,0,0,0,85,185,85,0,0,0,0,0,0,0,0,0,0,0,0,0,117,254,117,0,0,0,0,0,0,
0,0,0,0,0,0,152,237,101,0,0,68,117,0,0,0,0,0,0,0,0,0,0,117,32,0,117,32,0,0,0,0,
0,0,0,0,0,0,0,85,101,0,0,0,0,0,0,0,0,0,0,0,0,0,85,85,0,48,117,0,0,0,0,0,
0,0,0,0,0,0,68,101,0,68,101,0,0,0,0,0,0,0,0,0,0,0,0,0,32,117,16,0,0,0,0,0,
0,0,0,0,0,0,0,16,117,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,85,85,0,48,117,0,0,0,0,0,0,0,0,0,0,0,32,117,0,32,117,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,117,48,0,0,0,0,0,0,0,0,0,0,0,0,101,68,0,101,68,0,0,0,0,
0,0,0,0,0,0,0,117,48,0,85,85,0,0,0,0,0,0,0,0,0,0,0,0,32,117,16,0,0,0,0,0,
0,0,0,0,0,0,0,169,254,169,0,0,0,0,0,0,0,0,0,0,0,0,0,169,254,169,0,0,0,0,0,0,
0,0,0,0,0,68,254,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,16,254,205,254,16,0,0,0,0,0,0,0,0,0,0,0,16,254,205,254,16,0,0,0,0,0,
0,0,0,0,0,169,221,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,
0,0,0,0,0,0,68,205,254,237,152,16,0,0,0,0,0,0,0,0,0,32,169,237,254,237,117,0,0,0,0,0,
0,0,0,0,0,32,169,237,254,237,117,0,0,0,0,0,0,0,0,0,0,32,169,237,254,237,117,0,0,0,0,0,
0,0,0,0,0,32,169,237,254,237,117,0,0,0,0,0,0,0,0,0,0,0,0,85,205,254,254,221,101,0,0,0,
0,0,0,0,0,0,68,205,254,237,152,16,0,0,0,0,0,0,0,0,0,0,68,205,254,237,152,16,0,0,0,0,
0,0,0,0,0,0,68,205,254,237,152,16,0,0,0,0,0,0,0,0,0,0,254,254,254,254,117,0,0,0,0,0,
0,0,0,0,0,0,254,254,254,254,117,0,0,0,0,0,0,0,0,0,0,0,254,254,254,254,117,0,0,0,0,0,
0,0,0,0,0,0,101,237,48,254,101,0,0,0,0,0,0,0,0,0,0,0,101,237,48,254,101,0,0,0,0,0,
0,0,0,0,0,221,136,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,
0,0,0,0,0,48,254,117,0,48,237,152,0,0,0,0,0,0,0,0,0,48,101,16,0,136,254,32,0,0,0,0,
0,0,0,0,0,48,101,16,0,136,254,32,0,0,0,0,0,0,0,0,0,48,101,16,0,136,254,32,0,0,0,0,
0,0,0,0,0,48,101,16,0,136,254,32,0,0,0,0,0,0,0,0,0,0,68,254,152,16,0,48,48,0,0,0,
0,0,0,0,0,48,254,117,0,48,237,152,0,0,0,0,0,0,0,0,0,48,254,117,0,48,237,152,0,0,0,0,
0,0,0,0,0,48,254,117,0,48,237,152,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,169,136,0,221,169,0,0,0,0,0,0,0,0,0,0,0,169,136,0,221,169,0,0,0,0,0,
0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,
0,0,0,0,0,169,152,0,0,0,136,221,0,0,0,0,0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,
0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,
0,0,0,0,0,0,0,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,185,205,0,0,0,0,0,0,0,0,
0,0,0,0,0,169,152,0,0,0,136,221,0,0,0,0,0,0,0,0,0,169,152,0,0,0,136,221,0,0,0,0,
0,0,0,0,0,169,152,0,0,0,136,221,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,32,254,48,0,117,254,32,0,0,0,0,0,0,0,0,0,32,254,48,0,117,254,32,0,0,0,0,
0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,
0,0,0,0,0,254,221,185,185,185,221,254,0,0,0,0,0,0,0,0,0,0,68,152,185,205,254,68,0,0,0,0,
0,0,0,0,0,0,68,152,185,205,254,68,0,0,0,0,0,0,0,0,0,0,68,152,185,205,254,68,0,0,0,0,
0,0,0,0,0,0,68,152,185,205,254,68,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,254,221,185,185,185,221,254,0,0,0,0,0,0,0,0,0,254,221,185,185,185,221,254,0,0,0,0,
0,0,0,0,0,254,221,185,185,185,221,254,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,117,221,0,0,32,254,117,0,0,0,0,0,0,0,0,0,117,221,0,0,32,254,117,0,0,0,0,
0,0,0,0,0,205,185,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,
0,0,0,0,0,254,152,68,68,68,68,68,0,0,0,0,0,0,0,0,0,117,237,85,0,68,254,68,0,0,0,0,
0,0,0,0,0,117,237,85,0,68,254,68,0,0,0,0,0,0,0,0,0,117,237,85,0,68,254,68,0,0,0,0,
0,0,0,0,0,117,237,85,0,68,254,68,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,254,152,68,68,68,68,68,0,0,0,0,0,0,0,0,0,254,152,68,68,68,68,68,0,0,0,0,
0,0,0,0,0,254,152,68,68,68,68,68,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,205,254,254,254,254,254,205,0,0,0,0,0,0,0,0,0,205,254,254,254,254,254,205,0,0,0,0,
0,0,0,0,0,117,254,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,68,254,117,0,0,0,
0,0,0,0,0,205,205,0,0,0,0,0,0,0,0,0,0,0,0,0,0,237,117,0,0,68,254,68,0,0,0,0,
0,0,0,0,0,237,117,0,0,68,254,68,0,0,0,0,0,0,0,0,0,237,117,0,0,68,254,68,0,0,0,0,
0,0,0,0,0,237,117,0,0,68,254,68,0,0,0,0,0,0,0,0,0,0,205,205,0,0,0,0,0,0,0,0,
0,0,0,0,0,205,205,0,0,0,0,0,0,0,0,0,0,0,0,0,0,205,205,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,205,205,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,32,254,48,0,0,0,117,254,32,0,0,0,0,0,0,0,32,254,48,0,0,0,117,254,32,0,0,0,
0,0,0,0,0,16,205,237,68,0,0,0,32,0,0,0,0,0,0,0,0,0,221,221,85,117,169,254,117,0,0,0,
0,0,0,0,0,85,254,152,32,0,32,101,0,0,0,0,0,0,0,0,0,221,185,16,32,169,254,85,0,0,0,0,
0,0,0,0,0,221,185,16,32,169,254,85,0,0,0,0,0,0,0,0,0,221,185,16,32,169,254,85,0,0,0,0,
0,0,0,0,0,221,185,16,32,169,254,85,0,0,0,0,0,0,0,0,0,0,85,254,152,32,0,32,68,0,0,0,
0,0,0,0,0,85,254,152,32,0,32,101,0,0,0,0,0,0,0,0,0,85,254,152,32,0,32,101,0,0,0,0,
0,0,0,0,0,85,254,152,32,0,32,101,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,117,221,0,0,0,0,32,254,117,0,0,0,0,0,0,0,117,221,0,0,0,0,32,254,117,0,0,0,
0,0,0,0,0,0,32,185,254,205,185,221,169,0,0,0,0,0,0,0,0,0,48,221,254,152,16,254,117,0,0,0,
0,0,0,0,0,0,85,185,254,254,237,169,0,0,0,0,0,0,0,0,0,48,221,254,205,85,169,254,117,0,0,0,
0,0,0,0,0,48,221,254,205,85,169,254,117,0,0,0,0,0,0,0,0,48,221,254,205,85,169,254,117,0,0,0,
0,0,0,0,0,48,221,254,205,85,169,254,117,0,0,0,0,0,0,0,0,0,0,85,205,254,254,221,117,0,0,0,
0,0,0,0,0,0,85,185,254,254,237,169,0,0,0,0,0,0,0,0,0,0,85,185,254,254,237,169,0,0,0,0,
0,0,0,0,0,0,85,185,254,254,237,169,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,
0,0,0,0,205,117,0,0,0,0,0,185,205,0,0,0,0,0,0,0,205,117,0,0,0,0,0,185,205,0,0,0,
0,0,0,0,0,0,0,0,68,185,68,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,205,16,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,32,136,136,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,48,237,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,143,251,198,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,185,117,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,169,152,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,254,0,68,254,0,0,0,0,0,
0,0,0,0,0,0,0,254,68,0,254,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,16,68,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,117,85,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,101,185,32,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,85,117,48,0,0,0,0,0,0,0,0,0,0,0,0,101,185,32,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,68,0,16,68,0,0,0,0,0,
0,0,0,0,0,0,0,68,16,0,68,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,185,185,185,185,185,185,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,32,185,185,185,185,101,0,0,0,0,0,0,0,0,0,32,237,117,237,85,0,0,0,0,0,
0,0,0,0,0,0,101,136,0,101,136,0,0,0,0,0,0,0,0,0,0,0,0,0,152,185,0,0,0,0,0,0,
0,0,0,0,0,0,0,85,237,117,237,32,0,0,0,0,0,0,0,0,0,0,0,0,152,185,0,0,0,0,0,0,
0,0,0,0,0,0,0,185,48,0,185,48,0,0,0,0,0,0,0,0,0,0,16,169,254,254,169,16,0,0,0,0,
0,0,0,0,0,0,185,101,0,0,0,136,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,101,221,254,237,0,0,0,0,0,0,0,0,0,0,32,169,254,254,169,136,185,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,237,254,117,0,0,0,
0,0,0,0,0,0,254,152,68,68,68,68,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,117,254,254,68,68,32,0,0,0,0,0,0,0,0,0,85,85,0,48,117,0,0,0,0,0,
0,0,0,0,0,0,68,101,0,68,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,48,0,0,0,0,0,
0,0,0,0,0,0,0,117,48,0,85,85,0,0,0,0,0,0,0,0,0,0,0,0,0,117,48,0,0,0,0,0,
0,0,0,0,0,0,0,117,32,0,117,32,0,0,0,0,0,0,0,0,0,16,205,152,16,16,152,205,16,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,185,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,48,254,85,0,48,0,0,0,0,0,0,0,0,0,16,205,152,16,16,152,254,48,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,237,32,0,32,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,205,237,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,117,237,16,0,0,16,237,117,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,185,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,117,237,16,0,0,185,254,117,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,221,136,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,68,254,254,237,136,237,254,136,0,0,0,
0,0,0,0,0,0,48,254,152,254,0,0,0,0,0,0,0,0,0,0,0,0,85,205,254,237,152,16,0,0,0,0,
0,0,0,0,0,0,85,205,254,237,152,16,0,0,0,0,0,0,0,0,0,0,85,205,254,237,152,16,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,
0,0,0,0,0,152,221,0,0,0,0,117,221,0,0,0,0,0,0,0,0,185,169,0,0,0,0,169,185,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,185,117,0,0,0,0,0,0,0,0,0,85,205,254,254,169,221,48,0,0,0,
0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,185,169,0,0,85,221,205,185,0,0,0,
0,0,0,0,0,85,16,0,0,0,0,48,48,0,0,0,0,0,0,0,0,0,0,48,254,68,0,0,0,0,0,0,
0,0,0,0,0,0,254,152,68,68,68,48,0,0,0,0,0,0,0,0,0,16,32,0,169,254,117,48,254,48,0,0,
0,0,0,0,0,0,136,205,117,254,68,68,16,0,0,0,0,0,0,0,0,85,254,117,0,32,205,205,0,0,0,0,
0,0,0,0,0,85,254,117,0,32,205,205,0,0,0,0,0,0,0,0,0,85,254,117,0,32,205,205,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,
0,0,0,0,0,68,254,101,0,0,0,221,117,0,0,0,0,0,0,0,0,254,117,0,0,0,0,117,254,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,185,117,0,0,0,0,0,0,0,0,85,254,117,0,48,254,205,0,0,0,0,
0,0,0,0,0,0,48,152,254,68,32,0,0,0,0,0,0,0,0,0,0,254,117,0,16,221,85,117,254,0,0,0,
0,0,0,0,0,101,205,16,0,0,101,221,48,0,0,0,0,0,0,0,0,0,48,152,254,85,16,0,0,0,0,0,
0,0,0,0,0,0,254,221,185,185,185,136,0,0,0,0,0,0,0,0,0,0,0,48,152,254,68,68,254,117,0,0,
0,0,0,0,0,0,221,101,117,254,185,185,48,0,0,0,0,0,0,0,0,205,185,0,0,0,68,254,85,0,0,0,
0,0,0,0,0,205,185,0,0,0,68,254,85,0,0,0,0,0,0,0,0,205,185,0,0,0,68,254,85,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,
0,0,0,0,0,0,221,185,0,0,85,237,16,0,0,0,0,0,0,0,0,254,117,0,0,0,0,117,254,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,185,117,0,0,0,0,0,0,0,0,205,205,0,0,169,185,254,85,0,0,0,
0,0,0,0,0,0,136,221,254,185,101,0,0,0,0,0,0,0,0,0,0,254,117,0,136,185,0,117,254,0,0,0,
0,0,0,0,0,0,101,205,16,101,237,48,0,0,0,0,0,0,0,0,0,0,136,237,237,185,48,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,48,205,221,221,254,254,254,254,117,0,0,
0,0,0,0,0,85,254,16,117,254,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,254,117,0,0,0,
0,0,0,0,0,254,117,0,0,0,0,254,117,0,0,0,0,0,0,0,0,254,117,0,0,0,0,254,117,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,
0,0,0,0,0,0,101,254,32,0,185,152,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,117,254,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,185,117,0,0,0,0,0,0,0,0,254,117,0,117,185,0,254,117,0,0,0,
0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,254,117,48,254,32,0,117,254,0,0,0,
0,0,0,0,0,0,0,101,221,237,48,0,0,0,0,0,0,0,0,0,0,0,0,205,169,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,117,254,0,0,0,0,0,0,
0,0,0,0,0,152,237,185,221,254,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,254,117,0,0,0,
0,0,0,0,0,254,117,0,0,0,0,254,117,0,0,0,0,0,0,0,0,254,117,0,0,0,0,254,117,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,0,0,0,0,0,0,254,117,0,0,0,254,117,0,0,0,
0,0,0,0,0,0,16,237,136,48,254,32,0,0,0,0,0,0,0,0,0,205,152,0,0,0,0,152,205,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,185,117,0,0,0,0,0,0,0,0,254,117,68,237,16,0,254,117,0,0,0,
0,0,0,0,0,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,0,205,169,185,117,0,0,152,205,0,0,0,
0,0,0,0,0,0,0,48,221,205,16,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,117,254,16,0,0,0,0,0,
0,0,0,0,0,237,117,68,152,254,0,0,0,0,0,0,0,0,0,0,0,205,185,0,0,0,68,254,85,0,0,0,
0,0,0,0,0,205,185,0,0,0,68,254,85,0,0,0,0,0,0,0,0,205,185,0,0,0,68,254,85,0,0,0,
0,0,0,0,0,0,254,117,0,0,68,254,117,0,0,0,0,0,0,0,0,0,254,117,0,0,68,254,117,0,0,0,
0,0,0,0,0,0,0,152,237,169,169,0,0,0,0,0,0,0,0,0,0,136,221,0,0,0,0,221,136,0,0,0,
0,0,0,0,0,0,237,117,0,0,0,205,117,0,0,0,0,0,0,0,0,205,205,237,48,0,85,254,85,0,0,0,
0,0,0,0,0,0,0,152,169,0,0,0,0,0,0,0,0,0,0,0,0,136,254,221,16,0,0,221,136,0,0,0,
0,0,0,0,0,0,48,221,48,101,205,16,0,0,0,0,0,0,0,0,0,0,68,254,85,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,0,0,0,0,0,221,221,68,205,254,152,0,48,68,0,0,
0,0,0,0,101,237,0,0,117,254,0,0,0,0,0,0,0,0,0,0,0,85,254,117,0,32,205,205,0,0,0,0,
0,0,0,0,0,85,254,117,0,32,205,205,0,0,0,0,0,0,0,0,0,85,254,117,0,32,205,205,0,0,0,0,
0,0,0,0,0,0,221,221,85,117,169,254,117,0,0,0,0,0,0,0,0,0,221,221,85,117,169,254,117,0,0,0,
0,0,0,0,0,0,0,48,254,254,68,0,0,0,0,0,0,0,0,0,0,32,237,117,0,0,117,237,32,0,0,0,
0,0,0,0,0,0,152,221,16,0,48,254,32,0,0,0,0,0,0,0,0,101,254,169,0,32,205,205,0,0,0,0,
0,0,0,0,0,0,117,237,85,68,68,68,0,0,0,0,0,0,0,0,0,48,254,152,0,0,117,237,32,0,0,0,
0,0,0,0,0,48,221,48,0,0,101,205,16,0,0,0,0,0,0,0,0,0,117,254,32,0,0,0,0,0,0,0,
0,0,0,0,0,0,254,254,254,254,254,254,185,0,0,0,0,0,0,0,0,48,221,237,136,136,237,254,205,85,0,0,
0,0,0,0,169,152,0,0,117,254,254,254,185,0,0,0,0,0,0,0,0,0,85,205,254,237,152,16,0,0,0,0,
0,0,0,0,0,0,85,205,254,237,152,16,0,0,0,0,0,0,0,0,0,0,85,205,254,237,152,16,0,0,0,0,
0,0,0,0,0,0,48,221,254,152,16,254,117,0,0,0,0,0,0,0,0,0,48,221,254,152,16,254,117,0,0,0,
0,0,0,0,0,0,0,0,205,221,0,0,0,0,0,0,0,0,0,0,0,0,48,237,205,205,237,48,0,0,0,0,
0,0,0,0,0,0,16,205,237,185,254,101,0,0,0,0,0,0,0,0,0,152,185,221,254,237,152,16,0,0,0,0,
0,0,0,0,0,0,254,254,254,254,254,254,0,0,0,0,0,0,0,0,0,136,205,237,221,205,237,48,0,0,0,0,
0,0,0,0,0,117,48,0,0,0,0,101,85,0,0,0,0,0,0,0,0,0,136,237,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,237,101,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,48,68,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,16,0,68,68,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,185,185,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,152,221,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,117,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,117,254,205,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68,32,0,0,0,0,0,0,0,0
};
| 78,614 | C | 72.062268 | 94 | 0.562114 |
NVIDIA-Omniverse/PhysX/physx/snippets/snippetrender/SnippetFontRenderer.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "SnippetFontData.h"
#include "SnippetFontRenderer.h"
#include "SnippetRender.h"
bool GLFontRenderer::m_isInit=false;
unsigned int GLFontRenderer::m_textureObject=0;
int GLFontRenderer::m_screenWidth=640;
int GLFontRenderer::m_screenHeight=480;
float GLFontRenderer::m_color[4]={1.0f, 1.0f, 1.0f, 1.0f};
namespace
{
struct RGBAPixel
{
unsigned char R,G,B,A;
};
#define PIXEL_OPAQUE 0xff
}
bool GLFontRenderer::init()
{
glGenTextures(1, (GLuint*)&m_textureObject);
if(!m_textureObject)
return false;
glBindTexture(GL_TEXTURE_2D, m_textureObject);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// expand to rgba
RGBAPixel* P = new RGBAPixel[OGL_FONT_TEXTURE_WIDTH*OGL_FONT_TEXTURE_HEIGHT];
for(int i=0;i<OGL_FONT_TEXTURE_WIDTH*OGL_FONT_TEXTURE_HEIGHT;i++)
{
if(1)
{
P[i].R = PIXEL_OPAQUE;
P[i].G = PIXEL_OPAQUE;
P[i].B = PIXEL_OPAQUE;
P[i].A = OGLFontData[i];
}
else
{
P[i].R = OGLFontData[i];
P[i].G = OGLFontData[i];
P[i].B = OGLFontData[i];
P[i].A = PIXEL_OPAQUE;
}
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, OGL_FONT_TEXTURE_WIDTH, OGL_FONT_TEXTURE_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, P);
delete [] P;
m_isInit = true;
return true;
}
void GLFontRenderer::print(float x, float y, float fontSize, const char* pString, bool forceMonoSpace, int monoSpaceWidth, bool doOrthoProj)
{
if(1)
{
const float Saved0 = m_color[0];
const float Saved1 = m_color[1];
const float Saved2 = m_color[2];
m_color[0] = 0.0f;
m_color[1] = 0.0f;
m_color[2] = 0.0f;
// const float Offset = fontSize * 0.05f;
// const float Offset = fontSize * 0.075f;
const float Offset = fontSize * 0.1f;
print_(x+Offset, y-Offset, fontSize, pString, forceMonoSpace, monoSpaceWidth, doOrthoProj);
//print_(x-Offset, y-Offset, fontSize, pString, forceMonoSpace, monoSpaceWidth, doOrthoProj);
//print_(x+Offset, y+Offset, fontSize, pString, forceMonoSpace, monoSpaceWidth, doOrthoProj);
//print_(x-Offset, y+Offset, fontSize, pString, forceMonoSpace, monoSpaceWidth, doOrthoProj);
m_color[0] = Saved0;
m_color[1] = Saved1;
m_color[2] = Saved2;
}
print_(x, y, fontSize, pString, forceMonoSpace, monoSpaceWidth, doOrthoProj);
}
void GLFontRenderer::print_(float x, float y, float fontSize, const char* pString, bool forceMonoSpace, int monoSpaceWidth, bool doOrthoProj)
{
x = x*m_screenWidth;
y = y*m_screenHeight;
fontSize = fontSize*m_screenHeight;
if(!m_isInit)
m_isInit = init();
unsigned int num = (unsigned int)(strlen(pString));
if(m_isInit && num > 0)
{
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_textureObject);
if(doOrthoProj)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0, m_screenWidth, 0, m_screenHeight, -1, 1);
}
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glEnable(GL_BLEND);
glDisable(GL_CULL_FACE);
glColor4f(m_color[0], m_color[1], m_color[2], m_color[3]);
const float glyphHeightUV = ((float)OGL_FONT_CHARS_PER_COL)/OGL_FONT_TEXTURE_HEIGHT*2 - 1.0f/128.0f;
//const float glyphHeightUV = ((float)OGL_FONT_CHARS_PER_COL)/OGL_FONT_TEXTURE_HEIGHT*2;
float translate = 0.0f;
float* pVertList = new float[num*3*6];
float* pTextureCoordList = new float[num*2*6];
int vertIndex = 0;
int textureCoordIndex = 0;
float translateDown = 0.0f;
unsigned int count = 0;
for(unsigned int i=0;i<num; i++)
{
const float glyphWidthUV = ((float)OGL_FONT_CHARS_PER_ROW)/OGL_FONT_TEXTURE_WIDTH;
if (pString[i] == '\n')
{
translateDown-=0.005f*m_screenHeight+fontSize;
translate = 0.0f;
continue;
}
int c = pString[i]-OGL_FONT_CHAR_BASE;
if (c < OGL_FONT_CHARS_PER_ROW*OGL_FONT_CHARS_PER_COL)
{
count++;
float glyphWidth = (float)GLFontGlyphWidth[c]+1;
if(forceMonoSpace)
glyphWidth = (float)monoSpaceWidth;
glyphWidth = glyphWidth*(fontSize/(((float)OGL_FONT_TEXTURE_WIDTH)/OGL_FONT_CHARS_PER_ROW))-0.01f;
const float cxUV = float((c)%OGL_FONT_CHARS_PER_ROW)/OGL_FONT_CHARS_PER_ROW+0.008f;
const float cyUV = float((c)/OGL_FONT_CHARS_PER_ROW)/OGL_FONT_CHARS_PER_COL+0.008f;
pTextureCoordList[textureCoordIndex++] = cxUV;
pTextureCoordList[textureCoordIndex++] = cyUV+glyphHeightUV;
pVertList[vertIndex++] = x+0+translate;
pVertList[vertIndex++] = y+0+translateDown;
pVertList[vertIndex++] = 0;
pTextureCoordList[textureCoordIndex++] = cxUV+glyphWidthUV;
pTextureCoordList[textureCoordIndex++] = cyUV;
pVertList[vertIndex++] = x+fontSize+translate;
pVertList[vertIndex++] = y+fontSize+translateDown;
pVertList[vertIndex++] = 0;
pTextureCoordList[textureCoordIndex++] = cxUV;
pTextureCoordList[textureCoordIndex++] = cyUV;
pVertList[vertIndex++] = x+0+translate;
pVertList[vertIndex++] = y+fontSize+translateDown;
pVertList[vertIndex++] = 0;
pTextureCoordList[textureCoordIndex++] = cxUV;
pTextureCoordList[textureCoordIndex++] = cyUV+glyphHeightUV;
pVertList[vertIndex++] = x+0+translate;
pVertList[vertIndex++] = y+0+translateDown;
pVertList[vertIndex++] = 0;
pTextureCoordList[textureCoordIndex++] = cxUV+glyphWidthUV;
pTextureCoordList[textureCoordIndex++] = cyUV+glyphHeightUV;
pVertList[vertIndex++] = x+fontSize+translate;
pVertList[vertIndex++] = y+0+translateDown;
pVertList[vertIndex++] = 0;
pTextureCoordList[textureCoordIndex++] = cxUV+glyphWidthUV;
pTextureCoordList[textureCoordIndex++] = cyUV;
pVertList[vertIndex++] = x+fontSize+translate;
pVertList[vertIndex++] = y+fontSize+translateDown;
pVertList[vertIndex++] = 0;
translate+=glyphWidth;
}
}
glEnableClientState(GL_VERTEX_ARRAY);
// glVertexPointer(3, GL_FLOAT, num*6, pVertList);
glVertexPointer(3, GL_FLOAT, 3*4, pVertList);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
// glTexCoordPointer(2, GL_FLOAT, num*6, pTextureCoordList);
glTexCoordPointer(2, GL_FLOAT, 2*4, pTextureCoordList);
glDrawArrays(GL_TRIANGLES, 0, count*6);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
delete[] pVertList;
delete[] pTextureCoordList;
// glMatrixMode(GL_MODELVIEW);
// glPopMatrix();
if(doOrthoProj)
{
glMatrixMode(GL_PROJECTION);
glPopMatrix();
}
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glEnable(GL_CULL_FACE);
}
}
void GLFontRenderer::setScreenResolution(int screenWidth, int screenHeight)
{
m_screenWidth = screenWidth;
m_screenHeight = screenHeight;
}
void GLFontRenderer::setColor(float r, float g, float b, float a)
{
m_color[0] = r;
m_color[1] = g;
m_color[2] = b;
m_color[3] = a;
}
| 8,678 | C++ | 29.667844 | 141 | 0.70673 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.