Example #1
0
        public static NavigationData ToNavigationData(this NativeNavdata nativeNavdata)
        {
            var navigationData = new NavigationData();

            def_ardrone_state_mask_t ardroneState = nativeNavdata.ardrone_state;
            UpdateStateUsing(ardroneState, ref navigationData.State);

            var ctrlState = (CTRL_STATES) (nativeNavdata.demo.ctrl_state >> 0x10);
            UpdateStateUsing(ctrlState, ref navigationData.State);

            navigationData.Yaw = nativeNavdata.demo.psi/1000.0f;
            navigationData.Pitch = nativeNavdata.demo.theta/1000.0f;
            navigationData.Roll = nativeNavdata.demo.phi/1000.0f;

            navigationData.Altitude = nativeNavdata.demo.altitude/1000.0f;

            navigationData.Time = nativeNavdata.time.time;

            navigationData.Velocity.X = nativeNavdata.demo.vx/1000.0f;
            navigationData.Velocity.Y = nativeNavdata.demo.vy/1000.0f;
            navigationData.Velocity.Z = nativeNavdata.demo.vz/1000.0f;

            navigationData.Battery.Low = ardroneState.HasFlag(def_ardrone_state_mask_t.ARDRONE_VBAT_LOW);
            navigationData.Battery.Percentage = nativeNavdata.demo.vbat_flying_percentage;
            navigationData.Battery.Voltage = nativeNavdata.raw_measures.vbat_raw/1000.0f;
            
            navigationData.Wifi.LinkQuality = 1.0f - ToSingle(nativeNavdata.wifi.link_quality);

            return navigationData;
        }
Example #2
0
        public static NavigationData ToNavigationData(NavdataBag navdataBag)
        {
            var navigationData = new NavigationData();

            var ardroneState = (def_ardrone_state_mask_t) navdataBag.ardrone_state;
            UpdateStateUsing(ardroneState, ref navigationData.State);

            var ctrlState = (CTRL_STATES) (navdataBag.demo.ctrl_state >> 0x10);
            UpdateStateUsing(ctrlState, ref navigationData.State);

            navigationData.Yaw = DegreeToRadian*(navdataBag.demo.psi/1000.0f);
            navigationData.Pitch = DegreeToRadian*(navdataBag.demo.theta/1000.0f);
            navigationData.Roll = DegreeToRadian*(navdataBag.demo.phi/1000.0f);

            navigationData.Altitude = navdataBag.demo.altitude/1000.0f;

            navigationData.Time = navdataBag.time.time;

            navigationData.Velocity.X = navdataBag.demo.vx/1000.0f;
            navigationData.Velocity.Y = navdataBag.demo.vy/1000.0f;
            navigationData.Velocity.Z = navdataBag.demo.vz/1000.0f;

            navigationData.Battery.Low = ardroneState.HasFlag(def_ardrone_state_mask_t.ARDRONE_VBAT_LOW);
            navigationData.Battery.Percentage = navdataBag.demo.vbat_flying_percentage;
            navigationData.Battery.Voltage = navdataBag.raw_measures.vbat_raw/1000.0f;

            navigationData.Wifi.LinkQuality = 1.0f - ConversionHelper.ToSingle(navdataBag.wifi.link_quality);

            navigationData.Video.FrameNumber = navdataBag.video_stream.frame_number;

            return navigationData;
        }
 public static bool TryParse(ref NavigationPacket packet, out NavigationData navigationData)
 {
     navigationData = new NavigationData();
     NavdataBag navdataBag;
     if (NavdataBagParser.TryParse(ref packet, out navdataBag))
     {
         navigationData = NavdataConverter.ToNavigationData(navdataBag);
         return true;
     }
     return false;
 }
Example #4
0
        public static bool TryParse(ref NavigationPacket packet, out NavigationData navigationData)
        {
            navigationData = new NavigationData();
            NavdataBag navdataBag;

            if (NavdataBagParser.TryParse(ref packet, out navdataBag))
            {
                navigationData = NavdataConverter.ToNavigationData(navdataBag);
                return(true);
            }
            return(false);
        }
Example #5
0
        private void UpdateNavigationData(NavigationPacket packet)
        {
            NavigationData navigationData;
            if (NavigationPacketParser.TryParse(ref packet, out navigationData))
            {
                _navigationData = navigationData;

                ProcessRequestedState();

                if (NavigationDataUpdated != null)
                    NavigationDataUpdated(_navigationData);
            }
        }
Example #6
0
 private void ResetNavigationData()
 {
     _navigationData = new NavigationData();
 }
Example #7
0
        private void OnNavigationDataDecoded(NavigationData navigationData)
        {
            _navigationData = navigationData;

            ProcessRequest();

            if (NavigationDataDecoded != null)
                NavigationDataDecoded(navigationData);
        }
Example #8
0
 private void RecreateNavigationData()
 {
     _navigationData = new NavigationData();
 }