Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Python
__pycache__/
*.py[cod]
*.pyo
*.pyd
.Python
*.egg
*.egg-info/
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
lib/
lib64/

# Virtual environments
.env
.venv
env/
venv/

# Testing
.pytest_cache/
.coverage
htmlcov/
.tox/

# IDEs
.vscode/
.idea/
*.swp
*.swo

# Models (large binary files)
models/*.pt
models/*.pth
models/*.onnx

# Logs
*.log
logs/

# OS
.DS_Store
Thumbs.db
56 changes: 56 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Dockerfile – rag7 AGI Robotics Framework
# Multi-stage build: install deps then copy source.

# ---------------------------------------------------------------------------
# Stage 1: Builder – install Python dependencies
# ---------------------------------------------------------------------------
FROM python:3.10-slim AS builder

WORKDIR /build

# Install system build tools
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
cmake \
git \
&& rm -rf /var/lib/apt/lists/*

# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --user \
torch>=2.0.0 \
torchvision>=0.15.0 \
numpy>=1.24.0 \
scipy>=1.10.0 \
opencv-python-headless>=4.7.0 \
pyyaml>=6.0 \
pytest>=7.0.0 \
pytest-cov>=4.0.0

# ---------------------------------------------------------------------------
# Stage 2: Runtime – lean image with the application
# ---------------------------------------------------------------------------
FROM python:3.10-slim AS runtime

WORKDIR /app

# Copy installed Python packages from the builder stage
COPY --from=builder /root/.local /root/.local

# Install minimal runtime system libraries (OpenCV needs libGL)
RUN apt-get update && apt-get install -y --no-install-recommends \
libglib2.0-0 \
libsm6 \
libxext6 \
&& rm -rf /var/lib/apt/lists/*

# Copy source code
COPY . .

# Ensure user-installed packages are on the path
ENV PATH="/root/.local/bin:$PATH"
ENV PYTHONPATH="/app"

# Default command: run the test suite
CMD ["python", "-m", "pytest", "tests/", "-v", "--tb=short"]
207 changes: 206 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,206 @@
# rag7
# rag7 – Agentic AGI Robotics Framework

![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue)
![License MIT](https://img.shields.io/badge/license-MIT-green)
![Tests](https://img.shields.io/badge/tests-pytest-orange)
![ROS2 Optional](https://img.shields.io/badge/ROS2-optional-lightgrey)
![PyTorch](https://img.shields.io/badge/PyTorch-2.0%2B-red)

A production-quality, multi-agent AGI robotics framework that integrates
perception, planning, natural language control, reinforcement learning, and
ROS2 communication into a unified, extensible system.

---

## Features

- **Multi-agent architecture** – PerceptionAgent, PlanningAgent, ControlAgent,
CommunicationAgent, CoordinationAgent, all built on a common `BaseAgent`
abstract class with perceive → reason → act loops.
- **Natural language control** – Parse free-text operator commands into
structured robot actions via intent classification and LLM integration
(LangChain / GPT-4, with a rule-based fallback).
- **Modular perception** – RGB-D object detection, semantic segmentation,
IoU multi-object tracking, occupancy-grid SLAM, and sensor fusion.
- **Intelligent planning** – A* path planning, joint-space motion planning
with IK/FK, LLM-powered task decomposition, and safety-aware decision making.
- **Reinforcement learning** – DQN, PPO, experience replay, and behavioural
cloning trainers built on PyTorch.
- **ROS2 integration** – Optional rclpy node wrappers for every agent;
graceful fallback to mock mode when ROS2 is not installed.
- **Simulation** – Gazebo-compatible mock environment for policy development.

---

## Quick Start

```python
from agents.robotics_agi import RoboticsAGI

agi = RoboticsAGI(config_path="config")

# Natural language control
result = agi.execute_command("navigate to the charging station")
print(result["response"]) # "Understood. I will navigate to the specified location."

# Task API
task = agi.create_task("grasp", target_object="red_cube")
result = agi.execute_task(task)
print(result) # {"success": True, "details": "Grasped 'red_cube'"}

# System status
print(agi.get_status()["system"]) # "online"
```

---

## Installation

```bash
git clone https://github.com/your-org/rag7.git
cd rag7
pip install -e . # core only
pip install -e ".[llm,dev]" # + LangChain + testing tools
```

See [docs/installation.md](docs/installation.md) for full instructions
including ROS2 setup and Docker.

---

## Project Structure

```
rag7/
├── agents/ # Core agent classes
│ ├── base_agent.py
│ ├── perception_agent.py
│ ├── planning_agent.py
│ ├── control_agent.py
│ ├── communication_agent.py
│ ├── coordination_agent.py
│ └── robotics_agi.py # Top-level orchestrator
├── perception/ # Sensor processing
│ ├── vision/ # Detection, segmentation, tracking
│ ├── slam/ # Mapping & localisation
│ └── sensor_fusion.py
├── planning/ # Task, path, motion planning
├── nlp/ # NLP pipeline
├── learning/ # RL & imitation learning
│ ├── rl/ # DQN, PPO, ReplayBuffer
│ └── imitation/ # Behavioural cloning
├── ros2_interface/ # ROS2 node wrappers
│ ├── ros2_nodes/
│ └── launch/
├── simulation/ # Gazebo environment
├── config/ # YAML configuration files
├── examples/ # Runnable example scripts
├── tests/ # pytest test suite
├── docs/ # Documentation
├── Dockerfile
├── requirements.txt
└── setup.py
```

---

## Architecture Overview

The system follows a hierarchical multi-agent architecture:

```
Operator NL input
CommunicationAgent ──► parse intent & entities
PlanningAgent ──► decompose goal into steps
ControlAgent ──► execute steps (navigate / grasp / stop)
ROS2Interface (optional) ──► robot hardware
```

See [docs/architecture.md](docs/architecture.md) for the full diagram.

---

## Usage Examples

### Navigation

```python
agi = RoboticsAGI(config_path="config")
agi.execute_command("go to the storage room")
```

### Object Manipulation

```python
agi.execute_command("pick up the blue box and place it on shelf B")
```

### Multi-Robot Coordination

```python
from agents.control_agent import ControlAgent

robot_a = ControlAgent(config={})
robot_b = ControlAgent(config={})
task = agi.create_task("navigate", location={"x": 5.0, "y": 5.0})
agi.coordinate_robots([robot_a, robot_b], task)
```

### Reinforcement Learning

```python
from learning.rl.dqn_agent import DQNAgent
from learning.rl.replay_buffer import ReplayBuffer

agent = DQNAgent(state_dim=8, action_dim=4)
buffer = ReplayBuffer(capacity=10000)
buffer.push(state, action, reward, next_state, done)
batch = buffer.sample(32)
loss = agent.update(batch)
```

---

## Configuration

All runtime parameters live in `config/`:

| File | Description |
|------|-------------|
| `robot_config.yaml` | Sensor topics, dimensions, safety thresholds |
| `agent_config.yaml` | Per-agent update rates, tolerances, memory |
| `llm_config.yaml` | LLM provider, model, temperature, API key env var |

---

## Running Tests

```bash
python -m pytest tests/ -v
python -m pytest tests/ -v --cov=. --cov-report=html
```

---

## Contributing

1. Fork the repository and create a feature branch.
2. Follow PEP 8 and add docstrings to all public classes and functions.
3. Add or update tests for any changed behaviour.
4. Open a pull request with a clear description.

---

## License

MIT License – see [LICENSE](LICENSE) for details.

© 2024 Stacey Williams
25 changes: 25 additions & 0 deletions agents/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
Agents package for the RAG7 AGI Robotics Framework.

This package provides the core agent classes that implement
perceive-reason-act loops for autonomous robot control.
"""

from agents.base_agent import BaseAgent, AgentState
from agents.perception_agent import PerceptionAgent
from agents.planning_agent import PlanningAgent
from agents.control_agent import ControlAgent
from agents.communication_agent import CommunicationAgent
from agents.coordination_agent import CoordinationAgent
from agents.robotics_agi import RoboticsAGI

__all__ = [
"BaseAgent",
"AgentState",
"PerceptionAgent",
"PlanningAgent",
"ControlAgent",
"CommunicationAgent",
"CoordinationAgent",
"RoboticsAGI",
]
Loading