# ifl-camp/iiwa_stack architecture

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

- Interactive diagram: https://gitdiagram.com/ifl-camp/iiwa_stack
- Repository: https://github.com/ifl-camp/iiwa_stack

## Overview

##### Main Components
- Robot Description & Model:
– Represented by the “iiwa_description” package, which contains URDF/xacro files and meshes. This module defines the physical and visual model of the robot used for simulation and planning.
- Control Node & Motion Execution:
– “iiwa_control” contains launch files and configuration for high-level robot motion commands (integration with KUKA’s SmartServo and PTP motions).
- Hardware Interface:
– “iiwa_hw” encapsulates the hardware abstraction layer, including configuration and drivers (e.g., joint names YAML, hardware launch files, hardware plugin XML) that directly interface with robot actuators and sensors.
- Simulation Environment:
– “iiwa_gazebo” sets up the simulated robot environment for Gazebo, including world and launch files.
- Motion Planning & MoveIt! Integration:
– “iiwa_moveit” holds the configuration and launch files for integrating with MoveIt!. This includes planning pipelines, kinematics, and controllers.
- Message & Service Definitions:
– “iiwa_msgs” provides all the custom ROS messages, actions, and services needed for communication between components.
- ROS Interface Libraries (C++ and Java):
– “iiwa_ros” serves as the C++ client library bridging commands, services, and states across the project.
– “iiwa_ros_java” includes ROSJava nodes and helper classes that run as a Sunrise RoboticApplication on the robot, enabling native ROSJava integration.

##### Relationships and Interactions
- The ROS Master forms the backbone, orchestrating communication across all packages.
- “iiwa_msgs” acts as the lingua franca; all other modules (control, hardware, planning, Java interfaces) publish and subscribe to its topics/services.
- The “iiwa_control” and “iiwa_ros” packages manage sending control commands (via topics and services) that eventually propagate to the hardware layer (“iiwa_hw”) or get processed by the motion planning node (“iiwa_moveit”).
- “iiwa_description” feeds the robot model into both simulation (“iiwa_gazebo”) and planning (“iiwa_moveit”).
- “iiwa_ros_java” provides an alternative interface—running on the robot’s native environment—to support motion commands, status publishing, and parameter handling, effectively bridging the needs of Sunrise with the ROS ecosystem.

##### Architectural Patterns and Design Principles
- Modularity: Each package corresponds to a distinct component (e.g., control, simulation, hardware) and is loosely coupled through ROS messaging.
- Separation of Concerns: The stack delineates robot modeling, control commands, hardware drivers, and planning logic in separate modules.
- Middleware-Based Communication: The use of ROS topics, services, and actions ensures that data flow is consistent and decoupled.

##### Instructive Elements
- Rectangles for software modules.
- A central cloud or star for the ROS Master.
– Optionally add annotations that explain the communication type (e.g., “publishes JointPosition msg” or “calls ConfigureControlMode service”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Define nodes
    R("ROS Master"):::rosMaster
    M("iiwa_msgs\n(Message & Service Definitions)"):::msgs
    D("iiwa_description\n(Robot Description & Model)"):::description
    C("iiwa_control\n(Control Node & Motion Execution)"):::control
    H("iiwa_hw\n(Hardware Interface)"):::hw
    G("iiwa_gazebo\n(Simulation Environment)"):::simulate
    P("iiwa_moveit\n(Motion Planning & MoveIt! Integration)"):::moveit
    Rcpp("iiwa_ros\n(ROS C++ Interface Libraries)"):::rosif
    Rjava("iiwa_ros_java\n(ROSJava Interface Libraries)"):::rosjava

    %% Relationships with ROS Master
    R -->|"manages"| M
    M -->|"provides_msgs_to"| D
    M -->|"provides_msgs_to"| C
    M -->|"provides_msgs_to"| H
    M -->|"provides_msgs_to"| P
    M -->|"provides_msgs_to"| Rcpp
    M -->|"provides_msgs_to"| Rjava

    %% Robot Description feeds into Simulation and Planning
    D -->|"supplies_model_to"| G
    D -->|"supplies_model_to"| P

    %% Control and Interface relationships
    C -->|"sends_cmds_to"| H
    Rcpp -->|"bridges_cmds_to"| H

    %% ROSJava interface
    Rjava -->|"interfaces_with"| R

    %% Communication with ROS Master
    C -->|"communicates_with"| R
    Rcpp -->|"communicates_with"| R

    %% Simulation feedback
    G -->|"feedback_to"| R

    %% Click Events
    click D "https://github.com/ifl-camp/iiwa_stack/tree/master/iiwa_description/"
    click C "https://github.com/ifl-camp/iiwa_stack/tree/master/iiwa_control/"
    click H "https://github.com/ifl-camp/iiwa_stack/tree/master/iiwa_hw/"
    click G "https://github.com/ifl-camp/iiwa_stack/tree/master/iiwa_gazebo/"
    click P "https://github.com/ifl-camp/iiwa_stack/tree/master/iiwa_moveit/"
    click M "https://github.com/ifl-camp/iiwa_stack/tree/master/iiwa_msgs/"
    click Rcpp "https://github.com/ifl-camp/iiwa_stack/tree/master/iiwa_ros/"
    click Rjava "https://github.com/ifl-camp/iiwa_stack/tree/master/iiwa_ros_java/"

    %% Styles
    classDef rosMaster fill:#f9f,stroke:#333,stroke-width:4px;
    classDef msgs fill:#bbf,stroke:#333,stroke-width:2px;
    classDef description fill:#cfc,stroke:#333,stroke-width:2px;
    classDef control fill:#fc9,stroke:#333,stroke-width:2px;
    classDef hw fill:#f66,stroke:#333,stroke-width:2px;
    classDef simulate fill:#9cf,stroke:#333,stroke-width:2px;
    classDef moveit fill:#ff9,stroke:#333,stroke-width:2px;
    classDef rosif fill:#ccf,stroke:#333,stroke-width:2px;
    classDef rosjava fill:#c9f,stroke:#333,stroke-width:2px;
```
