Skip to content

Commit

Permalink
update links to gpr (#125)
Browse files Browse the repository at this point in the history
update links, remove unused scripts, fix ci/cd
  • Loading branch information
budzianowski authored Dec 5, 2024
1 parent 74cb9d7 commit ba66414
Show file tree
Hide file tree
Showing 20 changed files with 172 additions and 1,291 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ all:
# ------------------------ #

train-one-vis:
@python -m sim.train --task stompymini --num_envs 1
@python -m sim.train --task gpr --num_envs 1

train-many-vis:
@python -m sim.train --task stompymini --num_envs 16
@python -m sim.train --task gpr --num_envs 16

train:
@python -m sim.train --task stompymini --num_envs 4096 --headless
@python -m sim.train --task gpr --num_envs 4096 --headless

play:
@python -m sim.play --task stompymini
@python -m sim.play --task gpr

# ------------------------ #
# Build #
Expand Down
16 changes: 11 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.black]

line-length = 120
target-version = ["py311"]
target-version = ["py38"]
include = '\.pyi?$'

[tool.pytest.ini_options]
Expand Down Expand Up @@ -30,16 +30,21 @@ warn_redundant_casts = true
incremental = true
namespace_packages = false

exclude = ["sim/envs/", "sim/algo/*", "sim/utils/*", "sim/sim2sim.py",
"sim/scripts/create_mjcf.py", "sim/scripts/create_fixed_torso.py"]
exclude = ["sim/envs/", "sim/algo/", "sim/utils/", "sim/sim2sim.py",
"sim/scripts/create_mjcf.py", "sim/scripts/create_fixed_torso.py",
"sim/sim2sim_old.py", "sim/play_old.py"]

[[tool.mypy.overrides]]

module = [
"isaacgym.*",
"mujoco.*",
"sim.envs.*",
"sim.utils.*",
]

ignore_errors = true

[tool.isort]

profile = "black"
Expand All @@ -48,10 +53,11 @@ known_third_party = ["wandb"]
[tool.ruff]

line-length = 120
target-version = "py310"
target-version = "py38"

exclude = ["sim/envs/", "sim/algo/", "sim/play.py",
"sim/sim2sim.py","sim/utils", "sim/scripts/create_mjcf.py"]
"sim/sim2sim.py","sim/utils", "sim/scripts/create_mjcf.py",
"sim/play_old.py", "sim/sim2sim_old.py"]

[tool.ruff.lint]

Expand Down
119 changes: 0 additions & 119 deletions sim/compare_h5.py

This file was deleted.

8 changes: 2 additions & 6 deletions sim/envs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@
from sim.envs.humanoids.dora_env import DoraFreeEnv
from sim.envs.humanoids.g1_config import G1Cfg, G1CfgPPO
from sim.envs.humanoids.g1_env import G1FreeEnv
from sim.envs.humanoids.gpr_env import GprFreeEnv
from sim.envs.humanoids.grp_config import GprCfg, GprCfgPPO, GprStandingCfg
from sim.envs.humanoids.h1_config import H1Cfg, H1CfgPPO
from sim.envs.humanoids.h1_env import H1FreeEnv
from sim.envs.humanoids.stompymicro_config import StompyMicroCfg, StompyMicroCfgPPO
from sim.envs.humanoids.stompymicro_env import StompyMicroEnv
from sim.envs.humanoids.grp_config import (
GprCfg,
GprCfgPPO,
GprStandingCfg,
)
from sim.envs.humanoids.gpr_env import GprFreeEnv
from sim.envs.humanoids.xbot_config import XBotCfg, XBotCfgPPO
from sim.envs.humanoids.xbot_env import XBotLFreeEnv
from sim.utils.task_registry import TaskRegistry # noqa: E402
Expand Down
4 changes: 2 additions & 2 deletions sim/envs/humanoids/grp_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class rewards:
target_joint_pos_scale = 0.17 # rad
target_feet_height = 0.06 # m

cycle_time = 0.25 # sec
cycle_time = 0.64 # sec
# if true negative total rewards are clipped at zero (avoids early termination problems)
only_positive_rewards = True
# tracking reward = exp(error*sigma)
Expand Down Expand Up @@ -180,7 +180,7 @@ class scales:

# base pos
default_joint_pos = 0.5
orientation = 1.
orientation = 1.0
base_height = 0.2
base_acc = 0.2
# energy
Expand Down
35 changes: 15 additions & 20 deletions sim/h5_logger.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
""" Logger for logging data to HDF5 files """
"""Logger for logging data to HDF5 files."""

import os
import uuid
from datetime import datetime
from typing import Dict
from typing import Dict, Tuple

import h5py
import matplotlib.pyplot as plt # dependency issues with python 3.8
Expand All @@ -17,7 +18,7 @@ def __init__(
max_timesteps: int,
num_observations: int,
h5_out_dir: str = "sim/resources/",
):
) -> None:
self.data_name = data_name
self.num_actions = num_actions
self.max_timesteps = max_timesteps
Expand All @@ -27,7 +28,7 @@ def __init__(
self.h5_file, self.h5_dict = self._create_h5_file()
self.current_timestep = 0

def _create_h5_file(self):
def _create_h5_file(self) -> Tuple[h5py.File, Dict[str, h5py.Dataset]]:
# Create a unique file ID
idd = str(uuid.uuid4())
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
Expand All @@ -43,8 +44,8 @@ def _create_h5_file(self):
dset_prev_actions = h5_file.create_dataset(
"prev_actions", (self.max_timesteps, self.num_actions), dtype=np.float32
)
dset_2D_command = h5_file.create_dataset("observations/2D_command", (self.max_timesteps, 2), dtype=np.float32)
dset_3D_command = h5_file.create_dataset("observations/3D_command", (self.max_timesteps, 3), dtype=np.float32)
dset_2d_command = h5_file.create_dataset("observations/2D_command", (self.max_timesteps, 2), dtype=np.float32)
dset_3d_command = h5_file.create_dataset("observations/3D_command", (self.max_timesteps, 3), dtype=np.float32)
dset_q = h5_file.create_dataset("observations/q", (self.max_timesteps, self.num_actions), dtype=np.float32)
dset_dq = h5_file.create_dataset("observations/dq", (self.max_timesteps, self.num_actions), dtype=np.float32)
dset_ang_vel = h5_file.create_dataset("observations/ang_vel", (self.max_timesteps, 3), dtype=np.float32)
Expand All @@ -61,8 +62,8 @@ def _create_h5_file(self):
h5_dict = {
"prev_actions": dset_prev_actions,
"curr_actions": dset_curr_actions,
"2D_command": dset_2D_command,
"3D_command": dset_3D_command,
"2D_command": dset_2d_command,
"3D_command": dset_3d_command,
"joint_pos": dset_q,
"joint_vel": dset_dq,
"ang_vel": dset_ang_vel,
Expand All @@ -72,7 +73,7 @@ def _create_h5_file(self):
}
return h5_file, h5_dict

def log_data(self, data: Dict[str, np.ndarray]):
def log_data(self, data: Dict[str, np.ndarray]) -> None:
if self.current_timestep >= self.max_timesteps:
print(f"Warning: Exceeded maximum timesteps ({self.max_timesteps})")
return
Expand All @@ -83,7 +84,7 @@ def log_data(self, data: Dict[str, np.ndarray]):

self.current_timestep += 1

def close(self):
def close(self) -> None:
for key, dataset in self.h5_dict.items():
max_val = np.max(np.abs(dataset[:]))
if max_val > self.max_threshold:
Expand All @@ -97,9 +98,8 @@ def close(self):
self.h5_file.close()

@staticmethod
def visualize_h5(h5_file_path: str):
"""
Visualizes the data from an HDF5 file by plotting each variable one by one.
def visualize_h5(h5_file_path: str) -> None:
"""Visualizes the data from an HDF5 file by plotting each variable one by one.
Args:
h5_file_path (str): Path to the HDF5 file.
Expand All @@ -122,9 +122,8 @@ def visualize_h5(h5_file_path: str):
print(f"Failed to visualize HDF5 file: {e}")

@staticmethod
def _plot_dataset(name: str, data: np.ndarray):
"""
Helper method to plot a single dataset.
def _plot_dataset(name: str, data: np.ndarray) -> None:
"""Helper method to plot a single dataset.
Args:
name (str): Name of the dataset.
Expand All @@ -144,7 +143,3 @@ def _plot_dataset(name: str, data: np.ndarray):
plt.grid(True)
plt.tight_layout()
plt.show()


if __name__ == "__main__":
HDF5Logger.visualize_h5("stompypro/5a7dc371-445c-4f56-be05-4e65c5cc38bc.h5")
Loading

0 comments on commit ba66414

Please sign in to comment.