Esempio n. 1
0
        /// <summary>
        /// Fire this event.
        /// </summary>
        public override void Fire()
        {
            try
            {
                Logger.Log(this, "Planning route...");
                route = Planner.PlanRoute(NaoState.Instance.Map, locations);
                if (route != null && route.Count != 0)
                {
                    Logger.Log(this, "Path found, walking...");
                }
                else
                {
                    Logger.Log(this, "No path found.");
                    ReportFailure();
                    return;
                }

                Logger.Log(this, "RouteEntries: " + route.Count);
                foreach (RouteEntry entry in route)
                {
                    Logger.Log(entry);
                }

                foreach (RouteEntry entry in route)
                {
                    if (!Aborted)
                    {
                        Logger.Log(this, "Turning to " + entry.Direction + "...");
                        Walk.Instance.TurnTo(entry.Direction);
                        MarkerSearchWorker worker = Walk.Instance.WalkTowardsMarker(entry.MarkerID, entry.WantedDistance);
                        worker.Start();
                    }
                }

                if (Aborted)
                {
                    ReportFailure();
                }
                else
                {
                    ReportSuccess();
                }
            }
            catch (System.Exception e)
            {
                Logger.Log(this, "Unexpected exception caught: " + e.Message);
                ReportFailure();
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Fire this event.
 /// </summary>
 public override void Fire()
 {
     try
     {
         if (!Aborted)
         {
             Logger.Log("GoToMarker: start");
             worker = Walk.Instance.WalkTowardsMarker(markerID, distance);
             worker.Start();
         }
     }
     catch (Exception e)
     {
         Logger.Log(this, e.Message);
     }
 }