Ejemplo n.º 1
0
        /// <summary>
        /// Enqueues an MultiPointGather task.
        /// </summary>
        /// <param name="movableStation">The bot that shall execute the task.</param>
        /// <param name="order">The station at which the task will be executed.</param>
        protected void EnqueueMultiPointGather(MovableStation station, DummyOrder order)
        {
            MultiPointGatherTask task = new MultiPointGatherTask(Instance, station, order);

            task.Prepare();
            if (_taskQueues[station] != null)
            {
                _taskQueues[station].Cancel();
            }
            _taskQueues[station]       = task;
            _lastTaskEnqueued[station] = task;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the next task for the specified bot.
        /// </summary>
        /// <param name="bot">The bot to get a task for.</param>
        protected override void GetNextTask(Bot bot)
        {
            MovableStation station = null;

            if (bot is MovableStation)
            {
                station = bot as MovableStation;
                DummyOrder order = station.AssignedOrders.FirstOrDefault() as DummyOrder;
                if (order != null)
                {
                    EnqueueMultiPointGather(station, order);
                }
            }
            else
            {
                return;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a bot with the given characteristics.
        /// </summary>
        /// <param name="id">The ID of the bot.</param>
        /// <param name="tier">The initial position (tier).</param>
        /// <param name="x">The initial position (x-coordinate).</param>
        /// <param name="y">The initial position (y-coordinate).</param>
        /// <param name="radius">The radius of the bot.</param>
        /// <param name="orientation">The initial orientation.</param>
        /// <param name="podTransferTime">The time for picking up and setting down a pod.</param>
        /// <param name="maxAcceleration">The maximal acceleration in m/s^2.</param>
        /// <param name="maxDeceleration">The maximal deceleration in m/s^2.</param>
        /// <param name="maxVelocity">The maximal velocity in m/s.</param>
        /// <param name="turnSpeed">The time it takes the bot to take a full turn in s.</param>
        /// <param name="collisionPenaltyTime">The penalty time for a collision in s.</param>
        /// <returns>The newly created bot.</returns>
        public Bot CreateBot(int id, Tier tier, double x, double y, double radius, double orientation, double podTransferTime, double maxAcceleration, double maxDeceleration, double maxVelocity, double turnSpeed, double collisionPenaltyTime, bool createMovableStation = false)
        {
            // Consider override values
            if (SettingConfig.OverrideConfig != null && SettingConfig.OverrideConfig.OverrideBotPodTransferTime)
            {
                podTransferTime = SettingConfig.OverrideConfig.OverrideBotPodTransferTimeValue;
            }
            if (SettingConfig.OverrideConfig != null && SettingConfig.OverrideConfig.OverrideBotMaxAcceleration)
            {
                maxAcceleration = SettingConfig.OverrideConfig.OverrideBotMaxAccelerationValue;
            }
            if (SettingConfig.OverrideConfig != null && SettingConfig.OverrideConfig.OverrideBotMaxDeceleration)
            {
                maxDeceleration = SettingConfig.OverrideConfig.OverrideBotMaxDecelerationValue;
            }
            if (SettingConfig.OverrideConfig != null && SettingConfig.OverrideConfig.OverrideBotMaxVelocity)
            {
                maxVelocity = SettingConfig.OverrideConfig.OverrideBotMaxVelocityValue;
            }
            if (SettingConfig.OverrideConfig != null && SettingConfig.OverrideConfig.OverrideBotTurnSpeed)
            {
                turnSpeed = SettingConfig.OverrideConfig.OverrideBotTurnSpeedValue;
            }
            // Init
            Bot            bot = null;
            MovableStation ms  = null;

            if (createMovableStation)
            {
                ms  = new MovableStation(id, this, radius, maxAcceleration, maxDeceleration, maxVelocity, turnSpeed, collisionPenaltyTime, x, y);
                bot = ms;
            }
            else
            {
                switch (ControllerConfig.PathPlanningConfig.GetMethodType())
                {
                case PathPlanningMethodType.Simple:
                    bot = new BotHazard(this, ControllerConfig.PathPlanningConfig as SimplePathPlanningConfiguration);
                    break;

                case PathPlanningMethodType.Dummy:
                case PathPlanningMethodType.WHCAvStar:
                case PathPlanningMethodType.WHCAnStar:
                case PathPlanningMethodType.FAR:
                case PathPlanningMethodType.BCP:
                case PathPlanningMethodType.OD_ID:
                case PathPlanningMethodType.CBS:
                case PathPlanningMethodType.PAS:
                    bot = new BotNormal(id, this, radius, podTransferTime, maxAcceleration, maxDeceleration, maxVelocity, turnSpeed, collisionPenaltyTime, x, y);
                    break;

                default: throw new ArgumentException("Unknown path planning engine: " + ControllerConfig.PathPlanningConfig.GetMethodType());
                }
            }

            // Set values
            bot.ID                   = id;
            bot.Tier                 = tier;
            bot.Instance             = this;
            bot.Radius               = radius;
            bot.X                    = x;
            bot.Y                    = y;
            bot.PodTransferTime      = podTransferTime;
            bot.MaxAcceleration      = maxAcceleration;
            bot.MaxDeceleration      = maxDeceleration;
            bot.MaxVelocity          = maxVelocity;
            bot.TurnSpeed            = turnSpeed;
            bot.CollisionPenaltyTime = collisionPenaltyTime;
            bot.Orientation          = orientation;
            if (bot is BotHazard)
            {
                ((BotHazard)bot).EvadeDistance = 2.3 * radius;
                ((BotHazard)bot).SetTargetOrientation(orientation);
            }
            // Add bot
            if (ms != null)
            {
                ms.Capacity = 1000;
                Bots.Add(ms);
                //bot was referencing only bot-part of movable station and those values were updated
                MovableStations.Add(ms);
            }
            else
            {
                Bots.Add(bot);
            }
            tier.AddBot(bot);
            _idToBots[bot.ID] = bot;
            // Determine volatile ID
            int volatileID = 0;

            while (_volatileBotIDs.Contains(volatileID))
            {
                volatileID++;
            }
            bot.VolatileID = volatileID;
            _volatileBotIDs.Add(bot.VolatileID);
            // Return it
            return(bot);
        }