# icub-tech-iit/training-systemcomposer-pendulum architecture

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

- Interactive diagram: https://gitdiagram.com/icub-tech-iit/training-systemcomposer-pendulum
- Repository: https://github.com/icub-tech-iit/training-systemcomposer-pendulum

## Overview

##### Project Type and Purpose
- This is a model-based control system example built in MATLAB/Simulink using System Composer.
- Its purpose is to demonstrate a “digital thread” linking requirements → architecture → test harnesses for a pendulum control system (drive, sensors, physical plant, and obstacle handling).

##### File Structure
- Top‐level “architectures/arch_logical.slx” is your System Composer logical architecture.
- “models/” contains Simulink component models: Actuation, Driver, Controller, Environment, Obstacle, Pendulum, Sensors.
- “dictionaries/” holds Simulink data dictionaries (data_interface.sldd) and enumerations (PendulumTypes.m, ObstacleMode.m).
- “requirements/req_functional.slreqx” is the Requirements Toolbox project.
- “tests/” has test harnesses and test cases.
- “scripts/” contains helper MATLAB scripts (e.g., run_mech_explorer.m).

##### Pull Extra Insights from the README
- The README shows a high-level architecture image (assets/architecture.png).
- It stresses the digital thread: requirements linked to architecture, which links to test harnesses, which link to test cases.

##### Main Components & Interactions
- Controller (control algorithm)
- Driver (interface translating control commands to actuation signals)
- Actuation (power electronics / motor blockset)
- Pendulum (physical plant, Simscape Multibody)
- Sensors (feedback of angle, velocity)
- Environment (gravity, optional obstacle)
- Obstacle (variant subsystem modeling contact)
- Requirements repository (linked artifact)
- Test Harnesses (one per use case: normal operation, safety test)
– Controller → Driver: “torque_setpoint”
– Driver → Actuation: “electrical_signal”
– Actuation → Pendulum: “torque”
– Pendulum → Sensors: “angle, velocity”
– Sensors → Controller: “feedback”
– Environment + Obstacle feed into Pendulum (physical interaction)
– Requirements (Req Toolbox) → Architecture ports (requirement links)
– Architecture → Test Harnesses (import architecture into each harness)
– Test Harness → Test Cases (data-driven link)
c. Architectural Patterns & Principles
– Functional decomposition: each function in its own model
– Variant subsystem for obstacle handling (ObstacleMode enum)
– Digital‐thread linking: bidirectional requirement traceability
– Separation of concerns: control logic vs. plant vs. I/O
d. Key Technologies & Libraries
– System Composer (architectures/*.slx)
– Simulink and Simscape blocksets (models/*.slx)
– Requirements Toolbox (requirements/*.slreqx)
– Simulink Test (tests/*.slx, .mldatx)
– Data dictionary for shared interfaces (dictionaries/*.sldd)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Requirements and Data Definitions
    ReqRepo["Requirements Repository"]:::req
    DataDict["Data Dictionary / Interface Definitions"]:::data
    Enums["Enumeration Types"]:::data

    %% Main Architecture
    subgraph "System Composer Logical Architecture"
        Arch["Logical Architecture"]:::arch
    end

    %% Software Layer
    subgraph "Software"
        Controller["Controller"]:::software
        Driver["Driver"]:::software
    end

    %% Hardware Abstraction
    subgraph "Hardware Abstraction"
        Actuation["Actuation"]:::hardware
    end

    %% Plant Layer
    subgraph "Plant"
        Pendulum["Pendulum"]:::plant
        Environment["Environment"]:::plant
        Obstacle["Obstacle"]:::variant
    end

    %% I/O Layer
    subgraph "I/O"
        Sensors["Sensors"]:::io
    end

    %% Test Harnesses
    subgraph "Test & Verification"
        TestHarness["Playback Mech Explorer Harness"]:::test
        TestCases["Test Cases"]:::test
    end

    %% Connections: Digital Thread & Data Flow
    ReqRepo -->|"traceability"| Arch
    DataDict --> Arch
    Enums --> Obstacle

    Arch --> Controller
    Arch --> Driver
    Arch --> Actuation
    Arch --> Pendulum
    Arch --> Sensors
    Arch --> Environment
    Arch --> Obstacle

    Controller -->|"torque_setpoint"| Driver
    Driver -->|"electrical_signal"| Actuation
    Actuation -->|"torque"| Pendulum
    Pendulum -->|"angle, velocity"| Sensors
    Sensors -->|"feedback"| Controller
    Environment --> Pendulum
    Obstacle --> Pendulum

    Arch --> TestHarness
    TestHarness --> TestCases

    %% Click Events
    click Controller "https://github.com/icub-tech-iit/training-systemcomposer-pendulum/blob/master/models/Controller.slx"
    click Driver "https://github.com/icub-tech-iit/training-systemcomposer-pendulum/blob/master/models/Driver.slx"
    click Actuation "https://github.com/icub-tech-iit/training-systemcomposer-pendulum/blob/master/models/Actuation.slx"
    click Pendulum "https://github.com/icub-tech-iit/training-systemcomposer-pendulum/blob/master/models/Pendulum.slx"
    click Sensors "https://github.com/icub-tech-iit/training-systemcomposer-pendulum/blob/master/models/Sensors.slx"
    click Environment "https://github.com/icub-tech-iit/training-systemcomposer-pendulum/blob/master/models/Environment.slx"
    click Obstacle "https://github.com/icub-tech-iit/training-systemcomposer-pendulum/blob/master/models/Obstacle.slx"
    click Arch "https://github.com/icub-tech-iit/training-systemcomposer-pendulum/blob/master/architectures/arch_logical.slx"
    click ReqRepo "https://github.com/icub-tech-iit/training-systemcomposer-pendulum/blob/master/requirements/req_functional.slreqx"
    click DataDict "https://github.com/icub-tech-iit/training-systemcomposer-pendulum/blob/master/dictionaries/data_interface.sldd"
    click Enums "https://github.com/icub-tech-iit/training-systemcomposer-pendulum/blob/master/dictionaries/enums/ObstacleMode.m"
    click Enums "https://github.com/icub-tech-iit/training-systemcomposer-pendulum/blob/master/dictionaries/enums/PendulumTypes.m"
    click TestHarness "https://github.com/icub-tech-iit/training-systemcomposer-pendulum/blob/master/tests/playback_mech_explorer.slx"
    click TestCases "https://github.com/icub-tech-iit/training-systemcomposer-pendulum/blob/master/tests/test_req.mldatx"

    %% Styles
    classDef software fill:#cce5ff,stroke:#3399ff
    classDef hardware fill:#b3d9ff,stroke:#3385ff
    classDef plant fill:#ccffcc,stroke:#33cc33
    classDef io fill:#ffdb99,stroke:#ff9933
    classDef test fill:#e0b3ff,stroke:#b366ff
    classDef req fill:#ffcccc,stroke:#ff3333
    classDef data fill:#ffffb3,stroke:#cccc00
    classDef arch fill:#d9d9d9,stroke:#666666
    classDef variant fill:#e6ffe6,stroke:#009900,stroke-dasharray: 5 5
```
