Skip to content

Commit

Permalink
update Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
stompy-kscale committed Apr 13, 2024
1 parent e188cf7 commit b9306a0
Show file tree
Hide file tree
Showing 21 changed files with 2,565 additions and 578 deletions.
2 changes: 2 additions & 0 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# .gitignore

# Local files
.env
# Python
*.py[oc]
__pycache__/
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Benjamin Bolte
Copyright (c) 2023 KScale Labs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ kscale-sim-library

# Installing

1. Create a new Conda environment: `conda create --name kscale-sim-library python=3.11`
1. Create a new Conda environment: `conda create --name kscale-sim-library python=3.8.19`
2. Activate the environment: `conda activate kscale-sim-library`
3. Install the package: `make install-dev`

Expand Down
70 changes: 50 additions & 20 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,48 +1,78 @@
# K-Scale Sim Library
A library for simulating Stompy in Isaac Gym. This library is built on top of
the Isaac Gym library and Humanoid-gym and provides a simple interface for
running experiments with Stompy. For a start, we have defined two tasks:
getting up and walking.

We will be adding more tasks and simulator environments in upcoming weeks.

The walking task works reliably with upper body being fixed.
The getting up task is still an open challenge!


## Getting Started

1. Clone this repository:

```bash
git clone [email protected]:kscalelabs/sim.git
cd sim
```

2. Install the Isaac Docker image:

2. Create a new conda environment and install the package:
```bash
./sim/scripts/install_isaac_dependencies.sh
conda create --name kscale-sim-library python=3.8.19
conda activate kscale-sim-library
make install-dev
```

3. Start the Isaac Docker image in Headless mode (assuming you're working in a server environment):
3. Install third-party dependencies:
```bash
make install-third-party
```

### Running Stompy experiments
1. Download our model from
```bash
./sim/scripts/install_isaac_dependencies.sh
# Inside the Docker container
./runheadless.native.sh -v
wget https://media.kscale.dev/stompy.tar.gz & tar -xzvf stompy.tar.gz
python sim/scripts/create_fixed_stompy.py
export MODEL_DIR=stompy
```

### Notes
2. Run training with the following command:
```bash
python sim/humanoid_gym/train.py --task=legs_ppo --num_envs=4096 --headless
```
or for full body:
```bash
python sim/humanoid_gym/train.py --task=stompy_ppo --num_envs=4096 --headless
```

- After cloning Isaac Gym, sometimes the bindings mysteriously disappear. To fix this, update the submodule:
3. Run evaluation with the following command:
```bash
python sim/humanoid_gym/play.py --task legs_ppo --sim_device cpu
```

### Errors
After cloning Isaac Gym, sometimes the bindings mysteriously disappear.
To fix this, update the submodule:
```bash
git submodule update --init --recursive
```

- After generating the URDF, for some reason, Isaac Gym has a weird issue with the knee joints. To fix this, you should change the axis of the knee joints from:

```xml
<axis xyz="0 0 1" />
If you observe errors with libpython3.8.so.1.0, you can try the following:
```bash
export LD_LIBRARY_PATH=PATH_TO_YOUR_ENV/lib:$LD_LIBRARY_PATH
```

to

```xml
<axis xyz="0 0 -1" />
If you still see segmentation faults, you can try the following:
```bash
sudo apt-get vulkan1
```

For some reason this doesn't seem to happen for any other joints like the ankle, and also doesn't happen in other simulators like PyBullet.
### Appreciation
- [Humanoid-gym](https://sites.google.com/view/humanoid-gym/)
- [Isaac Gym](https://github.com/NVIDIA-Omniverse/IsaacGymEnvs)
- KScale Labs community for bugspotting and feedback

It might also be a good idea to remove the `mimic` joints between the motors and the ankles / knees.
### Discord
- [Discord](https://discord.com/invite/rhCy6UdBRD)
2 changes: 1 addition & 1 deletion setup.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
name="kscale-sim-library",
version=version,
description="Training models in simulation",
author="Benjamin Bolte",
author="Benjamin Bolte, Pawel Budzianowski",
url="https://github.com/kscalelabs/sim",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
10 changes: 7 additions & 3 deletions sim/env.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Defines common environment parameters."""

import os
from pathlib import Path

Expand All @@ -12,8 +11,13 @@ def run_dir() -> Path:
return Path(os.environ.get("RUN_DIR", "runs"))


def stompy_urdf_path() -> Path:
stompy_path = model_dir() / "robots" / "stompy" / "robot.urdf"
def stompy_urdf_path(legs_only=False) -> Path:
if legs_only:
stompy_path = model_dir() / "robot_fixed.urdf"
else:
stompy_path = model_dir() / "robot.urdf"

if not stompy_path.exists():
raise FileNotFoundError(f"URDF file not found: {stompy_path}")

return stompy_path.resolve()
Empty file modified sim/humanoid_gym/__init__.py
100644 → 100755
Empty file.
14 changes: 11 additions & 3 deletions sim/humanoid_gym/envs/__init__.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
import isaacgym
import torch

from .humanoid_config import StompyCfg, StompyPPO
from .humanoid_env import StompyFreeEnv
from .getup_config import GetupCfg, GetupCfgPPO
from .getup_env import GetupFreeEnv

from .legs_config import LegsCfg, LegsCfgPPO
from .legs_env import LegsFreeEnv

from .stompy_config import StompyCfg, StompyCfgPPO
from .stompy_env import StompyFreeEnv


def register_tasks() -> None:
Expand All @@ -22,7 +28,9 @@ def register_tasks() -> None:
"""
from humanoid.utils.task_registry import task_registry

task_registry.register("humanoid_ppo", StompyFreeEnv, StompyCfg(), StompyPPO())
task_registry.register("stompy_ppo", StompyFreeEnv, StompyCfg(), StompyCfgPPO())
task_registry.register("getup_ppo", GetupFreeEnv, GetupCfg(), GetupCfgPPO())
task_registry.register("legs_ppo", LegsFreeEnv, LegsCfg(), LegsCfgPPO())


register_tasks()
Loading

0 comments on commit b9306a0

Please sign in to comment.