Skip to content

InteractiveComputerGraphics/stark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STARK

STARK Logo

FEM · Shells · Rigid Bodies · Frictional Contact · Strongly Coupled
Docs  ·  PDF  ·  IEEE Page

STARK is a C++ and Python simulation platform for strongly coupled simulation of rigid and deformable bodies with frictional contact. It provides a rich set of physics models — volumetric FEM, discrete shells, rods, rigid body joints, and IPC frictional contact — driven by SymX, a symbolic differentiation and JIT compilation engine that eliminates manual derivative computation, evaluation loops, and most performance tuning.

STARK is very easy to use and it is great for research. It has been validated through real-world, challenging cases of interactions between robots and deformable objects, see the STARK ICRA'24 paper.

STARK/SymX gallery

Features

  • Deformable objects
    • 1D rods and cables — axial strain with optional strain limiting
    • 2D cloth and shells — Neo-Hookean membrane strain (Stable Neo-Hookean) + discrete shell bending, inflation pressure
    • 3D soft bodies — linear tetrahedral FEM with Neo-Hookean constitutive model
    • Strain limiting, inertial and material damping, quasistatic mode
    • Composite materials: freely mix volume, surface, and rod energies on a single mesh
  • Rigid bodies
    • Comprehensive joint library: fix, ball, hinge, slider, universal, planar, point-on-axis, and more
    • Velocity controllers with smooth force/torque caps (paper)
    • Damped springs and distance limits
    • Automatic stiffness hardening to enforce tight tolerances without hand-tuning
  • Frictional contact
    • IPC-based, guaranteed intersection-free
    • All coupling modes: deformable–deformable, rigid–deformable, rigid–rigid
    • Per-pair Coulomb friction, per-object contact thickness
  • Attachments — penalty-based gluing by point list, barycentric coords, or proximity search; deformable–deformable and rigid–deformable
  • Powered by SymX — symbolic differentiation, automatic code generation, JIT compilation, OpenMP parallelism, and a robust Newton solver with line search and projection to PD
  • Python API (pystark) — full access to the C++ API from Python with NumPy interop
  • Event-based scripting — time events, callbacks, and animated boundary conditions
  • Extensible — add custom SymX energy potentials without modifying STARK internals; the symbolic gradient and Hessian are derived automatically

Hello World

import numpy as np
import pystark

# 1. Configure output and solver settings
settings = pystark.Settings()
settings.output.simulation_name = "spinning_box_cloth"
settings.output.output_directory = "output_folder"
settings.output.codegen_directory = "codegen_folder"

# 2. Create the simulation
simulation = pystark.Simulation(settings)

# 3. Set global contact parameters
contact_params = pystark.EnergyFrictionalContact.GlobalParams()
contact_params.default_contact_thickness = 0.0025
simulation.interactions().contact().set_global_params(contact_params)

# 4. Add a deformable cloth surface
cV, cT, cH = simulation.presets().deformables().add_surface_grid(
    "cloth",
    size=np.array([0.4, 0.4]),
    subdivisions=np.array([32, 32]),
    params=pystark.Surface.Params.Cotton_Fabric()
)

# 5. Add a rigid body box
bV, bT, bH = simulation.presets().rigidbodies().add_box("box", mass=1.0, size=0.08)
bH.rigidbody.add_translation(np.array([0.0, 0.0, -0.08]))
fix_handler = simulation.rigidbodies().add_constraint_fix(bH.rigidbody)

# 6. Script: spin the box over time
duration = 10.0
def script(t):
    fix_handler.set_transformation(
        np.array([0.0, 0.0, -0.08]),
        90.0*t,
        np.array([0.0, 0.0, 1.0])
    )

# 7. Run
simulation.run(duration, script)

The native C++ scene definition is 1-to-1 the same calls. Output is written as VTK files; you can open them in ParaView or in Blender with the Sequence Loader Addon.

Extending STARK

STARK physics models are SymX symbolic definitions of energy potentials. You can inject custom physics, without modifying worrying about implementation details or STARK internals.

The following example adds an implicit magnetic attraction to deformable vertices. What would take some effort, even for such a simple model, it's just a handful of lines:

stark::core::Stark& stark_core = simulation.get_stark();
stark::PointDynamics* dyn = simulation.deformables->point_sets.get();

stark_core.global_potential->add_potential("EnergyMagneticAttraction", magnetic_vertices,
    [&](MappedWorkspace<double>& mws, Element& elem)
    {
        Vector v1  = mws.make_vector(dyn->v1.data, elem["point"]);
        Vector x0  = mws.make_vector(dyn->x0.data, elem["point"]);
        Scalar dt  = mws.make_scalar(stark_core.dt);
        Scalar k   = mws.make_scalar(magnet_force);
        Vector m   = mws.make_vector(magnet_center);

        Vector x1 = stark::time_integration(x0, v1, dt);
        Vector r  = x1 - m;
        return -k / r.norm();
    }
);

Examples

The repository comes with C++ and Python examples to get you started.

C++ examples (examples/main.cpp):

  • hanging_net — a net of rods fixed at its perimeter and hanging under gravity
  • hanging_cloth — cloth fixed by two corners and hanging under gravity
  • hanging_deformable_box — a soft body fixed by two corners, baseline for FEM
  • hanging_box_with_composite_material — volume + surface + rod on one mesh
  • quasistatic_column_extrusion — quasistatic Neo-Hookean
  • attachments — two cloth panels and a rigid body glued by attachments
  • deformable_and_rigid_collisions — stacked soft boxes on a rigid floor
  • spinning_box_cloth — cloth on a spinning rigid box, IPC contact and friction
  • simple_grasp — parallel gripper grasping a deformable object
  • twisting_cloth — cloth twisted by animated boundary conditions
  • magnetic_deformables_implicit — external magnetic energy definition

Python examples (pystark/examples/):

  • spinning_box_cloth.py — the hello world scene
  • boxes_on_cloth.py — stack of rigid boxes landing on a pinned cloth
  • twisting_cloth.py — cloth twisted by prescribed boundary conditions
  • inflation.py — inflatable membrane with animated internal pressure
  • viscoelasticity.py — viscoelastic soft body compressed by a rigid torus

Get STARK

C++

STARK requires only CMake 3.18+, a C++20 compiler, and OpenMP.

cmake -S . -B build
cmake --build build --parallel

build/examples/examples   # run C++ examples

See Setup in Docs for the full integration guide.

Python (pystark)

Build from source with CMake:

cmake -S . -B build \
  -DSTARK_BUILD_PYTHON_BINDINGS=ON \
  -DSTARK_PYTHON_EXECUTABLE=$(which python)
cmake --build build --parallel --target pystark

export PYTHONPATH=/path/to/stark/pystark:$PYTHONPATH

See Setup in Docs for Conda/virtualenv instructions and Windows notes.

Documentation

Full documentation: https://stark.physics-simulation.org/

Research Using STARK

Cite STARK

If STARK contributes to your research, please cite the paper.

@InProceedings{FLL+24,
  author={Fern\'{a}ndez-Fern\'{a}ndez, Jos\'{e} Antonio and Lange, Ralph and Laible, Stefan and Arras, Kai O. and Bender, Jan},
  booktitle={2024 IEEE International Conference on Robotics and Automation (ICRA)},
  title={STARK: A Unified Framework for Strongly Coupled Simulation of Rigid and Deformable Bodies with Frictional Contact},
  year={2024},
  pages={16888-16894},
  doi={10.1109/ICRA57147.2024.10610574}
}

Want to Collaborate?

STARK is exactly the kind of project that benefits from real use in real environments.

If you are:

  • simulating soft robots, surgical tools, garments, or other compliant mechanisms
  • building FEM pipelines for animation or engineering
  • exploring differentiable simulation, contact, or multi-physics coupling
  • interested in extending the physics models, solver, or Python API

then feel free to reach out!

Acknowledgments

Robert Bosch GmbH is acknowledged for generous financial support of the development of the initial version of STARK from 2019 to 2021.

Contributors to the codebase:

About

Stark is a C++ and Python simulation platform for the robust simulation of rigid and deformable objects in a strongly coupled manner.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors