Пример #1
0
        /// <summary>
        /// contains logic to collect food:
        ///   .) drive a bit back
        ///   .) lower grappler
        ///   .) drive a bit forward with rotating grappler-wheel
        ///   .) rise grappler
        /// </summary>
        public static void CollectFood()
        {
            SetTrackSpeed(Constants.DRIVE_BACKWARD_SPEED, Constants.DRIVE_BACKWARD_SPEED);
            Thread.Sleep(1500);
            TurnOffGrappler();
            GrapplerWheelMotor.SetSpeed(Constants.GRAPPLER_WHEEL_SPEED);
            SetTrackSpeed(Constants.DRIVE_FORWARD_AFT_BACKWARD_SPEED,
                          Constants.DRIVE_FORWARD_AFT_BACKWARD_SPEED);
            Thread.Sleep(1500);
            HaltMotors();
            RiseGrappler();

            FoodState = FoodState.Carrying;
        }
Пример #2
0
        /// <summary>
        /// puts down the grappler and opens it, if it's in the air
        /// closed
        /// </summary>
        public static void RealeaseBrickOnMeadow()
        {
            if (GrapplerPosition == GrapplerPosition.Up &&
                FoodState == FoodState.Carrying)
            {
                SetTrackSpeed(Constants.DRIVE_FORWARD_SPEED, Constants.DRIVE_FORWARD_SPEED);

                Thread.Sleep(500);

                HaltTracks();

                GrapplerWheelMotor.ResetTacho();
                GrapplerWheelMotor.SetSpeed(Constants.GRAPPLER_WHEEL_SPEED);

                while (Math.Abs(GrapplerWheelMotor.GetTachoCount())
                       < Constants.GRAPPLER_WHEEL_BOUNDARY)
                {
                    //Robot.Print($"tacho = {GrapplerMotor.GetTachoCount().ToString()}");
                }

                GrapplerWheelMotor.Off();
                FoodState = FoodState.Searching;
            }
        }