RoboticArms/Assets/dobot/Sc/RobotManager.cs
2025-11-17 15:16:36 +07:00

45 lines
1.1 KiB
C#

using System.Collections;
using UnityEngine;
public class RobotManager : MonoBehaviour
{
public RobotController abb;
public Robot2Controller yas;
void Start()
{
StartCoroutine(AbbLoop());
StartCoroutine(YasLoop());
}
bool IsAtTarget3()
{
return yas.HasPhoiAtTarget3();
}
IEnumerator AbbLoop()
{
for (int i = 0; i < abb.stackCount; i++)
{
yield return new WaitUntil(() => !IsAtTarget3());
yield return StartCoroutine(abb.RunStepsExternal());
// ✅ Sau khi ABB đặt phôi, đưa phôi vào queue của YAS
yas.EnqueuePhoi(abb.LastStackObject);
}
Debug.Log("ABB hoàn thành tất cả vòng");
}
IEnumerator YasLoop()
{
for (int i = 0; i < abb.stackCount; i++)
{
// Đợi tới khi có phôi ở target3
yield return new WaitUntil(() => IsAtTarget3());
yield return StartCoroutine(yas.RunStepsExternal());
}
Debug.Log("YAS hoàn thành tất cả vòng");
}
}