コード例 #1
0
ファイル: CarDriver.cs プロジェクト: Spawek/valeo
        public CarSteering CalculateCarSteering(Map currentMap)
        {
            CarSteering steering = new CarSteering();

            currentPosition = GetNewCurrentPosition(currentMap, currentPosition);
            currentMode     = GetNewMode(currentPosition);

            if (currentMode == Mode.ON_TRACK)
            {
                steering.speed = DEFAULT_SPEED_IN_MS;
                steering.brake = 0.0d;
            }
            else if (currentMode == Mode.REACHED_DESTINATION)
            {
                steering.speed = 0.0d;
                steering.brake = BREAKING_POWER_ON_DESTINATION;
            }
            else
            {
                throw new ApplicationException("unknown mode!");
            }

            double distanceAndSide        = CalculateDistanceAndSideBetweenLineAndPoint(currentPosition.Value, currentMap.car);
            double distanceRegulatorValue = distanceRegulator.ProvideObjectCurrentValueToRegulator(distanceAndSide);
            double angleRegulatorValue    = angleRegulator.ProvideObjectCurrentValueToRegulator(currentPosition.Value.angle);

            steering.angle = distanceRegulatorValue + angleRegulatorValue;

            return(steering);
        }
コード例 #2
0
ファイル: CarDriver.cs プロジェクト: Spawek/valeo
        public CarSteering CalculateCarSteering(Map currentMap)
        {
            CarSteering steering = new CarSteering();

            currentPosition = GetNewCurrentPosition(currentMap, currentPosition);
            currentMode = GetNewMode(currentPosition);

            if (currentMode == Mode.ON_TRACK)
            {
                steering.speed = DEFAULT_SPEED_IN_MS;
                steering.brake = 0.0d;
            }
            else if (currentMode == Mode.REACHED_DESTINATION)
            {
                steering.speed = 0.0d;
                steering.brake = BREAKING_POWER_ON_DESTINATION;
            }
            else
            {
                throw new ApplicationException("unknown mode!");
            }

            double distanceAndSide = CalculateDistanceAndSideBetweenLineAndPoint(currentPosition.Value, currentMap.car);
            double distanceRegulatorValue = distanceRegulator.ProvideObjectCurrentValueToRegulator(distanceAndSide);
            double angleRegulatorValue = angleRegulator.ProvideObjectCurrentValueToRegulator(currentPosition.Value.angle);
            steering.angle = distanceRegulatorValue + angleRegulatorValue;

            return steering;
        }