Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding wheeled files; TODO fix racetrack terrain C++ error #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import toml

# Conveniences to other module directories via relative paths
ISAACLAB_ASSETS_EXT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../"))
GROUNDCONTROL_ASSETS_EXT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../"))
"""Path to the extension source directory."""

ISAACLAB_ASSETS_DATA_DIR = os.path.join(ISAACLAB_ASSETS_EXT_DIR, "data")
GROUNDCONTROL_ASSETS_DATA_DIR = os.path.join(GROUNDCONTROL_ASSETS_EXT_DIR, "data")
"""Path to the extension data directory."""

ISAACLAB_ASSETS_METADATA = toml.load(os.path.join(ISAACLAB_ASSETS_EXT_DIR, "config", "extension.toml"))
GROUNDCONTROL_ASSETS_METADATA = toml.load(os.path.join(GROUNDCONTROL_ASSETS_EXT_DIR, "config", "extension.toml"))
"""Extension metadata dictionary parsed from the extension.toml file."""

# Configure the module-level variables
__version__ = ISAACLAB_ASSETS_METADATA["package"]["version"]
__version__ = GROUNDCONTROL_ASSETS_METADATA["package"]["version"]


##
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from omni.isaac.lab.assets import ArticulationCfg
import omni.isaac.lab.sim as sim_utils
from omni.isaac.lab.actuators import ImplicitActuatorCfg

from omni.isaac.groundcontrol_assets import GROUNDCONTROL_ASSETS_DATA_DIR

JOINT_NAMES = [
'chassis_to_back_left_wheel',
'chassis_to_back_right_wheel',
'chassis_to_front_left_hinge',
'chassis_to_front_right_hinge',
'front_left_hinge_to_wheel',
'front_right_hinge_to_wheel',
]

MITCAR_CFG = ArticulationCfg(
spawn=sim_utils.UsdFileCfg(
usd_path=f"{GROUNDCONTROL_ASSETS_DATA_DIR}/Robots/UWRLL/mitcar.usd",
rigid_props=sim_utils.RigidBodyPropertiesCfg(
rigid_body_enabled=True,
max_linear_velocity=1000.0,
max_angular_velocity=1000.0,
max_depenetration_velocity=100.0,
enable_gyroscopic_forces=True,
),
articulation_props=sim_utils.ArticulationRootPropertiesCfg(
enabled_self_collisions=False,
solver_position_iteration_count=4,
solver_velocity_iteration_count=0,
sleep_threshold=0.005,
stabilization_threshold=0.001,
),
collision_props=sim_utils.CollisionPropertiesCfg(
collision_enabled=True
)
),
init_state=ArticulationCfg.InitialStateCfg(
pos=(0.0, 0.0, 0.2),
joint_pos={
'front_left_hinge_to_wheel': 0.0,
'front_right_hinge_to_wheel': 0.0,
'chassis_to_back_left_wheel': 0.0,
'chassis_to_back_right_wheel': 0.0,
'chassis_to_front_left_hinge': 0.0,
'chassis_to_front_right_hinge': 0.0,
},
),
actuators={
f"{k}_actuator": ImplicitActuatorCfg(
joint_names_expr=[k],
effort_limit=400.0,
velocity_limit=100.0,
stiffness=0.0,
damping=10.0,
) for k in JOINT_NAMES
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,69 @@
# Register Gym environments.
##

import gymnasium as gym

###### WHEELED ######

from .manager_based.wheeled.mitcar.mitcar_manager_env_cfg import (
MITCarRLEnvCfg, MITCarPlayEnvCfg, MITCarIRLEnvCfg
)

import omni.isaac.groundcontrol_tasks.manager_based.wheeled.mitcar.agents as agents

gym.register(
id='Isaac-MITCar-v0',
entry_point='omni.isaac.lab.envs:ManagerBasedRLEnv',
kwargs={
"env_cfg_entry_point":MITCarRLEnvCfg,
"rsl_rl_cfg_entry_point": f"{agents.__name__}.rsl_rl_ppo_cfg:MITCarPPORunnerCfg",
}
)

gym.register(
id='Isaac-MITCarPlay-v0',
entry_point='omni.isaac.lab.envs:ManagerBasedRLEnv',
kwargs={
"env_cfg_entry_point":MITCarPlayEnvCfg,
"rsl_rl_cfg_entry_point": f"{agents.__name__}.rsl_rl_ppo_cfg:MITCarPPORunnerCfg",
}
)

gym.register(
id='Isaac-MITCarIRL-v0',
entry_point='omni.isaac.lab.envs:ManagerBasedRLEnv',
kwargs={
"env_cfg_entry_point":MITCarIRLEnvCfg,
"rsl_rl_cfg_entry_point": f"{agents.__name__}.rsl_rl_ppo_cfg:MITCarPPORunnerCfg",
}
)

########################################
############ RACETRACK ENVS ############
########################################

from .manager_based.wheeled.mitcar.mitcar_manager_racetrack_env_cfg import (
MITCarRacetrackRLEnvCfg, MITCarRacetrackPlayEnvCfg
)

gym.register(
id='Isaac-MITCarRacetrack-v0',
entry_point='omni.isaac.lab.envs:ManagerBasedRLEnv',
kwargs={
"env_cfg_entry_point":MITCarRacetrackRLEnvCfg,
"rsl_rl_cfg_entry_point": f"{agents.__name__}.rsl_rl_ppo_cfg:MITCarPPORunnerCfg",
}
)

gym.register(
id='Isaac-MITCarRacetrackPlay-v0',
entry_point='omni.isaac.lab.envs:ManagerBasedRLEnv',
kwargs={
"env_cfg_entry_point":MITCarRacetrackPlayEnvCfg,
"rsl_rl_cfg_entry_point": f"{agents.__name__}.rsl_rl_ppo_cfg:MITCarPPORunnerCfg",
}
)

from .utils import import_packages

# The blacklist is used to prevent importing configs from sub-packages
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright (c) 2022-2024, The Isaac Lab Project Developers.
# All rights reserved.

from omni.isaac.lab.utils import configclass

from omni.isaac.lab_tasks.utils.wrappers.rsl_rl import (
RslRlOnPolicyRunnerCfg,
RslRlPpoActorCriticCfg,
RslRlPpoAlgorithmCfg,
)


# Adapted from lab_tasks/direct/cartpole/agents/rsl_rl_ppo_cfg.py
#
@configclass
class MITCarPPORunnerCfg(RslRlOnPolicyRunnerCfg):
num_steps_per_env = 128
max_iterations = 150
save_interval = 50
experiment_name = "ppo_mitcar"

empirical_normalization = False
policy = RslRlPpoActorCriticCfg(
init_noise_std=1.0,
actor_hidden_dims=[128, 128],
critic_hidden_dims=[128, 128],
activation="elu",
)
algorithm = RslRlPpoAlgorithmCfg(
value_loss_coef=1.0,
use_clipped_value_loss=True,
clip_param=0.2,
entropy_coef=0.005,
num_learning_epochs=5,
num_mini_batches=4,
learning_rate=1.0e-3,
schedule="adaptive",
gamma=0.99,
lam=0.95,
desired_kl=0.01,
max_grad_norm=1.0,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This is the observation ordering (DO NOT CHANGE)
# TODO: allow arbitrary re-ordering using this list
JOINT_NAMES = [
'chassis_to_back_left_wheel',
'chassis_to_back_right_wheel',
'chassis_to_front_left_hinge',
'chassis_to_front_right_hinge',
'front_left_hinge_to_wheel',
'front_right_hinge_to_wheel',
]

from .actions import ActionsCfg
from .observations import ObservationsCfg
from .events import EventCfg
from .commands import NoCommandsCfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import omni.isaac.lab.envs.mdp as mdp
from omni.isaac.lab.utils import configclass

from . import JOINT_NAMES

@configclass
class ActionsCfg:
"""Action specifications for the environment."""

joint_efforts = mdp.JointEffortActionCfg(
asset_name="robot",
joint_names=JOINT_NAMES,
scale=250.
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from omni.isaac.lab.envs import mdp
from omni.isaac.lab.utils import configclass

@configclass
class NoCommandsCfg:
"""Command terms for the MDP."""

# no commands for this MDP
null = mdp.NullCommandCfg()
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from omni.isaac.lab.envs import mdp
from omni.isaac.lab.managers import EventTermCfg as EventTerm
from omni.isaac.lab.managers import SceneEntityCfg
from omni.isaac.lab.utils import configclass

from . import JOINT_NAMES

@configclass
class EventCfg:
"""Configuration for events."""

# on startup
# add_pole_mass = EventTerm(
# func=mdp.randomize_rigid_body_mass,
# mode="startup",
# params={
# "asset_cfg": SceneEntityCfg("chassis"),
# "mass_distribution_params": (0.1, 0.5),
# "operation": "add",
# },
# )

# on reset
reset_car_joints = EventTerm(
func=mdp.reset_joints_by_offset,
mode="reset",
params={
"asset_cfg": SceneEntityCfg("robot", joint_names=JOINT_NAMES),
"position_range": (-0.0, 0.0),
"velocity_range": (-0.0, 0.0),
},
)

reset_car_pos = EventTerm(
func=mdp.reset_root_state_uniform,
mode="reset",
params={
"asset_cfg": SceneEntityCfg("robot", body_names=['chassis']),
"pose_range": {},
"velocity_range": {},
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

import omni.isaac.lab.envs.mdp as mdp
from omni.isaac.lab.utils import configclass
from omni.isaac.lab.managers import ObservationGroupCfg as ObsGroup
from omni.isaac.lab.managers import ObservationTermCfg as ObsTerm

from .. import utils

@configclass
class ObservationsCfg:
"""Observation specifications for the environment."""

@configclass
class PolicyCfg(ObsGroup):
"""Observations for policy group."""

# observation terms (order preserved)
joint_vel_rel = ObsTerm(func=mdp.joint_vel_rel)
root_pos_w = ObsTerm(func=utils.root_pos_w) # position in simulation world frame
root_quat_w = ObsTerm(func=mdp.root_quat_w)
base_lin_vel = ObsTerm(func=mdp.base_lin_vel)
base_ang_vel = ObsTerm(func=mdp.base_ang_vel)

def __post_init__(self) -> None:
self.enable_corruption = False
self.concatenate_terms = True

# observation groups
policy: PolicyCfg = PolicyCfg()

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from dataclasses import field

from omni.isaac.lab.utils import configclass
from omni.isaac.lab.envs import ManagerBasedRLEnvCfg

from . import ObservationsCfg, ActionsCfg, EventCfg

@configclass
class MITCarRLCommonCfg(ManagerBasedRLEnvCfg):
"""
Common configuration for the MIT Car environment.
Includes the basic settings:
- Observations
- Actions
- Events
as well as the number of environments and the spacing between them.

Also sets sim dt and decimation.
"""

num_envs: int = field(default=5)
env_spacing: float = field(default=0.05)

# Basic settings
observations = ObservationsCfg()
actions = ActionsCfg()
events = EventCfg()

def __post_init__(self):

self.sim.dt = 0.025 # sim step every 25ms = 40Hz
self.decimation = 4 # env step every 4 sim steps: 40Hz / 4 = 10Hz
self.sim.render_interval = self.decimation
Loading