모든 경로를 전체 정의하기 전 백업

This commit is contained in:
backuppc
2026-03-03 13:00:13 +09:00
parent 6802967cde
commit 1a4b8a6a54
3 changed files with 153 additions and 21 deletions

View File

@@ -651,6 +651,28 @@ namespace AGVNavigationCore.PathFinding.Planning
Path = new List<string> { "7B", "11B", "3T", "3B", "11B", "7B", "8B", "9B", "20B", "34B", "33B", "32B", "31B", "35B", "36B" } Path = new List<string> { "7B", "11B", "3T", "3B", "11B", "7B", "8B", "9B", "20B", "34B", "33B", "32B", "31B", "35B", "36B" }
}); });
//일반노드를 포함하여 모든 노드를 정의하자
/* 예시
*retval.Add(new MapZonePathData { NodeSta = StationType.Plating, NodeEnd = StationType.Loader, Monitor = MapZoneMonitor.RightBtm, Path = new List<string> { "72F", "11F", "3B", "71B" } });
//retval.Add(new MapZonePathData { NodeSta = StationType.Plating, NodeEnd = StationType.Loader, Monitor = MapZoneMonitor.LeftTop, Path = new List<string> { "72B", "11B", "3T", "3B", "71B" } });
//retval.Add(new MapZonePathData { NodeSta = StationType.Plating, NodeEnd = StationType.Charger, Monitor = MapZoneMonitor.RightBtm, Path = new List<string> { "72F", "11F", "3T", "3F", "11F", "7B", "10B", "6B", "73B" } });
//retval.Add(new MapZonePathData { NodeSta = StationType.Plating, NodeEnd = StationType.Charger, Monitor = MapZoneMonitor.LeftTop, Path = new List<string> { "72B", "11B", "3F", "11F", "7B", "10B", "6B", "73B" } });
//retval.Add(new MapZonePathData { NodeSta = StationType.Plating, NodeEnd = StationType.Cleaner, Monitor = MapZoneMonitor.RightBtm, Path = new List<string> { "72F", "11F", "3T", "3B", "70B" } });
//retval.Add(new MapZonePathData { NodeSta = StationType.Plating, NodeEnd = StationType.Cleaner, Monitor = MapZoneMonitor.LeftTop, Path = new List<string> { "72B", "11B", "3B", "70B" } });
//retval.Add(new MapZonePathData { NodeSta = StationType.Plating, NodeEnd = StationType.Buffer, Monitor = MapZoneMonitor.RightBtm, Path = new List<string> { "72F", "11B", "7B", "8B", "9B", "20B", "34B", "33B", "32B", "31B", "35B", "36B" } });
//retval.Add(new MapZonePathData { NodeSta = StationType.Plating, NodeEnd = StationType.Buffer, Monitor = MapZoneMonitor.LeftTop, Path = new List<string> { "72B", "11B", "3T", "3B", "11B", "7B", "8B", "9B", "20B", "34B", "33B", "32B", "31B", "35B", "36B" } });
*/
// 일반노드 6 ->
// 일반노드 10 ->
// 일반노드 11 ->
// 일반노드 8 ->
// 일반노드 9 ->
// 일반노드 20 ->
return retval; return retval;
} }
/// <summary> /// <summary>
@@ -686,6 +708,14 @@ namespace AGVNavigationCore.PathFinding.Planning
public AGVPathResult CalculateScriptedPath(MapNode startNode, MapNode targetNode, MapNode prevNode, AgvDirection prevDir) public AGVPathResult CalculateScriptedPath(MapNode startNode, MapNode targetNode, MapNode prevNode, AgvDirection prevDir)
{ {
// 태그 내 숫자로 정확히 매칭하기 위한 람다 (예: 3을 찾을 때 "36"이 매칭되지 않도록)
Func<string, int, bool> matchNode = (tag, rfid) =>
{
string idStr = "";
foreach (char c in tag) if (char.IsDigit(c)) idStr += c;
return idStr == rfid.ToString();
};
var startZone = GetMapZone(startNode); var startZone = GetMapZone(startNode);
var targetZone = GetMapZone(targetNode); var targetZone = GetMapZone(targetNode);
@@ -855,14 +885,8 @@ namespace AGVNavigationCore.PathFinding.Planning
{ {
//위치는 현재위치이나 모니터방향이 일치하지 않으므로 턴을 한후 경로를 다시 찾아야한다. //위치는 현재위치이나 모니터방향이 일치하지 않으므로 턴을 한후 경로를 다시 찾아야한다.
// 태그 내 숫자로 정확히 매칭하기 위한 람다 (예: 3을 찾을 때 "36"이 매칭되지 않도록) //버퍼는 턴포인트까지는 항상B로 이동해야한다.
Func<string, int, bool> matchNode = (tag, rfid) => startTag = startNode.RfidId + "B";
{
string idStr = "";
foreach (char c in tag) if (char.IsDigit(c)) idStr += c;
return idStr == rfid.ToString();
};
// 1.현재위치에서 턴포인트(3)까지 이동하는 경로를 찾는다. // 1.현재위치에서 턴포인트(3)까지 이동하는 경로를 찾는다.
var path1Candidate = zonepath.FirstOrDefault(d => var path1Candidate = zonepath.FirstOrDefault(d =>
{ {
@@ -1018,10 +1042,107 @@ namespace AGVNavigationCore.PathFinding.Planning
} }
} }
} }
else if (startZone == MapZone.Loader && targetZone == MapZone.Loader)
{
//모니터가 아래에 있다면 방향이 일치하지 않으므로 턴(3)을 해야 한후 목표까지 이동해야한다
if (monitorMode == MapZoneMonitor.RightBtm)
{
var newpath = new List<string> { "71B", "3T", "3B", "71B" };
int startIndex = newpath.FindIndex(p => matchNode(p, startNode.RfidId));
if (startIndex != -1) newpath = newpath.Skip(startIndex).ToList();
return ConvertHardcodedPathToResult(newpath, startNode, prevNode, prevDir);
}
else if (startNode.RfidId.Equals(targetNode.RfidId)) //시작과 목표가 같을경우
{
var result = new AGVPathResult { Success = true };
result.Path = new List<MapNode> { startNode };
result.DetailedPath = new List<NodeMotorInfo> { new NodeMotorInfo(1, startNode.Id, startNode.RfidId, prevDir, null, MagnetDirection.Straight, false) };
result.TotalDistance = 0;
return result;
}
else else
{ {
//다른경우는 아직 처리하지 않는다 //시작과 목표가 다른경우이므로 현재위치에서 목표까지 단순경로 생성해서 반환하면 된다.
return this.FindBasicPath(startNode, targetNode, prevNode, prevDir);
} }
}
else if (startZone == MapZone.Cleaner && targetZone == MapZone.Cleaner)
{
//모니터가 위에 있다면 방향이 일치하지 않으므로 턴(3)을 해야 한후 목표까지 이동해야한다
if (monitorMode == MapZoneMonitor.LeftTop)
{
var newpath = new List<string> { "70B", "3T", "3B", "70B" };
int startIndex = newpath.FindIndex(p => matchNode(p, startNode.RfidId));
if (startIndex != -1) newpath = newpath.Skip(startIndex).ToList();
return ConvertHardcodedPathToResult(newpath, startNode, prevNode, prevDir);
}
else if (startNode.RfidId.Equals(targetNode.RfidId)) //시작과 목표가 같을경우
{
var result = new AGVPathResult { Success = true };
result.Path = new List<MapNode> { startNode };
result.DetailedPath = new List<NodeMotorInfo> { new NodeMotorInfo(1, startNode.Id, startNode.RfidId, prevDir, null, MagnetDirection.Straight, false) };
result.TotalDistance = 0;
return result;
}
else
{
//시작과 목표가 다른경우이므로 현재위치에서 목표까지 단순경로 생성해서 반환하면 된다.
return this.FindBasicPath(startNode, targetNode, prevNode, prevDir);
}
}
else if (startZone == MapZone.Plating && targetZone == MapZone.Plating)
{
//모티너가 좌측에 있다면 방향이 일치하지 않으므로 턴(3)을 해야 한후 목표까지 이동해야한다.
if (monitorMode == MapZoneMonitor.LeftTop)
{
var newpath = new List<string> { "72B", "11B", "3T", "3B", "11B", "72B" };
int startIndex = newpath.FindIndex(p => matchNode(p, startNode.RfidId));
if (startIndex != -1) newpath = newpath.Skip(startIndex).ToList();
return ConvertHardcodedPathToResult(newpath, startNode, prevNode, prevDir);
}
else if (startNode.RfidId.Equals(targetNode.RfidId)) //시작과 목표가 같을경우
{
var result = new AGVPathResult { Success = true };
result.Path = new List<MapNode> { startNode };
result.DetailedPath = new List<NodeMotorInfo> { new NodeMotorInfo(1, startNode.Id, startNode.RfidId, prevDir, null, MagnetDirection.Straight, false) };
result.TotalDistance = 0;
return result;
}
else
{
//시작과 목표가 다른경우이므로 현재위치에서 목표까지 단순경로 생성해서 반환하면 된다.
return this.FindBasicPath(startNode, targetNode, prevNode, prevDir);
}
}
else if (startZone == MapZone.Charger && targetZone == MapZone.Charger)
{
//모니터가 위에 있다면 방향이 일치하지 않으므로 턴(3)을 해야 한후 목표까지 이동해야한다
if (monitorMode == MapZoneMonitor.LeftTop)
{
var newpath = new List<string> { "73B", "6B", "10B", "7F", "11F", "3T", "3F", "11F", "7B", "10B", "6B", "73B" };
int startIndex = newpath.FindIndex(p => matchNode(p, startNode.RfidId));
if (startIndex != -1) newpath = newpath.Skip(startIndex).ToList();
return ConvertHardcodedPathToResult(newpath, startNode, prevNode, prevDir);
}
else if (startNode.RfidId.Equals(targetNode.RfidId)) //시작과 목표가 같을경우
{
var result = new AGVPathResult { Success = true };
result.Path = new List<MapNode> { startNode };
result.DetailedPath = new List<NodeMotorInfo> { new NodeMotorInfo(1, startNode.Id, startNode.RfidId, prevDir, null, MagnetDirection.Straight, false) };
result.TotalDistance = 0;
return result;
}
else
{
//시작과 목표가 다른경우이므로 현재위치에서 목표까지 단순경로 생성해서 반환하면 된다.
return this.FindBasicPath(startNode, targetNode, prevNode, prevDir);
}
}
else
{
//
}
return AGVPathResult.CreateFailure("경로를 계산할 수 없습니다"); return AGVPathResult.CreateFailure("경로를 계산할 수 없습니다");
} }
@@ -1141,11 +1262,23 @@ namespace AGVNavigationCore.PathFinding.Planning
{ {
if (prevNode.RfidId == 20) if (prevNode.RfidId == 20)
return MapZoneMonitor.LeftTop; return MapZoneMonitor.LeftTop;
else
{
int bdx = startNode.Position.X - prevNode.Position.X;
if (bdx < 0) return MapZoneMonitor.LeftTop;
else return MapZoneMonitor.RightBtm;
}
} }
else if (prevDir == AgvDirection.Backward) else if (prevDir == AgvDirection.Backward)
{ {
if (prevNode.RfidId == 20) if (prevNode.RfidId == 20)
return MapZoneMonitor.RightBtm; return MapZoneMonitor.RightBtm;
else
{
int bdx = startNode.Position.X - prevNode.Position.X;
if (bdx < 0) return MapZoneMonitor.RightBtm;
else return MapZoneMonitor.LeftTop;
}
} }
} }

View File

@@ -45,6 +45,12 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="fMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="fMain.Designer.cs">
<DependentUpon>fMain.cs</DependentUpon>
</Compile>
<Compile Include="Forms\ComboBoxItem.cs" /> <Compile Include="Forms\ComboBoxItem.cs" />
<Compile Include="Forms\DirectionItem.cs" /> <Compile Include="Forms\DirectionItem.cs" />
<Compile Include="Forms\PathTestLogItem.cs" /> <Compile Include="Forms\PathTestLogItem.cs" />
@@ -56,20 +62,9 @@
</Compile> </Compile>
<Compile Include="Models\SimulatorConfig.cs" /> <Compile Include="Models\SimulatorConfig.cs" />
<Compile Include="Models\SimulationState.cs" /> <Compile Include="Models\SimulationState.cs" />
<Compile Include="Forms\SimulatorForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\SimulatorForm.Designer.cs">
<DependentUpon>SimulatorForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Forms\SimulatorForm.resx">
<DependentUpon>SimulatorForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="build.bat" /> <None Include="build.bat" />
<None Include="packages.config" /> <None Include="packages.config" />
@@ -84,5 +79,10 @@
<Name>AGVMapEditor</Name> <Name>AGVMapEditor</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="fMain.resx">
<DependentUpon>fMain.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>

View File

@@ -1 +0,0 @@
,BACKUPPC/1,backuppc,26.02.2026 11:12,file:///C:/Users/1/AppData/Roaming/LibreOffice/4;