realvirtual.io
  • Building Digital Twins with Unity and realvirtual.io
  • Basics
    • Installation
    • Demo Model
      • Old Demo Model
    • Editor User Interface
      • Hierarchy Window
      • 3D Views
      • Quick Edit
      • Move Pivot Points (Pro)
      • Selection Window (Pro)
      • Material Window (Pro)
      • Measurement (Pro)
      • Kinematic Tool (Pro)
      • Model Checker
    • Runtime UI
      • Group Manager
      • Debug Console
      • Responsiveness
      • Runtime Persistence
    • Importing and exporting
    • Folder structure
    • Tutorial
    • Physics
    • CAD import (Pro)
      • CADLink (Pro)
      • CAD Checker (Pro)
      • CAD Updater (Pro)
    • Reusable Components (Prefabs)
    • Cadenas parts4cad
    • Publishing the Digital Twin
    • Revision management
  • News
  • Login & Download Updates (Pro)
  • Components & Scripts
    • Realvirtual
      • Environment Controller
    • MU, Source and Sink
      • Source
      • Sink
    • Motion and Kinematic
      • Drive
      • Kinematic
      • Group
      • Joint
      • CAM
      • TransportSurface
      • Guided Transport
      • KinematicMU (Pro)
      • Drive behavior
      • Chain
      • Chain element
      • Motion for developers
    • Sensors
      • Sensor
      • Measure
      • MeasureRaycast
    • Picking and Placing MUs
      • Grip
      • Gripper
      • Fixer
      • Pattern
    • Changing MUs
      • MaterialChanger
      • PartChanger
      • Cutter
    • Scene Interaction
      • Tooltip (Pro)
      • 3D Buttons
      • Screen Overlay Buttons
      • Scene Selectables (Pro)
      • Lamp
      • Interact3D
      • UI components
      • HMI components (Pro)
        • Start your own HMI
        • HMI Tab
        • HMI DropDown
        • HMI Puschbutton
        • HMI Switch
        • HMI Value
        • HMI Text
        • HMI Slider
        • HMI Message
        • HMI Marker
      • ModelZoo (Pro)
    • Interfaces
      • Interface Tools
        • Signal Manager
        • Signal Importer Exporter
        • Signal Catcher
        • OnValueChangedReconnect
      • Signal Importer / Exporter
      • ABB RobotStudio (Pro)
      • Denso Robotics (Pro)
      • EthernetIP (Pro)
      • Fanuc (Pro)
      • FMI
      • Igus Rebel
      • MQTT (Pro)
      • Modbus (Pro)
      • OPCUA (Pro)
      • PLCSIM Advanced (Pro)
      • RoboDK (Pro)
      • RFSuite (Pro)
      • SEW SimInterface (Pro)
      • Siemens Simit Interface (Pro)
      • Simit Shared Memory (Pro)
      • Simulink (Pro)
      • S7 TCP
      • TwinCAT (Pro)
      • TwinCAT HMI (Pro)
      • UDP (Pro)
      • Universal Robots (Pro)
      • Wandelbots Nova (Pro)
      • Websocket (Pro)
      • Windmod Y200 (Pro)
      • Custom Interfaces
    • Performance Tools
      • Combine Meshes (Pro)
      • Create Prefab (Pro)
      • Hierarchy Cleanup (Pro)
      • Mesh Optimizer (Pro)
      • Performance Optimizer (Pro)
    • Defining Logic
      • Unity Scripting
      • Behavior Graph
      • Logicsteps
      • Unity Visual Scripting
      • Recorder
    • Robot Inverse Kinematics (Pro)
    • Volume Tracking (Pro)
  • Multiplayer (Pro)
  • Extensions
    • ModelZoo
      • Beckhoff TwinCAT
      • Siemens S7
      • Denso Cobotta 1300
      • Wandelbots Nova Fanuc CRX
      • Universal Robots UR10
      • Fanuc Roboguide
    • realvirtual.io AIBuilder
      • realvirtual.io AI Builder Overview
      • Generate AI Training Data
      • AI Training
      • Testing AI in a Digital Twin
      • Deploying the AI
    • realvirtual.io Simulation
      • Conveyor Library
      • Path System
        • Path finding
        • Line
        • Curve
        • Workstation
        • Catcher
        • Pathmover
    • realvirtual.io Industrial Metaverse
      • Setup Guide
      • VR Modules
      • AR Modules
      • Multiuser
    • AGX Physics
    • VR Builder
    • CMC ViewR
  • Advanced Topics
    • Render Pipelines
    • Mixed Reality with Meta Quest3
    • Upgrade Guide
      • Upgrade to 2022
    • Open Digital Twin Interface
    • Usefull Addons
    • Improving Performance
    • Supported Platforms
    • Compiler Defines
    • For Developers
      • Important Classes and Interfaces
      • Assembly Definitions
      • Starting your development
      • Class documentation
      • realvirtual Init Sequence
      • realvirtualBehavior Lifetime Methods
      • Testing
    • Newtonsoft JSON
    • Troubleshooting
  • Release Notes
  • AI Digital Twin Assistant (GPT4)
  • License Conditions
Powered by GitBook
On this page
  • Basics
  • Implement your own strategies
Edit on GitHub
  1. Extensions
  2. realvirtual.io Simulation
  3. Path System

Path finding

PreviousPath SystemNextLine

Last updated 2 years ago

In automation systems, material flow strategies are often very important for throughput and very often simulation models are created to develop and optimize these strategies. Our library is open and extensible and you can implement your own strategies.

Basics

No successor or only one successor

automatically enter the next path if the end of the current path is connected to another path. If no path is connected, the will normally stop at the end of the current (unconnected) path. If the Exit Path property of the is set to true, the will exit the path and be automatically controlled by physics.

More than one successor

If there is more than one successor for a path, the TryMoveNext public method is called in the . The following sequence of strategies is invoked:

Step 1: Check the SelectNextPath methods of the components on the Path Mover.

  • First, all components on the that implement the ISelectNextPath interface are selected. In all components, the SelectNextPath method is called with a reference to a list (in the Path Mover) of all successor paths.

  • The implemented method SelectNextPath is able to remove paths from the list (so that this path is not taken as the next successor for sure) or to reorder the list so that a certain path is at the first position in the list.

** Step 2: Checking the PathStratey referenced by Path**.

  • The next step is to check if the path has an assigned PathStrategy. If not, we proceed to step 3. The PathStrategy is a reference to a component that inherits from PathStrategy. In a PathStrategy, the public method SelectNextPath must be implemented.

** Step 3: Check the SelectNextPath methods of components on the path itself**.

  • Next, call all components on the path itself that implement the ISelectNextPath interface. You will get the remaining list of successors from step2 (or a complete list of successors if no logic was found in step1)

** Step 4: Select remaining path and move MU to next path**.

  • Now the remaining list of NextPaths is taken. If there is no content left because the strategies have removed all successor paths, nothing happens. Otherwise, the first path in the list is taken and the is moved to the next path.

This pictures shows the overall logic of path finding:

Implement your own strategies

You can implement your own strategies for selecting the next path. The only thing you need to do is to create a script that implements the interface ISelectNextPath.

The strategy itself looks like this:

public class StrategyRandom : realvirtual.ioBehavior,ISelectNextPath
  {
      public int Seed = 1;
      
      public void SelectNextPath(PathMover pathMover,ref List<SimulationPath> Pathes)
      {
    
          var max = Pathes.Count-1;
          int random = (int)Mathf.Round(Random.Range(-0.4999f, max+0.4999f));
          var path = Pathes[random];
          Pathes.Remove(path);
          Pathes.Insert(0,path);
      }

      private void Start()
      {
          Random.seed = Seed;
      }
  }

Option2 - Add a reference to a component that inherits from PathStrategy.

Another way to define custom strategies is to reference a component in the path itself that inherits from PathStrategy. Here is an example of a strategy that limits the number in a given range.

public class PathStrategyLimitNumber : PathStrategy
{
    [Header("Settings")]
    public int MaxNumber;

    [ReorderableList] public List<SimulationPath> AreaEnterPathes;
    [ReorderableList] public List<SimulationPath> AreaExitPathes;
    
    [Header("Status")]
    [realvirtual.io.ReadOnly] public int CurrentNumber;

    public override void SelectNextPath(PathMover pathMover,ref List<SimulationPath> pathes)
    {
        if (CurrentNumber >= MaxNumber)
        {
            AddBlocked(pathMover);
            pathes.Clear();
        }
    }

    public void OnPathEntered(SimulationPath path, PathMover pathMover)
    {
        CurrentNumber = CurrentNumber + 1;
    }
    
    public void OnPathExit(SimulationPath path, PathMover pathMover)
    {
        CurrentNumber = CurrentNumber - 1;
        if (CurrentNumber < MaxNumber)
            AwakeBlocked();
    }

    void Start()
    {
        CurrentNumber = 0;
        foreach (var enterpath in AreaEnterPathes)
        {
            enterpath.OnPathEntered.AddListener(OnPathEntered);
            foreach (var pred in enterpath.Predecessors)
            {
                pred.PathStrategy = this;
            }

        }
        foreach (var exitpath in AreaEnterPathes)
        {
            exitpath.OnPathExit.AddListener(OnPathExit);
        }
    }
}

If you delete all from the NextPaths list in your logic, the will stop at the end of the current path. As soon as something changes in your system that could make the path strategy successful, you need to call TryMoveNext in the blocked . You can see this in the example in Option2 below.

Option1 - Add a component with the ISelectNextPath interface to a or path.

Here is an example from the DemoPathsystem_UseCases demonstration model. The StrategyRandom randomly selects the next path. It is attached as a component to the :

The SelectNextPath method is called from the located at the end of a path. If the current number in the range is greater than the allowed number, the list of paths is cleared. As a result, the is stopped. The waiting is added to the blocked list by calling AddBlocked.

During startup, event listeners are added on all paths entering or exiting the scope, referencing the OnPathExit or OnPathEntered methods. During simulation, these methods increment or decrement the counter. If the count is below the defined threshold, AwakeBlocked is called. AwakeBlocked is implemented in the PathStrategy base class. It calls TryMoveNext in all blocked .

© 2022 in2Sight GmbH - All rights reserved. No part of this publication may be reproduced, distributed, or transmitted in any form or by any means, including printing, saving, photocopying, recording, or other electronic or mechanical methods, without the prior written permission of the publisher.

MUs
MU
path mover
MUs
Path Mover
Path Mover
MU
path movers
path mover
Path Mover
Path Mover
Line
Path Mover
Path Mover
Path Mover
path movers
https://realvirtual.io