# woolfrey/software_robot_library architecture

> Architecture diagram of the GitHub repository woolfrey/software_robot_library, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/woolfrey/software_robot_library
- Repository: https://github.com/woolfrey/software_robot_library

## Overview

##### Project Type and Purpose
- RobotLibrary is a modular C++ library (not a networked application) that provides building blocks for robotic modeling, trajectory generation, and control.

##### File Structure Analysis
- Top-level: CMakeLists.txt, Config.cmake.in, LICENSE, README.md
- Subdirectories Control/, Math/, Model/, Trajectory/, each containing:
- CMakeLists.txt (build configuration)
- README.md (purpose, interfaces)
- /… (public headers under Control/, Math/, etc.)
- src/… (implementation .cpp files)
- External dependency: Eigen3 (for linear algebra) and tinyxml2 within Model for URDF parsing.

##### Insights from README
- Control builds on Model (kinematic tree) and Math (splines, polynomials).
- Model uses Math for numeric routines.
- Trajectory uses Math for smooth path generation.
- The library is consumed by client executables (examples or ROS2 packages) that link against RobotLibrary and Eigen.

a. Main Components
- Build System (CMake): orchestrates compilation of each module into a single RobotLibrary target.
- Math Module: low-level functions and data structures (polynomials, skew symmetric matrices, splines).
- Model Module: rigid-body and joint representations, kinematic tree, URDF parsing (tinyxml2).
- Trajectory Module: trajectory base class, polynomial splines, Cartesian splines, trapezoidal velocity profiles.
- Control Module: base controller class (SerialLinkBase), concrete velocity control (SerialKinematicControl).
- External Libraries:
- Eigen3 (linear algebra)
- (Embedded) tinyxml2 in Model
- Consumers: example executables, ROS2 action servers (external to this codebase).

b. Relationships and Data Flow
- Math module sits at the bottom layer.
- Trajectory is orthogonal but can be used by Control (not enforced by build, but possible at runtime).
- Build System coordinates all sub-modules into one library artifact.
- Clients (examples, ROS2 nodes) link RobotLibrary::RobotLibrary and Eigen3::Eigen.

c. Architectural Patterns
- Layered architecture: core utilities (Math) → domain model (Model) → application logic (Trajectory, Control).
- Modular design: each sub-library compiles independently with its own public include directory.
- Inheritance/Polymorphism: TrajectoryBase, SerialLinkBase provide extension points.

d. Key Technologies
- C++17 (language standard)
- CMake (build configuration, find_package for Eigen3 and RobotLibrary)
- eigen3-dev (external linear algebra)
- tinyxml2 (embedded in Model for URDF)

##### Detail
- That CMakeLists.txt at the root includes subdirectories for each module and installs a single RobotLibrary target.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Build System
    subgraph "Build System" 
        CMakeRoot["CMakeLists.txt"]:::build
        Config["Config.cmake.in"]:::build
        CMakeCtrl["Control/CMakeLists.txt"]:::build
        CMakeMath["Math/CMakeLists.txt"]:::build
        CMakeModel["Model/CMakeLists.txt"]:::build
        CMakeTraj["Trajectory/CMakeLists.txt"]:::build
    end

    %% Core Modules
    subgraph "Math Module" 
        direction TB
        MInc["include/Math"]:::core
        MSrc["src"]:::core
        MDoc["doc/ClassDiagrams.drawio"]:::core
    end

    subgraph "Model Module" 
        direction TB
        MoInc["include/Model"]:::core
        MoSrc["src"]:::core
        MoDoc["doc/ClassDiagrams.drawio"]:::core
    end

    %% Application Modules
    subgraph "Trajectory Module" 
        direction TB
        TInc["include/Trajectory"]:::app
        TSrc["src"]:::app
        TDoc["doc/ClassDiagrams.drawio"]:::app
    end

    subgraph "Control Module" 
        direction TB
        CInc["include/Control"]:::app
        CSrc["src"]:::app
        CDoc["doc/ClassDiagrams.drawio"]:::app
    end

    %% External and Clients
    subgraph "External Libraries" 
        Eigen["Eigen3"]:::external
        Tiny["tinyxml2"]:::external
    end

    Clients["Clients\n(example executables, ROS2 nodes)"]:::external

    %% Library Target
    RobotLib["RobotLibrary Target\n(C++17)"]:::core

    %% Dependencies
    CMakeRoot --> RobotLib
    RobotLib --> Clients
    Eigen --> RobotLib
    Tiny --> MoInc

    RobotLib --> MInc
    RobotLib --> MoInc
    RobotLib --> TInc
    RobotLib --> CInc

    MInc --> MoInc
    MInc --> TInc
    MInc --> CInc
    MoInc --> CInc
    TInc -.-> CInc

    %% Build system includes
    CMakeRoot --> CMakeMath
    CMakeRoot --> CMakeModel
    CMakeRoot --> CMakeTraj
    CMakeRoot --> CMakeCtrl

    %% Click Events
    click CMakeRoot "https://github.com/woolfrey/software_robot_library/blob/master/CMakeLists.txt"
    click Config "https://github.com/woolfrey/software_robot_library/blob/master/Config.cmake.in"
    click CMakeCtrl "https://github.com/woolfrey/software_robot_library/blob/master/Control/CMakeLists.txt"
    click CMakeMath "https://github.com/woolfrey/software_robot_library/blob/master/Math/CMakeLists.txt"
    click CMakeModel "https://github.com/woolfrey/software_robot_library/blob/master/Model/CMakeLists.txt"
    click CMakeTraj "https://github.com/woolfrey/software_robot_library/blob/master/Trajectory/CMakeLists.txt"

    click MInc "https://github.com/woolfrey/software_robot_library/tree/master/Math/include/Math"
    click MSrc "https://github.com/woolfrey/software_robot_library/tree/master/Math/src"
    click MDoc "https://github.com/woolfrey/software_robot_library/blob/master/Math/doc/ClassDiagrams.drawio"

    click MoInc "https://github.com/woolfrey/software_robot_library/tree/master/Model/include/Model"
    click MoSrc "https://github.com/woolfrey/software_robot_library/tree/master/Model/src"
    click MoDoc "https://github.com/woolfrey/software_robot_library/blob/master/Model/doc/ClassDiagrams.drawio"

    click TInc "https://github.com/woolfrey/software_robot_library/tree/master/Trajectory/include/Trajectory"
    click TSrc "https://github.com/woolfrey/software_robot_library/tree/master/Trajectory/src"
    click TDoc "https://github.com/woolfrey/software_robot_library/blob/master/Trajectory/doc/ClassDiagrams.drawio"

    click CInc "https://github.com/woolfrey/software_robot_library/tree/master/Control/include/Control"
    click CSrc "https://github.com/woolfrey/software_robot_library/tree/master/Control/src"
    click CDoc "https://github.com/woolfrey/software_robot_library/blob/master/Control/doc/ClassDiagrams.drawio"

    %% Styles
    classDef core fill:#D0E1F9,stroke:#1E4E79,stroke-width:2px
    classDef app fill:#DFF2D8,stroke:#3E6B35,stroke-width:2px
    classDef build fill:#ECECEC,stroke:#7A7A7A,stroke-width:2px
    classDef external fill:#FDEBD0,stroke:#B36308,stroke-width:2px
```
