Ejemplo n.º 1
0
        public Attitude(ITelloState state, bool useMissionPad = false)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            if (!useMissionPad)
            {
                Pitch = state.Pitch;
                Roll  = state.Roll;
                Yaw   = state.Yaw;
            }
            else
            {
                if (!state.MissionPadDetected)
                {
                    throw new ArgumentException($"{nameof(state)}.{nameof(ITelloState.MissionPadDetected)} == false");
                }

                Pitch = state.MissionPadPitch;
                Roll  = state.MissionPadRoll;
                Yaw   = state.MissionPadYaw;
            }
            Timestamp = state.Timestamp;
        }
Ejemplo n.º 2
0
 public void SetState(ITelloState telloState)
 {
     if (telloState != null)
     {
         this.available = 0;
         this.Buffer    = Encoding.UTF8.GetBytes(telloState.ToString());
     }
 }
Ejemplo n.º 3
0
        public Battery(ITelloState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            TemperatureLowC  = state.TemperatureLowC;
            TemperatureHighC = state.TemperatureHighC;
            PercentRemaining = state.BatteryPercent;
            Timestamp        = state.Timestamp;
        }
Ejemplo n.º 4
0
 public Position(ITelloState state)
     : this(
         state?.HeightInCm,
         state?.BarometerInCm + _altitudeDelta,
         0,
         0,
         0,
         state?.Timestamp)
 {
     if (state == null)
     {
         throw new ArgumentNullException(nameof(state));
     }
 }
Ejemplo n.º 5
0
 //todo: fix "this" calls to look like : (state ?? throw new ArgumentNullException(nameof(state))).HeightInCm
 public Position(ITelloState state, Vector vector)
     : this(
         state?.HeightInCm,
         state?.BarometerInCm + _altitudeDelta,
         vector?.Heading,
         vector?.X,
         vector?.Y,
         state?.Timestamp)
 {
     if (state == null)
     {
         throw new ArgumentNullException(nameof(state));
     }
 }
Ejemplo n.º 6
0
        public AirSpeed(ITelloState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }

            this.AccelerationX = state.AccelerationX;
            this.AccelerationY = state.AccelerationY;
            this.AccelerationZ = state.AccelerationZ;
            this.SpeedX        = state.SpeedX;
            this.SpeedY        = state.SpeedY;
            this.SpeedZ        = state.SpeedZ;
            this.Timestamp     = state.Timestamp;
        }
Ejemplo n.º 7
0
        private string Invoke(Command command)
        {
            if (command != Commands.EnterSdkMode && !this.inCommandMode)
            {
                throw new TelloException("Call EnterSdkMode first.");
            }

            if (!this.isFlying && command.Rule.IsInFlightRequired)
            {
                throw new TelloException("Call Takeoff first.");
            }

            switch (command.Rule.ExpectedResponse)
            {
            case Responses.Ok:
                this.HandleOk(command);
                this.state = new TelloState(this.position);
                return("ok");

            case Responses.Speed:
                return(this.speed.ToString());

            case Responses.Battery:
                return("99");

            case Responses.Time:
                return("0");

            case Responses.WIFISnr:
                return("unk");

            case Responses.SdkVersion:
                return("Sim V1");

            case Responses.SerialNumber:
                return("SIM-1234");

            case Responses.None:
                return(String.Empty);

            default:
                throw new NotSupportedException();
            }
        }
Ejemplo n.º 8
0
        private string Invoke(Command command)
        {
            if (command != Commands.EnterSdkMode && !_inCommandMode)
            {
                throw new TelloException("Call EnterSdkMode first.");
            }

            if (!_isFlying && command.Rule.MustBeInFlight)
            {
                throw new TelloException("Call Takeoff first.");
            }

            switch (command.Rule.Response)
            {
            case Responses.Ok:
                HandleOk(command);
                _state = new TelloState(_position);
                return("ok");

            case Responses.Speed:
                return(_speed.ToString());

            case Responses.Battery:
                return("99");

            case Responses.Time:
                return("0");

            case Responses.WIFISnr:
                return("unk");

            case Responses.SdkVersion:
                return("Sim V1");

            case Responses.SerialNumber:
                return("SIM-1234");

            default:
                throw new NotSupportedException();
            }
        }
Ejemplo n.º 9
0
 public void UpdateState(object _, StateChangedArgs e)
 {
     this.State = e.State;
 }
 public StateChangedArgs(ITelloState state)
 {
     State = state ?? throw new ArgumentNullException(nameof(state));
 }
 public AttitudeObservation(
     IObservationGroup group,
     ITelloState state)
     : this(
         (group ?? throw new ArgumentNullException(nameof(group))).Id,
Ejemplo n.º 12
0
 public HobbsMeter(ITelloState state)
 {
     this.DistanceTraversedInCm = state.DistanceTraversedInCm;
     this.MotorTimeInSeconds    = state.MotorTimeInSeconds;
     this.Timestamp             = state.Timestamp;
 }