Exemplo n.º 1
0
 public Path(PathNodeType[] pNodes, float pathLength, PathStatus pStatus, int pPathSearchTestCount)
 {
     Nodes               = pNodes;
     PathLength          = pathLength;
     Status              = pStatus;
     PathSearchTestCount = pPathSearchTestCount;
 }
Exemplo n.º 2
0
        private void SetPathList(NavNode start, NavNode end)
        {
            Running = false;

            _pathStatus = PathStatus.success;
            var search = end;

            path.Clear();
            while (search != start)
            {
                if (_cameFrom.ContainsKey(search))
                {
                    path.Add(search);
                    search = _cameFrom[search];
                }
                else
                {
                    _pathStatus = PathStatus.failure;
                    return;
                }
            }

            path.Add(start);
            path.Reverse();
            if (_pathStatus == PathStatus.success)
            {
                OnPathfindingComplete?.Invoke(this);
            }
        }
Exemplo n.º 3
0
 public MapGooglePath(List<MapGooglePoint> pathPoint, MapGooglePath.PathColor pathColor)
 {
     this._pathPoint = new List<MapGooglePoint>();
     this._pathPoint = pathPoint;
     this._pathColor = pathColor;
     this._pathStatus = PathStatus.pc;
 }
Exemplo n.º 4
0
 public MapGooglePath(List <MapGooglePoint> pathPoint, MapGooglePath.PathWidth pathWidth)
 {
     this._pathPoint  = new List <MapGooglePoint>();
     this._pathPoint  = pathPoint;
     this._pathWidth  = pathWidth;
     this._pathStatus = PathStatus.pw;
 }
Exemplo n.º 5
0
 /// <summary>
 /// 检测到文件;
 /// </summary>
 /// <param name="status"></param>
 private void OnUpdateStatus(PathStatus status)
 {
     Application.Current.Dispatcher.BeginInvoke(new Action(() =>
     {
         PathStatusItems.SortedAdd(new FileDiffItem(status));
     }));
 }
Exemplo n.º 6
0
 public MapGooglePath(List <MapGooglePoint> pathPoint, MapGooglePath.PathColor pathColor)
 {
     this._pathPoint  = new List <MapGooglePoint>();
     this._pathPoint  = pathPoint;
     this._pathColor  = pathColor;
     this._pathStatus = PathStatus.pc;
 }
Exemplo n.º 7
0
    /// <summary>
    /// Expands a node.
    /// </summary>
    /// <param name='node'>
    /// Node to be expanded
    /// </param>
    private void expandNode(ARAstarNode node)
    {
        nodesExpanded++;
        Open.Remove(node.action.state);

        if (node.g > node.rhs)
        {
            node.g = node.rhs;
            Close.Insert(node);
        }
        else
        {
            node.g = Mathf.Infinity;
            UpdateVertex(node);
        }

        generateNodeSuccessors(ref node);

        if (Visited.nodeForState(stateReached).h > node.h)
        {
            stateReached = node.action.state;
        }

        if (!usingHeap)
        {
            Open.Sort();
        }

        if (node == null)
        {
            Status = PathStatus.NoPath;
        }
    }
Exemplo n.º 8
0
 public Path(PointTileNode[] pNodes, float pPathLength, PathStatus pStatus, int pPathSearchTestCount)
 {
     nodes = pNodes;
     pathLength = pPathLength;
     status = pStatus;
     pathSearchTestCount = pPathSearchTestCount;
 }
    private void SetPathToTarget()
    {
        IntVector3 destination = GetClosestAvailableTile();

        if (destination == _unit.MoveController.MapPosition)
        {
            CustomLogger.Warn(nameof(AIState_Chase), $"Could not find closest available tile!");
            _unit.Navigator.OnArrivedFinalDestination -= OnArrivedFinalDestination;
            SetReadyToTransition(_onFailedToPath);
        }
        PathStatus status = _unit.Navigator.SetDestination(
            _unit.MoveController.MapPosition,
            destination);

        if (status == PathStatus.Invalid)
        {
            CustomLogger.Warn(nameof(AIState_Chase), $"Could not path to destination: {destination}!");
            _unit.Navigator.OnArrivedFinalDestination -= OnArrivedFinalDestination;
            SetReadyToTransition(_onFailedToPath);
            return;
        }
        _unit.Navigator.OnArrivedFinalDestination += OnArrivedFinalDestination;
        _unit.Navigator.LookTarget = null;
        float speed = _fullSpeed ? _unit.UnitData.RunSpeed : _unit.UnitData.WalkSpeed;

        _moveController.SetSpeed(speed);
    }
Exemplo n.º 10
0
 public MapGooglePath(List<MapGooglePoint> pathPoint, MapGooglePath.PathWidth pathWidth)
 {
     this._pathPoint = new List<MapGooglePoint>();
     this._pathPoint = pathPoint;
     this._pathWidth = pathWidth;
     this._pathStatus = PathStatus.pw;
 }
Exemplo n.º 11
0
        public TelegramBotClient Initialize()
        {
            //Se LoadData torna false, inserisci i dati
            if (!LoadData())
            {
                try
                {
                    Console.WriteLine("Insert your d2bot folder path which contain D2Bot.exe:");
                    Console.WriteLine("Example \"C:\\Users\\YOUR_USERNAME\\Desktop\\d2bot-with-kolbot\"");
                    string halfPath = Console.ReadLine();
                    Path              = halfPath + "\\";;
                    PathData          = halfPath + "\\data\\";
                    PathToItemLog     = halfPath + "\\d2bs\\kolbot\\logs\\ItemLog.txt";
                    PathImages        = halfPath + "\\images\\";
                    PathToJsonProfile = halfPath + "\\data\\profile.json";
                    PathToSchedules   = halfPath + "\\data\\schedules.json";

                    DirectoryInfo d = new DirectoryInfo(halfPath + "\\d2bs\\kolbot\\data\\");
                    //Get all json file that represetn all profile on d2bot
                    FileInfo[] Files = d.GetFiles("*.json");
                    foreach (FileInfo file in Files)
                    {
                        PathStatus.Add(file.FullName);
                    }
                    Console.WriteLine("Creating all folders for images...");
                    CreateFolders(PathImages, PathStatus);

                    Console.WriteLine("Insert your Bot Telegram TOKEN:");
                    Console.WriteLine("Example of TOKEN: 1234567890:ABCDEfghilMnopQrs56qwe0qwO2B1Koosq");
                    BotToken = Console.ReadLine();

                    Console.WriteLine("Now say \"Hi\"/\"Hello\" to your bot on Telegram or press START button if it is the first time you open it up");
                    return(new TelegramBotClient(BotToken));
                }
                catch (Exception e)
                {
                    logger.Error(e, "EXCEPTION RAISED");
                    Console.WriteLine(e.StackTrace);
                    Console.WriteLine(e.Message);
                    return(null);
                }
            }
            else
            {
                try
                {
                    return(new TelegramBotClient(BotToken));
                }
                catch (Exception e)
                {
                    logger.Error(e, "EXCEPTION RAISED");
                    Console.WriteLine(e.StackTrace);
                    Console.WriteLine(e.Message);
                    return(null);
                }
            }
            return(null);
        }
Exemplo n.º 12
0
    public GridNavigationTask(State t_startState, State t_goalState, float t_inflationFactor, ref List <State> t_path,
                              float t_tunnelDistanceThreshold, float t_tunnelTimeThreshold, ref List <State> t_spaceTimePath, GridTimeDomain t_gridTimeDomain,
                              TaskPriority t_taskPriority, TaskManager taskManager)
        : base(taskManager, t_taskPriority)          // defaults to a real-time task -- now what happens when both this and Global are first put in queue ??
    {
        taskType = TaskType.GridNavigationTask;

        startState = t_startState;
        goalState  = t_goalState;

        // EVENT : startState will trigger GridNavigationTask that STATE_CHANGED
        startState.registerObserver(Event.STATE_POSITION_CHANGED, this);

        // EVENT : goalState will trigger GridNavigationTask that STATE_CHANGED
        goalState.registerObserver(Event.STATE_POSITION_CHANGED, this);

        // EVENT : goalState will trigger GridNavigationTask that it is GOAL_INVALID or VALID
        goalState.registerObserver(Event.GOAL_INVALID, this);
        goalState.registerObserver(Event.GOAL_VALID, this);


        inflationFactor = t_inflationFactor;

        //planner = t_planner;
        outputPlan = new Dictionary <DefaultState, ARAstarNode>();
        path       = t_path;


        // TODO : deprecate these lists
        List <PlanningDomainBase> domainList    = new List <PlanningDomainBase>();
        ARAstarDomain             araStarDomain = new ARAstarDomain();

        araStarDomain.setPlanningTask(this);
        domainList.Add(araStarDomain);

        gridPlanner = new ARAstarPlanner();
        gridPlanner.init(ref domainList, 100);

        initialized = true;

        obstacleChanged     = false;
        obstacleChangedData = new List <object> ();


        // tunnel planner variables
        tunnelDistanceThreshold = t_tunnelDistanceThreshold;
        tunnelTimeThreshold     = t_tunnelTimeThreshold;
        gridTimeDomain          = t_gridTimeDomain;
        spaceTimePath           = t_spaceTimePath;

        spaceTimePathStatus = false;

        dynamicChange = false;

        currentlyExecutingTask = false;

        gridPathStatus = PathStatus.NoPath;
    }
Exemplo n.º 13
0
 public Boolean IsValid(PathStatus status)
 {
     return(status switch
     {
         Utils.IO.PathStatus.All => PathUtils.IsValidUrl(Path),
         Utils.IO.PathStatus.Exist => PathUtils.IsUrlContainData(Path),
         Utils.IO.PathStatus.NotExist => !PathUtils.IsUrlContainData(Path),
         _ => throw new NotSupportedException($"{nameof(PathStatus)} {status} is not supported")
     });
Exemplo n.º 14
0
        public UrlWatcher(String url, PathStatus status = Utils.IO.PathStatus.All)
        {
            if (!PathUtils.IsValidUrl(url))
            {
                throw new ArgumentException("Url is invalid");
            }

            Path       = url;
            PathStatus = status;
        }
Exemplo n.º 15
0
 public void SetAllPathStatuses(PathStatus status)
 {
     this.InitializeComInterfaces();
     try
     {
         this.port.SetAllPathStatuses(status);
     }
     catch (COMException exception)
     {
         throw new VdsException("The call to IVdsHbaPort::SetAllPathStatuses failed.", exception);
     }
 }
    private void SetNextDestination()
    {
        Transform  nextPoint            = _patrolLoop.PatrolPoints[_currentPatrolLoopIndex];
        IntVector3 nextPointMapPosition = LevelDataManager.Instance.WorldToArraySpace(nextPoint.position);
        PathStatus pathStatus           = _unit.Navigator.SetDestination(_unit.MoveController.MapPosition, nextPointMapPosition);

        if (pathStatus == PathStatus.Invalid)
        {
            SetReadyToTransition(_onFailedToPath);
            return;
        }
    }
Exemplo n.º 17
0
    private void PathFound(Waypoint[] path, PathStatus pathStatus)
    {
        if (pathStatus != PathStatus.Fail)
        {
            if (_pathCoroutine != null)
            {
                StopCoroutine(_pathCoroutine);
            }

            _path          = path;
            _pathCoroutine = FollowPath();
            StartCoroutine(_pathCoroutine);
        }
    }
        public BurstAStarPathFinder GetPath(GridNode from, GridNode to)
        {
            Id = _random.Next(1, int.MaxValue);

            var jobResult = PathFindingJob.Complete(this,
                                                    ref Grid.InnerGrid, Areas, Id,
                                                    from.GridPoint, to.GridPoint,
                                                    AllowFlags, Grid.Transform.ToWorldMatrix);

            Status   = jobResult.PathStatus;
            NodePath = jobResult.NodePath;
            Path     = jobResult.VectorPath;
            return(this);
        }
    private void SetDestination()
    {
        // find a location away from the current hostile target
        IntVector3 targetDestination = GetFleeLocation();

        // listen to the move controller for pathing events
        _unit.Navigator.OnArrivedFinalDestination += OnArrivedDestination;
        // path to that safer location
        PathStatus pathStatus = _unit.Navigator.SetDestination(_unit.MoveController.MapPosition, targetDestination);

        if (pathStatus == PathStatus.Invalid)
        {
            OnArrivedDestination();
        }
    }
Exemplo n.º 20
0
    /// <summary>
    /// Determines whether a complete path exists or not.
    /// </summary>
    /// <returns>
    /// The path status.
    /// </returns>
    bool completePathExists()
    {
        Dictionary <DefaultState, ARAstarNode> tempDic = new Dictionary <DefaultState, ARAstarNode>();

        foreach (KeyValuePair <DefaultState, ARAstarNode> keyval in Visited.dictionary)
        {
            tempDic[keyval.Key] = keyval.Value;
        }

        DefaultState s = goalPair.Key;

        if (!stateReached.Equals(s))
        {
            Status = PathStatus.Incomplete;
        }
        while (!s.Equals(currentStart))
        {
            if (Visited.ContainsState(s) && Visited.nodeForState(s).g == Mathf.Infinity)
            {
                return(false);
            }
            if (!tempDic.ContainsKey(s))
            {
                Status = PathStatus.NoPath;
                return(false);
            }
            else
            {
                DefaultState tempState = s;
                s = tempDic[s].previousState;
                tempDic.Remove(tempState);
            }
        }

        if (selectedPlanningDomain.equals(stateReached, goalState, false))
        {
            if (inflationFactor == 1.0f)
            {
                Status = PathStatus.Optimal;
            }
            else
            {
                Status = PathStatus.SubOptimal;
            }
        }

        return(true);
    }
Exemplo n.º 21
0
 private void FinishedRoutine()
 {
     if (pathStatus == PathStatus.Intersected)
     {
         OneStepBack();
         for (; nodeStack.Peek().Designation != CellRole.EndNode;)
         {
             OneStepBack();
         }
         OneStepBack();
         pathStatus = PathStatus.Nonintersected;
     }
     GetSessionStatus = SessionStatus.Idle;
     EventServices.GenericInstance.InvokeOnFlowUpdate(pathStack.Count);
     WinCondition();
 }
Exemplo n.º 22
0
        public ArbiterFLS()
        {
            Shoot     = new PathStatus(1);
            Pass      = new PathStatus(2);
            BallX     = new BallXLocation(3);
            BallY     = new BallYLocation(4);
            Priority  = new Priority(5);
            listInput = new List <FuzzySet <IInputFuzzyMember> >()
            {
                Shoot, Pass, BallX, BallY
            };

            var rules    = CreateRules();
            var ruleBase = new EvaluationTreeRuleBase(listInput, Priority, rules);

            fls = new FuzzyLogicSystem(new Fuzzifier(), new CenterOfSumsDefuzzifier(), ruleBase);
        }
Exemplo n.º 23
0
        public void Search(NavNode start, NavNode end)
        {
            //Reset our status if need be (ie:this object is cached).
            if (_cachedStart != start)
            {
                _pathStatus = PathStatus.searching;
            }

            if (_pathStatus == PathStatus.searching || _pathStatus == PathStatus.failure)
            {
                //if path is unfound or failed to find

                _tilemapNavigation.StartCoroutine(FindAllPaths(start, end, 100));
                //high iteration number basically means "we need it now!"
                //sadly it restarts. Could we have it find a currently running coroutine and change the iteration value?
                //that would be neat
            }
        }
Exemplo n.º 24
0
    public void tryARAStarPlanner(List <State> spaceTimePath)
    {
        gridTimeDomain.UseTunnelSearch(tunnel);

        DefaultState defStartState = startState as DefaultState;
        DefaultState defLastState  = lastState as DefaultState;

        Dictionary <DefaultState, ARAstarNode> araStarPlan = new Dictionary <DefaultState, ARAstarNode>();
        float        inflationFactor = 2.5f;
        PathStatus   status          = araStarPlanner.computePlan(ref defStartState, ref defLastState, ref araStarPlan, ref inflationFactor, maxTime);
        DefaultState stateReached    = araStarPlanner.FillPlan();

        Debug.Log("TUNNEL ARA SEARCH TEST " + araStarPlan.Count + " status " + status.ToString());

        generateSpaceTimePlanStack(defStartState, stateReached, araStarPlan, spaceTimePath);

        gridTimeDomain.DisableTunnelSearch();
    }
Exemplo n.º 25
0
        public KTreeNode(KfsStatusPath obj, ImageListManager mgr, IAppHelper _helper)
            : base()
        {
            Debug.Assert(obj.IsDir());
            m_helper = _helper;

            m_childs = new SortedDictionary<string, KListViewItem>();
            m_onServer = obj.OnServer();

            m_lvImageListMgr = mgr;

            this.Text = obj.IsRoot() ? "Share" : obj.Name;
            this.ImageKey = "FolderClosed";
            this.SelectedImageKey = "FolderOpened";
            m_status = obj.Status;
            m_name = obj.Name;

            CreateChilds(obj);
        }
Exemplo n.º 26
0
    // Use this for initialization
    void Start()
    {
        planner          = new ARAstarPlanner();
        BestFirstPlanner = new BestFirstSearchPlanner();

        GetComponent <NeighbourObstacles>().Init();

        GridTimeDomain            domain = new GridTimeDomain(GetComponent <NeighbourObstacles>(), GetComponent <NeighbourAgents>());
        List <PlanningDomainBase> dl     = new List <PlanningDomainBase>();

        dl.Add(domain);



        DefaultState startState = new GridTimeState(transform.position) as DefaultState;
        DefaultState goalState  = new GridTimeState(new Vector3(5, 0.5f, 0), 5.0f)  as DefaultState;

        plan       = new Dictionary <DefaultState, ARAstarNode>();
        outputPlan = new Stack <DefaultState>();

        if (BestFirstSearchPlanner)
        {
            BestFirstPlanner.init(ref dl, 200);
            bool completed = BestFirstPlanner.computePlan(ref startState, ref goalState, ref outputPlan, 10.0f);
            Debug.Log("BestFirst Plan " + outputPlan.Count);
            Debug.Log("Plan found: " + completed);
        }
        else
        {
            planner.init(ref dl, 200);
            float      inflationFactor = 2.5f;
            PathStatus status          = planner.computePlan(ref startState, ref goalState, ref plan, ref inflationFactor, 10.0f);
            planner.FillPlan();
            Debug.Log("ARA Plan " + plan.Count);
            Debug.Log("Nodes Expanded: " + planner.Close.Elements().Count);
            Debug.Log("Status: " + status);
        }
    }
    // set the destination
    public PathStatus SetDestination(IntVector3 start, IntVector3 destination)
    {
        ClearDestination();
        PathStatus pathStatus = MapService.GetPathToDestination(
            start,
            destination,
            _currentPath,
            _unit,
            _unit.UnitData.TraversableThreshold
            );

        if (pathStatus == PathStatus.Invalid)
        {
            ArrivedFinalDestination();
            return(PathStatus.Invalid);
        }
        _isPathing = true;
        _moveController.OnMapPositionUpdated += OnMapPositionUpdated;
        UpdateCurrentDestination();
        _targetPosition = destination;
        OnTargetPositionSet?.Invoke(destination);
        return(PathStatus.Complete);
    }
Exemplo n.º 28
0
    private void search()
    {
        status = PathStatus.inProcess;
        //Nodes to search
        List <Node> openSet   = new List <Node>();
        List <Node> closedSet = new List <Node>();

        //Debug.Log("Starting search");

        openSet.Add(start);
        while (openSet.Count > 0)
        {
            Node current = openSet[0];
            openSet.RemoveAt(0);
            closedSet.Add(current);

            if (current.occCode != -1 && UnitManager.manager.getUnitFromUnitCodes(current.occCode).teamCode != teamCode)
            {
                result = UnitManager.manager.getUnitFromUnitCodes(current.occCode);
                status = PathStatus.succeeded;
                return;
            }

            foreach (Node n in Map.getNeighbors(current))
            {
                if (n != null && !closedSet.Contains(n) && Vector3.Distance(start.position, n.position) <= range)
                {
                    if (!openSet.Contains(n))
                    {
                        openSet.Add(n);
                    }
                }
            }
        }
        status = PathStatus.failed;
    }
Exemplo n.º 29
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            Debug.Log("Planning");
            DStartState    = new ARAstarState(startObject.transform.position) as DefaultState;
            DGoalState     = new ARAstarState(goalObject.transform.position) as DefaultState;
            DPrevGoalState = prevGoalState as DefaultState;
            actions.Clear();
            planner.OneStep = false;
            //planner.computePlan(ref DStartState, ref DGoalState, DPrevGoalState, ref outputPlan, ref inflationFactor, 1.0f);
            PlanStatus = planner.computePlan(ref DStartState, ref DGoalState, ref outputPlan, ref inflationFactor, 10.0f);
            Debug.Log("Status: " + PlanStatus);
            if (PlanStatus == PathStatus.NoPath)
            {
                Debug.LogWarning("NO PLAN. PLANNING AGAIN");
                //inflationFactor = 2.5f;
                PlanStatus = planner.computePlan(ref DStartState, ref DGoalState, ref outputPlan, ref inflationFactor, 10.0f);
            }
            new WaitForEndOfFrame();
        }

        if (Input.GetKeyDown(KeyCode.Z))
        {
            showOpen = !showOpen;
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            showClose = !showClose;
        }

        if (Input.GetKeyDown(KeyCode.X))
        {
            showVisited = !showVisited;
        }

        if (Input.GetKeyDown(KeyCode.V))
        {
            showIncons = !showIncons;
        }

        if (Input.GetKeyDown(KeyCode.Q))
        {
            DStartState = new ARAstarState(startObject.transform.position) as DefaultState;
            PlanStatus  = PathStatus.NoPath;
            planner.restartPlanner();
        }

        if (Input.GetKeyDown(KeyCode.S))
        {
            Debug.Log("Planning");
            DStartState    = new ARAstarState(startObject.transform.position) as DefaultState;
            DGoalState     = new ARAstarState(goalObject.transform.position) as DefaultState;
            DPrevGoalState = prevGoalState as DefaultState;
            actions.Clear();
            //planner.computePlan(ref DStartState, ref DGoalState, DPrevGoalState, ref outputPlan, ref inflationFactor, 1.0f);
            planner.OneStep = true;
            PlanStatus      = planner.computePlan(ref DStartState, ref DGoalState, ref outputPlan, ref inflationFactor, 10.0f);
            Debug.Log("Status: " + PlanStatus);
            new WaitForEndOfFrame();
        }

        if (Input.GetKeyDown(KeyCode.Return))
        {
            if (actions.Count > 0)
            {
                ARAstarAction action = actions.Pop();
                Debug.Log("Direction: " + action.direction);
                Vector3 prevPost = startObject.transform.position;
                startObject.transform.position = new Vector3(prevPost.x + action.direction.x, prevPost.y + action.direction.y, prevPost.z + action.direction.z);
            }
            ARAstarPlanner.moved = true;
        }
        if (selectedGameObject != null)
        {
            if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                moveSelectedObjectWithDirection(1.0f, 0.0f, 0.0f);
            }
            else if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                moveSelectedObjectWithDirection(-1.0f, 0.0f, 0.0f);
            }
            else if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                moveSelectedObjectWithDirection(0.0f, 0.0f, 1.0f);
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                moveSelectedObjectWithDirection(0.0f, 0.0f, -1.0f);
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            Debug.Log("Mouse Down");
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(ray, out hit, 100.0f))
            {
                Debug.Log("Selected");
                selectedGameObject = hit.transform.gameObject;
                Debug.Log("Position: " + selectedGameObject.transform.position);
            }
            else
            {
                Debug.Log("Nothing selected");
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("Obstacle Moved Update");
            Debug.Log("Prev: " + (previousState as ARAstarState).state);
            Debug.Log("Curret: " + (currentState as ARAstarState).state);
            planner.UpdateAfterObstacleMoved(previousState, currentState);
        }
        if (Input.GetKeyDown(KeyCode.P))
        {
            DefaultState stateReached = planner.FillPlan();
            fillActionStack(stateReached);
        }
    }
Exemplo n.º 30
0
    public override TaskStatus execute(float maxTime)
    {
        // TODO : make sure start and goal are set to integers -- else this planner will crash, never return
        // TODO : make sure the 'y' value is consistent throughout -- causes big problems
        // as soon as u see the planner expanding max nodes -- u know its prob y value .

        bool doWeNeedToGridPlan = false;
        if (firstPlan == false) doWeNeedToGridPlan = true;

        if (startChanged == true && firstPlan == true )
        {
            Debug.LogError("HANDLING START CHANGE " );
            DefaultState newStartState = new ARAstarState( startState.getPosition() ) as DefaultState;
            gridPlanner.UpdateAfterStartMoved(newStartState);
            startChanged = false;

            doWeNeedToGridPlan = true;
        }

        // handle obstacle changes here
        if (obstacleChanged == true && firstPlan == true)
        {

            Debug.LogError("HANDLING OBSTACLE CHANGE");
            foreach (object data in obstacleChangedData)
            {
                Vector3[] pc = (Vector3[]) data; // {oldPos, newPos}

                DefaultState ps = new ARAstarState( pc[0] ) as DefaultState;
                DefaultState ns = new ARAstarState( pc[1] ) as DefaultState;

                gridPlanner.UpdateAfterObstacleMoved(ps, ns);
            }

            obstacleChanged = false;
            obstacleChangedData.Clear ();

            doWeNeedToGridPlan = true;

        }

        if (goalChanged == true && firstPlan == true) // update goal is called only if we have already planned once
        {
            Debug.LogError("HANDLING GOAL CHANGE");
            DefaultState newGoalState = new ARAstarState( goalState.getPosition() ) as DefaultState;
            gridPlanner.UpdateAfterGoalMoved(newGoalState);

            doWeNeedToGridPlan = true;
        }

        // SINISTER BUG THAT GOALCHANGED WAS NOT BEING SET TO FALSE IF firstPlan was false -- always set it when we come here
        goalChanged = false;

        // grid planning only if start, goal, or obstracle changed OR first time
        if (doWeNeedToGridPlan)
        {

            Debug.Log("grid Planning from " + startState.getPosition() + "to " + goalState.getPosition() + " " + doWeNeedToGridPlan + " " + firstPlan);
            DefaultState DStartState = new ARAstarState(startState.getPosition()) as DefaultState;
            DefaultState DGoalState = new ARAstarState(goalState.getPosition()) as DefaultState;

            gridPathStatus = gridPlanner.computePlan(ref DStartState, ref DGoalState, ref outputPlan, ref inflationFactor, 1.0f);
            Debug.Log("grid Plan result : " + gridPathStatus);

            // filling plan -- made separate operations now
            DefaultState stateReached = gridPlanner.FillPlan();
            generatePlanList (stateReached);

            if ( firstPlan == false ) firstPlan = true;
        }

        // space time planning only if grid plan chagned or DYNAMIC CHANGE
        if ( doWeNeedToGridPlan || dynamicChange || firstPlan)
        {

            Debug.LogError("SPACE TIME PLANNING");
            spaceTimePathStatus = false;
            if (gridPathStatus == PathStatus.NoPath || gridPathStatus == PathStatus.Incomplete )
            {
                Debug.LogError("GRID PLAN IS INCOMPLETE OR NO PATH EXISTS -- CANNOT DO TUNNEL PLANNING");
            }
            else
                spaceTimePathStatus = doTunnelTask ();

            dynamicChange = false; // just assuming it was handled here for now
        }

        // TODO : accomodate tunnel status in this
        //if ( finished != PathStatus.Optimal)
        if ( gridPathStatus == PathStatus.Incomplete || spaceTimePathStatus == false)
            setTaskPriority(TaskPriority.RealTime);
        else
            setTaskPriority(TaskPriority.Inactive);

        return TaskStatus.Success;
    }
Exemplo n.º 31
0
    // defaults to a real-time task -- now what happens when both this and Global are first put in queue ??
    public GridNavigationTask(State t_startState, State t_goalState, float t_inflationFactor, ref List<State> t_path,
		float t_tunnelDistanceThreshold, float t_tunnelTimeThreshold, ref List<State> t_spaceTimePath, GridTimeDomain t_gridTimeDomain,
		TaskPriority t_taskPriority, TaskManager taskManager)
        : base(taskManager, t_taskPriority)
    {
        taskType = TaskType.GridNavigationTask;

        startState = t_startState;
        goalState = t_goalState;

        // EVENT : startState will trigger GridNavigationTask that STATE_CHANGED
        startState.registerObserver(Event.STATE_POSITION_CHANGED, this);

        // EVENT : goalState will trigger GridNavigationTask that STATE_CHANGED
        goalState.registerObserver(Event.STATE_POSITION_CHANGED, this);

        // EVENT : goalState will trigger GridNavigationTask that it is GOAL_INVALID or VALID
        goalState.registerObserver(Event.GOAL_INVALID, this);
        goalState.registerObserver(Event.GOAL_VALID, this);

        inflationFactor = t_inflationFactor;

        //planner = t_planner;
        outputPlan = new Dictionary<DefaultState, ARAstarNode>();
        path = t_path;

        // TODO : deprecate these lists
        List<PlanningDomainBase> domainList = new List<PlanningDomainBase>();
        ARAstarDomain araStarDomain = new ARAstarDomain ();
        araStarDomain.setPlanningTask(this);
        domainList.Add(araStarDomain);

        gridPlanner = new ARAstarPlanner();
        gridPlanner.init(ref domainList, 100);

        initialized = true;

        obstacleChanged = false;
        obstacleChangedData = new List<object> ();

        // tunnel planner variables
        tunnelDistanceThreshold = t_tunnelDistanceThreshold;
        tunnelTimeThreshold = t_tunnelTimeThreshold;
        gridTimeDomain = t_gridTimeDomain;
        spaceTimePath = t_spaceTimePath;

        spaceTimePathStatus = false;

        dynamicChange = false;

        currentlyExecutingTask = false;

        gridPathStatus = PathStatus.NoPath;
    }
Exemplo n.º 32
0
        public Path <IntPointNode> FindPath(IPathNode start, IPathNode goal, bool reset)
        {
            if (start == null || goal == null)
            {
                return(new Path <IntPointNode>(new IntPointNode[] { }, 0f, PathStatus.DESTINATION_UNREACHABLE, 0));
            }

            if (start == goal)
            {
                return(new Path <IntPointNode>(new IntPointNode[] { }, 0f, PathStatus.ALREADY_THERE, 0));
            }

            int testCount = 0;

            if (reset)
            {
                Reset();
            }

            start.IsStartNode = true;
            goal.IsGoalNode   = true;
            List <IntPointNode> resultNodeList = new List <IntPointNode>();

            IPathNode currentNode = start;
            IPathNode goalNode    = goal;

            currentNode.Visited         = true;
            currentNode.LinkLeadingHere = null;
            AStarStack nodesToVisit = new AStarStack();
            PathStatus pathResult   = PathStatus.NOT_CALCULATED_YET;

            testCount = 1;

            while (pathResult == PathStatus.NOT_CALCULATED_YET)
            {
                foreach (PathLink l in currentNode.Links)
                {
                    IPathNode otherNode = l.GetOtherNode(currentNode);

                    if (!otherNode.Visited)
                    {
                        TryQueueNewNode(otherNode, l, nodesToVisit, goalNode);
                    }
                }

                if (nodesToVisit.Count == 0)
                {
                    pathResult = PathStatus.DESTINATION_UNREACHABLE;
                }
                else
                {
                    currentNode = nodesToVisit.Pop();
                    testCount++;

                    currentNode.Visited = true;

                    if (currentNode == goalNode)
                    {
                        pathResult = PathStatus.FOUND_GOAL;
                    }
                }
            }

            // Path finished, collect
            float tLength = 0;

            if (pathResult == PathStatus.FOUND_GOAL)
            {
                tLength = currentNode.PathCostHere;

                while (currentNode != start)
                {
                    resultNodeList.Add((IntPointNode)currentNode);
                    currentNode = currentNode.LinkLeadingHere.GetOtherNode(currentNode);
                }

                resultNodeList.Add((IntPointNode)currentNode);
                resultNodeList.Reverse();
            }

            return(new Path <IntPointNode>(resultNodeList.ToArray(), tLength, pathResult, testCount));
        }
Exemplo n.º 33
0
 public PathResult(PathStatus status = PathStatus.NotFound)
 {
     _status = status;
     _path   = new List <PathEdge>();
 }
Exemplo n.º 34
0
        public void UpdateInfos(KfsStatusPath obj)
        {
            m_fileName = obj.Name;

            if ((obj.IsDir() && obj.HasServerDir()) ||
                (obj.IsFile() && obj.HasServerFile() && !((KfsServerFile)obj.ServerObject).HasCurrentVersion()))
            {
                // Get the creator if obj is a directory on the server or if its a new file
                // that has no current version yet.
                m_modifiedBy = m_helper.GetUserDisplayName((UInt32)obj.ServerObject.CreationUserID);
            }
            else if(obj.IsFile() && obj.HasServerFile() &&
                ((KfsServerFile)obj.ServerObject).HasCurrentVersion() &&
                (obj.Status !=  PathStatus.ModifiedCurrent && obj.Status != PathStatus.ModifiedStale))
            {
                // We have a file and its current version, and it is NOT modified locally.
                m_modifiedBy = m_helper.GetUserDisplayName(((KfsServerFile)obj.ServerObject).CurrentVersion.UserID);
            }
            else
            {
                m_modifiedBy = m_helper.GetUserDisplayName(m_helper.GetKwmUserID());
            }

            m_modifiedDate = obj.LastModifiedDate;

            m_path = obj.Path;
            m_status = obj.Status;
            m_onServer = obj.OnServer();

            m_size = obj.Size;

            m_isFile = obj.IsFile();
            m_isDirectory = obj.IsDir();

            this.Text = m_fileName;
            this.Name = m_fileName;

            // FIXME : need a way to distinguish between an upload and a download.
            // Always set the icon, play with ShowIcon to display it or not.
            // This crashes the kwm with a Corrupted memory exception. See if the ressource is ok.
            /*((CustomListViewSubItem)SubItems[TransferStatusKey]).icon = KwmAppControls.Properties.Resources.download;
            if (obj.Share.IsTransferringFile(m_path))
                ((CustomListViewSubItem)SubItems[TransferStatusKey]).showIcon = true;
            else
                ((CustomListViewSubItem)SubItems[TransferStatusKey]).showIcon = true;
             * */

            SubItems[ModifiedDateKey].Text = m_modifiedDate.ToString();
            SubItems[ModifiedByKey].Text = m_modifiedBy;

            if (m_size != UInt64.MaxValue)
                SubItems[SizeKey].Text = Base.GetHumanFileSize(m_size);
            else if (m_status == PathStatus.Directory)
                SubItems[SizeKey].Text = "";
            else
                SubItems[SizeKey].Text = "In progress...";

            if (m_status == PathStatus.Directory)
            {
                if (obj.OnServer())
                    SubItems[StatusKey].Text = "";
                else
                    SubItems[StatusKey].Text = "Not Added";
            }
            else
            {
                SubItems[StatusKey].Text = Base.GetEnumDescription(m_status);
                m_hasCurrentVersion = (obj.HasServerFile() && ((KfsServerFile)obj.ServerObject).HasCurrentVersion());
            }

            Font strikeout = new Font(this.Font, FontStyle.Strikeout);
            Font standard = new Font(this.Font, FontStyle.Regular);
            Font italic = new Font(this.Font, FontStyle.Italic);

            // Set default color and style
            this.Font = standard;
            this.ForeColor = Color.Black;

            // Modify color / style for specific statuses.
            switch (m_status)
            {
                case PathStatus.NotAdded:
                    this.Font = italic;
                    break;
                case PathStatus.Directory:
                    if (!m_onServer)
                        this.Font = italic;
                    break;
                case PathStatus.DirFileConflict:
                case PathStatus.FileDirConflict:
                case PathStatus.ModifiedStale:
                    this.ForeColor = Color.Red;
                    break;
                case PathStatus.NotDownloaded:
                    this.ForeColor = Color.DarkGray;
                    break;
            }
        }
Exemplo n.º 35
0
 public MapGooglePath()
 {
     _pathPoint = new List<MapGooglePoint>();
     this._pathStatus = PathStatus.none;
 }
Exemplo n.º 36
0
 public MapGooglePath(List<MapGooglePoint> pathPoint)
 {
     this._pathPoint = new List<MapGooglePoint>();
     this._pathPoint = pathPoint;
     this._pathStatus = PathStatus.p;
 }
Exemplo n.º 37
0
 /// <summary>
 /// Return true if the Listview selected items all have the
 /// same PathStatus
 /// </summary>
 /// <param name="_desiredStatus"></param>
 /// <returns></returns>
 private bool EntireLvSelectionHasStatus(PathStatus _desiredStatus)
 {
     foreach (KListViewItem itm in lvFileList.SelectedItems)
     {
         if (itm.Status != _desiredStatus)
             return false;
     }
     return true;
 }
Exemplo n.º 38
0
 private void OnUpdateStatus(PathStatus status)
 {
     this.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => _status_paths.Add(status)));
 }
Exemplo n.º 39
0
 public void FinishedProcessingPath(Waypoint[] path, PathStatus pathStatus)
 {
     _currentPathRequest.Callback(path, pathStatus);
     _isProcessingPath = false;
     TryProcessNext();
 }
Exemplo n.º 40
0
        /// <summary>
        /// Update the status of path.
        /// </summary>
        public void UpdateStatus()
        {
            Debug.Assert(LocalObject != null || ServerObject != null);

            if (LocalObject == null)
            {
                // This is a server ghost.
                if (ServerObject.IsGhost()) Status = PathStatus.ServerGhost;

                // This is a remote directory.
                else if (ServerObject is KfsServerDirectory) Status = PathStatus.Directory;

                // This is a not-downloaded file.
                else Status = PathStatus.NotDownloaded;
            }

            else if (LocalObject is KfsLocalDirectory)
            {
                // There is no directory conflict.
                if (ServerObject == null || ServerObject is KfsServerDirectory || ServerObject.IsGhost())
                    Status = PathStatus.Directory;

                // There is a directory/file conflict.
                else Status = PathStatus.DirFileConflict;
            }

            else
            {
                Debug.Assert(LocalObject is KfsLocalFile);

                // The file has no version on the server.
                if (ServerObject == null ||
                    (ServerObject is KfsServerFile && !ServerObject.HasCurrentVersion()))
                {
                    Status = PathStatus.NotAdded;
                }

                // There is a file/directory conflict.
                else if (ServerObject is KfsServerDirectory)
                {
                    Status = PathStatus.FileDirConflict;
                }

                else
                {
                    Debug.Assert(ServerObject is KfsServerFile);
                    KfsLocalFile localFile = LocalObject as KfsLocalFile;
                    KfsServerFile serverFile = ServerObject as KfsServerFile;

                    // The current local status is unknown or the server view does not
                    // see the local file. In either case, the status is undetermined
                    // and we must ask for an update.
                    if (serverFile.CurrentLocalStatus == LocalStatus.Error ||
                        serverFile.CurrentLocalStatus == LocalStatus.Absent ||
                        serverFile.CurrentLocalStatus == LocalStatus.None)
                    {
                        Status = PathStatus.Undetermined;
                        Logging.Log(2, "Requesting update of file " + serverFile.RelativePath +
                                       " in status view because current local status is " +
                                       serverFile.CurrentLocalStatus + ".");
                        serverFile.RequestUpdate();
                    }

                    // The file is unmodified.
                    else if (serverFile.CurrentLocalStatus == LocalStatus.Unmodified)
                    {
                        // The current server version is the downloaded version, so the
                        // file is current.
                        if (serverFile.CurrentVersion == serverFile.DownloadVersion)
                            Status = PathStatus.UnmodifiedCurrent;

                        // The current server version is not downloaded version, so the
                        // file is stale.
                        else Status = PathStatus.UnmodifiedStale;
                    }

                    // The file is modified.
                    else
                    {
                        Debug.Assert(serverFile.CurrentLocalStatus == LocalStatus.Modified);

                        // The current server version is the downloaded version, so
                        // there is no conflict, as would say Darth Vador.
                        if (serverFile.CurrentVersion == serverFile.DownloadVersion)
                            Status = PathStatus.ModifiedCurrent;

                        // The downloaded version exists but it is not the current
                        // version, so there is a conflict, or the user created his own
                        // file at the location of a non-downloaded server file. Since
                        // the user is possibly unaware of this fact, we must also
                        // report it as modified stale (conflict).
                        else Status = PathStatus.ModifiedStale;
                    }
                }
            }
        }
Exemplo n.º 41
0
 public override void OnTick() => PathStatus.Draw();
		private void OnUpdateStatus(PathStatus status)
		{
			this.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => _status_paths.Add(status)));
		}