Esempio n. 1
0
        public void mapFlightMode(FlightMode flightMode, FlightAttitude flightAttitude, ReferenceFrame frame)
        {
            computerMode     = ComputerMode.Off;
            computerAttitude = flightAttitude;

            switch (flightMode)
            {
            case FlightMode.Off: { computerMode = ComputerMode.Off; break; }

            case FlightMode.KillRot: { computerMode = ComputerMode.Kill; break; }

            case FlightMode.AttitudeHold:
            {
                computerMode = ComputerMode.Custom;
                switch (frame)
                {
                case ReferenceFrame.Maneuver: { computerMode = ComputerMode.Node; break; }

                case ReferenceFrame.Orbit: { computerMode = ComputerMode.Orbital; break; }

                case ReferenceFrame.Surface: { computerMode = ComputerMode.Surface; break; }

                case ReferenceFrame.TargetParallel: { computerMode = ComputerMode.TargetPos; break; }

                case ReferenceFrame.TargetVelocity: { computerMode = ComputerMode.TargetVel; break; }
                }
                break;
            }
            }
        }
Esempio n. 2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        Vector2 correctionForce;

        if (flightMode == FlightMode.Circle)
        {
            correctionForce = RelativePitchToTarget(target.transform.position, 37f);
        }
        else if (flightMode == FlightMode.DiveBomb)
        {
            correctionForce = RelativePitchToTarget(target.transform.position, 0f);
            if (correctionForce == Vector2.zero)
            {
                flightMode = FlightMode.Fixated;
            }
        }
        else
        {
            correctionForce = Vector2.zero;
            print("doing nothing...");
        }

        rb.AddForce(correctionForce);

        // Cap speed
        rb.velocity = rb.velocity.normalized * speed;

        // Set direction

        //transform.LookAt(getPosition() + rb.velocity * 0.1f);
    }
Esempio n. 3
0
 protected void OnProgress(FlightMode mode, float roll = 0, float pitch = 0, float yaw = 0, float gaz = 0)
 {
     if (Emergency != null)
     {
         Progress(mode, roll, pitch, yaw, gaz);
     }
 }
Esempio n. 4
0
        public override bool Execute(FlightComputer f, FlightCtrlState fcs)
        {
            if (mAbort)
            {
                Mode   = FlightMode.Off;
                mAbort = false;
            }

            switch (Mode)
            {
            case FlightMode.Off:
                break;

            case FlightMode.KillRot:
                FlightCore.HoldOrientation(fcs, f, Orientation * Quaternion.AngleAxis(90, Vector3.left));
                break;

            case FlightMode.AttitudeHold:
                FlightCore.HoldAttitude(fcs, f, Frame, Attitude, Orientation);
                break;

            case FlightMode.AltitudeHold:
                break;
            }

            return(false);
        }
Esempio n. 5
0
    void FixedUpdate()
    {
        if (transitioning)
        {
            dive_timer += current_mode == FlightMode.HIGH ? Time.deltaTime : -Time.deltaTime;

            float curve_step = high_altitude * dive_curve.Evaluate(dive_timer / dive_duration);
            rigid_body.MovePosition(new Vector3(transform.position.x, curve_step, transform.position.z) + (transform.forward * move_speed * Time.deltaTime));

            if ((current_mode == FlightMode.HIGH && dive_timer >= dive_duration) ||
                (current_mode == FlightMode.LOW && dive_timer <= 0))
            {
                current_mode = target_mode;
            }
        }
        else
        {
            rigid_body.MovePosition(transform.position + (transform.forward * move_speed * Time.deltaTime));
        }

        if (!transitioning)
        {
            float trigger_axis = Input.GetAxis("Controller 1 - Trigger");
            float modifier     = 1 + (trigger_axis * 0.75f);

            transform.Rotate(Vector3.up, horizontal * turn_speed * modifier * Time.deltaTime);
        }
    }
        /// <summary>
        /// This command controls the drone flight motions.
        /// </summary>
        /// <param name="mode">Enabling the use of progressive commands and/or the Combined Yaw mode (bitfield).</param>
        /// <param name="roll">Drone left-right tilt - value in range [−1..1].</param>
        /// <param name="pitch">Drone front-back tilt - value in range [−1..1].</param>
        /// <param name="yaw">Drone angular speed - value in range [−1..1].</param>
        /// <param name="gaz">Drone vertical speed - value in range [−1..1].</param>
        /// <param name="psi">Magneto psi - value in range [−1..1]</param>
        /// <param name="accuracy">Magneto psi accuracy - value in range [−1..1].</param>
        public void ProgressWithMagneto(FlightMode mode, float roll = 0, float pitch = 0, float yaw = 0, float gaz = 0, float psi = 0, float accuracy = 0)
        {
            if (roll > 1 || roll < -1)
            {
                throw new ArgumentOutOfRangeException("roll");
            }
            if (pitch > 1 || pitch < -1)
            {
                throw new ArgumentOutOfRangeException("pitch");
            }
            if (yaw > 1 || yaw < -1)
            {
                throw new ArgumentOutOfRangeException("yaw");
            }
            if (gaz > 1 || gaz < -1)
            {
                throw new ArgumentOutOfRangeException("gaz");
            }
            if (psi > 1 || psi < -1)
            {
                throw new ArgumentOutOfRangeException("psi");
            }
            if (accuracy > 1 || accuracy < -1)
            {
                throw new ArgumentOutOfRangeException("accuracy");
            }

            if (_navigationData.State.HasFlag(NavigationState.Flying))
            {
                Send(new ProgressWithMagnetoCommand(mode, roll, pitch, yaw, gaz, psi, accuracy));
            }
        }
 public ProgressCommand(FlightMode mode, float roll, float pitch, float yaw, float gaz)
 {
     _mode  = mode;
     _roll  = roll;
     _pitch = pitch;
     _yaw   = yaw;
     _gaz   = gaz;
 }
Esempio n. 8
0
 public ProgressCommand(FlightMode mode, float roll, float pitch, float yaw, float gaz)
 {
     _mode = mode;
     _roll = roll;
     _pitch = pitch;
     _yaw = yaw;
     _gaz = gaz;
 }
 public ProgressWithMagnetoCommand(FlightMode mode, float roll, float pitch, float yaw, float gaz, float psi, float accuracy)
 {
     _mode     = mode;
     _roll     = roll;
     _pitch    = pitch;
     _yaw      = yaw;
     _gaz      = gaz;
     _psi      = psi;
     _accuracy = accuracy;
 }
 public ProgressWithMagnetoCommand(FlightMode mode, float roll, float pitch, float yaw, float gaz, float psi, float accuracy)
 {
     _mode = mode;
     _roll = roll;
     _pitch = pitch;
     _yaw = yaw;
     _gaz = gaz;
     _psi = psi;
     _accuracy = accuracy;
 }
Esempio n. 11
0
    void ChanceChangeToDiveBomb()
    {
        if (flightMode != FlightMode.Circle)
        {
            return;
        }

        if (Random.Range(0.0f, 1.0f) < chanceDiveBomb)
        {
            flightMode = FlightMode.DiveBomb;
        }
    }
Esempio n. 12
0
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent <Rigidbody2D>();

        direction = new Vector2(Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f)).normalized;
        rb.AddForce(direction * speed);

        flightMode = FlightMode.Circle;
        target     = FindClosestEnemy();

        InvokeRepeating(nameof(ChanceChangeToDiveBomb), 5.0f, 1f);
        InvokeRepeating(nameof(ChangeTarget), 0.0f, 5.0f);
    }
Esempio n. 13
0
        bool CompilePath(string [] points, FlightMode mode, out Queue <PathKey> currentPaths)
        {
            currentPaths = new Queue <PathKey>();
            if (points.Length < 3)
            {
                return(false);
            }
            for (int i = 2; i < points.Length; i++)
            {
                PathKey p = new PathKey(points [i - 1], points [i]);
                if (ContainsKey(ref p))
                {
                    currentPaths.Enqueue(p);
                }
                else
                {
                    return(false);
                }
            }

            if (mode == FlightMode.Circle)
            {
                PathKey p = new PathKey(points [points.Length - 1], points [1]);
                if (ContainsKey(ref p))
                {
                    currentPaths.Enqueue(p);
                }
                else
                {
                    return(false);
                }
            }

            if (mode == FlightMode.Patrol)
            {
                for (int i = points.Length - 1; i >= 1; i++)
                {
                    PathKey p = new PathKey(points [i], points [i - 1]);
                    if (ContainsKey(ref p))
                    {
                        currentPaths.Enqueue(p);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Esempio n. 14
0
        public FlightSystem()
        {
            _frontOrientationStyle = FrontOrientationStyle.T;
            _flightMode = FlightMode.Hover;

            _radio.Id = "OC1";
            _radio.PartnerId = "OM1";
            _radio.SendFrequency = 100;
            MotorScale = 100;
            const Period periodLength = Period.P50Hz;

            RegisterPropeller(new BrushlessMotor((PWM.Pin) FEZ_Pin.PWM.Di6, periodLength));           // 3:00 position
            RegisterPropeller(new BrushlessMotor((PWM.Pin) FEZ_Pin.PWM.Di5, periodLength));           // 12:00 (green)
            RegisterPropeller(new BrushlessMotor((PWM.Pin) FEZ_Pin.PWM.Di9, periodLength));           // 9:00 position
            RegisterPropeller(new BrushlessMotor((PWM.Pin) FEZ_Pin.PWM.Di8, periodLength));           // 6:00 position
        }
Esempio n. 15
0
    public void SwitchFlightMode(FlightMode currentFlightMode, FlightMode newFlightMode)
    {
        if (currentFlightMode != newFlightMode)
        {
            switch (currentFlightMode)
            {
            case FlightMode.Feather:
                FeatherActivatedImage.enabled = false;
                break;

            case FlightMode.Normal:
                StarshipActivatedImage.enabled = false;
                break;

            case FlightMode.Chain:
                ChainActivatedImage.enabled = false;
                break;

            case FlightMode.Sword:
                OnMouseOverEnd?.Invoke();
                SwordActivatedImage.enabled = false;
                break;
            }

            switch (newFlightMode)
            {
            case FlightMode.Feather:
                FeatherActivatedImage.enabled = true;
                break;

            case FlightMode.Normal:
                StarshipActivatedImage.enabled = true;
                break;

            case FlightMode.Chain:
                ChainActivatedImage.enabled = true;
                break;

            case FlightMode.Sword:
                SwordActivatedImage.enabled = true;
                break;
            }
            flightModeSwitcher.SwitchFlightMode(newFlightMode);
        }
    }
Esempio n. 16
0
        /// <summary>
        /// Highlight the directional arrows on the GUI to display where the drone moves
        /// </summary>
        void inputManager_Progress(FlightMode mode, float roll = 0, float pitch = 0, float yaw = 0, float gaz = 0)
        {
            labelAngles.Text = string.Format("Roll: {0:0.00}\nPitch: {1:0.00}\nYaw: {2:0.00}\nGaz: {3:0.00}\n", roll, pitch, yaw, gaz);

            if (mode == FlightMode.Hover)
            {
                inputManager_Hover();
                return;
            }

            labelRotateLeft.ForeColor  = yaw < 0   ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
            labelRotateRight.ForeColor = yaw > 0   ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
            labelForward.ForeColor     = pitch < 0 ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
            labelBackward.ForeColor    = pitch > 0 ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
            labelLeft.ForeColor        = roll < 0  ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
            labelRight.ForeColor       = roll > 0  ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
            labelUp.ForeColor          = gaz > 0   ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
            labelDown.ForeColor        = gaz < 0   ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
        }
Esempio n. 17
0
    void SetFlightMode(FlightMode _mode, bool _sound = true)
    {
        switch (_mode)
        {
        case FlightMode.HIGH:
        {
            dive_timer = dive_duration;

            GameManager.scene.pigeon_cam.SetFollowSpeed(high_flight_camera_speed);
            GameManager.scene.pigeon_cam.SetFOV(high_flight_fov);
            GameManager.scene.pigeon_cam.follow_offset = Vector3.zero;

            if (_sound)
            {
                AudioManager.PlayOneShot("SwooshUP");
            }

            target_mode = FlightMode.HIGH;
            AudioManager.SetAmbience(AmbienceType.ABOVE);
        } break;

        case FlightMode.LOW:
        {
            dive_timer = 0;

            GameManager.scene.pigeon_cam.SetFollowSpeed(low_flight_camera_speed);
            GameManager.scene.pigeon_cam.SetFOV(low_flight_fov);
            GameManager.scene.pigeon_cam.follow_offset = new Vector3(0, -10, 0);

            if (_sound)
            {
                AudioManager.PlayOneShot("SwooshDOWN");
            }

            target_mode = FlightMode.LOW;
            AudioManager.SetAmbience(AmbienceType.BELOW);
        } break;

        default: {} break;
        }
    }
Esempio n. 18
0
        /// <summary>
        /// This command controls the drone flight motions.
        /// </summary>
        /// <param name="mode">Enabling the use of progressive commands and/or the Combined Yaw mode (bitfield).</param>
        /// <param name="roll">Drone left-right tilt - value in range [−1..1].</param>
        /// <param name="pitch">Drone front-back tilt - value in range [−1..1].</param>
        /// <param name="yaw">Drone angular speed - value in range [−1..1].</param>
        /// <param name="gaz">Drone vertical speed - value in range [−1..1].</param>
        public void Progress(FlightMode mode, float roll = 0, float pitch = 0, float yaw = 0, float gaz = 0)
        {
            if (roll > 1 || roll < -1)
            {
                throw new ArgumentOutOfRangeException("roll");
            }
            if (pitch > 1 || pitch < -1)
            {
                throw new ArgumentOutOfRangeException("pitch");
            }
            if (yaw > 1 || yaw < -1)
            {
                throw new ArgumentOutOfRangeException("yaw");
            }
            if (gaz > 1 || gaz < -1)
            {
                throw new ArgumentOutOfRangeException("gaz");
            }

            if (_navigationData.State.HasFlag(NavigationState.Flying))
            {
                Send(new ProgressCommand(mode, roll, pitch, yaw, gaz));
            }
        }
Esempio n. 19
0
        public void mapFlightMode(FlightMode flightMode, FlightAttitude flightAttitude, ReferenceFrame frame)
        {
            computerMode = ComputerMode.Off;
            computerAttitude = flightAttitude;

            switch (flightMode)
            {
                case FlightMode.Off: { computerMode = ComputerMode.Off; break; }
                case FlightMode.KillRot: { computerMode = ComputerMode.Kill; break; }
                case FlightMode.AttitudeHold:
                {
                    computerMode = ComputerMode.Custom;
                    switch (frame)
                    {
                        case ReferenceFrame.Maneuver: { computerMode = ComputerMode.Node; break; }
                        case ReferenceFrame.Orbit: { computerMode = ComputerMode.Orbital; break; }
                        case ReferenceFrame.Surface: { computerMode = ComputerMode.Surface; break; }
                        case ReferenceFrame.TargetParallel: { computerMode = ComputerMode.TargetPos; break; }
                        case ReferenceFrame.TargetVelocity: { computerMode = ComputerMode.TargetVel; break; }
                    }
                    break;
                }
            }
        }
Esempio n. 20
0
        public void ChangeFlightMode(FlightMode flightMode)
        {
            if (flightMode != m_currentFlightMode)
            {
                m_currentFlightMode.Value = flightMode;
            }

            SetAutoPilotEnabled(m_autoPilotEnabled);
        }
Esempio n. 21
0
        private void OnPasteAutopilotSetup(MyObjectBuilder_AutopilotClipboard clipboard)
        {
            m_currentDirection = (Base6Directions.Direction)clipboard.Direction;
            m_currentFlightMode = (FlightMode)clipboard.FlightMode;
            m_dockingModeEnabled = clipboard.DockingModeEnabled;
            if (clipboard.Waypoints != null)
            {
                m_waypoints = new List<MyAutopilotWaypoint>(clipboard.Waypoints.Count);
                foreach (var waypoint in clipboard.Waypoints)
                {
                    if (waypoint.Actions != null)
                    {
                        foreach (var action in waypoint.Actions)
                        {
                            var blockAction = action as MyObjectBuilder_ToolbarItemTerminalBlock;
                            //Swith from old entity to the new one
                            if (blockAction != null && blockAction.BlockEntityId == clipboard.RemoteEntityId)
                            {
                                blockAction.BlockEntityId = EntityId;
                            }
                        }
                    }
                    m_waypoints.Add(new MyAutopilotWaypoint(waypoint, this));
                }
            }

            m_selectedWaypoints.Clear();

            RaisePropertiesChangedRemote();
        }
Esempio n. 22
0
            public void ChangeFlightMode(FlightMode flightMode)
            {
                if (m_syncing)
                {
                    return;
                }

                var msg = new ChangeFlightModeMsg();
                msg.EntityId = m_remoteControl.EntityId;

                msg.NewFlightMode = flightMode;

                Sync.Layer.SendMessageToAllAndSelf(ref msg);
            }
Esempio n. 23
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;
            base.Init(objectBuilder, cubeGrid);
            NeedsUpdate = MyEntityUpdateEnum.BEFORE_NEXT_FRAME | MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.EACH_10TH_FRAME;

            var remoteOb = (MyObjectBuilder_RemoteControl)objectBuilder;
            m_savedPreviousControlledEntityId = remoteOb.PreviousControlledEntityId;


            PowerReceiver = new MyPowerReceiver(
                MyConsumerGroupEnum.Utility,
                false,
                m_powerNeeded,
                this.CalculateRequiredPowerInput);

            PowerReceiver.IsPoweredChanged += Receiver_IsPoweredChanged;
            PowerReceiver.RequiredInputChanged += Receiver_RequiredInputChanged;
            PowerReceiver.Update();

            m_autoPilotEnabled = remoteOb.AutoPilotEnabled;
            m_dockingModeEnabled = remoteOb.DockingModeEnabled;
            m_currentFlightMode = (FlightMode)remoteOb.FlightMode;
            m_currentDirection = (Base6Directions.Direction)remoteOb.Direction;

            if (remoteOb.Coords == null || remoteOb.Coords.Count == 0)
            {
                if (remoteOb.Waypoints == null)
                {
                    m_waypoints = new List<MyAutopilotWaypoint>();
                    CurrentWaypoint = null;
                }
                else
                {
                    m_waypoints = new List<MyAutopilotWaypoint>(remoteOb.Waypoints.Count);
                    for (int i = 0; i < remoteOb.Waypoints.Count; i++)
                    {
                        m_waypoints.Add(new MyAutopilotWaypoint(remoteOb.Waypoints[i], this));
                    }
                }
            }
            else
            {
                m_waypoints = new List<MyAutopilotWaypoint>(remoteOb.Coords.Count);
                for (int i = 0; i < remoteOb.Coords.Count; i++)
                {
                    m_waypoints.Add(new MyAutopilotWaypoint(remoteOb.Coords[i], remoteOb.Names[i], this));
                }

                if (remoteOb.AutoPilotToolbar != null && m_currentFlightMode == FlightMode.OneWay)
                {
                    m_waypoints[m_waypoints.Count - 1].SetActions(remoteOb.AutoPilotToolbar.Slots);
                }
            }

            if (remoteOb.CurrentWaypointIndex == -1 || remoteOb.CurrentWaypointIndex >= m_waypoints.Count)
            {
                CurrentWaypoint = null;
            }
            else
            {
                CurrentWaypoint = m_waypoints[remoteOb.CurrentWaypointIndex];
            }

            m_actionToolbar = new MyToolbar(MyToolbarType.ButtonPanel, pageCount: 1);
            m_actionToolbar.DrawNumbers = false;
            m_actionToolbar.Init(null, this);

            m_selectedGpsLocations = new List<IMyGps>();
            m_selectedWaypoints = new List<MyAutopilotWaypoint>();
            UpdateText();
        }
Esempio n. 24
0
        /// <summary>
        /// Highlight the directional arrows on the GUI to display where the drone moves
        /// </summary>
        void inputManager_Progress(FlightMode mode, float roll = 0, float pitch = 0, float yaw = 0, float gaz = 0)
        {
            labelAngles.Text = string.Format("Roll: {0:0.00}\nPitch: {1:0.00}\nYaw: {2:0.00}\nGaz: {3:0.00}\n", roll, pitch, yaw, gaz);

            if (mode == FlightMode.Hover)
            {
                inputManager_Hover();
                return;
            }

            labelRotateLeft.ForeColor  = yaw < 0   ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
            labelRotateRight.ForeColor = yaw > 0   ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
            labelForward.ForeColor     = pitch < 0 ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
            labelBackward.ForeColor    = pitch > 0 ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
            labelLeft.ForeColor        = roll < 0  ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
            labelRight.ForeColor       = roll > 0  ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
            labelUp.ForeColor          = gaz > 0   ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
            labelDown.ForeColor        = gaz < 0   ? UISettings.Default.IconHighlightColor : UISettings.Default.IconDefaultColor;
        }
Esempio n. 25
0
 private void ChangeFlightMode(FlightMode flightMode)
 {
     if (flightMode != m_currentFlightMode)
     {
         SyncObject.ChangeFlightMode(flightMode);
     }
 }
Esempio n. 26
0
 private void OnChangeFlightMode(FlightMode flightMode)
 {
     m_currentFlightMode = flightMode;
     RaisePropertiesChangedRemote();
 }
Esempio n. 27
0
 private void ChangeFlightMode(FlightMode flightMode)
 {
     if (flightMode != m_currentFlightMode)
     {
         m_currentFlightMode.Value = flightMode;
     }
 }
Esempio n. 28
0
 private void SwitchFlightMode(FlightMode flightMode)
 {
     currentFlightMode = flightMode;
     flightModeSwitcher.SwitchFlightMode(flightMode);
 }
Esempio n. 29
0
        void Command(string command)
        {
            string [] args = command.Split(';');

            switch (args [0])
            {
            case ("halt"):
                Runtime.UpdateFrequency = UpdateFrequency.None;
                break;

            case ("record"):     // path;start;end
                if (args.Length == 3 && args [1] != args [2])
                {
                    Stop();
                    PathKey p    = new PathKey(args [1], args [2]);
                    Path    path = new Path();
                    paths [p] = path;
                    path.UpdateStatus(Path.Mode.Recording);
                    recordingPath = path;
                }
                break;

            case ("stop"):
                Stop();
                break;

            case ("oneway"):     // oneway;id1;id2;... | Navigates to all of the points in one direction, then stops.
                if (args.Length > 2)
                {
                    Queue <PathKey> newCurrentPaths;
                    if (CompilePath(args, FlightMode.OneWay, out newCurrentPaths))
                    {
                        currentPaths = newCurrentPaths;
                    }
                    else
                    {
                        return;
                    }
                    ActivateNextPath();
                    mode = FlightMode.OneWay;
                }
                break;

            case ("patrol"):     // patrol;id1;id2;... | Navigates to all of the points in one direction, then in the reverse direction, and starts over.
                if (args.Length > 2)
                {
                    Queue <PathKey> newCurrentPaths;
                    if (CompilePath(args, FlightMode.Patrol, out newCurrentPaths))
                    {
                        currentPaths = newCurrentPaths;
                    }
                    else
                    {
                        return;
                    }
                    ActivateNextPath();
                    mode = FlightMode.Patrol;
                }
                break;

            case ("circle"):     // circle;id1;id2;... | Navigates to all of the points in one direction, then back to the first point, and starts over.
                if (args.Length > 2)
                {
                    Queue <PathKey> newCurrentPaths;
                    if (CompilePath(args, FlightMode.Circle, out newCurrentPaths))
                    {
                        currentPaths = newCurrentPaths;
                    }
                    else
                    {
                        return;
                    }
                    ActivateNextPath();
                    mode = FlightMode.Circle;
                }
                break;
            }
        }
Esempio n. 30
0
 public override string ToString()
 {
     return(FlightMode.ToString() + ";" + TimeStamp.ToString() + ";" + AngleEstimate.ToString() + AngleMeasured.ToString() + AngleReference.ToString() + AngularVelocity.ToString() + MotorSpeeds.ToString() +
            HeightEstimate.ToString() + ";" + HeightMeasured.ToString() + ";" + HeightReference.ToString() + ";"
            + PositionEstimate.ToString() + PositionMeasured.ToString() + PositionReference.ToString() + VelocitySet.ToString() + "\n");
 }
        public override bool Execute(FlightComputer f, FlightCtrlState fcs)
        {
            if (mAbort)
            {
                Mode = FlightMode.Off;
                mAbort = false;
            }

            switch (Mode)
            {
                case FlightMode.Off:
                    break;
                case FlightMode.KillRot:
                    FlightCore.HoldOrientation(fcs, f, Orientation * Quaternion.AngleAxis(90, Vector3.left));
                    break;
                case FlightMode.AttitudeHold:
                    FlightCore.HoldAttitude(fcs, f, Frame, Attitude, Orientation);
                    break;
                case FlightMode.AltitudeHold:
                    break;
            }

            return false;
        }
Esempio n. 32
0
        /// <summary>
        /// This command controls the drone flight motions.
        /// </summary>
        /// <param name="mode">Enabling the use of progressive commands and/or the Combined Yaw mode (bitfield).</param>
        /// <param name="roll">Drone left-right tilt - value in range [−1..1].</param>
        /// <param name="pitch">Drone front-back tilt - value in range [−1..1].</param>
        /// <param name="yaw">Drone angular speed - value in range [−1..1].</param>
        /// <param name="gaz">Drone vertical speed - value in range [−1..1].</param>
        public void Progress(FlightMode mode, float roll = 0, float pitch = 0, float yaw = 0, float gaz = 0)
        {
            if (roll > 1 || roll < -1)
                throw new ArgumentOutOfRangeException("roll");
            if (pitch > 1 || pitch < -1)
                throw new ArgumentOutOfRangeException("pitch");
            if (yaw > 1 || yaw < -1)
                throw new ArgumentOutOfRangeException("yaw");
            if (gaz > 1 || gaz < -1)
                throw new ArgumentOutOfRangeException("gaz");

            if (_navigationData.State.HasFlag(NavigationState.Flying))
                Send(new ProgressCommand(mode, roll, pitch, yaw, gaz));
        }
Esempio n. 33
0
        private void sendFlightMode(FlightMode mode)
        {
            int toSend = (int)mode;

            xbee.send <int>(toSend, 'f');
        }
Esempio n. 34
0
        /// <summary>
        /// This command controls the drone flight motions.
        /// </summary>
        /// <param name="mode">Enabling the use of progressive commands and/or the Combined Yaw mode (bitfield).</param>
        /// <param name="roll">Drone left-right tilt - value in range [−1..1].</param>
        /// <param name="pitch">Drone front-back tilt - value in range [−1..1].</param>
        /// <param name="yaw">Drone angular speed - value in range [−1..1].</param>
        /// <param name="gaz">Drone vertical speed - value in range [−1..1].</param>
        /// <param name="psi">Magneto psi - value in range [−1..1]</param>
        /// <param name="accuracy">Magneto psi accuracy - value in range [−1..1].</param>
        public void ProgressWithMagneto(FlightMode mode, float roll = 0, float pitch = 0, float yaw = 0, float gaz = 0, float psi = 0, float accuracy = 0)
        {
            if (roll > 1 || roll < -1)
                throw new ArgumentOutOfRangeException("roll");
            if (pitch > 1 || pitch < -1)
                throw new ArgumentOutOfRangeException("pitch");
            if (yaw > 1 || yaw < -1)
                throw new ArgumentOutOfRangeException("yaw");
            if (gaz > 1 || gaz < -1)
                throw new ArgumentOutOfRangeException("gaz");
            if (psi > 1 || psi < -1)
                throw new ArgumentOutOfRangeException("psi");
            if (accuracy > 1 || accuracy < -1)
                throw new ArgumentOutOfRangeException("accuracy");

            if (_navigationData.State.HasFlag(NavigationState.Flying))
                Send(new ProgressWithMagnetoCommand(mode, roll, pitch, yaw, gaz, psi, accuracy));
        }
Esempio n. 35
0
 public override string ToString()
 {
     return(FlightMode.ToString() + ";" + TimeStamp.ToString() + ";" + Armed.ToString() + ";" + AngleMeasured.ToString() + AngleReference.ToString() + MotorSpeeds.ToString() + "\n");
 }
Esempio n. 36
0
 protected void OnProgress(FlightMode mode, float roll = 0, float pitch = 0, float yaw = 0, float gaz = 0)
 {
     if (Emergency != null)
         Progress(mode, roll, pitch, yaw, gaz);
 }