Skip to content
SofaDefrostPublic

About

A SOFA plugin to simulate linear structures using Cosserat theory

Topics

Resources

Stars

62 stars

Watchers

6 watching

Forks

Repository files navigation

Cosserat Plugin

Gitter Support download forks stars

Overview

An open-source plugin compatible with the SOFA framework for simulating 1D objects. It enables modeling of rigid and flexible 1D entities such as rods, wires, or needles using Cosserat beam theory. You can create scenes in Python or XML, or develop new C++ components. Contributions are welcome!

Theory and Background

The Cosserat model simulates deformation of robot bodies with rod-like geometry and mechanical properties. It replicates nonlinear deformations including bending, torsion, extension, and shearing.

Key feature: each material point is treated as a rigid body with 6 degrees of freedom (3 translations + 3 rotations), unlike traditional models that treat points as particles with 3 translations.

This creates a framework similar to articulated solids, where relative positions are defined by strain states. It is well suited to modeling concentric tube robots, cable-actuated continuum robots, or pneumatic soft robots with constant cross-sections.

For theoretical details: Theory. The strain convention used in the code is described in STRAIN_CONVENTION.md.

Features

Piece-wise Constant Strain (PCS)

The main model of the plugin. The beam is split into sections, each with a constant strain (torsion, bending, elongation, shear). It is based on:

  • Discrete cosserat approach for soft robot dynamics: A new piece-wise constant strain model with torsion and shears Link
  • Coupling numerical deformable models in global and reduced coordinates for the simulation of the direct and inverse kinematics of Soft Robots Link
Video demonstration

Main components (see the READMEs in src/Cosserat/mapping and src/Cosserat/forcefield for details):

Kind Components
Mappings DiscreteCosseratMapping, DiscreteDynamicCosseratMapping, Strain2FramesCosseratMapping, Frames2StrainCosseratMapping, DifferenceMultiMapping, RigidDistanceMapping
Force fields BeamHookeLawForceField, HookeSeratPCSForceField (and their Rigid variants)
Constraints CosseratActuatorConstraint, CosseratSlidingConstraint, CosseratNeedleSlidingConstraint, QPSlidingConstraint

Lie group library

The src/liegroups folder contains an internal Lie group library used by the mappings and force fields: SO2, SO3, SE2, SE3, SE23, SGal3 and Bundle, together with Jacobians, BCH, interpolation and geometric integrators. It also contains tools built on top of it: trajectory optimization, an iLQR controller and parameter calibration for Cosserat rods. Unit tests are in src/liegroups/Tests, and the audit report is in AUDIT_LIEGROUPS.md.

Articulated rigid bodies

KinematicChain describes kinematic trees (one parent per segment) with per-segment Jacobians, and is exposed to Python through the standalone articulated_rigids module (see python-bindings). KinematicChainMapping maps joint coordinates and a rigid base to rigid frames in SOFA (apply, J, J^T, and constraint J^T), with dynamics on the mapped frames through RigidBodyMass.

Staggered (Painless) discretization — experimental

An alternative discretization where positions live on the nodes (Vec3) and rotations on the middle of the edges (SO3), following Painless Differentiable Rotation Dynamics (Romanyà-Serrasolsas, Casafranca, Otaduy, ACM ToG / SIGGRAPH 2025, DOI 10.1145/3730944). It is implemented by PainlessBeamForceField and StaggeredCosseratMapping. Forces and torques are exact, but the tangent stiffness is not complete yet, so only explicit integration is supported. Python scenes are in tutorials/advanced/staggered.

Piece-wise Non-constant Strain (planned)

Allow the strain to vary continuously within each beam section, for a more accurate description of complex deformations than the constant strain assumption. Useful for beams with varying material properties or under non-uniform loads.

DCM with Plastic Model (planned)

Extend the Discrete Cosserat Model (DCM) to plastic behavior, to simulate permanent deformations in materials that exceed their elastic limit.

Use Cases and Applications

Cochlear Implant Modeling

Using the Discrete Cosserat Model (DCM):

View 1 View 2 View 3
DCM implant, view 1 DCM implant, view 2 DCM implant, view 3

Cable Modeling for Deformable Robot Control

Soft gripper simulation Model convergence study
Soft gripper Convergence study with ten Cosserat sections

Actuation Examples

DCM beam actuated by cables:

Cable actuation 1 Cable actuation 2 Cable actuation 3
Beam actuated by a given cable Beam actuated along a circle Beam actuated by a cable

Animation Examples

Example 1 Example 2
PCS example 1 PCS example 2

Getting Started

  1. Install SOFA (v24 or later) with the SofaPython3 plugin, and build this repository as a SOFA plugin (C++17).
  2. Follow the setup tutorial: Tutorial 00 — Introduction and setup.
  3. Continue with the step-by-step tutorials in tutorials/getting_started (discretization, gravity, constraints, contact, curved beams, hybrid modeling) and read the tutorial guide.

The full Cosserat tutorial is also available here: Cosserat Tutorial.

Repository Layout

Path Content
src/Cosserat SOFA components: mappings, force fields, constraints, engines
src/liegroups Lie group library, kinematic chains, optimization and control tools, Python bindings, tests
tutorials Tutorial scenes: getting_started, intermediate, advanced (needle, staggered)
examples Python examples and the Python helper package
docs Documentation and images

Publications

  1. Discrete cosserat approach for soft robot dynamics: A new piece-wise constant strain model with torsion and shears
    IEEE Link

  2. Coupling numerical deformable models in global and reduced coordinates for the simulation of the direct and the inverse kinematics of Soft Robots
    IEEE Link
    PDF Download

  3. Painless Differentiable Rotation Dynamics (staggered discretization)
    DOI 10.1145/3730944

Contributing

We welcome contributions! Please open an issue or a pull request. For questions, use GitHub Discussions or the Gitter room.

License

This plugin is distributed under the GNU LGPL v3.

About

A SOFA plugin to simulate linear structures using Cosserat theory

Topics

Resources

Stars

62 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages