Skip to content

Commit

Permalink
Update code to not have to change gymutil.py in Isaac Gym source code.
Browse files Browse the repository at this point in the history
Signed-off-by: Mihir Kulkarni <[email protected]>
  • Loading branch information
mihirk284 committed Dec 27, 2024
1 parent a07bfd5 commit 71bf152
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 10 deletions.
4 changes: 2 additions & 2 deletions aerial_gym/config/asset_config/env_object_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class thin_asset_params(asset_state_params):


class tree_asset_params(asset_state_params):
num_assets = 6
num_assets = 1

asset_folder = f"{AERIAL_GYM_DIRECTORY}/resources/models/environment_assets/trees"

Expand Down Expand Up @@ -271,7 +271,7 @@ class tree_asset_params(asset_state_params):


class object_asset_params(asset_state_params):
num_assets = 40
num_assets = 5

asset_folder = f"{AERIAL_GYM_DIRECTORY}/resources/models/environment_assets/objects"

Expand Down
10 changes: 5 additions & 5 deletions aerial_gym/config/robot_config/base_quad_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,31 +189,31 @@ class motor_model_config:
)

class BaseQuadWithImuCfg(BaseQuadCfg):
class sensor_config:
class sensor_config(BaseQuadCfg.sensor_config):
enable_imu = True
imu_config = BaseImuConfig


class BaseQuadWithCameraCfg(BaseQuadCfg):
class sensor_config:
class sensor_config(BaseQuadCfg.sensor_config):
enable_camera = True
camera_config = BaseDepthCameraConfig

class BaseQuadWithCameraImuCfg(BaseQuadCfg):
class sensor_config:
class sensor_config(BaseQuadCfg.sensor_config):
enable_camera = True
camera_config = BaseDepthCameraConfig

enable_imu = True
imu_config = BaseImuConfig

class BaseQuadWithLidarCfg(BaseQuadCfg):
class sensor_config:
class sensor_config(BaseQuadCfg.sensor_config):
enable_lidar = True
lidar_config = BaseLidarConfig

class BaseQuadWithFaceIDNormalCameraCfg(BaseQuadCfg):
class sensor_config:
class sensor_config(BaseQuadCfg.sensor_config):
enable_camera = True
camera_config = BaseNormalFaceIDCameraConfig

2 changes: 1 addition & 1 deletion aerial_gym/examples/save_camera_stream_normal_faceID.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
# discretize image for better visualization

seg_image1_normalized_int = (255.0 * seg_image1_normalized).astype(np.uint8)
seg1_image_normalized_discrete = 25 *np.mod(seg_image1_normalized_int, 10).astype(np.uint8)
seg1_image_normalized_discrete = 25 * (np.mod(seg_image1_normalized_int, 11)).astype(np.uint8)

# set colormap to plasma in matplotlib
seg_image1_normalized_plasma = matplotlib.cm.plasma(seg1_image_normalized_discrete/255.0)
Expand Down
1 change: 1 addition & 0 deletions aerial_gym/robots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from aerial_gym.registry.robot_registry import robot_registry

from aerial_gym.config.robot_config.base_quad_config import BaseQuadWithImuCfg
from aerial_gym.config.robot_config.base_quad_config import BaseQuadWithCameraCfg
from aerial_gym.config.robot_config.base_quad_config import BaseQuadWithCameraImuCfg
from aerial_gym.config.robot_config.base_quad_config import BaseQuadWithLidarCfg
from aerial_gym.config.robot_config.base_quad_config import BaseQuadWithFaceIDNormalCameraCfg
Expand Down
77 changes: 76 additions & 1 deletion aerial_gym/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from isaacgym import gymapi
from isaacgym import gymutil
import argparse

import distutils

Expand Down Expand Up @@ -87,6 +88,80 @@ def update_cfg_from_args(cfg, args):
return cfg


def parse_arguments(description="Isaac Gym Example", headless=False, no_graphics=False, custom_parameters=[]):
parser = argparse.ArgumentParser(description=description)
if headless:
parser.add_argument('--headless', action='store_true', help='Run headless without creating a viewer window')
if no_graphics:
parser.add_argument('--nographics', action='store_true',
help='Disable graphics context creation, no viewer window is created, and no headless rendering is available')
parser.add_argument('--sim_device', type=str, default="cuda:0", help='Physics Device in PyTorch-like syntax')
parser.add_argument('--pipeline', type=str, default="gpu", help='Tensor API pipeline (cpu/gpu)')
parser.add_argument('--graphics_device_id', type=int, default=0, help='Graphics Device ID')

physics_group = parser.add_mutually_exclusive_group()
physics_group.add_argument('--flex', action='store_true', help='Use FleX for physics')
physics_group.add_argument('--physx', action='store_true', help='Use PhysX for physics')

parser.add_argument('--num_threads', type=int, default=0, help='Number of cores used by PhysX')
parser.add_argument('--subscenes', type=int, default=0, help='Number of PhysX subscenes to simulate in parallel')
parser.add_argument('--slices', type=int, help='Number of client threads that process env slices')

for argument in custom_parameters:
if ("name" in argument) and ("type" in argument or "action" in argument):
help_str = ""
if "help" in argument:
help_str = argument["help"]

if "type" in argument:
if "default" in argument:
parser.add_argument(argument["name"], type=argument["type"], default=argument["default"], help=help_str)
else:
parser.add_argument(argument["name"], type=argument["type"], help=help_str)
elif "action" in argument:
parser.add_argument(argument["name"], action=argument["action"], help=help_str)

else:
print()
print("ERROR: command line argument name, type/action must be defined, argument not added to parser")
print("supported keys: name, type, default, action, help")
print()

args, unknown_args = parser.parse_known_args()
print("[isaacgym:gymutil.py] Unknown args: ", unknown_args)

args.sim_device_type, args.compute_device_id = gymutil.parse_device_str(args.sim_device)
pipeline = args.pipeline.lower()

assert (pipeline == 'cpu' or pipeline in ('gpu', 'cuda')), f"Invalid pipeline '{args.pipeline}'. Should be either cpu or gpu."
args.use_gpu_pipeline = (pipeline in ('gpu', 'cuda'))

if args.sim_device_type != 'cuda' and args.flex:
print("Can't use Flex with CPU. Changing sim device to 'cuda:0'")
args.sim_device = 'cuda:0'
args.sim_device_type, args.compute_device_id = parse_device_str(args.sim_device)

if (args.sim_device_type != 'cuda' and pipeline == 'gpu'):
print("Can't use GPU pipeline with CPU Physics. Changing pipeline to 'CPU'.")
args.pipeline = 'CPU'
args.use_gpu_pipeline = False

# Default to PhysX
args.physics_engine = gymapi.SIM_PHYSX
args.use_gpu = (args.sim_device_type == 'cuda')

if args.flex:
args.physics_engine = gymapi.SIM_FLEX

# Using --nographics implies --headless
if no_graphics and args.nographics:
args.headless = True

if args.slices is None:
args.slices = args.subscenes

return args

def get_args(additional_parameters=[]):
custom_parameters = [
{
Expand All @@ -109,7 +184,7 @@ def get_args(additional_parameters=[]):
},
]
# parse arguments
args = gymutil.parse_arguments(
args = parse_arguments(
description="RL Policy",
custom_parameters=custom_parameters + additional_parameters,
)
Expand Down
2 changes: 1 addition & 1 deletion docs/2_getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
# or over HTTPS
# git clone https://github.com/ntnu-arl/aerial_gym_simulator.git
cd aerial_gym
cd aerial_gym_simulator
pip3 install -e .
```
1. Test an example environment
Expand Down

0 comments on commit 71bf152

Please sign in to comment.