public void Enable(bool enabled)
    {
        isEnabled = enabled;
        objId     = 0;

        if (isEnabled && isFirstEnabled)
        {
            isFirstEnabled = false;
            AgentSetup agentSetup = GetComponentInParent <AgentSetup>();
            if (agentSetup != null && agentSetup.NeedsBridge != null)
            {
                agentSetup.AddToNeedsBridge(this);
            }
        }

        groundTruthCamera.enabled = enabled;
        cameraPreview.gameObject.SetActive(enabled);

        if (detectedObjects != null)
        {
            detectedObjects.Clear();
        }

        if (cameraDetectedColliders != null)
        {
            cameraDetectedColliders.Clear();
        }
    }
    public void Enable(bool enabled)
    {
        isEnabled = enabled;
        objId     = 0;

        if (isEnabled && isFirstEnabled)
        {
            isFirstEnabled = false;
            AgentSetup agentSetup = GetComponentInParent <AgentSetup>();
            if (agentSetup != null && agentSetup.NeedsBridge != null)
            {
                agentSetup.AddToNeedsBridge(this);
            }
        }

        if (detectedObjects != null)
        {
            detectedObjects.Clear();
        }

        if (lidarDetectedColliders != null)
        {
            lidarDetectedColliders.Clear();
        }
    }
Exemple #3
0
        internal void CreateChild(AgentSetup setup)
        {
            counterChilds++;
            var childRef = Agent.Behaviour.ChildMaker(arg1: Agent.Context, arg2: setup);

            Agent.Send(instruction: BasicInstruction.Initialize.Create(target: childRef, message: setup.Behaviour));
        }
Exemple #4
0
        private void StartProductionAgent(FArticle fArticle)
        {
            _forwardScheduleTimeCalculator = new ForwardScheduleTimeCalculator(fArticle: fArticle);
            // check for Children
            if (fArticle.Article.ArticleBoms.Any())
            {
                Agent.DebugMessage(
                    msg: "Article: " + fArticle.Article.Name + " (" + fArticle.Key + ") is last leave in BOM.");
            }

            if (fArticle.Article.Operations == null)
            {
                throw new Exception("Production agent without operations");
            }


            // Ask the Directory Agent for Service
            RequestHubAgentsFromDirectoryFor(agent: Agent, operations: fArticle.Article.Operations);
            // And create Operations
            CreateJobsFromArticle(fArticle: fArticle);

            var requiredDispoAgents = OperationManager.CreateRequiredArticles(articleToProduce: fArticle
                                                                              , requestingAgent: Agent.Context.Self
                                                                              , currentTime: Agent.CurrentTime);

            for (var i = 0; i < requiredDispoAgents; i++)
            {
                // create Dispo Agents for to provide required articles
                var agentSetup = AgentSetup.Create(agent: Agent,
                                                   behaviour: DispoAgent.Behaviour.Factory.Get(simType: SimulationType.None));
                var instruction = Guardian.Instruction.CreateChild.Create(setup: agentSetup,
                                                                          target: ((IAgent)Agent).Guardian, source: Agent.Context.Self);
                Agent.Send(instruction: instruction);
            }
        }
Exemple #5
0
 private void Awake()
 {
     if (Agent == null)
     {
         Agent = transform.root.gameObject;
     }
     agentSetup = Agent?.GetComponent <AgentSetup>();
     AddUIElement();
 }
Exemple #6
0
        internal void CreateChild(AgentSetup setup)
        {
            _counterChilds++;
            //System.Diagnostics.Debug.WriteLine($"({Agent.CurrentTime}) {Agent.Context.Self.Path.Name} add child and has {counterChilds} now");

            var childRef = Agent.Behaviour.ChildMaker(arg1: Agent.Context, arg2: setup);

            Agent.Send(instruction: BasicInstruction.Initialize.Create(target: childRef, message: setup.Behaviour));
        }
Exemple #7
0
        /// <summary>
        /// Startup with Creating Dispo Agent for current Item.
        /// </summary>
        /// <param name="agent"></param>
        /// <param name="orderItem"></param>
        public void StartOrder(T_CustomerOrderPart orderItem)
        {
            // create Request Item
            _fArticle = orderItem.ToRequestItem(requester: Agent.Context.Self, currentTime: Agent.CurrentTime);
            // Tell Guardian to create Dispo Agent
            var agentSetup  = AgentSetup.Create(agent: Agent, behaviour: DispoAgent.Behaviour.Factory.Get(simType: Agent.Behaviour.SimulationType));
            var instruction = Guardian.Instruction.CreateChild.Create(setup: agentSetup, target: ((IAgent)Agent).Guardian, source: Agent.Context.Self);

            Agent.Send(instruction: instruction);
            // init end
        }
Exemple #8
0
        private void CreateContractAgent(T_CustomerOrderPart orderPart)
        {
            _orderQueue.Enqueue(item: orderPart);
            DebugMessage(msg: $"Creating Contract Agent for order {orderPart.CustomerOrderId} with {orderPart.Article.Name} DueTime {orderPart.CustomerOrder.DueTime}");
            var agentSetup  = AgentSetup.Create(agent: this, behaviour: ContractAgent.Behaviour.Factory.Get(simType: _simulationType));
            var instruction = CreateChild.Create(setup: agentSetup
                                                 , target: ActorPaths.Guardians
                                                 .Single(predicate: x => x.Key == GuardianType.Contract)
                                                 .Value
                                                 , source: this.Self);

            Send(instruction: instruction);
        }
Exemple #9
0
    private void SetLEDColor(LEDColorTypes colorIndex)
    {
        if (isFirstEnabled)
        {
            isFirstEnabled = false;
            AgentSetup agentSetup = GetComponentInParent <AgentSetup>();
            if (agentSetup != null && agentSetup.NeedsBridge != null)
            {
                agentSetup.AddToNeedsBridge(this);
            }
        }

        currentLEDColor = colorIndex;
    }
Exemple #10
0
    public RosBridgeConnector(AgentSetup type)
    {
        agentType       = type;
        lastEnvironment = agentType.TargetRosEnv;

        if (type.TargetRosEnv == ROSTargetEnvironment.APOLLO35)
        {
            Bridge = new Comm.Cyber.CyberBridge();
        }
        else
        {
            Bridge = new Comm.Ros.RosBridge();
        }
    }
    void Awake()
    {
        LidarBitmask        = ~(1 << LayerMask.NameToLayer("Lidar Ignore") | 1 << LayerMask.NameToLayer("Sensor Effects")) | 1 << LayerMask.NameToLayer("Lidar Only") | 1 << LayerMask.NameToLayer("PlayerConstrain");
        PointCloudLayerMask = 1 << LayerMask.NameToLayer("Sensor Effects");
        PointCloudMaterial  = Object.Instantiate(PointCloudMaterial);

        if (Agent == null)
        {
            Agent = transform.root.gameObject;
        }
        agentSetup = Agent?.GetComponent <AgentSetup>();
        var lidarCheckbox = Agent.GetComponent <UserInterfaceTweakables>().AddCheckbox("ToggleLidar", "Enable LIDAR:", false);

        lidarCheckbox.onValueChanged.AddListener(x => enabled = x);
    }
Exemple #12
0
        private void CreateContractAgent(T_CustomerOrder order)
        {
            _productionContext.CustomerOrders.Add(order);
            _productionContext.SaveChanges();

            var orderPart = order.CustomerOrderParts.First();

            _orderQueue.Enqueue(item: orderPart);
            Agent.DebugMessage(msg: $"Creating Contract Agent for order {orderPart.CustomerOrderId} with {orderPart.Article.Name} DueTime {orderPart.CustomerOrder.DueTime}");
            var agentSetup  = AgentSetup.Create(agent: Agent, behaviour: ContractAgent.Behaviour.Factory.Get(simType: _simulationType));
            var instruction = Instruction.CreateChild.Create(setup: agentSetup
                                                             , target: Agent.ActorPaths.Guardians
                                                             .Single(predicate: x => x.Key == GuardianType.Contract)
                                                             .Value
                                                             , source: Agent.Context.Self);

            Agent.Send(instruction: instruction);
        }
        internal void ResponseFromSystemForBom(M_Article article)
        {
            // Update
            var dueTime = _fArticle.DueTime;

            if (article.Operations != null)
            {
                dueTime = _fArticle.DueTime - article.Operations.Sum(selector: x => x.Duration + x.AverageTransitionDuration);
            }
            // TODO: Object that handles the different operations- current assumption is all operations are handled as a sequence (no alternative/parallel plans)

            _fArticle = _fArticle.UpdateCustomerOrderAndDue(id: _fArticle.CustomerOrderId, due: dueTime, storage: _fArticle.StorageAgent)
                        .UpdateArticle(article: article);

            // Creates a Production Agent for each element that has to be produced
            for (var i = 0; i < _quantityToProduce; i++)
            {
                var agentSetup  = AgentSetup.Create(agent: Agent, behaviour: ProductionAgent.Behaviour.Factory.Get(simType: SimulationType.None));
                var instruction = CreateChild.Create(setup: agentSetup, target: ((IAgent)Agent).Guardian, source: Agent.Context.Self);
                Agent.Send(instruction: instruction);
            }
        }
    private void Awake()
    {
        if (Agent == null)
        {
            Agent = transform.root.gameObject;
        }
        agentSetup = Agent?.GetComponent <AgentSetup>();

        AddUIElement();
        detectedObjects        = new List <Ros.Detection3D>();
        lidarDetectedColliders = new Dictionary <Collider, Ros.Detection3D>();
        lidarPredictedObjects  = new List <Ros.Detection3D>();
        lidarPredictedVisuals  = new List <Ros.Detection3D>();
        lidarRangeTrigger.SetCallback(onLidarRangeTriggered);

        if (lidarSensor && lidarSensor.GetComponent <LidarSensor>())
        {
            lidarRangeTrigger.transform.localScale = new Vector3(
                lidarSensor.GetComponent <LidarSensor>().MaxDistance * 2,
                lidarSensor.GetComponent <LidarSensor>().MaxDistance * 2,
                lidarSensor.GetComponent <LidarSensor>().MaxDistance * 2
                );
        }
    }
    public void EnableLidarPrediction(bool enabled)
    {
        isLidarPredictionEnabled = enabled;

        if (isLidarPredictionEnabled && isFirstEnabled)
        {
            isFirstEnabled = false;
            AgentSetup agentSetup = GetComponentInParent <AgentSetup>();
            if (agentSetup != null && agentSetup.NeedsBridge != null)
            {
                agentSetup.AddToNeedsBridge(this);
            }
        }

        if (lidarPredictedVisuals != null)
        {
            lidarPredictedVisuals.Clear();
        }

        if (lidarPredictedObjects != null)
        {
            lidarPredictedObjects.Clear();
        }
    }
Exemple #16
0
    void Awake()
    {
        PointCloudMaterial = Object.Instantiate(PointCloudMaterial);

        if (Agent == null)
        {
            Agent = transform.root.gameObject;
        }
        agentSetup = Agent?.GetComponent <AgentSetup>();
        var lidarCheckbox = Agent.GetComponent <UserInterfaceTweakables>().AddCheckbox("ToggleLidar", "Enable LIDAR:", false);

        lidarCheckbox.onValueChanged.AddListener(x => enabled = x);

        PointCloudLayerMask = 1 << LayerMask.NameToLayer("Sensor Effects");

        Camera.enabled         = false;
        Camera.renderingPath   = RenderingPath.Forward;
        Camera.clearFlags      = CameraClearFlags.Color;
        Camera.backgroundColor = Color.black;
        Camera.allowMSAA       = false;
        Camera.allowHDR        = false;

        Reset();
    }
Exemple #17
0
    private void SetTopLightMode(bool enabled)
    {
        isEnabled = enabled;
        if (isFirstEnabled)
        {
            isFirstEnabled = false;
            AgentSetup agentSetup = GetComponentInParent <AgentSetup>();
            if (agentSetup != null && agentSetup.NeedsBridge != null)
            {
                agentSetup.AddToNeedsBridge(this);
            }
        }

        if (enabled == false)
        {
            StopAllCoroutines();
            ToggleTopLight(enabled);
            lightRenderer.material.color = offColor;
        }
        else
        {
            StartCoroutine(BlinkTopLight());
        }
    }
Exemple #18
0
 public RosBridgeConnector(string address, int port, AgentSetup type) : this()
 {
     Address   = address;
     Port      = port;
     agentType = type;
 }
 public static CreateChild Create(AgentSetup setup, IActorRef target, IActorRef source)
 {
     return(new CreateChild(message: setup, target: target, source: source));
 }