상속: Equipment
예제 #1
0
            public GyroscopeSystem(List <IMyGyro> Gyroscopes, IMyTerminalBlock Reference)
            {
                foreach (IMyGyro gyroscope in Gyroscopes)
                {
                    Gyro g = new Gyro();
                    g.block            = gyroscope;
                    g.conversionVector = new int[3];

                    for (int i = 0; i < 3; i++)
                    {
                        Vector3D vectorShip = GetAxis(i, Reference);

                        for (int j = 0; j < 3; j++)
                        {
                            double dot = vectorShip.Dot(GetAxis(j, g.block));

                            if (dot > 0.9)
                            {
                                g.conversionVector[j] = i;
                                break;
                            }
                            if (dot < -0.9)
                            {
                                g.conversionVector[j] = i + 3;
                                break;
                            }
                        }
                    }
                    Gyros.Add(g);
                }
            }
예제 #2
0
    void Start()
    {
        GM = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();

        switch (GM.planeType)
        {
        case GameManager.PLANETYPE.F16:
            F16.SetActive(true);
            mr = F16;
            break;

        case GameManager.PLANETYPE.A10:
            A10.SetActive(true);
            mr = A10;
            break;

        case GameManager.PLANETYPE.GYRO:
            Gyro.SetActive(true);
            mr = Gyro;
            break;
        }
        SetCalibration();
        menuController    = GameObject.FindGameObjectWithTag("GameManager").GetComponent <MenuController>();
        moveSpeed         = defaultMoveSpeed * GM.sensitivity * 2;
        playerShootScript = gameObject.GetComponent <PlayerShoot>();
        cameraScript      = Camera.main.GetComponent <CameraFollow>();
        // get player's collider
        hitbox = GetComponent <BoxCollider>();
    }
예제 #3
0
 public bool Equals(DroneData other)
 {
     return(State == other.State &&
            MotorValues.Equals(other.MotorValues) &&
            Gyro.Equals(other.Gyro) &&
            BatteryVoltage == other.BatteryVoltage);
 }
예제 #4
0
 public static void DisableGyroOverride(this IMyCubeGrid Grid)
 {
     foreach (IMyGyro Gyro in Grid.GetWorkingBlocks <IMyGyro>())
     {
         Gyro.SetValueBool("Override", false);
     }
 }
예제 #5
0
    void Start()
    {
        gyro       = GameObject.Find("Main Camera").GetComponent(typeof(Gyro)) as Gyro;
        camara     = GameObject.Find("Main Camera");
        hudManage2 = GameObject.Find("MenuOpciones").GetComponent(typeof(HudManage)) as HudManage;

        ToggleVR();
    }
예제 #6
0
    public void GyroMouv()
    {
        Gyro g = new Gyro();

        g.angle        = Input.gyro.attitude.eulerAngles;
        g.rotationRate = Input.gyro.rotationRate;

        m_terrain.eulerAngles = g.angle;
    }
예제 #7
0
 public void OnClick()
 {
     target.gyroOverride ^= true;
     //var colors = button.colors;
     //colors.normalColor = target.gyroOverride ? enabledColor : normalColor;
     //button.colors = colors;
     UpdateColor();
     Gyro.Calibrate();
 }
    private void OnGUI()
    {
        Init();

        EditorGUIUtility.labelWidth = 50;
        Rect previewRect = new Rect(0, 0, position.width, position.height / 2);

        EditorGUI.BeginChangeCheck();
        _previewDir = Drag2D(_previewDir, previewRect);
        if (EditorGUI.EndChangeCheck())
        {
            _eulerAngles.x = Gyro.SignedAngle(Gyro.UnsignedAngle(_previewDir.y % 360));
            _eulerAngles.z = Gyro.SignedAngle(Gyro.UnsignedAngle(_previewDir.x % 360));
        }
        else
        {
            _eulerAngles.x = Gyro.SignedAngle(EditorGUI.Slider(new Rect(0, previewRect.height, position.width, 20), "Pitch",
                                                               Gyro.SignedAngle(_eulerAngles.x), -180f, 180));
            _eulerAngles.z = Gyro.SignedAngle(EditorGUI.Slider(
                                                  new Rect(0, previewRect.height + position.height / 10, position.width, 20),
                                                  "Roll", Gyro.SignedAngle(_eulerAngles.z), -180f, 180));
            _eulerAngles.y = Gyro.SignedAngle(EditorGUI.Slider(
                                                  new Rect(0, previewRect.height + 2 * position.height / 10, position.width, 20), "Yaw",
                                                  Gyro.SignedAngle(_eulerAngles.y), -180f, 180));
        }

        if (GUI.Button(new Rect(0, previewRect.height + 4 * position.height / 10, position.width, 20), "Reset"))
        {
            _eulerAngles = Vector3.zero;
            _previewDir  = Vector2.zero;
        }

        _proxy.transform.eulerAngles = _eulerAngles;
        _preview.BeginPreview(previewRect, GUIStyle.none);

        Bounds bounds   = _proxyFilter.sharedMesh.bounds;
        float  halfSize = bounds.extents.magnitude;
        float  distance = halfSize * 7f;

        _preview.camera.transform.position    = Vector3.up * distance;
        _preview.camera.nearClipPlane         = distance - halfSize * 1.1f;
        _preview.camera.farClipPlane          = distance + halfSize * 1.1f;
        _preview.camera.transform.eulerAngles = Vector3.right * 90;

        _preview.lights[0].intensity          = 1.4f;
        _preview.lights[0].transform.rotation = Quaternion.Euler(90, 0, 0);
        _preview.ambientColor = Color.black;

        //_preview.DrawMesh(_proxyFilter.sharedMesh, _proxyTransform.position, _proxyTransform.rotation, _proxyRenderer.sharedMaterial, 0);
        _preview.Render();

        _preview.EndAndDrawPreview(previewRect);

        Gyro.VirtualTilt = Quaternion.Euler(Gyro.UnsignedAngle(-_eulerAngles.x), Gyro.UnsignedAngle(-_eulerAngles.z), _eulerAngles.y);
        EditorGUI.LabelField(new Rect(0, previewRect.height + 3 * position.height / 10, position.width, 20), "Attitude: " + Gyro.VirtualTilt);
    }
    private void Tilt()
    {
        Vector3 euler = Gyro.Tilt.eulerAngles;

        euler.x = Gyro.ClampAngle(Gyro.SignedAngle(euler.x) * _tiltFactor, -_maxAngle, _maxAngle);
        euler.y = 0;
        euler.z = Gyro.ClampAngle(Gyro.SignedAngle(euler.z) * _tiltFactor, -_maxAngle, _maxAngle);

        transform.position = _target.position + Quaternion.Euler(euler) * _baseOffset;
        transform.rotation = Quaternion.Euler(euler) * _baseTilt;
    }
예제 #10
0
 public override int GetHashCode()
 {
     unchecked {
         int hash = 13;
         hash = hash * 7 + State.GetHashCode();
         hash = hash * 7 + MotorValues.GetHashCode();
         hash = hash * 7 + Gyro.GetHashCode();
         hash = hash * 7 + (int)BatteryVoltage;
         return(hash);
     }
 }
예제 #11
0
        /// <summary>
        /// Testing method for Gyro module (function never returns)
        /// </summary>
        static void TestGyro()
        {
            var gyro = new Gyro(FEZRaptor.I2cBus.I2c1);

            gyro.MeasurementComplete += (sender, e) =>
            {
                Debug.WriteLine(e.ToString());
            };
            gyro.StartTakingMeasurements();
            Thread.Sleep(Timeout.Infinite);
        }
예제 #12
0
    // Use this for initialization
    void Start()
    {
        view               = null;
        gyroscope          = null;
        log                = null;
        r_flag             = true;
        Input.gyro.enabled = true;

        log       = gameObject.AddComponent <logger> ();
        gyroscope = gameObject.AddComponent <Gyro> ();
        view      = gameObject.AddComponent <ViewControl> ();
    }
예제 #13
0
    /// <summary>
    /// Instantiate an gyro sensor (measure angular rotation rate) and set its name, local position, local rotation, and add it to
    /// both sensor list and active sensor list
    /// </summary>
    /// <param name="parent"></param> the parent node to which the sensor is attached
    /// <param name="position"></param> local position of the sensor
    /// <param name="rotation"></param> local rotation of the sensor
    public SensorBase AddGyro(GameObject parent, Vector3 position, Vector3 rotation)
    {
        GameObject gyro = GameObject.Instantiate(Gyro, parent.transform);

        gyro.transform.localPosition = position;
        gyro.transform.localRotation = Quaternion.Euler(rotation);
        gyro.name = "Gyro_" + sensorList.Count;
        gyro.GetComponent <SensorBase>().Robot = main.activeRobot;
        sensorList.Add(gyro);
        activeSensorList.Add(gyro);

        Gyro sensor = gyro.GetComponent <Gyro>();

        return(sensor);
    }
예제 #14
0
 public void initNavigation(MyGridProgram myGrid)
 {
     this.myGrid        = myGrid;
     this.navHandle     = new Navigation(myGrid);
     this.gyroHandle    = new Gyro(myGrid);
     this.dockingHandle = new Docking(myGrid);
     this.navHandle.setDockingHandle(this.dockingHandle);
     this.navHandle.setGyroHandle(this.gyroHandle);
     this.navHandle.setCommunicationHandle(this.commHandle);
     this.dockingHandle.setNavHandle(this.navHandle);
     if (this.isMasterNode())
     {
         this.dockingHandle.amAMaster = true;
     }
 }
예제 #15
0
 public override bool Equals(object obj)
 {
     if (obj == null)
     {
         return(false);
     }
     if (GetType() == obj.GetType() && obj is MotionSensorSample other)
     {
         if (SampleId == other.SampleId &&
             Acc.Equals(other.Acc) &&
             Gyro.Equals(other.Gyro))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #16
0
파일: GPS.cs 프로젝트: frankvHoof93/Compass
    /// <summary>
    /// IEnumerator to Start Location Services
    /// Use with Coroutine
    /// </summary>
    /// <returns>Used in Coroutine</returns>
    private IEnumerator StartLocationService()
    {
        Debug.Log("Starting Compass");
        Input.compass.enabled = true;
        Debug.Log("Starting GPS");
        // Wait until the editor and unity remote are connected before starting a location service
        if (unityRemote)
        {
            yield return(new WaitForSeconds(2));
        }
        Input.location.Start(accuracy, minUpdateDistance);
        if (unityRemote)
        {
            yield return(new WaitForSeconds(2));
        }
        while (currentStatus == LocationServiceStatus.Initializing && timeout > 0)
        {
            timeout--;
            Debug.Log(currentStatus);
            yield return(new WaitForSeconds(1));
        }
        if (timeout <= 0)
        {
            Debug.LogError("GPS: Init timed out");
            yield break;
        }
        if (currentStatus == LocationServiceStatus.Failed)
        {
            Debug.LogError("GPS: Unable to init GPS");
            yield break;
        }
        Origin         = new GeoCoordinate(Input.location.lastData.latitude, Input.location.lastData.longitude);
        Coordinate     = new GeoCoordinate(Input.location.lastData.latitude, Input.location.lastData.longitude);
        Running        = true;
        LastCoordinate = Coordinate;

        Debug.Log("GPS Running");
        Gyro gyro = GameObject.FindObjectOfType <Gyro>();

        gyro.EnableGyro();
        gyro.cameraContainer.transform.RotateAround(Vector3.up, 90f);
        yield break;
    }
    private void Tilt()
    {
        Vector3 euler = Gyro.Tilt.eulerAngles;

        euler.x = _freezeRotationX ? 0 : Gyro.ClampAngle(Gyro.SignedAngle(euler.x) * _tiltFactor, -_maxAngle, _maxAngle);
        euler.y = _freezeRotationY ? 0 : Gyro.ClampAngle(Gyro.SignedAngle(euler.y) * _tiltFactor, -_maxAngle, _maxAngle);
        euler.z = _freezeRotationZ ? 0 : Gyro.ClampAngle(Gyro.SignedAngle(euler.z) * _tiltFactor, -_maxAngle, _maxAngle);

        if (_orbitTarget)
        {
            transform.position = _target.position + Quaternion.Euler(euler) * _baseOffset;
            transform.rotation = Quaternion.Euler(euler) * _baseTilt;
        }
        else if (_rigidbody != null)
        {
            _rigidbody.MoveRotation(Quaternion.Euler(euler) * _baseTilt);
        }
        else
        {
            transform.rotation = Quaternion.Euler(euler) * _baseTilt;
        }
    }
예제 #18
0
 public Sensors(Gyro gyro)
 {
     _gyro = gyro;
 }
예제 #19
0
 public void RegisterHubTest()
 {
     Assert.IsTrue(Gyro.RegisterHub());
     Assert.IsTrue(Gyro.RegisterGyroscope());
 }
예제 #20
0
 public Communication(MyGridProgram myGrid)
 {
     this.myGrid        = myGrid;
     this.dataStructure = new CommunicationDataStructure();
     this.gyroHandle    = new Gyro(myGrid);
 }
예제 #21
0
        /// <summary>
        /// Initializes a new instance of the PacketSniffer class that contain the values extracted from the given byte array.
        /// </summary>
        /// <param name="byteArray">14 bytes array for basic information OR 256 byte for packet time.</param>
        public PacketSniffer(Byte[] byteArray)
        {
            _MagicNumber            = 0;
            _HeaderType             = 0;
            _SubChannelNumber       = 0;
            _NumberChannelsToFollow = 0;
            _NumberBytesThisRecord  = 0;
            _PacketTime             = DateTime.MinValue;
            _TimeTag = 0;

            using (BinaryReader pd = new BinaryReader(ArrayToStream.BytesToMemory(byteArray)))
            {
                if (byteArray.Length >= 14)
                {
                    // Read the basic information of the packet
                    XtfBasePacket basePkt = new XtfBasePacket(byteArray);

                    _MagicNumber            = basePkt.MagicNumber;
                    _HeaderType             = basePkt.HeaderType;
                    _SubChannelNumber       = basePkt.SubChannelNumber;
                    _NumberChannelsToFollow = basePkt.NumberChannelsToFollow;
                    _NumberBytesThisRecord  = basePkt.NumberBytesThisRecord;

                    if (byteArray.Length >= 256)
                    {
                        // Extract packet time from each packet type known
                        switch (HeaderType)
                        {
                        // Ping header packet types
                        case 0:
                        case 2:
                        case 4:
                        case 5:
                        case 8:
                        case 9:
                        case 10:
                        case 14:
                        case 16:
                        case 17:
                        case 18:
                        case 19:
                        case 22:
                        case 25:
                        case 27:
                        case 28:
                        case 60:
                        case 61:
                        case 62:
                        case 65:
                        case 66:
                        case 68:
                        case 69:
                        case 73:
                            PingHeader tmpHdr0 = new PingHeader(byteArray);
                            _PacketTime = tmpHdr0.PacketTime;
                            break;

                        // Notes - text annotation packet types
                        case 1:
                            Notes tmpHdr1 = new Notes(byteArray);
                            _PacketTime = tmpHdr1.PacketTime;
                            break;

                        // Attitude Data packet types
                        case 3:
                        case 103:
                            AttitudeData tmpHdr2 = new AttitudeData(byteArray);
                            _PacketTime = tmpHdr2.PacketTime;
                            _TimeTag    = tmpHdr2.TimeTag;
                            break;

                        // Raw Serial packet types
                        case 6:
                            RawSerialHeader tmpHdr3 = new RawSerialHeader(byteArray);
                            _PacketTime = tmpHdr3.PacketTime;
                            break;

                        // High speed sensor packet types
                        case 11:
                        case 15:
                            HighSpeedSensor tmpHdr4 = new HighSpeedSensor(byteArray);
                            _PacketTime = tmpHdr4.PacketTime;
                            break;

                        // Gyro packet types
                        case 23:
                        case 84:
                            Gyro tmpHdr5 = new Gyro(byteArray);
                            _PacketTime = tmpHdr5.PacketTime;
                            _TimeTag    = tmpHdr5.TimeTag;
                            break;

                        // QPS Singlebeam packet types
                        case 26:
                            QpsSingleBeam tmpHdr6 = new QpsSingleBeam(byteArray);
                            _PacketTime = tmpHdr6.PacketTime;
                            break;

                        // Navigation packet types
                        case 42:
                        case 100:
                            Navigation tmpHdr7 = new Navigation(byteArray);
                            _PacketTime = tmpHdr7.PacketTime;
                            _TimeTag    = tmpHdr7.TimeTag;
                            break;

                        // Pos Raw Navigation packet types
                        case 107:
                            PosRawNavigation tmpHdr8 = new PosRawNavigation(byteArray);
                            _PacketTime = tmpHdr8.PacketTime;
                            break;

                        // Navigation packet types
                        case 199:
                            RawCustomHeader tmpHdr9 = new RawCustomHeader(byteArray);
                            _PacketTime = tmpHdr9.PacketTime;
                            _TimeTag    = tmpHdr9.TimeTag;
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }
예제 #22
0
 public void Update(Gyro gyro)
 {
     this.gyro = gyro;
 }
예제 #23
0
 public void setGyroHandle(Gyro gyroHandle)
 {
     this.gyroHandle = gyroHandle;
 }
예제 #24
0
        public Controller(MotorMixer mixer, AxesController pid, Gyro gyro, Radio radio, ControllerLoopSettings loopSettings, MotorSettings motorSettings, ILogger logger)
        {
            TelemetryData telemetryData     = new TelemetryData();
            long          previousTime      = DateTime.Now.Ticks;
            long          lastRadioTime     = 0;
            long          lastSensorTime    = 0;
            long          lastControlTime   = 0;
            long          lastMotorTime     = 0;
            long          lastTelemetryTime = 0;

            bool systemArmed = false;


            while (true)
            {
                long currentTime = DateTime.Now.Ticks;
                if (currentTime >= (lastRadioTime + loopSettings.RadioLoopPeriod))
                {
                    //Debug.Print((loopSettings.LoopUnit/(float)(currentTime-lastRadioTime)).ToString());
                    lastRadioTime = currentTime;
                    radio.Update();
                    systemArmed = radio.Throttle > motorSettings.MinimumOutput;
                    if (!systemArmed)
                    {
                        logger.Flush();
                    }
                }


                currentTime = DateTime.Now.Ticks;
                if (systemArmed && (currentTime >= (lastSensorTime + loopSettings.SensorLoopPeriod)))
                {
                    //Debug.Print((loopSettings.LoopUnit / (float)(currentTime - lastSensorTime)).ToString());
                    lastSensorTime = currentTime;
                    gyro.Update();
                }

                currentTime = DateTime.Now.Ticks;
                if (systemArmed && (currentTime >= (lastControlTime + loopSettings.ControlAlgorithmPeriod)))
                {
                    //Debug.Print((loopSettings.LoopUnit / (float)(currentTime - lastControlTime)).ToString());
                    lastControlTime = currentTime;
                    pid.Update(radio.Axes, gyro.Axes, (float)(currentTime - previousTime) / loopSettings.LoopUnit);
                    previousTime = currentTime;
                }

                currentTime = DateTime.Now.Ticks;
                if (currentTime >= (lastMotorTime + loopSettings.MotorLoopPeriod))
                {
                    //Debug.Print((loopSettings.LoopUnit / (float)(currentTime - lastMotorTime)).ToString());
                    if (systemArmed)
                    {
                        mixer.Update(radio.Throttle, pid.Axes);
                    }
                    else
                    {
                        mixer.SetSafe();
                    }

                    lastMotorTime = currentTime;
                }

                currentTime = DateTime.Now.Ticks;
                if (systemArmed && (currentTime >= (lastTelemetryTime + loopSettings.TelemetryLoopPeriod)))
                {
                    //Debug.Print((loopSettings.LoopUnit / (float)(currentTime - lastTelemetryTime)).ToString());
                    telemetryData.Update(gyro.Axes, radio.Axes, pid.Axes, currentTime);
                    lastTelemetryTime = currentTime;
                    logger.Write(telemetryData);
                }
            }
        }