예제 #1
0
 private void WriteMissionCommandExecute()
 {
     if (VehicleSelected != null && VehicleSelected.Tasks.Count > 0)
     {
         MissionComponent.UploadTask(VehicleSelected.ID, VehicleSelected.HomePosition,
                                     new MavlinkWaypoint
         {
             Latitude  = VehicleSelected.Latitude,
             Longitude = VehicleSelected.Longitude,
             Altitude  = DefaultAltitude,
             Param4    = (float)VehicleSelected.Heading
         },
                                     VehicleSelected.Tasks[0]);
     }
 }
예제 #2
0
        private void SelectTaskCommandExecute(object obj)
        {
            var vehicle = obj as Vehicle;

            if (vehicle != null)
            {
                vehicle.Tasks.Clear();
                vehicle.Tasks.Add(vehicle.Task);
                vehicle.Task = vehicle.Task;
                vehicle.IsActivateMission = false;
                MissionComponent.UploadTask(vehicle.ID,
                                            vehicle.HomePosition,
                                            new MavlinkWaypoint
                {
                    Latitude  = vehicle.Latitude,
                    Longitude = vehicle.Longitude,
                    Altitude  = DefaultAltitude,
                    Param4    = (float)vehicle.Heading
                },
                                            vehicle.Task);
                vehicle.MissionID = vehicle.Task.TaskID;
            }
        }
예제 #3
0
 private async void SendMissionCommandsExecute()
 {
     await AsyncUtil.RaunAsync(() =>
     {
         foreach (var vehicle in Vehicles.Where(vehicle => vehicle.IsSelected))
         {
             if (vehicle.Task != null)
             {
                 vehicle.IsActivateMission = false;
                 MissionComponent.UploadTask(vehicle.ID,
                                             vehicle.HomePosition,
                                             new MavlinkWaypoint
                 {
                     Latitude  = vehicle.Latitude,
                     Longitude = vehicle.Longitude,
                     Altitude  = DefaultAltitude,
                     Param4    = (float)vehicle.Heading
                 },
                                             vehicle.Task);
             }
         }
         return(true);
     });
 }
예제 #4
0
 private void SelectedTaskCommandExecute(ITask obj)
 {
     foreach (var vehicle in VehiclesSource.Vehicles)
     {
         if (vehicle.ID == VehicleSelected.ID)
         {
             vehicle.Tasks.Clear();
             vehicle.Tasks.Add(obj);
             vehicle.Task = obj;
             vehicle.IsActivateMission = false;
             MissionComponent.UploadTask(vehicle.ID,
                                         vehicle.HomePosition,
                                         new MavlinkWaypoint
             {
                 Latitude  = vehicle.Latitude,
                 Longitude = vehicle.Longitude,
                 Altitude  = DefaultAltitude,
                 Param4    = (float)VehicleSelected.Heading
             },
                                         vehicle.Tasks[0]);
             vehicle.MissionID = VehicleSelected.Tasks[0].TaskID;
         }
     }
 }
예제 #5
0
        private void MapMouseLeftButtonDownAction(MapMouseLeftButtonDownMessenger obj)
        {
            int DistanceDefault = 50;

            if (VehicleSelected == null)
            {
                return;
            }

            if (InsertHoverPoint)
            {
                //Target
                //var a = Utils.Utils.DegreeBearing(VehicleSelected.Latitude, VehicleSelected.Longitude, obj.Latitude,obj.Longitude);

                var convertPoint = new ObservableCollection <Waypoint>();

                var x = VehicleSelected.Latitude;
                var y = VehicleSelected.Longitude;
                //Utils.Utils.ConvertMercatorToGeo(ref y, ref x);

                /*var bearing = Utils.Utils.DegreeBearing(VehicleSelected.Latitude, VehicleSelected.Longitude, obj.Latitude,obj.Longitude);
                 * var distance = Utils.Utils.CalculateDistance(VehicleSelected.Latitude, VehicleSelected.Longitude,
                 *                                           obj.Latitude, obj.Longitude, "K") *1000;
                 * if (distance > DistanceDefault)
                 * {
                 *  Utils.Utils.PointRadialDistance(ref x, ref y, bearing, DistanceDefault);
                 * }*/
                convertPoint.Add(new MavlinkWaypoint
                {
                    Latitude  = x,
                    Longitude = y,
                    Altitude  = DefaultAltitude,
                    Id        = 1,
                    Param4    = (float)VehicleSelected.Heading,
                    Command   = (ushort)MissionMavCmd.WAYPOINT,
                });

                convertPoint.Add(new MavlinkWaypoint
                {
                    Latitude  = obj.Latitude,
                    Longitude = obj.Longitude,
                    Altitude  = DefaultAltitude,
                    Id        = 2,
                    Command   = (ushort)MissionMavCmd.WAYPOINT,
                });


                var task = new MavlinkTaskNav("HoverTask", TaskID)
                {
                    NavPath  = convertPoint,
                    TaskType = TaskTypeEnum.Hoverrer
                };

                MissionSource.AddTask(task);
                VehicleSelected.Tasks.Clear();
                VehicleSelected.Tasks.Add(task);
                var newShape = new Shape(TaskID, convertPoint)
                {
                    Symbol = (LineSymbol)Application.Current.FindResource("LineSymbol")
                };

                ServiceLocator.Current.GetInstance <IMap>().AddShape(newShape);

                //MissionComponent.UploadTask(VehicleSelected.ID,
                //                            VehicleSelected.HomePosition,
                //                            new MavlinkWaypoint
                //                                {
                //                                    Latitude = VehicleSelected.Latitude,
                //                                    Longitude = VehicleSelected.Longitude,
                //                                    Altitude = DefaultAltitude,
                //                                    Param4 = (float) VehicleSelected.Heading
                //                                },
                //                            VehicleSelected.Tasks[0]);
                VehicleSelected.IsActivateMission = false;
                MissionComponent.UploadTask(VehicleSelected.ID, VehicleSelected.HomePosition, null, VehicleSelected.Tasks[0]);

                VehicleSelected.MissionID = VehicleSelected.Tasks[0].TaskID;
            }
        }
예제 #6
0
        private void CommandStateClick(object obj)
        {
            if (VehicleComponent == null)
            {
                VehicleComponent = ServiceLocator.Current.GetInstance <IVehicleComponent>();
            }
            if (VehicleComponent == null)
            {
                return;
            }

            if (MissionComponent == null)
            {
                MissionComponent = ServiceLocator.Current.GetInstance <IMissionComponent>();
            }
            if (MissionComponent == null)
            {
                return;
            }

            VisibilityView = Visibility.Hidden;
            var state = obj as string;

            switch (state)
            {
            case "CameHome":
                if (VehicleSelected != null)
                {
                    VehicleComponent.SendModeCommand(VehicleSelected.ID, (uint)VehicleModeEnum.RTL);
                }
                break;

            case "Land":
                if (VehicleSelected != null)
                {
                    VehicleComponent.SendModeCommand(VehicleSelected.ID, (uint)VehicleModeEnum.Land);
                }
                break;

            case "Pause":
                if (VehicleSelected != null)
                {
                    VehicleComponent.SendModeCommand(VehicleSelected.ID, (uint)VehicleModeEnum.Loiter);
                }
                break;

            case "Start":
                if (VehicleSelected != null)
                {
                    //VehicleComponent.SendModeCommand(VehicleSelected.ID, (uint) VehicleModeEnum.Auto);
                    //MissionComponent.StartMission(VehicleSelected.ID, 0);
                    MissionComponent.StartMissionAuto(VehicleSelected.ID, 0);
                }
                break;

            case "LoadMission":
                if (VehicleSelected.Tasks.Count > 0)
                {
                    VehicleSelected.IsActivateMission = false;
                    MissionComponent.UploadTask(VehicleSelected.ID,
                                                VehicleSelected.HomePosition,
                                                new MavlinkWaypoint
                    {
                        Latitude  = VehicleSelected.Latitude,
                        Longitude = VehicleSelected.Longitude,
                        Altitude  = DefaultAltitude,
                        Param4    = (float)VehicleSelected.Heading
                    },
                                                VehicleSelected.Tasks[0]);
                    VehicleSelected.MissionID = VehicleSelected.Tasks[0].TaskID;
                }
                break;

            case "TakeOff":
                if (VehicleSelected != null)
                {
                    VehicleComponent.TakeOffCommand(VehicleSelected.ID, 100, (float)VehicleSelected.Latitude,
                                                    (float)VehicleSelected.Longitude, (float)VehicleSelected.Heading);
                }
                break;

            case "ControlRequest":
                //if (value)
                //    ServiceLocator.Current.GetInstance<IJoystick>(idx).Start();
                //else
                //    ServiceLocator.Current.GetInstance<IJoystick>().Stop();
                break;

            case "OpenCamera":

                if (QuadPropertyWindow != null)
                {
                    QuadPropertyWindow.Close();
                    QuadPropertyWindow = null;
                }

                QuadPropertyWindow = new QuadPropertyWindow();
                QuadPropertyWindow.Show();
                break;
            }
        }