Skip to content

Commit

Permalink
merge: <- master
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustDG committed Jan 8, 2025
2 parents 69c2acf + a4527aa commit 8bbed76
Show file tree
Hide file tree
Showing 59 changed files with 2,905 additions and 510 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "ros/newton_ros"]
path = ros/pkgs/newton_ros
url = https://github.com/TheNewtonCapstone/newton-ros
[submodule "ros/newton_sim_ros"]
path = ros/pkgs/newton_sim_ros
url = https://github.com/TheNewtonCapstone/newton-sim-ros
7 changes: 7 additions & 0 deletions .idea/libraries/ROS.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/libraries/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/newton-isaac-sim.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/Training.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 34 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
# TWIP - Isaac Sim
This repo contains the code and configuration used during our journey of developing TWIP using NVIDIA's Isaac Sim and rl games.
# Newton - Isaac Sim
This repo contains the code and configuration used during our journey of developing Newton using NVIDIA's Isaac Sim.

## Requirements
- Ubuntu 22.04 LTS (Works with Pop OS as well)
- Nvidia GPU with 510.73.05+ drivers (`nvidia-smi` to make sure these are set up)
- Isaac Sim (tested with version `4.0.0`)
- RL games
- Nvidia GPU (RTX 2070 & above) with 510.73.05+ drivers (execute `nvidia-smi` in your terminal to make sure the drivers are set up)
- Isaac Sim (tested with version `4.2.0`)
- Stable Baselines 3
- Anaconda | Miniconda
- If using ROS: install Mamba (optional; with `conda install mamba -c conda-forge`) for faster package installation

## Isaac Sim Setup
- Download Isaac Sim by following the steps found within Nvidia's installation (guide)[https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_workstation.html].
- Download Isaac Sim by following the steps found within Nvidia's installation [guide](https://docs.omniverse.nvidia.com/isaacsim/latest/installation/install_workstation.html).
- Run Isaac sim from the Omniverse application to make sure it runs properly
- Clone this repository `git clone https://github.com/TheNewtonCapstone/twip-isaac-sim`
- Remove any folder named `_isaac_sim`
- Run `cd twip-isaac-sim && ln -s home/YOUR_NAME/.local/share/ov/pkg/isaac-sim-4.0.0`
- Create the conda environment `conda env create -f environment.yml`
- Clone this repository `git clone https://github.com/TheNewtonCapstone/newton-isaac-sim`
- Run `cd newton-isaac-sim && ln -s /home/YOUR_USERNAME/.local/share/ov/pkg/isaac-sim-4.2.0 _isaac_sim`
- Create the conda environment `conda env create -f environment.yml`
- If using ROS: `conda env create -f environment_ros.yml`

## Repo Structure
- `twip.py`: Main script used for training/testing/exporting models
- `export.py`: Script for exporting models as ONNX files
- `cfg/task/`: YAML configs for each task defining environment parameters and domain randomization
- `cfg/train/`: YAML configs for each task defining RL model and hyperparameters
- `tasks/`: Class definitions and assets for each task
- `runs/`: Model checkpoints and summaries will be saved here

## Usage
- `newton.py`: Main script used for training/testing/exporting models
- `environment(_ros).yml`: Project dependency requirements
- `core/`: Contains all the core functionalities (Simulation, Training, Animation...)
- `assets/`: Contains miscellaneous assets (e.g. animations, USD files)
- `docs/`: Contains general project documentation
- `scripts/`: Contains helper scripts such as the animation keyframe extractor
- `configs/`: Contains the configuration files
- `runs/`: Model checkpoints and summaries will be saved here (by default)
- `apps/`: Contains the Isaac Sim applications configuration files

### Running Isaac Sim
The entry point of our project is `twip.py`. To run our project you must configure the environment:
The entry point of our project is `newton.py`. **Before running your IDE** (and in any terminal that you wish to run the project in), you must configure the environment:
- `conda activate isaac-sim`
- `source _isaac_sim/setup_conda_env.sh`
- `python twip.py --sim-only --num-envs 4`
- `source setup.sh`
- If using ROS: this script will automatically source the Newton ROS workspace

Now with your environment configured, within the same terminal, you can open your desired IDE:
- `pycharm` for Pycharm (recommended)
- `code` for VS Code

We have provided a simple CLI to allow you to start training your very own Newton. All you have to do is run `newton.py`!
Here is how the first option should look like:

`--sim-only` is used to run the simluation alone without any reinforcement learning. `--num-envs` specifies the number of twip environments within the simulation. To see all the options, run `twip.py --help`.
![docs/assets/mode_select.png](docs/assets/mode_select.png)

### Training
- `python train.py task={task_name}` to begin training
- execute `python newton.py` and select `training`.
- Models are saved as `runs/{TaskName}/nn/{checkpoint_name}.pth`

### Exporting ONNX
- `python twip.py --checkpoint="runs/{checkpoint_name}/nn/{task_name}.pth --export-onnx"` to export
- Model is exported to `runs/{checkpoint_name}/nn/{task_name}.pth.onnx`

### Adding a New Task (?)
Create a new folder called `tasks/{task_name}`. The following files will be needed:
- `tasks/{task_name}/{task_name}.py`: Class defining the task. Rewards, observations, actions are all defined here.
- `tasks/{task_name}/assets/`: URDF and meshes should be placed here.
- `cfg/task/{TaskName}.yaml`: Config file defining environment parameters and domain randomization
- `cfg/train/{TaskName}PPO.yaml`: Config file defining hyperparameters for training
- execute`python newton.py` and select `Exporting`.
- Model is exported to `runs/{checkpoint_name}/nn/{task_name}.pth.onnx`
Binary file modified assets/newton/.thumbs/256x256/newton.usd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/newton/newton.usd
Binary file not shown.
84 changes: 63 additions & 21 deletions configs/robots/newton.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,73 @@ robot_type: quadruped

# Kinematics
joints:
limits:
positions:
FR_HAA: [-45, 45]
gear_ratios:
FL_HAA: 9
FR_HAA: 9
HL_HAA: 9
HR_HAA: 9
FL_HFE: 9
FR_HFE: 9
HL_HFE: 9
HR_HFE: 9
FL_KFE: 9
FR_KFE: 9
HL_KFE: 9
HR_KFE: 9

effort_saturation: # of the input (i.e. the motor; before applying any gear ratio)
FL_HAA: 0.4
FR_HAA: 0.4
HL_HAA: 0.4
HR_HAA: 0.4
FL_HFE: 0.4
FR_HFE: 0.4
HL_HFE: 0.4
HR_HFE: 0.4
FL_KFE: 0.4
FR_KFE: 0.4
HL_KFE: 0.4
HR_KFE: 0.4

limits: # of the output (i.e. the joint itself, after applying any gear ratio)
positions: # deg
FL_HAA: [-45, 45]
HR_HAA: [-45, 45]
FR_HAA: [-45, 45]
HL_HAA: [-45, 45]
FR_HFE: [-90, 90]
HR_HFE: [-90, 90]
HR_HAA: [-45, 45]
FL_HFE: [-90, 90]
FR_HFE: [-90, 90]
HL_HFE: [-90, 90]
FR_KFE: [-175, 175]
HR_HFE: [-90, 90]
FL_KFE: [-175, 175]
HR_KFE: [-175, 175]
FR_KFE: [-175, 175]
HL_KFE: [-175, 175]
HR_KFE: [-175, 175]

velocities: # deg/s
FL_HAA: 5440
FR_HAA: 5440
HL_HAA: 5440
HR_HAA: 5440
FL_HFE: 5440
FR_HFE: 5440
HL_HFE: 5440
HR_HFE: 5440
FL_KFE: 5440
FR_KFE: 5440
HL_KFE: 5440
HR_KFE: 5440

velocities:
FR_HAA: 8000
FL_HAA: 8000
HR_HAA: 8000
HL_HAA: 8000
FR_HFE: 8000
HR_HFE: 8000
FL_HFE: 8000
HL_HFE: 8000
FR_KFE: 8000
FL_KFE: 8000
HR_KFE: 8000
HL_KFE: 8000
efforts: # Nm
FL_HAA: 6.3
FR_HAA: 6.3
HL_HAA: 6.3
HR_HAA: 6.3
FL_HFE: 6.3
FR_HFE: 6.3
HL_HFE: 6.3
HR_HFE: 6.3
FL_KFE: 6.3
FR_KFE: 6.3
HL_KFE: 6.3
HR_KFE: 6.3
42 changes: 42 additions & 0 deletions configs/ros.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
enabled: true
namespace: sim
domain_id: 25

defaults:
qos:
history: 0 # 0: system default, 1: keep last, 2: keep all, 3: unknown
depth: 5 # number of samples in history
reliability: 0 # 0: system default, 1: reliable, 2: best effort, 3: unknown
durability: 0 # 0: system default, 1: transient_local, 2: volatile, 3: unknown
lifespan:
seconds: 0
nanoseconds: 0
deadline:
seconds: 0
nanoseconds: 0
liveliness: 0 # 0: system default, 1: automatic, 2: manual_by_topic, 3: unknown
liveliness_lease_duration:
seconds: 0
nanoseconds: 0

nodes:
imu:
name: imu_node
pub_sim_topic: /sim/imu
pub_real_topic: /imu
pub_period: 5
pub_qos: None

contact:
name: contact_node
pub_sim_topic: /sim/contact
pub_real_topic: /contact
pub_period: 10
pub_qos: None

joints_controller:
name: joints_controller_node
pub_sim_topic: /sim/joints
pub_real_topic: /joints
pub_period: 5
pub_qos: None
1 change: 1 addition & 0 deletions configs/tasks/newton_idle_task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ base_lr: 3e-6
episode_length: 500

newton:
# TODO: Remove inverse_control_frequency as a task parameter
inverse_control_frequency: 4 # we're aiming for a total compute budget of 2 times the physics timestep (0.005s * 4 = 0.02s)

# TODO: Add gains as a configuration parameter
Expand Down
5 changes: 4 additions & 1 deletion configs/world.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
physics_dt: 0.005000
stage_units_in_meters: 1.0
# TODO: Fully implement control_dt functionality across all systems
# The idea is to have everything inside of the Universe object, so it's more easily accessed from one place
control_dt: 0.020000
rendering_dt: 0.01667
stage_units_in_meters: 1.0
backend: torch
device: cuda

Expand Down
2 changes: 2 additions & 0 deletions core/actuators/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .base_actuator import BaseActuator
from .dc_actuator import DCActuator
Loading

0 comments on commit 8bbed76

Please sign in to comment.