Files
ENIG/Cs_HMI/AGVLogic/BACKWARD_FIX_SUMMARY_KO.md
backuppc d932b8d332 fix: Add motor direction parameter to magnet direction calculation in pathfinding
- Fixed critical issue in ConvertToDetailedPath where motor direction was not passed to GetRequiredMagnetDirection
- Motor direction is essential for backward movement as Left/Right directions must be inverted
- Modified AGVPathfinder.cs line 280 to pass currentDirection parameter
- Ensures backward motor direction properly inverts magnet sensor directions

feat: Add waypoint support to pathfinding system

- Added FindPath overload with params string[] waypointNodeIds in AStarPathfinder
- Supports sequential traversal through multiple intermediate nodes
- Validates waypoints and prevents duplicates in sequence
- Returns combined path result with aggregated metrics

feat: Implement path result merging with DetailedPath preservation

- Added CombineResults method in AStarPathfinder for intelligent path merging
- Automatically deduplicates nodes when last of previous path equals first of current
- Preserves DetailedPath information including motor and magnet directions
- Essential for multi-segment path operations

feat: Integrate magnet direction with motor direction awareness

- Modified JunctionAnalyzer.GetRequiredMagnetDirection to accept AgvDirection parameter
- Inverts Left/Right magnet directions when moving Backward
- Properly handles motor direction context throughout pathfinding

feat: Add automatic start node selection in simulator

- Added SetStartNodeToCombo method to SimulatorForm
- Automatically selects start node combo box when AGV position is set via RFID
- Improves UI usability and workflow efficiency

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 15:46:16 +09:00

3.8 KiB
Raw Blame History

Backward 방향 로직 수정 - 최종 요약

수정 완료: 2025-10-23 상태: 🟢 완료됨


문제점

사용자 피드백

"002 → 003으로 후진상태로 이동완료한 후. 003위치에서 후진방향으로 다음 노드를 예측하면 004가 아니라 002가 나와.. 잘못되었어."

발생한 오류

이동: 002 → 003 (Backward 모터)
위치: 003
다음 노드 예측: GetNextNodeId(Backward)

잘못된 결과: N002 ❌
올바른 결과: N004 ✅

원인 분석

Backward 케이스의 잘못된 로직

case AgvDirection.Backward:
    if (dotProduct < -0.9f)  // ❌ 반대 방향만 찾음
        baseScore = 100.0f;

이렇게 하면:

  • 002→003 이동 벡터: (72, 34)
  • Backward에서는 반대 벡터만 선호
  • 결과: (-72, -34) = N002를 선택

사용자의 올바른 이해

"역방향모터 구동이든 정방향 모터 구동이든 의미야.. 모터 방향 바꾼다고해서 AGV몸체가 방향을 바꾸는게 아니야."

해석:

  • 모터 방향(Forward/Backward)은 단순히 모터가 어느 방향으로 회전하는지
  • AGV 몸체의 이동 방향은 변하지 않음
  • 따라서 경로 선택도 동일해야 함

해결책

수정된 Backward 로직

case AgvDirection.Backward:
    // ✅ Forward와 동일하게 같은 경로 방향 선호
    // 모터 방향(역진)은 이미 _currentDirection에 저장됨
    if (dotProduct > 0.9f)
        baseScore = 100.0f;
    else if (dotProduct > 0.5f)
        baseScore = 80.0f;
    // ... Forward와 동일한 로직

수정된 파일

  • 파일: AGVNavigationCore\Models\VirtualAGV.cs
  • 라인: 755-767
  • 변경: Backward 케이스를 Forward와 동일하게 처리

검증 결과

문제였던 시나리오 4: 002 → 003 → Backward

이동 벡터: (72, 34)

후보 N004 (380, 340):

  • 벡터: (102, 62) → 정규화: (0.853, 0.519)
  • 내적: 0.901 × 0.853 + 0.426 × 0.519 ≈ 0.989
  • Forward/Backward 모두: dotProduct > 0.9 → 100점

후보 N002 (206, 244):

  • 벡터: (-72, -34) → 정규화: (-0.901, -0.426)
  • 내적: 0.901 × (-0.901) + 0.426 × (-0.426) ≈ -0.934
  • Forward/Backward 모두: dotProduct < -0.9 하지만... < -0.5 → 20점

결과: N004 선택 문제 해결!


모든 시나리오 검증

시나리오 이동 경로 모터 결과 예상 상태
1 001→002 Forward N003 N003
2 001→002 Backward N003 N003
3 002→003 Forward N004 N004
4 002→003 Backward N004 N004 FIXED

개념 정리

Forward vs Backward의 의미

❌ 잘못된 이해:
  Forward = 앞으로 가는 방향
  Backward = 뒤로 가는 방향 (경로도 반대)

✅ 올바른 이해:
  Forward = 모터 정방향 회전 (경로는 그대로)
  Backward = 모터 역방향 회전 (경로는 그대로)

  → 경로 선택은 이동 벡터에만 의존
  → Forward/Backward 모두 같은 경로 선호

AGV 이동의 실제 동작

002에서 003으로 이동: 이동 벡터 = (72, 34)

③에서 다음 노드 선택:
- Forward 모터: 같은 방향 경로 선호 → N004
- Backward 모터: 같은 방향 경로 선호 → N004

모터 방향은 모터 회전 방향만 나타낼 뿐,
경로 선택에는 영향을 주지 않음!

최종 상태

Backward 로직 수정 완료

  • 파일: VirtualAGV.cs (라인 755-767)
  • 변경: Forward와 동일한 로직으로 수정
  • 결과: 사용자 피드백 "N004가 나와야 한다" 충족
  • 검증: 모든 4가지 시나리오 패스

다음 단계: 실제 맵 파일로 통합 테스트


완료: 2025-10-23 상태: 🟢 전체 구현 및 수정 완료