# woolfrey/server_serial_link architecture

> Architecture diagram of the GitHub repository woolfrey/server_serial_link, 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/server_serial_link
- Repository: https://github.com/woolfrey/server_serial_link

## Overview

##### Project type and purpose
- This is a ROS2 package (“serial_link_action_server”) that implements a set of action servers to control serial-link robot arms in real time.
- It builds on an external “interface_serial_link” message definitions package and uses “RobotLibrary” for kinematics, dynamics, and control algorithms.

##### File structure
- Top-level artifacts:
- CMakeLists.txt / package.xml → ROS2 build and package configuration
- /serial_link_action_server → templated headers for the ActionServerBase and derived control classes
- src/ → implementation .cpp files and nodes/ subfolder containing ROS2 node entrypoints
- README.md → project description, usage, architecture overview
- Key patterns:
- A base class (ActionServerBase) with several derived servers (FollowTransform, FollowTwist, TrackCartesianTrajectory, TrackJointTrajectory)
- A ModelUpdater node that updates the RobotLibrary::Model::KinematicTree from joint states
- Nodes launch executables that combine these classes into running ROS2 action servers

##### README for additional insights
- The “Classes” section provides a logical overview:
- KinematicTree ← sensor_msgs::JointState
- ModelUpdater → updates the model
- SerialLinkBase ← uses model to control an arm branch
- ActionServerBase<TGoal> ← templated glue with feedback, goal handling
- Derived classes implement specific control loops
- The “Nodes” section explains how each executable wires up:
- Arguments: URDF path, endpoint link, joint command topic, joint state topic, plus YAML parameters

##### Detail
- ModelUpdater as a distinct component
- Parameters flowing from YAML into SerialLinkBase
- External action clients or transform/twist publishers as separate actors if relevant

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% ROS2 Nodes
    subgraph "ROS2 Nodes"
        ModelUpdater["ModelUpdater"]:::node
        FollowTransformServer["FollowTransformServer"]:::node
        FollowTwistServer["FollowTwistServer"]:::node
        CartesianTrajectoryServer["CartesianTrajectoryServer"]:::node
        JointTrajectoryServer["JointTrajectoryServer"]:::node
    end

    %% Core Libraries
    subgraph "Core Libraries"
        RobotLibrary["RobotLibrary::Model::KinematicTree"]:::lib
        SerialLinkBase["RobotLibrary::Control::SerialLinkBase"]:::lib
        ActionServerBase["ActionServerBase<T>"]:::lib
        ControlDerived["Derived Control Classes"]:::lib
    end

    %% Topics / Messages
    subgraph "Topics & Messages"
        JointStates["sensor_msgs::msg::JointState"]:::topic
        JointCommand["serial_link_interfaces::msg::JointCommand"]:::topic
        Twist["geometry_msgs::msg::TwistStamped / tf2"]:::topic
    end

    %% Configuration & Inputs
    subgraph "Configuration & Inputs"
        URDF["URDF File"]:::config
        YAML["YAML Config"]:::config
        CMake["CMakeLists.txt"]:::config
        PackageXML["package.xml"]:::config
        README["README.md"]:::config
        Drawio["doc/server_class_diagrams.drawio"]:::config
        BackupDrawio["doc/.$ClassDiagrams.drawio.bkp"]:::config
    end

    %% Connections: Topic flow
    JointStates -->|"/joint_states"| ModelUpdater
    ModelUpdater -->|updates| RobotLibrary
    RobotLibrary -->|kinematics/dynamics| SerialLinkBase
    SerialLinkBase -->|uses| ActionServerBase
    ActionServerBase -->|templated glue| ControlDerived

    %% Nodes use libraries
    ControlDerived -->|implements logic| FollowTransformServer
    ControlDerived -->|implements logic| FollowTwistServer
    ControlDerived -->|implements logic| CartesianTrajectoryServer
    ControlDerived -->|implements logic| JointTrajectoryServer

    %% Nodes publish/subscribe topics
    FollowTransformServer -->|publishes| JointCommand
    FollowTransformServer -->|subscribes| Twist
    FollowTwistServer -->|publishes| JointCommand
    FollowTwistServer -->|subscribes| Twist
    CartesianTrajectoryServer -->|publishes| JointCommand
    CartesianTrajectoryServer -->|subscribes| JointStates
    JointTrajectoryServer -->|publishes| JointCommand
    JointTrajectoryServer -->|subscribes| JointStates

    %% Configuration inputs to nodes
    URDF --> ModelUpdater
    YAML --> FollowTransformServer
    YAML --> FollowTwistServer
    YAML --> CartesianTrajectoryServer
    YAML --> JointTrajectoryServer

    %% Build & Documentation
    CMake --> PackageXML
    CMake --> README
    README --> Drawio
    README --> BackupDrawio

    %% Click Events
    click CMake "https://github.com/woolfrey/server_serial_link/blob/master/CMakeLists.txt"
    click PackageXML "https://github.com/woolfrey/server_serial_link/blob/master/package.xml"
    click README "https://github.com/woolfrey/server_serial_link/blob/master/README.md"
    click Drawio "https://github.com/woolfrey/server_serial_link/blob/master/doc/server_class_diagrams.drawio"
    click BackupDrawio "https://github.com/woolfrey/server_serial_link/blob/master/doc/.$ClassDiagrams.drawio.bkp"
    click ActionServerBase "https://github.com/woolfrey/server_serial_link/blob/master/include/serial_link_action_server/action_server_base.hpp"
    click ActionServerBase "https://github.com/woolfrey/server_serial_link/blob/master/include/serial_link_action_server/action_server_base.tpp"
    click FollowTransformServer "https://github.com/woolfrey/server_serial_link/blob/master/include/serial_link_action_server/follow_transform.hpp"
    click FollowTransformServer "https://github.com/woolfrey/server_serial_link/blob/master/src/follow_transform.cpp"
    click FollowTransformServer "https://github.com/woolfrey/server_serial_link/blob/master/src/nodes/follow_transform_server.cpp"
    click FollowTwistServer "https://github.com/woolfrey/server_serial_link/blob/master/include/serial_link_action_server/follow_twist.hpp"
    click FollowTwistServer "https://github.com/woolfrey/server_serial_link/blob/master/src/follow_twist.cpp"
    click FollowTwistServer "https://github.com/woolfrey/server_serial_link/blob/master/src/nodes/follow_twist_server.cpp"
    click CartesianTrajectoryServer "https://github.com/woolfrey/server_serial_link/blob/master/include/serial_link_action_server/track_cartesian_trajectory.hpp"
    click CartesianTrajectoryServer "https://github.com/woolfrey/server_serial_link/blob/master/src/track_cartesian_trajectory.cpp"
    click CartesianTrajectoryServer "https://github.com/woolfrey/server_serial_link/blob/master/src/nodes/trajectory_tracking_server.cpp"
    click JointTrajectoryServer "https://github.com/woolfrey/server_serial_link/blob/master/include/serial_link_action_server/track_joint_trajectory.hpp"
    click JointTrajectoryServer "https://github.com/woolfrey/server_serial_link/blob/master/src/track_joint_trajectory.cpp"
    click JointTrajectoryServer "https://github.com/woolfrey/server_serial_link/blob/master/src/nodes/trajectory_tracking_server.cpp"
    click ModelUpdater "https://github.com/woolfrey/server_serial_link/blob/master/include/serial_link_action_server/model_updater.hpp"
    click ModelUpdater "https://github.com/woolfrey/server_serial_link/blob/master/src/model_updater.cpp"
    click Utilities "https://github.com/woolfrey/server_serial_link/blob/master/include/serial_link_action_server/utilities.hpp"
    click Utilities "https://github.com/woolfrey/server_serial_link/blob/master/src/utilities.cpp"

    %% Styles
    classDef node fill:#d4edda,stroke:#28a745,stroke-width:1px
    classDef lib fill:#cce5ff,stroke:#004085,stroke-width:1px
    classDef topic fill:#ffe5b4,stroke:#d39e00,stroke-width:1px
    classDef config fill:#e2e3e5,stroke:#6c757d,stroke-width:1px
```
