예제 #1
0
 ///
 /// It sends updated telemetry information to ForceSeatPM for further processing.
 /// Make sure that 'mask' and 'state' fields are set correctly.
 /// Make sure to call ForceSeatMI_BeginMotionControl before this function is called.
 ///
 public bool SendTelemetry(ref FSMI_Telemetry telemetry)
 {
     if (m_api == IntPtr.Zero)
     {
         return(false);
     }
     return(m_fsmiSendTelemetry(m_api, ref telemetry) != 0);
 }
예제 #2
0
 ///
 /// It sends updated telemetry information to ForceSeatPM for further processing.
 /// Make sure that 'mask' and 'state' fields are set correctly.
 /// Make sure to call ForceSeatMI_BeginMotionControl before this function is called.
 ///
 /// NOTE: sfx and audioEffects are optional.
 ///
 public bool SendTelemetry2(ref FSMI_Telemetry telemetry,
                            ref FSMI_SFX sfx,
                            ref FSMI_TactileAudioBasedFeedbackEffects audioEffects)
 {
     if (m_api == IntPtr.Zero)
     {
         return(false);
     }
     return(m_fsmiSendTelemetry2(m_api, ref telemetry, ref sfx, ref audioEffects) != 0);
 }
예제 #3
0
        public virtual void Update(float deltaTime, ref FSMI_Telemetry telemetry)
        {
            var velocity      = m_rb.transform.InverseTransformDirection(m_rb.velocity);
            var rotation      = m_rb.transform.rotation;
            var localRotation = m_rb.transform.localRotation;

            telemetry.rpm        = 0;
            telemetry.maxRpm     = 0;
            telemetry.speed      = velocity.magnitude * 3.6f;             // km/h
            telemetry.surgeSpeed = velocity.z;
            telemetry.swaySpeed  = velocity.x;
            telemetry.heaveSpeed = velocity.y;
            telemetry.roll       = -Mathf.Deg2Rad * (localRotation.eulerAngles.z > 180 ? localRotation.eulerAngles.z - 360 : localRotation.eulerAngles.z);
            telemetry.pitch      = -Mathf.Deg2Rad * (localRotation.eulerAngles.x > 180 ? localRotation.eulerAngles.x - 360 : localRotation.eulerAngles.x);
            telemetry.yaw        = Mathf.Deg2Rad * (localRotation.eulerAngles.y > 180 ? localRotation.eulerAngles.y - 360 : localRotation.eulerAngles.y);

            if (m_firstCall)
            {
                m_firstCall = false;

                telemetry.surgeAcceleration = 0;
                telemetry.swayAcceleration  = 0;
                telemetry.heaveAcceleration = 0;
                telemetry.pitchSpeed        = 0;
                telemetry.rollSpeed         = 0;
                telemetry.yawSpeed          = 0;
            }
            else
            {
                ForceSeatMI_Utils.LowPassFilter(ref telemetry.surgeAcceleration, (telemetry.surgeSpeed - m_prevSurgeSpeed) / deltaTime, FSMI_VT_ACC_LOW_PASS_FACTOR);
                ForceSeatMI_Utils.LowPassFilter(ref telemetry.swayAcceleration, (telemetry.swaySpeed - m_prevSwaySpeed) / deltaTime, FSMI_VT_ACC_LOW_PASS_FACTOR);
                ForceSeatMI_Utils.LowPassFilter(ref telemetry.heaveAcceleration, (telemetry.heaveSpeed - m_prevHeaveSpeed) / deltaTime, FSMI_VT_ACC_LOW_PASS_FACTOR);

                var deltaAngles = new Vector3(
                    Mathf.DeltaAngle(m_rb.transform.eulerAngles.x, m_prevAngles.x),
                    Mathf.DeltaAngle(m_rb.transform.eulerAngles.y, m_prevAngles.y),
                    Mathf.DeltaAngle(m_rb.transform.eulerAngles.z, m_prevAngles.z)
                    );

                ForceSeatMI_Utils.LowPassFilter(ref telemetry.rollSpeed, deltaAngles.z / deltaTime, FSMI_VT_ANGLES_SPEED_LOW_PASS_FACTOR);
                ForceSeatMI_Utils.LowPassFilter(ref telemetry.pitchSpeed, deltaAngles.x / deltaTime, FSMI_VT_ANGLES_SPEED_LOW_PASS_FACTOR);
                ForceSeatMI_Utils.LowPassFilter(ref telemetry.yawSpeed, deltaAngles.y / deltaTime, FSMI_VT_ANGLES_SPEED_LOW_PASS_FACTOR);
            }

            m_prevSurgeSpeed = telemetry.surgeSpeed;
            m_prevSwaySpeed  = telemetry.swaySpeed;
            m_prevHeaveSpeed = telemetry.heaveSpeed;
            m_prevAngles.x   = m_rb.transform.eulerAngles.x;
            m_prevAngles.y   = m_rb.transform.eulerAngles.y;
            m_prevAngles.z   = m_rb.transform.eulerAngles.z;

            telemetry.gearNumber = m_gearNumber;
        }
예제 #4
0
        public void Pause(bool paused)
        {
            if (null != m_platformInfoObject)
            {
                m_platformInfoObject.Pause(paused);
            }

            if (null != m_telemetryObject)
            {
                m_telemetryObject.Pause(paused);

                if (paused)
                {
                    FSMI_Telemetry pauseTelemetry = new FSMI_Telemetry();
                    pauseTelemetry.mask       = FSMI_TEL_BIT.STATE;
                    pauseTelemetry.structSize = (byte)Marshal.SizeOf(pauseTelemetry);
                    pauseTelemetry.state      = paused ? (byte)FSMI_State.PAUSE : (byte)FSMI_State.NO_PAUSE;

                    m_api.SendTelemetry(ref pauseTelemetry);
                }
            }

            if (null != m_positioningObject)
            {
                m_positioningObject.Pause(paused);

                if (paused)
                {
                    FSMI_TopTableMatrixPhysical pauseMatrix = new FSMI_TopTableMatrixPhysical();
                    pauseMatrix.mask       = FSMI_POS_BIT.STATE;
                    pauseMatrix.structSize = (byte)Marshal.SizeOf(pauseMatrix);
                    pauseMatrix.state      = paused ? (byte)FSMI_State.PAUSE : (byte)FSMI_State.NO_PAUSE;

                    m_api.SendTopTableMatrixPhy(ref pauseMatrix);
                }
            }
        }