# rethinkrobotics-opensource/sns_ik architecture

> Architecture diagram of the GitHub repository rethinkrobotics-opensource/sns_ik, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rethinkrobotics-opensource/sns_ik
- Repository: https://github.com/rethinkrobotics-opensource/sns_ik

## Overview

SNS-IK is a ROS/C++ library for computing constrained inverse kinematics on redundant robot chains. The main workflow configures a solver with a chain and joint limits, accepts a Cartesian pose or velocity task, and returns joint-space results; velocity algorithms also support prioritized/null-space goals, and the library includes a position solver and acceleration-level base solvers. The graph reflects documented solver variants and sampled initialization/solver internals. Several algorithm implementations were not sampled, so their wiring is shown only where the public facade explicitly selects solver types.

Main entry points: [`sns_ik_lib/src/sns_ik.cpp`](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_ik.cpp) (SNS IK facade), [`sns_ik_lib/src/sns_ik_base.cpp`](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_ik_base.cpp) (Shared solver base), [`sns_ik_lib/src/sns_vel_ik_base.cpp`](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_vel_ik_base.cpp) (Base velocity IK), [`sns_ik_lib/utilities/sns_linear_solver.cpp`](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/utilities/sns_linear_solver.cpp) (Linear solver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public interface"]
  node_facade["SNS IK facade<br/>[sns_ik.cpp]"]
  node_api_header["Solver API<br/>[sns_ik.hpp]"]
  node_position["Position IK"]
  node_jacobian["Chain Jacobian<br/>[sns_ik.cpp]"]
end

subgraph group_velocity["Velocity algorithms"]
  node_sns_vel["SNS velocity"]
  node_optimal["Optimal SNS"]
  node_margin["Margin optimal"]
  node_fast["Fast SNS"]
  node_fast_optimal["Fast optimal"]
end

subgraph group_base["Base solvers"]
  node_base_velocity["Base velocity IK"]
  node_base_interface["Base solver interface"]
  node_base_acceleration["Base acceleration IK"]
end

subgraph group_numerics["Numerical support"]
  node_base_common["Shared solver base<br/>[sns_ik_base.cpp]"]
  node_linear["Linear solver"]
  node_math["IK math utilities"]
end

node_client(("IK caller"))
node_ros["ROS parameter server"]
node_urdf["Robot description"]
node_kdl["KDL kinematics"]

node_client -->|"requests IK"| node_facade
node_facade -->|"returns joints"| node_client
node_api_header -->|"defines API"| node_facade
node_facade -->|"solves pose"| node_position
node_facade -->|"dispatches velocity"| node_sns_vel
node_facade -->|"selects variant"| node_optimal
node_facade -->|"selects variant"| node_margin
node_facade -->|"selects variant"| node_fast
node_facade -->|"selects variant"| node_fast_optimal
node_facade -->|"creates solver"| node_jacobian
node_facade -->|"reads parameters"| node_ros
node_ros -->|"supplies description"| node_urdf
node_facade -->|"builds chain"| node_kdl
node_base_interface -->|"uses base"| node_base_velocity
node_base_velocity -->|"uses shared state"| node_base_common
node_base_acceleration -->|"uses shared state"| node_base_common
node_base_common -->|"decomposes systems"| node_linear
node_linear -.->|"uses legacy inverse"| node_math

click node_facade "https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_ik.cpp"
click node_api_header "https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/include/sns_ik/sns_ik.hpp"
click node_position "https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_position_ik.cpp"
click node_jacobian "https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_ik.cpp"
click node_sns_vel "https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_velocity_ik.cpp"
click node_optimal "https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/osns_velocity_ik.cpp"
click node_margin "https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/osns_sm_velocity_ik.cpp"
click node_fast "https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/fsns_velocity_ik.cpp"
click node_fast_optimal "https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/fosns_velocity_ik.cpp"
click node_base_velocity "https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_vel_ik_base.cpp"
click node_base_interface "https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_vel_ik_base_interface.cpp"
click node_base_acceleration "https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_acc_ik_base.cpp"
click node_base_common "https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_ik_base.cpp"
click node_linear "https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/utilities/sns_linear_solver.cpp"
click node_math "https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/utilities/sns_ik_math_utils.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_facade,node_api_header,node_position,node_jacobian toneBlue
class node_sns_vel,node_optimal,node_margin,node_fast,node_fast_optimal toneAmber
class node_base_velocity,node_base_interface,node_base_acceleration,node_ros toneMint
class node_base_common,node_linear,node_math toneRose
class node_client,node_urdf,node_kdl toneIndigo
```

## Components

### Public interface

- [SNS IK facade](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_ik.cpp): `sns_ik_lib/src/sns_ik.cpp`
- [Solver API](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/include/sns_ik/sns_ik.hpp): `sns_ik_lib/include/sns_ik/sns_ik.hpp`
- [Position IK](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_position_ik.cpp): `sns_ik_lib/src/sns_position_ik.cpp`
- [Chain Jacobian](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_ik.cpp): `sns_ik_lib/src/sns_ik.cpp`

### Velocity algorithms

- [SNS velocity](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_velocity_ik.cpp): `sns_ik_lib/src/sns_velocity_ik.cpp`
- [Optimal SNS](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/osns_velocity_ik.cpp): `sns_ik_lib/src/osns_velocity_ik.cpp`
- [Margin optimal](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/osns_sm_velocity_ik.cpp): `sns_ik_lib/src/osns_sm_velocity_ik.cpp`
- [Fast SNS](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/fsns_velocity_ik.cpp): `sns_ik_lib/src/fsns_velocity_ik.cpp`
- [Fast optimal](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/fosns_velocity_ik.cpp): `sns_ik_lib/src/fosns_velocity_ik.cpp`

### Base solvers

- [Base velocity IK](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_vel_ik_base.cpp): `sns_ik_lib/src/sns_vel_ik_base.cpp`
- [Base solver interface](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_vel_ik_base_interface.cpp): `sns_ik_lib/src/sns_vel_ik_base_interface.cpp`
- [Base acceleration IK](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_acc_ik_base.cpp): `sns_ik_lib/src/sns_acc_ik_base.cpp`

### Numerical support

- [Shared solver base](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/src/sns_ik_base.cpp): `sns_ik_lib/src/sns_ik_base.cpp`
- [Linear solver](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/utilities/sns_linear_solver.cpp): `sns_ik_lib/utilities/sns_linear_solver.cpp`
- [IK math utilities](https://github.com/rethinkrobotics-opensource/sns_ik/blob/indigo-devel/sns_ik_lib/utilities/sns_ik_math_utils.cpp): `sns_ik_lib/utilities/sns_ik_math_utils.cpp`

### Other components

- **IK caller**
- **ROS parameter server**
- **Robot description**
- **KDL kinematics**

## Connections

- IK caller → SNS IK facade: requests IK
- SNS IK facade → IK caller: returns joints
- Solver API → SNS IK facade: defines API
- SNS IK facade → Position IK: solves pose
- SNS IK facade → SNS velocity: dispatches velocity
- SNS IK facade → Optimal SNS: selects variant
- SNS IK facade → Margin optimal: selects variant
- SNS IK facade → Fast SNS: selects variant
- SNS IK facade → Fast optimal: selects variant
- SNS IK facade → Chain Jacobian: creates solver
- SNS IK facade → ROS parameter server: reads parameters
- ROS parameter server → Robot description: supplies description
- SNS IK facade → KDL kinematics: builds chain
- Base solver interface → Base velocity IK: uses base
- Base velocity IK → Shared solver base: uses shared state
- Base acceleration IK → Shared solver base: uses shared state
- Shared solver base → Linear solver: decomposes systems
- Linear solver → IK math utilities: uses legacy inverse
