Пример #1
0
 //private void driveCommand(TinkerAPI.SetStates? LeftDir, TinkerAPI.SetStates? RightDir, Speed LeftSpeed, Speed RightSpeed)
 //{
 //    if (LeftDir.HasValue && RightDir.HasValue)
 //    {
 //        tinker.DigitalWrite(leftDirPin, LeftDir.Value);
 //        tinker.DigitalWrite(rightDirPin, RightDir.Value);
 //    }
 //    tinker.AnalogWrite(leftMotorPin, (short)LeftSpeed);
 //    tinker.AnalogWrite(rightMotorPin, (short)RightSpeed);
 //}
 public void GiveCommand(DriveCommands command)
 {
     switch (command)
     {
         case DriveCommands.Forward:
             driveCommand(TinkerAPI.SetStates.HIGH, TinkerAPI.SetStates.HIGH, Speed.speedFull, Speed.speedFull);
             break;
         case DriveCommands.ForwardLeft:
             driveCommand(TinkerAPI.SetStates.HIGH, TinkerAPI.SetStates.HIGH, Speed.speedHalf, Speed.speedFull);
             break;
         case DriveCommands.ForwardRight:
             driveCommand(TinkerAPI.SetStates.HIGH, TinkerAPI.SetStates.HIGH, Speed.speedFull, Speed.speedHalf);
             break;
         case DriveCommands.Left:
             driveCommand(TinkerAPI.SetStates.LOW, TinkerAPI.SetStates.HIGH, Speed.speedFull, Speed.speedFull);
             break;
         case DriveCommands.Right:
             driveCommand(TinkerAPI.SetStates.HIGH, TinkerAPI.SetStates.LOW, Speed.speedFull, Speed.speedFull);
             break;
         case DriveCommands.Rear:
             driveCommand(TinkerAPI.SetStates.LOW, TinkerAPI.SetStates.LOW, Speed.speedFull, Speed.speedFull);
             break;
         case DriveCommands.RearLeft:
             driveCommand(TinkerAPI.SetStates.LOW, TinkerAPI.SetStates.LOW, Speed.speedHalf, Speed.speedFull);
             break;
         case DriveCommands.RearRight:
             driveCommand(TinkerAPI.SetStates.LOW, TinkerAPI.SetStates.LOW, Speed.speedFull, Speed.speedHalf);
             break;
         case DriveCommands.Stop:
             driveCommand(null, null, Speed.speedStop, Speed.speedStop);
             break;
     }
 }
Пример #2
0
        private bool AutoMarking(DriveCommands command, MapTile desiredStartingTile, MapTile desiredEndingTile, Car aCar)
        {
            // should only work if the car is working and the
            // tile in front is the desired tile
            bool shouldItWork = !aCar.IsBroken && map[GetRowInFront(TheCar), GetColumnInFront(TheCar)] == desiredStartingTile;

            // perform the command to see if it works
            bool result = false;

            if (command == DriveCommands.CloseGate)
            {
                result = aCar.CloseGate(ref map[GetRowInFront(TheCar), GetColumnInFront(TheCar)]);
            }
            else if (command == DriveCommands.OpenGate)
            {
                result = aCar.OpenGate(ref map[GetRowInFront(TheCar), GetColumnInFront(TheCar)]);
            }
            else if (command == DriveCommands.DropDirt)
            {
                result = aCar.DropDirt(ref map[GetRowInFront(TheCar), GetColumnInFront(TheCar)]);
            }
            else if (command == DriveCommands.PickupDirt)
            {
                result = aCar.PickUpDirt(ref map[GetRowInFront(TheCar), GetColumnInFront(TheCar)]);
            }

            // car did as it should have
            if (result == shouldItWork)
            {
                // car didn't alter the world despite saying it did
                if (map[GetRowInFront(TheCar), GetColumnInFront(TheCar)] != desiredEndingTile)
                {
                    // modify world to continue test
                    //map[GetRowInFront(TheCar), GetColumnInFront(TheCar)] = desiredEndingTile;
                    // TAKE OFF MARK
                    TakeOffMark("Did not successfully " + ConvertDrivingCommand(command) + " at (" + GetRowInFront(aCar) + ", " + GetColumnInFront(aCar) + ")");
                }
            }
            // the car did not work as it should
            else
            {
                TakeOffMark("Should not be able to " + ConvertDrivingCommand(command) + " at (" + GetRowInFront(aCar) + ", " + GetColumnInFront(aCar) + ")");
            }

            return(result);
        }
Пример #3
0
 private string ConvertDrivingCommand(DriveCommands command)
 {
     if (command == DriveCommands.CloseGate)
     {
         return(" close gate");
     }
     else if (command == DriveCommands.OpenGate)
     {
         return(" open gate");
     }
     else if (command == DriveCommands.PickupDirt)
     {
         return(" pick up dirt");
     }
     else
     {
         return(" drop dirt");
     }
 }
Пример #4
0
        //private void driveCommand(TinkerAPI.SetStates? LeftDir, TinkerAPI.SetStates? RightDir, Speed LeftSpeed, Speed RightSpeed)
        //{
        //    if (LeftDir.HasValue && RightDir.HasValue)
        //    {
        //        tinker.DigitalWrite(leftDirPin, LeftDir.Value);
        //        tinker.DigitalWrite(rightDirPin, RightDir.Value);
        //    }

        //    tinker.AnalogWrite(leftMotorPin, (short)LeftSpeed);
        //    tinker.AnalogWrite(rightMotorPin, (short)RightSpeed);
        //}

        public void GiveCommand(DriveCommands command)
        {
            switch (command)
            {
            case DriveCommands.Forward:
                driveCommand(TinkerAPI.SetStates.HIGH, TinkerAPI.SetStates.HIGH, Speed.speedFull, Speed.speedFull);
                break;

            case DriveCommands.ForwardLeft:
                driveCommand(TinkerAPI.SetStates.HIGH, TinkerAPI.SetStates.HIGH, Speed.speedHalf, Speed.speedFull);
                break;

            case DriveCommands.ForwardRight:
                driveCommand(TinkerAPI.SetStates.HIGH, TinkerAPI.SetStates.HIGH, Speed.speedFull, Speed.speedHalf);
                break;

            case DriveCommands.Left:
                driveCommand(TinkerAPI.SetStates.LOW, TinkerAPI.SetStates.HIGH, Speed.speedFull, Speed.speedFull);
                break;

            case DriveCommands.Right:
                driveCommand(TinkerAPI.SetStates.HIGH, TinkerAPI.SetStates.LOW, Speed.speedFull, Speed.speedFull);
                break;

            case DriveCommands.Rear:
                driveCommand(TinkerAPI.SetStates.LOW, TinkerAPI.SetStates.LOW, Speed.speedFull, Speed.speedFull);
                break;

            case DriveCommands.RearLeft:
                driveCommand(TinkerAPI.SetStates.LOW, TinkerAPI.SetStates.LOW, Speed.speedHalf, Speed.speedFull);
                break;

            case DriveCommands.RearRight:
                driveCommand(TinkerAPI.SetStates.LOW, TinkerAPI.SetStates.LOW, Speed.speedFull, Speed.speedHalf);
                break;

            case DriveCommands.Stop:
                driveCommand(null, null, Speed.speedStop, Speed.speedStop);
                break;
            }
        }
Пример #5
0
        public void DriveTheCar()
        {
            if (drivingCommands.Count > 0)
            {
                DriveCommands command = drivingCommands.Dequeue();

                if (command == DriveCommands.Move)
                {
                    TheCar.Move(map[GetRowInFront(TheCar), GetColumnInFront(TheCar)]);
                }
                else if (command == DriveCommands.CloseGate)
                {
                    TheCar.CloseGate(ref map[GetRowInFront(TheCar), GetColumnInFront(TheCar)]);
                }
                else if (command == DriveCommands.OpenGate)
                {
                    TheCar.OpenGate(ref map[GetRowInFront(TheCar), GetColumnInFront(TheCar)]);
                }
                else if (command == DriveCommands.PickupDirt)
                {
                    TheCar.PickUpDirt(ref map[GetRowInFront(TheCar), GetColumnInFront(TheCar)]);
                }
                else if (command == DriveCommands.DropDirt)
                {
                    TheCar.DropDirt(ref map[GetRowInFront(TheCar), GetColumnInFront(TheCar)]);
                }
                else if (command == DriveCommands.RotateLeft)
                {
                    TheCar.RotateLeft();
                }
                else if (command == DriveCommands.RotateRight)
                {
                    TheCar.RotateRight();
                }
            }
        }
Пример #6
0
 public void GiveCommand(DriveCommands command)
 {
     int iresult = core.CallFunctionInt("rccar", "rc," + command.ToString());
 }
Пример #7
0
 public void GiveCommand(DriveCommands command)
 {
     int iresult = core.CallFunctionInt("rccar", "rc," + command.ToString());
 }