Skip to content

Latest commit

ย 

History

62 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CSA banner

๐Ÿ“š Cognitive Synergy Architecture (CSA)


โœจ Project Summary

CSA (Cognitive Synergy Architecture) is an advanced ROS 2โ€“native framework for human-centric robots.
It integrates perception (SEGO), planning (IMAGO), reasoning (ONN/LOGOS) and meta-reasoning (D-LOGOS)
for robots that understand, reason, adapt plans, and explain decisions in real time.

CSA is not just code โ€” it is a research journey that embodies my vision:

Robots that reason, reflect, and co-think with humans.

This repository contains the codebase, architecture, and demo pipelines for CSA research and development.

Modular cognition for robots that perceive, reason, and co-think with humans.

CSA is a multistage robotics framework that unifies semantic perception, adaptive planning, and explainable control under a single, ROS 2โ€“native codebase. It is organized into three tightly-coupled sub-architectures SEGO, IMAGO, and LOGOS that together deliver a full perception-to-action loop with built-in reasoning, safety, and self-reflection.

Sub-Architecture Core Question Key Capabilities (current state)
SEGO
(Semantic Graph Ontology mapper)
โ€œWhat exactly am I seeing?โ€ โ€ข Real-time RGB-D detection (YOLO v5)
โ€ข Multi-object tracking (StrongSORT)
โ€ข 6-DoF pose fusion (ORB-SLAM2 / RTAB-Map)
โ€ข 3-D semantic mapping + scene-graph export
IMAGO
(Intent Modeling & Action Generation Operator)
โ€œWhy should I act and how do I adapt my plan?โ€ โ€ข Natural-language intent parsing (LLM plugin)
โ€ข Symbolic & neuro-symbolic planners (HTN, BT, CoT)
โ€ข PPO-based self-adaptation + meta-controller
LOGOS
(Logical Ontological Generator for Self-adjustment)
โ€œDoes my behaviour remain safe, valid, and explainable?โ€ โ€ข Run-time ontology checks (OWL 2, DL-query)
โ€ข Policy distillation โ†’ decision trees
โ€ข Human-readable rationales (XAI report)

Status โ€“ 2025-06 14 SEGO Stage-1 is feature-complete; IMAGO & LOGOS scaffolding is included but most PRs are still WIP.
Road-mapped milestones are listed here ยป.


The CSA Stages

Stage Module Purpose
โ‘  SEGO Semantic mapping, scene graph construction
โ‘ก IMAGO Intent-driven planning, adaptive control
โ‘ข ONN Ontology Neural Network for topological reasoning
โ‘ฃ LOGOS Explainable decision making, reasoning trace
โ‘ค D-LOGOS Meta-reasoning, self-reflective rule evolution

๐Ÿ”ฌ Mathematical Foundations

  • Topological stability guarantee:

$$ d_{\rm PH}(G_C(t), G_C(t+\delta)) \le C_1 \sqrt{\mathcal{L}{\rm ricci}} + C_2 \mathcal{L}{\rm ph} $$

  • Phase margin under delay:

$$ \phi_{\rm margin}^{\rm effective} = \phi_{\rm design} - 360 f_c \Delta t + \phi_{\rm comp} \ge \phi_{\rm safe} $$

  • Adaptive control law:

$$ \dot{K} = -\alpha e(t) \dot{e}(t) $$ $$ V = \frac{1}{2} e^T P e $$ $$ \dot{V} = -e^T Q e \le 0 $$


๐Ÿ“˜ Learn More

This repository is based on the system architecture and cognitive vision proposed in
my own review papers:

These papers present the conceptual and theoretical foundation for CSA (Cognitive Synergy Architecture) โ€”
a modular framework that integrates semantic perception (SEGO), intention-aware planning (IMAGO),
and ontological reasoning with explainable control (LOGOS).

โœจ This project aims to realize the vision outlined in these papers:
to build robots that not only act, but also understand โ€”
semantically, ethically, and reflectively, in collaboration with humans.


๐Ÿ“‘ Table of Contents

  1. Quick Start
  2. High-Level Architecture
  3. Detailed Modules
  4. Installation Guide
  5. Runtime Walk-through
  6. Directory Layout
  7. Roadmap & Milestones

๐Ÿš€ Quick Start

# 0 ยท Host prerequisites (Ubuntu 22.04 + ROS 2 Humble assumed)
sudo apt update && sudo apt install build-essential git lsb-release curl

# 1 ยท Clone
git clone https://github.com/jack0682/CSA.git
cd CSA && git submodule update --init --recursive

# 2 ยท Setup ROS 2 & Python env
source /opt/ros/humble/setup.bash        # adjust if using another distro
python3 -m venv .venv && source .venv/bin/activate
pip install -U pip wheel
rosdep install --from-paths src -yi      # system deps

# 3 ยท Build (SEGO only)
colcon build --packages-select \
    csa_interfaces csa_yolo_inference csa_slam_interface csa_semantic_mapper
source install/setup.bash

# 4 ยท Run semantic mapping pipeline
ros2 launch csa_launch sego_pipeline.launch.py \
    camera_model:=realsense bag:=false visualize:=true

SEGO System Pipeline

SEGO System Pipeline

IMAGO System Pipeline

IMAGO System Pipeline


๐Ÿงญ High-Level Architecture

graph TD

%% === SEGO: Semantic Mapping ===
subgraph SEGO [Stage 1: Semantic Mapping]
  YT[yolo_tracker_node] --> OBJS[/tracked_objects/]
  SLAM[slam_pose_node] --> CAM[/camera/pose/]
  OBJS --> MAP[semantic_mapper_node]
  CAM --> MAP
  MAP --> SG[Scene Graph - JSON]
  SG --> MEM[Semantic Memory]
end

%% === IMAGO: Intent Parsing + Planning ===
subgraph IMAGO [Stage 2: Intent Planning]
  INTENT[Intent Parser] --> GGRAPH[Goal Graph]
  MEM --> GGRAPH
  GGRAPH --> PLAN[Trajectory Planner]
end

%% === LOGOS: Reasoning + Control ===
subgraph LOGOS [Stage 3: Ontological Control]
  PLAN --> ACT[ฯ• Actuator Commands]
  PLAN --> XAI[ฮจ XAI Rationale]
  XAI --> HRI[HRI UI / Speech]
  ONT[ฮฉ Ontology Rules] -.-> PLAN
end

classDef dim fill:#f9f9f9,stroke:#bbb,stroke-dasharray:5 5,color:#777;
class ONT dim;

Loading

Data Loop: sensor โ†’ semantic map โ†’ reasoning โ†’ plan โ†’ control โ†’ explanation

Safety Loop: LOGOS continuously validates each plan slice (ฮ”t) via OWL-based rules; if violation, a fallback BT and human prompt are triggered.

๐Ÿ”ฌ Module Breakdown (SEGO Stage-1)

1 ยท csa_yolo_inference

Feature Implementation
Detector YOLO v5 6.2 + Ultralytics API
Tracker StrongSORT (boxmot fork)
Depth Sampling RealSense D435 / any aligned depth topic
Output Message csa_interfaces/TrackedObjectArray

2 ยท csa_slam_interface

Wraps ORB-SLAM2 (stereo/RGB-D) or RTAB-Map. Publishes geometry_msgs/PoseStamped @ โ‰ˆ30 Hz on /camera/pose. Automatic time-sync with YOLO frames via TF + approx-time-policy.

3 ยท csa_semantic_mapper

Projects 2-D bounding boxes into 3-D world frame: Builds an online scene graph (network-x) and dumps incremental .json logs per track (ready for Neo4J ingestion).

{
  "class"   : "cbn_wooden_box",
  "track_id": 27,
  "position": [ 0.773, -0.142, 1.035 ],
  "size"    : [ 0.28, 0.35, 0.12 ],     // meters
  "pose_cov": [ 5.2e-4, 8.9e-4, โ€ฆ ],
  "timestamp": 1715530123.447,
  "world_frame": "map",
  "source": {
    "camera_frame": "realsense_link",
    "depth_px": 713
  }
}

4 ยท Visualization

Launch RViz2 with pre-loaded config: /rviz/sego_live.rviz Display: TF tree, /tracked_objects markers (ID-color keyed), occupancy map.

๐Ÿ–ฅ๏ธ Installation & Build

Layer Package Version Install hint
System Ubuntu 22.04 LTS apt โ€ฆ
ROS 2 Humble Hawksbill โ‰ฅ 0.11 link
Vision OpenCV 4.9 apt install libopencv-dev
ML PyTorch 2.2 + CUDA-11.7 pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117
SLAM ORB-SLAM2 custom included as git submodule
Tracker boxmot 0.2.x pip install boxmot
Misc pangolin / eigen3 latest apt install libeigen3-dev libgl1-mesa-dev

๐ŸŽฎ Runtime Flow

Step Node Topic Rate Note
โ‘  Sensor /camera/color/image_raw 30 Hz RealSense RGB
โ‘ก yolo_tracker_node /tracked_objects 15 Hz after NMS + tracker
โ‘ข slam_pose_node /camera/pose 30 Hz worldโ€“camera TF
โ‘ฃ semantic_mapper_node /scene_graph (latched) 2 Hz heavy but sparse
โ‘ค rviz2 markers live for debugging

๐Ÿ“‚ Repository Layout

CSA/
โ”œโ”€โ”€ docs/                 โ† diagrams, papers, design notes
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ csa_interfaces/   โ† ROS 2 msg definitions
โ”‚   โ”œโ”€โ”€ csa_yolo_inference/
โ”‚   โ”œโ”€โ”€ csa_slam_interface/
โ”‚   โ”œโ”€โ”€ csa_semantic_mapper/
โ”‚   โ”œโ”€โ”€ csa_utils/        โ† time_sync, coord transforms
โ”‚   โ”œโ”€โ”€ csa_launch/
โ”‚   โ”œโ”€โ”€ imago_core/       โ† planner skeleton (Stage 2)
โ”‚   โ””โ”€โ”€ logos_core/       โ† ontology + XAI (Stage 3)
โ”œโ”€โ”€ third_party/          โ† submodules (ORB-SLAM2, pangolinโ€ฆ)
โ”œโ”€โ”€ docker/
โ”œโ”€โ”€ .devcontainer/        โ† VS Code remote config
โ””โ”€โ”€ README.md             โ† you are here

๐Ÿ—บ๏ธ Roadmap & Milestones

Quarter Theme Deliverable
2025 Q3 IMAGO ฮฑ HTN planner; LLM intent parser
2025 Q4 LOGOS ฮฑ Live policy distillation + OWL safety layer
2026 Q1 Multi-robot demo Cross-agent shared scene graphs
2026 Q2 HRI pilot Common-ground intent classifier, voice+gesture
2026 Q4 Science Robotics submission End-to-end human+robots furniture assembly

IMAGO Control Architecture Backbone


โš™๏ธ IMAGO + Panda Integrated Design

IMAGO+Panda design Draft


โš™๏ธ IMAGO Core Structure

High-Level Input

  • TEXT QUERY
    Parses user language or natural language commands into intent representations.
    Connected with an sLLM-based text query and answering system.

  • SEGO MODULE
    Provides semantic information via scene graphs.
    Utilizes SEGO Scene Graph and Ontology Database.


Control Layer

  • Adaptive Compensator (Pole-Zero Autonomous)
    Real-time error correction based on pole-zero compensation.
    Receives rule/state feedback from the LOGOS MODULE for compensator adjustment.

  • Self-Adjusting Controller
    Adaptive control optimization.

  • Real-Time Motion Executor
    Executes final motion commands at the physical level.


LOGOS Interaction

  • Adaptive Compensator & LOGOS MODULE:
    Pole-zero compensation rule exchange
    Real-time rule optimization
    Meta-level reasoning feedback
    Handshake with real-time executor

โš™๏ธ Robot Arm Requirements

โœ… Provides joint-level control interface (Torque / Velocity / Position)
โœ… Real-time control loop period <1ms (RTOS or RT-capable)
โœ… Modifiable controller (Open Source or SDK provided)
โœ… Access to high-performance sensors/drivers (Force-Torque, Encoders)
โœ… Easy ROS2 or RTAPI integration
โœ… Low-level bus access (e.g., EtherCAT, CANopen)
โœ… Public SDK / HAL available

๐Ÿ‘‰ Target robot arm: Franka Emika Panda


โฑ Delay Issues and Architectural Limitations

  • libfranka API provides access above the HAL wrapping layer.
  • Torque commands are injected after internal impedance safety layers.
  • Latency accumulates through ROS2 โ†’ API โ†’ internal RT thread โ†’ driver stack.
  • Estimated accumulated delay: 3โ€“5 ms, which threatens phase margin and may induce oscillations.

๐Ÿ“ IMAGO Control Formulation

Plant Model

$$ G(s) = \frac{1}{J s^2 + B s} $$


Pole-Zero Compensator Design

Ideal design target:

$$ C(s) G(s) = 1 $$

Actual compensator:

$$ C(s) = J' s^2 + B' s $$


Delay-Aware Controller

With delay:

$$ G_d(s) = G(s) e^{-s \Delta t} $$

Effective compensator:

$$ C(s) G_d(s) = C(s) G(s) e^{-s \Delta t} $$

Phase margin degradation:

$$ \Phi_{\text{margin,eff}} = \Phi_{\text{design}} - 360 f \Delta t $$


Delay Compensation

Lead compensator form:

$$ C_{\text{delay}}(s) = \frac{\alpha T_{\text{lead}} s + 1}{T_{\text{lead}} s + 1}, \quad 0 < \alpha < 1 $$

Smith predictor (model-based):

$$ \tau_{\text{cmd}}(s) = C(s) \frac{G(s)}{G_d(s)} r(s) $$

Final torque command:

$$ \tau_{\text{cmd}}(s) = \left( J' s^2 + B' s \right) C_{\text{delay}}(s) e^{+s \Delta t} r(s) $$


Wrapping Transfer Function

$$ \tau_{\text{actual}}(s) = H_{\text{int}}(s) C(s) C_{\text{delay}}(s) e^{+s \Delta t} r(s) $$

Where:

$$ H_{\text{int}}(s) = \frac{\theta(s)}{\tau(s)} = \frac{1}{M s^2 + B s} $$


Nonlinear MIMO Dynamics

$$ M(\theta) \ddot{\theta} + C(\theta, \dot{\theta}) \dot{\theta} + G(\theta) = \tau_{\text{actual}} $$

$$ M(\theta) = \sum_{i=1}^6 M_i(\theta_1, \dots, \theta_i) $$

$$ C(\theta, \dot{\theta}) = \sum_{i=1}^6 \sum_{j=1}^6 c_{ij}(\theta) \dot{\theta}_j $$

$$ c_{ij}(\theta) = \frac{1}{2} \left[ \frac{\partial M_{ij}}{\partial \theta_j} + \frac{\partial M_{ij}}{\partial \theta_i} + \frac{\partial M_{jj}}{\partial \theta_i} \right] $$

$$ G(\theta) = \sum_{i=1}^6 g_i(\theta) $$


๐Ÿ”ง Self-Adjusting Adaptive Control Law

Adaptive update:

$$ \dot{K} = -\alpha e(t) \dot{e}(t) $$

Lyapunov function:

$$ V = \frac{1}{2} e^\top P e, \quad \dot{V} = -e^\top Q e \leq 0 $$

With delay compensation:

$$ e_J(t - \Delta t), \quad e_B(t - \Delta t) $$


โš™๏ธ Multi-Robot End-Effector Plan Synchronization

Global plan reference:

$$ \chi_d^{\text{ref}}(t) $$

Synchronization constraint:

$$ \forall i,j: \left| \chi_d^{\text{ee,i}}(t) - \chi_d^{\text{ref}}(t) \right| < \varepsilon_{\text{sync},ij} \quad \wedge \quad \left| \Delta t^i - \Delta t^j \right| < \varepsilon_{\text{latency}} $$

Synchronization torque:

$$ \tau_{\text{actual}}^i(s) \leftarrow \tau_{\text{actual}}^i(s) + K_{\text{sync}} \sum_j \left( \chi_d^{\text{ee,j}}(t) - \chi_d^{\text{ee,i}}(t) \right) $$


โš™๏ธ Final IMAGO Wrapping Control Structure

$$ \tau_{\text{actual}}(s) = H_{\text{int}}(s) C^{\text{ML}}(s) C_{\text{delay}}(s) e^{+s \Delta t} \mathcal{L} \theta_d^{\text{final}}(t) $$


Notes

  • Franka internal controller:
    RTOS + safety layers + motor driver layers โ†’ user control applies above HAL.
    Internal safety core modification is not allowed.

  • libfranka loop:
    1 kHz control loop โ†’ 1 ms period
    ROS2 โ†’ C++ API call โ†’ internal RT thread

  • Delay accumulation risk:
    Accumulated delay of several ms reduces phase margin, induces oscillation or overshoot.


Potential Extended Formulations

  • Multi-joint Smith predictor:

$$ \tau_{\text{cmd}}(s) = \sum_{i=1}^6 C_i(s) \frac{G_i(s)}{G_{d,i}(s)} r_i(s) $$

  • Frequency response with delay:

$$ |C(j\omega) G(j\omega)| \angle e^{-j \omega \Delta t} $$

  • Phase margin with frequency dependency:

$$ \Phi_{\text{margin,eff}}(\omega) = \Phi_{\text{design}}(\omega) - 360 \frac{\omega}{2 \pi} \Delta t $$


imago_controller/
โ”œโ”€โ”€ CMakeLists.txt                  # ROS2 + C++ ๋นŒ๋“œ ํŒŒ์ผ
โ”œโ”€โ”€ package.xml                      # ROS2 ํŒจํ‚ค์ง€ ๋ฉ”ํƒ€ ์ •๋ณด
โ”œโ”€โ”€ launch/
โ”‚   โ””โ”€โ”€ imago_controller.launch.py   # ROS2 launch ํŒŒ์ผ
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ controller_params.yaml       # IMAGO ํŒŒ๋ผ๋ฏธํ„ฐ (J, B, delay ๋“ฑ)
โ”‚   โ””โ”€โ”€ sync_params.yaml             # ๋‹ค์ค‘ ๋กœ๋ด‡ sync ํŒŒ๋ผ๋ฏธํ„ฐ
โ”œโ”€โ”€ include/
โ”‚   โ””โ”€โ”€ imago_controller/
โ”‚       โ”œโ”€โ”€ imago_controller.hpp          # ๋ฉ”์ธ ํด๋ž˜์Šค ์„ ์–ธ
โ”‚       โ”œโ”€โ”€ pole_zero_compensator.hpp     # Pole-Zero ๋ณด์ƒ๊ธฐ ํด๋ž˜์Šค
โ”‚       โ”œโ”€โ”€ delay_compensator.hpp         # Delay-aware ๋ณด์ƒ๊ธฐ ํด๋ž˜์Šค
โ”‚       โ”œโ”€โ”€ ml_estimator.hpp              # ML ๊ธฐ๋ฐ˜ inertia/Coriolis/gravity ์ถ”์ •
โ”‚       โ”œโ”€โ”€ sync_manager.hpp              # ๋‹ค์ค‘ ๋กœ๋ด‡ sync ๊ด€๋ฆฌ
โ”‚       โ”œโ”€โ”€ low_level_interface.hpp       # libfranka / EtherCAT ์ธํ„ฐํŽ˜์ด์Šค
โ”‚       โ””โ”€โ”€ utils.hpp                     # ๊ณตํ†ต ํ•จ์ˆ˜ (matrix ops, logging ๋“ฑ)
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ imago_controller.cpp              # ๋ฉ”์ธ control loop
โ”‚   โ”œโ”€โ”€ pole_zero_compensator.cpp
โ”‚   โ”œโ”€โ”€ delay_compensator.cpp
โ”‚   โ”œโ”€โ”€ ml_estimator.cpp
โ”‚   โ”œโ”€โ”€ sync_manager.cpp
โ”‚   โ”œโ”€โ”€ low_level_interface.cpp
โ”‚   โ””โ”€โ”€ main.cpp                          # ROS2 ๋…ธ๋“œ ์ง„์ž…์ 
โ”œโ”€โ”€ urdf/
โ”‚   โ””โ”€โ”€ panda_with_imago.urdf.xacro       # Panda + IMAGO ์ถ”๊ฐ€ ๋งํฌ/์„ผ์„œ URDF
โ”œโ”€โ”€ meshes/
โ”‚   โ””โ”€โ”€ (ํ•„์š” ์‹œ custom link/EE mesh ํŒŒ์ผ)
โ”œโ”€โ”€ scripts/
โ”‚   โ””โ”€โ”€ test_plot.py                      # Latency/torque/sync ๋ฐ์ดํ„ฐ ์‹œ๊ฐํ™”
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_imago_controller.cpp         # gtest ๊ธฐ๋ฐ˜ ์œ ๋‹›ํ…Œ์ŠคํŠธ
โ”œโ”€โ”€ docs/
โ”‚   โ””โ”€โ”€ design_overview.md                # ์„ค๊ณ„ ๋ฌธ์„œ
โ”œโ”€โ”€ data_logs/
โ”‚   โ””โ”€โ”€ (์‹คํ—˜ ์ค‘ ์ƒ์„ฑ๋˜๋Š” log ํŒŒ์ผ ์ €์žฅ)
โ””โ”€โ”€ README.md                             # ์ „์ฒด ๊ฐœ์š” ์„ค๋ช…

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages