Setup

Google Colab

!git clone --depth 1 https://github.com/anthonyjclark/lwmr.git
!cd lwmr && uv pip compile pyproject.toml -o requirements.txt
!uv pip install -r lwmr/requirements.txt

import sys
sys.path.insert(0, "/content/lwmr/tutorial")

from google.colab import output

serializer = viewer._server.get_scene_serializer() serializer.show()

Project Setup

I always recommend cloning the main libraries and tools you will be using for a project. Unlike the installed versions, the source code often includes examples, documentation, and other resources that are helpful for learning and debugging.

# Create a directory for this tutorial
cd SOME/DIRECTORY/WHERE/YOU/KEEP/PROJECTS
mkdir simr
cd simr

# We won't be using Isaac Lab directly, but it includes a lot of useful resources and examples
# But only on the develop branch
git clone --depth 1 --branch develop https://github.com/isaac-sim/IsaacLab.git

git clone --depth 1 https://github.com/newton-physics/newton.git

# Clone the tutorial repository and sync dependencies
git clone --depth 1 https://github.com/anthonyjclark/lwmr.git
cd lwmr
uv sync
source .venv/bin/activate

# Test the package with
python -m lwmr # see options with --help

# Configuring ipykernel
# python -m ipykernel install --user --name 'lwmr' --display-name "Python (lwmr)"

python -m jupyter lab --port 8047 --no-browser

When necessary, I will install the cloned libraries as editable packages in the project. This allows you to import them as if they were installed, but any changes you make to the source code will be reflected immediately without needing to reinstall.

Starting a New Project

You do not need to start a new project for this tutorial.

# From inside your project directory
uv init --python 3.13 --bare
uv init --package packages/lwmr

# Install dependencies
# If using local installation: uv add "./path/to/newton[examples,notebook,torch-cu12]")
uv add "newton[examples,notebook,torch-cu12]"

# Minimal example
uv run -m newton.examples basic_pendulum --viewer null
# Extended example
uv run --extra examples -m newton.examples robot_humanoid --num-envs 16 --viewer null
# Torch example
uv run --extra examples --extra torch-cu12 -m newton.examples robot_anymal_c_walk --viewer null
# List all examples
uv run -m newton.examples

# Create packages and add them to the project
uv init --package packages/lwmr
uv add --editable packages/lwmr

# This patch is needed until the gymnasium support is merged into stable-baselines3-contrib
uv add git+https://github.com/Stable-Baselines-Team/stable-baselines3-contrib@feat/gymnasium-support

Adding LWMR to Your Project

# Adding from a repo
uv add "lwmr @ git+https://github.com/anthonyjclark/lwmr#subdirectory=packages/lwmr"

# Adding from a local directory (recommended for development)
uv add --editable ../lwmr/packages/lwmr

Running the Tutorials

cd tutorial
python basic_gym.py --help
python basic_gym.py --quiet --steps 200
python basic_gym.py --quiet --steps 200 --num-legs 3
python basic_gym.py --quiet --steps 200 --num-legs 3 --num-worlds 2
python basic_gym.py --quiet --steps 200 --num-legs 3 --num-worlds 16 --add-step
python basic_gym.py --quiet --steps 200 --num-legs 3 --num-worlds 16 --add-step --fixed_base
python basic_gym.py --quiet --steps 200 --num-legs 3 --num-worlds 16 --add-step --wh-radius 0.02

# In a separate terminal
python -m http.server