# bharatm11/geomagic_touch_ros_drivers architecture

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

- Interactive diagram: https://gitdiagram.com/bharatm11/geomagic_touch_ros_drivers
- Repository: https://github.com/bharatm11/geomagic_touch_ros_drivers

## Overview

##### Main Components
- Hardware: 3D Systems Geomagic Touch haptic device.
- External Device Drivers & Libraries: OpenHaptics and Geomagic Touch device drivers (installed in /opt/OpenHaptics/ and /opt/geomagic_touch_device_driver/ respectively) along with low-level libraries like libraw1394, libPHANToMIO, libHD, and libHL.
- ROS Packages:
- omni_common: Contains the main driver logic including C++ source files (omni.cpp and omni_state.cpp), launch configurations (launch files for different modes), and a subfolder (dummyraw1394) that contains low-level hooks for device communication. This package is the central node that interfaces directly with the device via hardware libraries.
- omni_msgs: Defines custom ROS message types (OmniButtonEvent, OmniFeedback, and OmniState) that standardize the communication between the hardware interface node and other components or nodes in the ROS ecosystem.
- ROS Ecosystem (Middleware): The ROS core concepts (like the ROS Master, topics, and messages) that manage the communication between nodes.

##### Relationships and Interactions
- The haptic device communicates with the system via USB and its low-level drivers. The drivers (installed externally) provide an interface that is used by the "omni_common" package.
- The omni_common nodes process the device signals and convert them into standard ROS messages (as defined in omni_msgs). These messages are published on topics (such as /phantom/button, /phantom/force_feedback, /phantom/joint_states, /phantom/pose, and /phantom/state).
- The omni_description package holds the robot’s description (URDF and meshes) which is used by visualization tools (like RViz) to visually represent the device’s state and for simulation purposes.
- Launch files in omni_common coordinate the startup of these nodes. They define parameters and, in the case of dual device operation, orchestrate different device nodes with unique identifiers.

##### Architectural Patterns and Design Principles
- Modularity: Each package is designed to focus on a separate aspect of the overall system (driver functionality, robot description, message definitions), allowing for easy maintenance and potential future extension.
- Separation of Concerns: Hardware interfacing (within omni_common) is decoupled from the visual/model-related components (omni_description) and the standardized message definitions (omni_msgs).
- Standard ROS Communication: The system leverages ROS messaging (with custom message types) which simplifies integration with other ROS-based systems and nodes.

##### Relevant Technologies and Frameworks
- ROS (Robot Operating System): Central to the entire system for message passing, node management, and launching.
- C++: The primary language for the driver nodes within omni_common.
- CMake: For building the ROS packages, as indicated by the CMakeLists.txt files.
- URDF and RViz: Used for the robot description and visualization in omni_description.

##### Elements
- Clear Labels: Name each component (e.g., "3D Systems Geomagic Touch Hardware", "OpenHaptics / Geomagic Device Drivers", "omni_common Node", "omni_msgs Message Definitions", "omni_description URDF and Meshes", "ROS Master").
- Relationships: Mark dependencies such as the need for symbolic links to specific libraries (e.g., libraw1394, libPHANToMIO) that enable hardware communication.

##### Detailed Step-by-Step Outline
- "omni_description" component which provides URDF and meshes for visualization, and link it to the overall ROS ecosystem or directly to visualization tools such as RViz.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Hardware & Drivers
    Hardware["3D Systems Geomagic Touch Hardware"]:::hardware
    Drivers["Device Drivers & External Libraries\n(OpenHaptics, Geomagic Drivers, libraw1394,\nlibPHANToMIO, libHD, libHL)"]:::drivers

    %% ROS Packages container
    subgraph "ROS Packages"
        %% omni_common Package with Driver Core and dummyraw1394 Module
        subgraph "omni_common Package"
            subgraph "Driver Core"
                OCPP["omni.cpp"]:::ros_pkg
                OState["omni_state.cpp"]:::ros_pkg
            end
            Dummy["dummyraw1394 Module"]:::ros_pkg
        end

        %% Launch Configurations as separate nodes
        subgraph "Launch Configurations"
            LSingle["omni_state.launch"]:::ros_pkg
            LDual["dual_phantom.launch"]:::ros_pkg
        end

        %% Custom ROS Message Definitions
        ROSMsg["omni_msgs Message Definitions"]:::ros_pkg

        %% Robot Description assets (URDF and Meshes)
        subgraph "omni_description Assets"
            URDF["URDF Files"]:::ros_pkg
            Meshes["Mesh Files"]:::ros_pkg
        end
    end

    %% ROS Middleware node
    Middleware["ROS Middleware\n(Master, Topics)"]:::middleware

    %% Connections
    Hardware -->|"USB"| Drivers
    Drivers -->|"interfaces with"| OCPP
    LSingle -->|"launches"| OCPP
    LDual -->|"launches"| OCPP
    OCPP -->|"publishes"| ROSMsg
    OCPP -->|"streams data"| Middleware
    OCPP -->|"uses"| Dummy
    ROSMsg -->|"via_ROS_topics"| Middleware
    URDF -->|"for_visualization"| Middleware
    Meshes -->|"for_visualization"| Middleware

    %% Dashed arrow to indicate internal module dependency
    OCPP -. "calls" .-> Dummy

    %% Click Events
    click OCPP "https://github.com/bharatm11/geomagic_touch_ros_drivers/blob/hydro-devel/omni_common/src/omni.cpp"
    click OState "https://github.com/bharatm11/geomagic_touch_ros_drivers/blob/hydro-devel/omni_common/src/omni_state.cpp"
    click LSingle "https://github.com/bharatm11/geomagic_touch_ros_drivers/blob/hydro-devel/omni_common/launch/omni_state.launch"
    click LDual "https://github.com/bharatm11/geomagic_touch_ros_drivers/blob/hydro-devel/omni_common/launch/dual_phantom.launch"
    click Dummy "https://github.com/bharatm11/geomagic_touch_ros_drivers/tree/hydro-devel/omni_common/dummyraw1394/"
    click ROSMsg "https://github.com/bharatm11/geomagic_touch_ros_drivers/tree/hydro-devel/omni_msgs/msg/"
    click URDF "https://github.com/bharatm11/geomagic_touch_ros_drivers/tree/hydro-devel/omni_description/urdf/"
    click Meshes "https://github.com/bharatm11/geomagic_touch_ros_drivers/tree/hydro-devel/omni_description/meshes/"

    %% Styles
    classDef hardware fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef drivers fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef ros_pkg fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef middleware fill:#FFB6C1,stroke:#000,stroke-width:2px;
```
