Thanks to visit codestin.com
Credit goes to github.com

Skip to content

aleskucera/axion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Axion: A Differentiable Physics Simulator

Axion is a high-performance, differentiable physics simulator designed for robotics research, machine learning, and applications requiring accurate gradients through complex dynamics. Built on top of NVIDIA Warp, it leverages GPU acceleration and automatic differentiation to enable gradient-based optimization for physics-driven systems.

๐Ÿš€ Overview

Differentiable simulators are crucial tools for bridging physics-based modeling with gradient-based optimization techniques common in machine learning and robotics. Axion provides a powerful and flexible simulation environment that addresses key challenges in the field:

Core Capabilities

  • โšก GPU Acceleration: Built on NVIDIA Warp for parallel execution on modern GPUs, maximizing computational throughput
  • ๐Ÿ”ง Flexible Configuration: Hydra-based configuration system for easy experimentation and parameter tuning
  • ๐Ÿ“Š Comprehensive Logging: HDF5-based logging system for detailed simulation data capture and analysis
  • ๐ŸŽฎ Simulation Visualization: Rendering with configurable frame rates

Physics Features

  • Rigid Body Dynamics: Robust simulation of articulated and unarticulated rigid body systems
  • Contact & Collision: Advanced contact constraint handling with configurable stiffness and damping
  • Friction Modeling: Coulomb friction implementation with customizable coefficients
  • Joint Constraints: Support for various joint types in articulated systems
  • Adaptive Time Stepping: Dynamic integration methods for optimal performance and stability

๐Ÿ“ฆ Installation

Prerequisites

  • Python 3.12 or higher
  • CUDA-capable GPU (recommended)
  • NVIDIA Warp (automatically installed as dependency)

Install from Source

# Clone the repository
git clone https://github.com/aleskucera/axion.git
cd axion

# Install third-party dependencies
git submodule update --init --recursive

# Install with pip
pip install -e .

# Or install with uv (if you have it)
uv pip install -e .

Dependencies

Axion depends on the following key packages:

  • warp-lang: NVIDIA's differentiable graphics and physics library
  • torch: PyTorch for machine learning integration
  • hydra-core: Configuration management
  • h5py: HDF5 data logging
  • usd-core: Universal Scene Description support
  • trimesh: 3D mesh processing

๐ŸŽฏ Quick Start

Running Examples

Axion comes with several pre-built examples that demonstrate its capabilities:

# Simple ball bouncing example
python -m axion.examples.ball_bounce

# Collision primitives demonstration
python -m axion.examples.collision_primitives

# Helhest robot simulation
python -m axion.examples.helhest

# Simplified Helhest example
python -m axion.examples.helhest_simple

โš™๏ธ Configuration

Axion uses Hydra for flexible configuration management. Configuration files are organized in a modular structure:

conf/
โ”œโ”€โ”€ config.yaml          # Main configuration
โ”œโ”€โ”€ engine/             # Physics engine settings
โ”‚   โ”œโ”€โ”€ base.yaml
โ”‚   โ””โ”€โ”€ helhest.yaml
โ”œโ”€โ”€ simulation/         # Simulation parameters
โ”‚   โ”œโ”€โ”€ base.yaml
โ”‚   โ””โ”€โ”€ helhest.yaml
โ”œโ”€โ”€ rendering/          # Visualization settings
โ”‚   โ”œโ”€โ”€ 30_fps.yaml
โ”‚   โ””โ”€โ”€ headless.yaml
โ”œโ”€โ”€ execution/          # Execution modes
โ”‚   โ”œโ”€โ”€ cuda_graph.yaml
โ”‚   โ””โ”€โ”€ no_graph.yaml
โ””โ”€โ”€ profiling/          # Performance profiling
    โ”œโ”€โ”€ disabled.yaml
    โ”œโ”€โ”€ timing.yaml
    โ””โ”€โ”€ hdf5_logging.yaml

Configuration Override

You can override configuration parameters from the command line:

# Run with different frame rate
python -m axion.examples.ball_bounce rendering=headless

# Change engine parameters
python -m axion.examples.helhest engine=helhest simulation=helhest

# Enable profiling
python -m axion.examples.ball_bounce profiling=timing

๐Ÿ—๏ธ Architecture

Project Structure

axion/
โ”œโ”€โ”€ core/               # Core simulation engine
โ”‚   โ”œโ”€โ”€ engine.py      # Main physics engine
โ”‚   โ”œโ”€โ”€ engine_config.py
โ”‚   โ”œโ”€โ”€ engine_data.py
โ”‚   โ””โ”€โ”€ abstract_simulator.py
โ”œโ”€โ”€ constraints/        # Physics constraints
โ”‚   โ”œโ”€โ”€ contact_constraint.py
โ”‚   โ”œโ”€โ”€ friction_constraint.py
โ”‚   โ”œโ”€โ”€ joint_constraint.py
โ”‚   โ””โ”€โ”€ dynamics_constraint.py
โ”œโ”€โ”€ optim/             # Optimization algorithms
โ”‚   โ”œโ”€โ”€ cr.py          # Conjugate residual solver
โ”‚   โ”œโ”€โ”€ preconditioner.py
โ”‚   โ””โ”€โ”€ matrix_operator.py
โ”œโ”€โ”€ logging/           # Data logging utilities
โ”‚   โ”œโ”€โ”€ hdf5_logger.py
โ”‚   โ””โ”€โ”€ hdf5_reader.py
โ”œโ”€โ”€ types/             # Data structures
โ”‚   โ”œโ”€โ”€ contact_interaction.py
โ”‚   โ”œโ”€โ”€ joint_interaction.py
โ”‚   โ””โ”€โ”€ generalized_mass.py
โ””โ”€โ”€ examples/          # Example simulations

Key Components

  1. Engine Core: The AxionEngine class handles the main simulation loop, integrating Newton's method for solving nonlinear systems arising from implicit time integration.

  2. Constraint System: Modular constraint handlers for different physics phenomena:

    • Contact constraints with configurable stiffness/damping
    • Friction constraints using Coulomb model
    • Joint constraints for articulated bodies
    • Dynamics constraints for Newton-Euler equations
  3. Optimization Layer: Efficient linear solvers and preconditioners for handling large-scale systems:

    • Conjugate Residual (CR) solver
    • Matrix-free operators for memory efficiency
    • Jacobi preconditioning
  4. Logging Infrastructure: Comprehensive data capture for analysis and debugging:

    • HDF5-based storage for efficient data management
    • Real-time performance metrics
    • Configurable logging levels and outputs

๐Ÿ“Š Performance & Benchmarking

Axion includes benchmarking tools for performance analysis:

# Run constraint kernel benchmarks
python tests/contact_kernel_benchmark.py
python tests/dynamics_kernel_benchmark.py
python tests/friction_kernel_benchmark.py
python tests/joint_kernel_benchmark.py

# Combined kernel benchmark
python tests/combined_kernel_benchmark.py

Performance Features

  • CUDA Graph Execution: Optimized GPU kernel execution
  • Sparse Matrix Operations: Efficient handling of large systems
  • Parallel Constraint Resolution: GPU-accelerated constraint solving
  • Adaptive Timestep Control: Dynamic adjustment for stability and speed

๐Ÿ› ๏ธ Development

Running Tests

# Run all tests
pytest tests/

# Run specific test
pytest tests/test_ncp.py -v

Building Documentation

# Build with mkdocs
mkdocs build

# Serve locally
mkdocs serve

๐Ÿค Contributing

We welcome contributions! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ง Contact

Author: Aleลก Kuฤera
Email: [email protected]
Institution: Czech Technical University in Prague


Built with โค๏ธ for the robotics and machine learning community

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages