# alfakentavr/kinova_positional_control architecture

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

- Interactive diagram: https://gitdiagram.com/alfakentavr/kinova_positional_control
- Repository: https://github.com/alfakentavr/kinova_positional_control

## Overview

##### Project Type and Purpose
- This is a ROS‐based robotics control package for a Kinova Gen3 7DoF arm.
- It integrates two external ROS packages—`relaxed_ik` (IK solver) and `kinova_pid` (joint‐level PID controller)—to achieve end‐effector positional control.

##### File Structure
- **launch/**
Multiple launch files that orchestrate different modes (e.g., positional control, joints control, teleoperation, gripper control).
- **scripts/**
ROS Python nodes implementing:
- `/positional_control` (computes IK & commands joints)
- `/joints_control` (direct joint‐space commands)
- `/gripper_control` (open/close via service calls)
- `/oculus_mapping` (maps Oculus VR device pose to target EE pose)
- `/teleoperation` (teleoperation commands)
- **srv/**
Custom service definitions for gripper force, position, and PID velocity limits.
- **CMakeLists.txt / package.xml**
Declare dependencies and build/install instructions.

##### Extract Architectural Insights from README
- Inputs: desired end‐effector pose (from user, VR, or higher‐level planner).
- `relaxed_ik` solves for desired joint positions.
- `kinova_pid` executes joint‐level commands.
- Custom nodes mediate between inputs, solver, and controller.
- Services expose gripper and PID‐limit functionality.

##### Main Components
a. ROS Master
b. Input Sources
‣ VR Device (Oculus) ⇒ `oculus_mapping` node
‣ Teleoperation joystick ⇒ `teleoperation` node
‣ High‐level planner/user API ⇒ topics or services
c. Control Nodes (scripts/)
‣ PositionalControl
‣ JointsControl
‣ GripperControl
d. External ROS Packages
‣ `relaxed_ik` (IK solver node)
‣ `kinova_pid` (PID controller node)
e. Kinova Gen3 Hardware Driver
f. Custom Services (srv/)
‣ GripperForceGrasping.srv
‣ GripperPosition.srv
‣ PidVelocityLimit.srv

##### Relationships and Data Flows
- Inputs publish desired EE Pose on `/desired_ee_pose` topic.
- `positional_control` node
- Subscribes `/desired_ee_pose`
- Calls `relaxed_ik/solve_ik` service ⇒ returns joint targets
- Publishes joint targets on `/kinova_pid/desired_joint_states`
- `joints_control` node
- Accepts direct joint‐target topic/service, bypasses IK if needed
- `kinova_pid` node
- Subscribes `/kinova_pid/desired_joint_states`
- Commands motors via Kinova driver
- `gripper_control` node
- Exposes `/gripper_force_grasp` & `/gripper_position` services
- Under the hood calls Kinova gripper action topics
- `oculus_mapping` node maps VR pose ⇒ `/desired_ee_pose`
- `teleoperation` node maps joystick ⇒ `/desired_ee_pose` or joint targets
- Launch files instantiate subsets of these nodes, set parameters.

##### Architectural Patterns & Principles
- Modular ROS nodes with single responsibility
- Clear separation: Perception/Input → Planning (IK) → Control (PID) → Hardware
- Service‐oriented extensions for gripper & PID tuning
- Parameterization via ROS parameters in launch files
- Reusability by leveraging external packages (`relaxed_ik`, `kinova_pid`)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core ROS Master
    RM[/"ROS Master"/]:::master

    %% kinova_positional_control Package
    subgraph "kinova_positional_control Package"
        direction TB
        subgraph "Scripts"
            direction TB
            Oculus["oculus_mapping"]:::input
            Teleop["teleoperation"]:::input
            PosControl["positional_control"]:::control
            JointsControl["joints_control"]:::control
            GripperControl["gripper_control"]:::control
        end
        subgraph "Services"
            direction TB
            S1[/"GripperForceGrasping.srv"/]:::service
            S2[/"GripperPosition.srv"/]:::service
            S3[/"PidVelocityLimit.srv"/]:::service
        end
    end

    %% Launch Configurations
    subgraph "Launch Configurations"
        direction TB
        LaunchPos["positional_control.launch"]:::launch
        LaunchJoints["joints_control.launch"]:::launch
        LaunchOculus["oculus_mapping.launch"]:::launch
        LaunchPID["pid_controllers.launch"]:::launch
        LaunchTeleop["teleoperation.launch"]:::launch
        LaunchBimanual["bimanual_oculus_kinova_control.launch"]:::launch
    end

    %% External Packages
    subgraph "External Packages"
        direction TB
        RelaxedIK["relaxed_ik"]:::external
        KinovaPID["kinova_pid"]:::external
    end

    %% Hardware
    Hardware["Kinova Gen3 Arm & Driver"]:::hardware

    %% Data Flows and Relationships
    Oculus -->|"/desired_ee_pose"| PosControl
    Teleop -->|"/desired_ee_pose or joint targets"| PosControl
    PosControl -->|"solve_ik service call"| RelaxedIK
    RelaxedIK -->|"joint targets"| PosControl
    PosControl -->|"/kinova_pid/desired_joint_states"| KinovaPID
    JointsControl -->|"/kinova_pid/desired_joint_states"| KinovaPID
    KinovaPID -->|"motor commands"| Hardware
    GripperControl -->|"gripper action topics"| Hardware
    GripperControl -->|"/gripper_force_grasp"| S1
    GripperControl -->|"/gripper_position"| S2
    GripperControl -->|"/pid_velocity_limit"| S3

    %% Launch to Nodes
    LaunchPos --> PosControl
    LaunchJoints --> JointsControl
    LaunchOculus --> Oculus
    LaunchPID --> KinovaPID
    LaunchTeleop --> Teleop
    LaunchBimanual --> Oculus
    LaunchBimanual --> PosControl

    %% ROS Master registrations
    Oculus --> RM
    Teleop --> RM
    PosControl --> RM
    JointsControl --> RM
    GripperControl --> RM
    RelaxedIK --> RM
    KinovaPID --> RM

    %% Click Events
    click Oculus "https://github.com/alfakentavr/kinova_positional_control/blob/main/scripts/oculus_mapping.py"
    click Teleop "https://github.com/alfakentavr/kinova_positional_control/blob/main/scripts/teleoperation.py"
    click PosControl "https://github.com/alfakentavr/kinova_positional_control/blob/main/scripts/kinova_control/positional_control.py"
    click JointsControl "https://github.com/alfakentavr/kinova_positional_control/blob/main/scripts/kinova_control/joints_control.py"
    click GripperControl "https://github.com/alfakentavr/kinova_positional_control/blob/main/scripts/kinova_control/gripper_control.py"
    click LaunchPos "https://github.com/alfakentavr/kinova_positional_control/blob/main/launch/positional_control.launch"
    click LaunchJoints "https://github.com/alfakentavr/kinova_positional_control/blob/main/launch/joints_control.launch"
    click LaunchOculus "https://github.com/alfakentavr/kinova_positional_control/blob/main/launch/oculus_mapping.launch"
    click LaunchPID "https://github.com/alfakentavr/kinova_positional_control/blob/main/launch/pid_controllers.launch"
    click LaunchTeleop "https://github.com/alfakentavr/kinova_positional_control/blob/main/launch/teleoperation.launch"
    click LaunchBimanual "https://github.com/alfakentavr/kinova_positional_control/blob/main/launch/bimanual_oculus_kinova_control.launch"
    click S1 "https://github.com/alfakentavr/kinova_positional_control/blob/main/srv/GripperForceGrasping.srv"
    click S2 "https://github.com/alfakentavr/kinova_positional_control/blob/main/srv/GripperPosition.srv"
    click S3 "https://github.com/alfakentavr/kinova_positional_control/blob/main/srv/PidVelocityLimit.srv"

    %% Styles
    classDef input fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef control fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef external fill:#e5ccff,stroke:#333,stroke-width:1px
    classDef hardware fill:#dddddd,stroke:#333,stroke-width:1px
    classDef service stroke-dasharray: 5 5,fill:#fff,stroke:#333
    classDef launch fill:#ffe5cc,stroke:#333,stroke-width:1px
    classDef master fill:#fff2cc,stroke:#333,stroke-width:1px
```
