fix: AGV 방향 전환 시스템 대폭 개선
- DirectionChangePlanner에 간단한 방향 전환 로직 추가 - 직접 경로에 갈림길이 포함된 경우 해당 갈림길에서 방향 전환 - PathTester 테스트 케이스를 실제 맵 파일 노드 ID와 일치하도록 수정 - 갈림길 정보 분석 기능 추가 테스트 결과: - 기본 경로: 6/11 → 8/11 통과 (+2) - 방향 전환: 0/11 → 10/11 통과 (+10) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
224
Cs_HMI/AGVPathTester/Program.cs
Normal file
224
Cs_HMI/AGVPathTester/Program.cs
Normal file
@@ -0,0 +1,224 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace AGVPathTester
|
||||
{
|
||||
/// <summary>
|
||||
/// AGV 경로 탐색 및 방향전환 로직 테스트 프로그램
|
||||
/// </summary>
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.Title = "AGV Path Tester - ENIG Navigation System";
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
Console.WriteLine("======================================");
|
||||
Console.WriteLine(" AGV Path Tester v1.0");
|
||||
Console.WriteLine(" ENIG Navigation System");
|
||||
Console.WriteLine("======================================");
|
||||
Console.ResetColor();
|
||||
Console.WriteLine();
|
||||
|
||||
try
|
||||
{
|
||||
// 맵 파일 경로
|
||||
string mapFilePath = @"C:\Data\Source\(5613#) ENIG AGV\Source\Cs_HMI\Data\NewMap.agvmap";
|
||||
|
||||
if (!File.Exists(mapFilePath))
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine($"❌ 맵 파일을 찾을 수 없습니다: {mapFilePath}");
|
||||
Console.ResetColor();
|
||||
Console.WriteLine("Enter 키를 눌러 종료하세요...");
|
||||
Console.ReadLine();
|
||||
return;
|
||||
}
|
||||
|
||||
// PathTester 초기화
|
||||
var pathTester = new PathTester(mapFilePath);
|
||||
|
||||
if (!pathTester.Initialize())
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("❌ PathTester 초기화 실패");
|
||||
Console.ResetColor();
|
||||
Console.WriteLine("Enter 키를 눌러 종료하세요...");
|
||||
Console.ReadLine();
|
||||
return;
|
||||
}
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine("✅ PathTester 초기화 완료");
|
||||
Console.WriteLine($"📍 로드된 맵 노드 수: {pathTester.GetNodeCount()}");
|
||||
Console.ResetColor();
|
||||
Console.WriteLine();
|
||||
|
||||
// 자동 테스트 모드 체크
|
||||
bool autoMode = args.Length > 0 && (args[0].ToLower() == "auto" || args[0].ToLower() == "batch");
|
||||
|
||||
if (autoMode)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("🚀 자동 테스트 모드 실행");
|
||||
Console.ResetColor();
|
||||
Console.WriteLine();
|
||||
|
||||
// 먼저 맵 정보 표시
|
||||
ShowMapInfo(pathTester);
|
||||
Console.WriteLine("\n" + new string('=', 50) + "\n");
|
||||
|
||||
// 자동으로 모든 테스트 실행
|
||||
RunBatchTests(pathTester);
|
||||
|
||||
Console.WriteLine();
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
Console.WriteLine("📊 모든 자동 테스트 완료!");
|
||||
Console.ResetColor();
|
||||
return;
|
||||
}
|
||||
|
||||
// 대화형 메뉴
|
||||
bool continueRunning = true;
|
||||
while (continueRunning)
|
||||
{
|
||||
ShowMenu();
|
||||
|
||||
Console.Write("선택: ");
|
||||
var input = Console.ReadLine()?.Trim();
|
||||
|
||||
switch (input)
|
||||
{
|
||||
case "1":
|
||||
RunBasicPathTests(pathTester);
|
||||
break;
|
||||
case "2":
|
||||
RunDirectionChangeTests(pathTester);
|
||||
break;
|
||||
case "3":
|
||||
RunCustomTest(pathTester);
|
||||
break;
|
||||
case "4":
|
||||
RunBatchTests(pathTester);
|
||||
break;
|
||||
case "5":
|
||||
ShowMapInfo(pathTester);
|
||||
break;
|
||||
case "0":
|
||||
case "q":
|
||||
case "quit":
|
||||
case "exit":
|
||||
continueRunning = false;
|
||||
break;
|
||||
default:
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("❓ 잘못된 선택입니다.");
|
||||
Console.ResetColor();
|
||||
break;
|
||||
}
|
||||
|
||||
if (continueRunning)
|
||||
{
|
||||
Console.WriteLine("\nEnter 키를 눌러 계속하세요...");
|
||||
Console.ReadLine();
|
||||
// Console.Clear(); // Windows 콘솔 호환성 문제로 제거
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine($"❌ 프로그램 오류: {ex.Message}");
|
||||
Console.WriteLine($"상세 정보: {ex}");
|
||||
Console.ResetColor();
|
||||
Console.WriteLine("Enter 키를 눌러 종료하세요...");
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
|
||||
static void ShowMenu()
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
Console.WriteLine("============ 메뉴 ============");
|
||||
Console.WriteLine("1. 기본 경로 탐색 테스트");
|
||||
Console.WriteLine("2. 방향 전환 경로 테스트");
|
||||
Console.WriteLine("3. 사용자 정의 테스트");
|
||||
Console.WriteLine("4. 배치 테스트 실행");
|
||||
Console.WriteLine("5. 맵 정보 보기");
|
||||
Console.WriteLine("0. 종료");
|
||||
Console.WriteLine("=============================");
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
static void RunBasicPathTests(PathTester pathTester)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Magenta;
|
||||
Console.WriteLine("🧪 기본 경로 탐색 테스트 실행");
|
||||
Console.ResetColor();
|
||||
|
||||
pathTester.RunBasicPathTests();
|
||||
}
|
||||
|
||||
static void RunDirectionChangeTests(PathTester pathTester)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Magenta;
|
||||
Console.WriteLine("🔄 방향 전환 경로 테스트 실행");
|
||||
Console.ResetColor();
|
||||
|
||||
pathTester.RunDirectionChangeTests();
|
||||
}
|
||||
|
||||
static void RunCustomTest(PathTester pathTester)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Magenta;
|
||||
Console.WriteLine("🎯 사용자 정의 테스트");
|
||||
Console.ResetColor();
|
||||
|
||||
Console.Write("시작 노드 ID: ");
|
||||
string startNodeId = Console.ReadLine()?.Trim();
|
||||
|
||||
Console.Write("목표 노드 ID: ");
|
||||
string targetNodeId = Console.ReadLine()?.Trim();
|
||||
|
||||
Console.WriteLine("현재 방향 선택:");
|
||||
Console.WriteLine("1. Forward (전진)");
|
||||
Console.WriteLine("2. Backward (후진)");
|
||||
Console.Write("선택 (기본값: Forward): ");
|
||||
|
||||
var directionInput = Console.ReadLine()?.Trim();
|
||||
var currentDirection = (directionInput == "2") ?
|
||||
AGVNavigationCore.Models.AgvDirection.Backward :
|
||||
AGVNavigationCore.Models.AgvDirection.Forward;
|
||||
|
||||
if (!string.IsNullOrEmpty(startNodeId) && !string.IsNullOrEmpty(targetNodeId))
|
||||
{
|
||||
pathTester.RunSingleTest(startNodeId, targetNodeId, currentDirection);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("❓ 시작 노드 또는 목표 노드 ID가 비어있습니다.");
|
||||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
|
||||
static void RunBatchTests(PathTester pathTester)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Magenta;
|
||||
Console.WriteLine("📦 배치 테스트 실행");
|
||||
Console.ResetColor();
|
||||
|
||||
pathTester.RunBatchTests();
|
||||
}
|
||||
|
||||
static void ShowMapInfo(PathTester pathTester)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
Console.WriteLine("🗺️ 맵 정보");
|
||||
Console.ResetColor();
|
||||
|
||||
pathTester.ShowMapInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user