Spaces:
Sleeping
Sleeping
| """Knowledge base loader for AI context.""" | |
| import os | |
| from pathlib import Path | |
| from typing import List | |
| class KnowledgeBaseLoader: | |
| """Load AI knowledge from project files.""" | |
| def __init__(self): | |
| self.knowledge_files = [ | |
| ("ai_knowledge_base/ai_instructions.txt", "AI INSTRUCTIONS"), | |
| ("ai_knowledge_base/mavlink_commands.txt", "MAVLINK COMMANDS"), | |
| ("ai_knowledge_base/copter_flightmodes.txt", "COPTER FLIGHT MODES"), | |
| ("ai_knowledge_base/drone-ai-knowledge-base.md", "DRONE AI KNOWLEDGE BASE"), | |
| ("ai_knowledge_base/professional_drone_control.md", "PROFESSIONAL DRONE CONTROL") | |
| ] | |
| def load_complete_knowledge_base(self) -> str: | |
| """Load complete AI knowledge base from project files.""" | |
| knowledge_parts = [] | |
| for file_path, section_name in self.knowledge_files: | |
| try: | |
| if os.path.exists(file_path): | |
| with open(file_path, "r", encoding='utf-8') as f: | |
| content = f.read().strip() | |
| if content: | |
| knowledge_parts.append(f"{section_name}:\n{content}") | |
| except (FileNotFoundError, UnicodeDecodeError): | |
| continue | |
| # Add built-in mission planning expertise | |
| knowledge_parts.append(self._get_built_in_expertise()) | |
| return "\n\n".join(knowledge_parts) | |
| def _get_built_in_expertise(self) -> str: | |
| """Get built-in mission planning expertise.""" | |
| return """MISSION PLANNING EXPERTISE: | |
| - Survey missions require grid patterns with 70% overlap for complete coverage | |
| - Inspection missions need low altitude (40-80m) and slow speeds (8 m/s) for detail | |
| - Patrol missions use perimeter patterns at medium altitude (60-100m) | |
| - Photography missions require strategic positioning with hold time for image capture | |
| - All missions must use proper coordinate frames: GLOBAL_RELATIVE_ALT(3) for navigation | |
| - Landing sequence requires DO_LAND_START(203) command before RTL(20) | |
| - Mission safety requires 30% battery reserve and obstacle clearance | |
| - Coordinate accuracy is critical - use proper GPS conversion formulas | |
| - QGroundControl compatibility requires specific mission item structure""" | |