|
| 1 | +# Collision Algorithm for Needle Insertion - SOFA Plugin |
| 2 | + |
| 3 | +[](https://github.com/sofa-framework/sofa/discussions/) |
| 4 | +[](https://discord.gg/G63t3a8Ra6) |
| 5 | +[](https://infinytech3d.com/) |
| 6 | +[](https://github.com/sponsors/InfinyTech3D) |
| 7 | + |
1 | 8 | ## Description |
2 | | -This is a SOFA plugin (https://github.com/sofa-framework/sofa) that provides a customized collision pipeline, specifically designed to support needle insertion simulations. |
3 | | -Works in conjunction with https://github.com/InfinyTech3D/ConstraintGeometry. |
| 9 | +This SOFA plugin (https://github.com/sofa-framework/sofa) provides a customized collision |
| 10 | +pipeline, designed specifically for needle insertion simulations. |
| 11 | + |
| 12 | +When used together with SOFA haptic device plugins, the system offers tactile feedback |
| 13 | +for puncture resistance, release and friction during insertion and retraction. |
| 14 | + |
| 15 | +This plugin has also been integrated in Unity via the [`SOFAUnity`](https://github.com/InfinyTech3D/SofaUnity) |
| 16 | +plugin by InfinyTech3D for an enhanced simulation experience. Contact us for more information! |
| 17 | + |
| 18 | +## Features |
| 19 | + |
| 20 | +- Proximity detection between the needle and tissue mesh primitives |
| 21 | +- Needle simulation phases: puncture, insertion, retraction |
| 22 | +- Constraint-based needle simulation during the 3 phases |
| 23 | +- Support for haptic feedback such as resistance during puncture and friction during insertion |
| 24 | +- Compatible with SOFA-Unity integration for real-time interactive applications |
| 25 | + |
| 26 | +## Installation and Setup |
| 27 | + |
| 28 | +First review the official SOFA documentation for building and registering SOFA plugins |
| 29 | +https://sofa-framework.github.io/doc/plugins/build-a-plugin-from-sources/ |
| 30 | + |
| 31 | +### Build Steps |
| 32 | + |
| 33 | +- Set up your `external_directories` directory (described in the SOFA documentation link above) |
| 34 | +- Clone this repository into your `external_directories` directory: |
| 35 | + - git clone https://github.com/InfinyTech3D/CollisionAlgorithm.git |
| 36 | +- Register the path to your local `CollisionAlgorithm` repository in the CMakeLists.txt file located inside your `external_directories` directory |
| 37 | +```sofa_add_subdirectory(plugin CollisionAlgorithm CollisionAlgorithm)``` |
| 38 | +- Set `SOFA_EXTERNAL_DIRECTORIES` variable (preferably using CMake GUI) to point to your `external_directories` directory |
| 39 | +- Configure and generate the SOFA solution using CMake |
| 40 | +- Compile SOFA solution (the plugin will be compiled as well) |
| 41 | + |
| 42 | +> [!IMPORTANT] |
| 43 | +> In order to use the plugin, make sure that you have also built the downstream |
| 44 | +[`ConstraintGeometry`](https://github.com/InfinyTech3D/ConstraintGeometry) plugin. |
| 45 | + |
| 46 | +Supported SOFA version: v25.06 and above |
| 47 | + |
| 48 | +## Architecture |
| 49 | + |
| 50 | +- doc: |
| 51 | + - Documentation and screenshots of the examples |
| 52 | +- scenes: |
| 53 | + - Various simple demo scenes |
| 54 | +- src/CollisionAlgorithm: |
| 55 | + - source code of the insertion algorithm SOFA component and supporting collision pipeline classes |
| 56 | +- regression: |
| 57 | + - Files for automated regression testing in alignment with SOFA's testing framework |
| 58 | + |
| 59 | +## Usage |
| 60 | + |
| 61 | +- To use the plugin, include the `CollisionAlgorithm` plugin in your SOFA .xml scene file. |
| 62 | + |
| 63 | +``` <RequiredPlugin name=`CollisionAlgorithm`/> ``` |
| 64 | +- Add the `CollisionLoop` component in the root node of your scene. |
| 65 | + |
| 66 | +``` |
| 67 | +<FreeMotionAnimationLoop/> |
| 68 | +<ProjectedGaussSeidelConstraintSolver tolerance='<your tolerance>' maxIt='<maximum solver iterations>' /> |
| 69 | +<CollisionLoop/> |
| 70 | +
|
| 71 | +<CollisionPipeline/> |
| 72 | +<BruteForceBroadPhase/> |
| 73 | +<BVHNarrowPhase/> |
| 74 | +<CollisionResponse name='response' response='FrictionContactConstraint'/> |
| 75 | +<LocalMinDistance name='proximity' alarmDistance='0.2' contactDistance='0.08'/> |
| 76 | +``` |
| 77 | +This component substitutes the default `CollisionPipeline` and manages the needle insertion algorithm. |
| 78 | +However, the two components can co-exist, allowing users to mix the standard collision detection/constraint resolution pipelines of SOFA. |
| 79 | + |
| 80 | +- Create a node to represent the needle and additional nodes for the needle tip and shaft geometries |
| 81 | +Refer to the `scenes/NeedleInsertion.xml` example scene for guidance. |
| 82 | + |
| 83 | +- Add an `InsertionAlgorithm` component inside the needle node as shown below. |
| 84 | +``` |
| 85 | +<Node name='needleInsertion'> |
| 86 | + <InsertionAlgorithm name='algorithm' |
| 87 | + tipGeom='@<path to needle tip geometry component>' |
| 88 | + shaftGeom='@<path to needle shaft geometry component>' |
| 89 | + surfGeom='@<path to tissue surface geometry component>' |
| 90 | + volGeom='@<path to tissue volume geometry component>' |
| 91 | + punctureForceThreshold='<float>' |
| 92 | + tipDistThreshold='<float>' |
| 93 | + /> |
| 94 | + <DistanceFilter algo='@algorithm' distance='<float>'/> |
| 95 | + <SecondDirection name='punctureDirection' |
| 96 | + handler='@<path to the tissue surface triangle handler>' |
| 97 | + /> |
| 98 | + <ConstraintUnilateral name='punctureConstraint' |
| 99 | + input='@algoSkin.collisionOutput' |
| 100 | + directions='@punctureDirection' |
| 101 | + mu='<float>' |
| 102 | + /> |
| 103 | + <FirstDirection name='bindDirection' handler='@<path to the normal handler of the needle beam'/> |
| 104 | + <ConstraintInsertion name='insertionConstraint' |
| 105 | + input='@algorithm.insertionOutput' |
| 106 | + directions='@bindDirection' |
| 107 | + frictionCoeff='<float>' |
| 108 | + /> |
| 109 | +</Node> |
| 110 | +``` |
4 | 111 |
|
5 | 112 | ## Acknowledgments |
6 | | -This project builds upon the original repository from [ICube Laboratory, University of Strasbourg](https://icube.unistra.fr/en/) and extends it with a needle insertion algorithm and additional functionality. |
| 113 | +This project builds upon the original repository from |
| 114 | +[ICube Laboratory, University of Strasbourg](https://icube.unistra.fr/en/) |
| 115 | +and extends it with a needle insertion algorithm and additional functionality. |
0 commit comments