/// <summary>
        /// Creates an immutable copy of the interface's current state.
        /// </summary>
        /// <returns>
        /// The state.
        /// </returns>
        public CarState CreateState()
        {
            CarState state = new CarState();

            state.Accelerometer = new AccelerometorSensor();
            state.Accelerometer.SetValues(Accelerometor.X, Accelerometor.Y, Accelerometor.Z);

            state.RearUltrasonicSensor = new UltrasonicSensor();
            state.RearUltrasonicSensor.DistanceReadingCM = RearUltrasonicSensor.DistanceReadingCM;

            state.FrontUltrasonicSensors = new UltrasonicSensor[] {
                new UltrasonicSensor(),
                new UltrasonicSensor(),
                new UltrasonicSensor()
            };

            state.FrontUltrasonicSensors[(int)UltrasonicSensorIndex.FrontLeft].DistanceReadingCM = FrontUltrasonicSensors[(int)UltrasonicSensorIndex.FrontLeft].DistanceReadingCM;
            state.FrontUltrasonicSensors[(int)UltrasonicSensorIndex.FrontMiddle].DistanceReadingCM = FrontUltrasonicSensors[(int)UltrasonicSensorIndex.FrontMiddle].DistanceReadingCM;
            state.FrontUltrasonicSensors[(int)UltrasonicSensorIndex.FrontRight].DistanceReadingCM = FrontUltrasonicSensors[(int)UltrasonicSensorIndex.FrontRight].DistanceReadingCM;

            state.SteeringServo = new Servo(null);
            state.SteeringServo.Value = SteeringServo.Value;

            state.ThrottleServo = new Servo(null);
            state.ThrottleServo.Value = ThrottleServo.Value;

            return state;
        }
Esempio n. 2
0
 public virtual bool ShouldTriggerInterruptWithState(CarState state)
 {
     return false;
 }
Esempio n. 3
0
 public virtual bool PerformAIWork(CarState state, double cumulativeThrottleValue, double cumulativeSteeringValue, out double computedThrottleValue, out double computedSteeringValue)
 {
     computedSteeringValue = cumulativeSteeringValue;
     computedThrottleValue = cumulativeThrottleValue;
     return false;
 }