Input Variables
The script has access to following variables:- in_Paused – 0 working, 1 paused
- in_SystemTime – current system time in milliseconds
- in_SystemTimeDiff – difference between this and previous script call in milliseconds
- in_SystemTimeDiff_us – difference between this and previous script call in nanoseconds
- in_InputFlags – input flags from plug-in
- in_MaxSpeed – maximum speed from profile
- in_DoF – DoF for the connected motion platform
- in_RevLimiterOutput – 0 disabled, 1 on the motion platform, 2 on tactile transducer
Output Variables
The script can set following output variables:- out_Paused – by default copy of in_Paused, can be overwrite
- out_Parking – 0 no parking, 1 park to center, 2 park normal, 3 park for transport
- out_ControlMode – 0 indirect, 1 direct, 2 inverse kinematics matrix, 3 inverse kinematics vector
- out_Trigger1…out_Trigger8 – only for specific applications
- out_Dbg1…out_Dbg8 – values to be disabled in Show debug graphs
- out_LeftRightRotation – top frame position in logical units, signed 16-bit
- out_RearFrontRotation – top frame position in logical units, signed 16-bit
- out_DownUpMovement – top frame position in logical units, signed 16-bit
- out_HorizontalLeftRightRotation – top frame position in logical units, signed 16-bit
- out_LeftRightMovement – top frame position in logical units, signed 16-bit
- out_RearFrontMovement – top frame position in logical units, signed 16-bit
- out_LeftRightRotation_Speed – maximum allowable speed in logical units, unsigned 16-bit
- out_RearFrontRotation_Speed – maximum allowable speed in logical units, unsigned 16-bit
- out_DownUpMovement_Speed – maximum allowable speed in logical units, unsigned 16-bit
- out_HorizontalLeftRightRotation_Speed – maximum allowable speed in logical units, unsigned 16-bit
- out_LeftRightMovement_Speed – maximum allowable speed in logical units, unsigned 16-bit
- out_RearFrontMovement_Speed – maximum allowable speed in logical units, unsigned 16-bit
- out_Position1…out_Position6 – position of each actuator in logical units, signed 16-bit
- out_MaxSpeed1…out_MaxSpeed6 – maximum allowable speed of each actuator in logical units, unsigned 16-bit
- out_Ramp1…out_Ramp6 – ramp for each actuator
- out_Roll_rad – top frame position in real world units (radians)
- out_Pitch_rad – top frame position in real world units (radians)
- out_Yaw_rad – top frame position in real world units (radians)
- out_Heave_mm – top frame position in real world units (mm)
- out_Surge_mm – top frame position in real world units (mm)
- out_Sway_mm – top frame position in real world units (mm)
- out_MaxSpeed – by default copy on in_MaxSpeed, the script can ovewrite the speed
- out_BestMatchStrategy – if “true” is specified, then out of the range positions are interpolated back to in range; if “false” is specified, then no interpolation is performed
Standard Javascript functions
List of available standard Javascript functions can be found here.Predefined functions in scripts
Following predefined functions are also available in scripts:// It returns b clamped to the inclusive range of a and c. function MoSy_Bound(a, b, c); // It returns true if b is in [a, c] function MoSy_IsWithin(a, b, c); // It returns 1 if a is greater or equal 0 or -1 otherwise function MoSy_Sign(a); // It cuts signal if it does not exceed specified minimum value // value: source signal // valueThreshold: required level of signal // return: if value is greater than threshold then (value – threshold) else (0) // example: rollSignal = MoSy_CutBump(rollSignal, 1000); function MoSy_CutBump(value, valueThreshold); // It applies simple and fast low pass filter. // filteredValue: value accumulator from previous calls // currentValue: value received from the SIM // maxValue: bounds for output value (-maxValue, return, maxValue) // lowPassFactor: bigger value means slower output value changes // return: new filtered value // example: filteredRoll = MoSy_LowPass(filteredRoll, rollFromTheSim, 32000, 10); function MoSy_LowPass(filteredValue, currentValue, maxValue, lowPassFactor); // It applies simple and fast low pass filter. In comparision to MoSy_LowPass, it does not perform value clamping. // filteredValue: value accumulator from previous calls // currentValue: value received from the SIM // lowPassFactor: bigger value means slower output value changes // return: new filtered value // example: filteredRoll = MoSy_LowPass(filteredRoll, rollFromTheSim, 10); function MoSy_LowPass2(filteredValue, currentValue, lowPassFactor); // It extracts bump value signal from source signal. It can be used to redirect bump to different output or filter them separately. // This function calls MoSy_CutBumpinternally. // avgValue: average signal, e.g. result of low pass filtering // currentValue: value received from the SIM // factor: bump gain // threshold: required level of signal // maxValue: bounds for output value (-maxValue, return, maxValue) // return: extracted and filtered bump singal // example: rollBumps = MoSy_Bump(avgRoll, rollFromTheSim, 20, 1000, 32000); function MoSy_Bump(avgValue, currentValue, factor, threshold, maxValue); // It returns true if interval between this and previous motion script call is valid (500us to 500ms) function MoSy_IsSystemTimeDiffValid(); // It returns rotated 2D vector [new_x, new_y]; function MoSy_Rotate_Vector(x, y, angle_rad, centerX, centerY); // It is advanced telemetry processor that applies low pass filters and bumps extracing on telemetry signal received from the SIM. // Beside input parameters it uses static global configuration parameters and quick tunes values for preferences adjustments. // rollValue: roll signal from the SIM // pitchValue: pitch signal from the SIM // heaveValue: heavesignal from the SIM // yawValue: yaw signal from the SIM // surgeValue: surge signal from the SIM // swayValue: sway signal from the SIM // return: none // // It requires global static configuration parameters (explained in section Signal filtering for racing games): // - rollLowPassFactor, rollHighPassFactor, rollOutputFactor, rollHighOutputFactor, rollMax, rollHighPassFilterCutOff, rollBumpMin // - pitchLowPassFactor, pitchHighPassFactor, pitchOutputFactor, pitchHighOutputFactor, pitchMax, pitchHighPassFilterCutOff, pitchBumpMin // - heaveLowPassFactor, heaveHighPassFactor, heaveOutputFactor, heaveHighOutputFactor, heaveMax, heaveHighPassFilterCutOff, heaveBumpMin // - yawLowPassFactor, yawHighPassFactor, yawOutputFactor, yawHighOutputFactor, yawMax, yawHighPassFilterCutOff, yawBumpMin // - surgeLowPassFactor, surgeHighPassFactor, surgeOutputFactor, surgeHighOutputFactor, surgeMax, surgeHighPassFilterCutOff, surgeBumpMin // - swayLowPassFactor, swayHighPassFactor, swayOutputFactor, swayHighOutputFactor, swayMax, swayHighPassFilterCutOff, swayBumpMin // // It requires quick tunes parameters defined in profiles.ini (if user is allowed to adjust them) or defined as global variables (if user is not allowed to adjust them): // - Overall Intensity (as quick tune in profiles.ini) or tune_Overall_Intensity (global variable) // - Bumps Intensity (as quick tune in profiles.ini) or tune_Bumps_Intensity (global variable) // - Body Roll Gain (as quick tune in profiles.ini) or tune_Body_Roll_Gain (global variable) // - Body Pitch Gain (as quick tune in profiles.ini) or tune_Body_Pitch_Gain (global variable) // - Vertical G Force_Gain (as quick tune in profiles.ini) or tune_Vertical_G_Force_Gain (global variable) // - Turning Rate Gain (as quick tune in profiles.ini) or tune_Turning_Rate_Gain (global variable) // - Longitudinal G-Force Gain (as quick tune in profiles.ini) or tune_Longitudinal_G_Force_Gain (global variable) // - Lateral G-Force Gain (as quick tune in profiles.ini) or tune_Lateral_G_Force_Gain (global variable) function MoSy_DefaultProcessor(rollValue, pitchValue, heaveValue, yawValue, surgeValue, swayValue); // It is advanced telemetry processor that applies low pass filters and bumps extracting on telemetry signal received from the SIM. // Beside input parameters it uses static global configuration parameters and quick tunes values for preferences adjustments. // // In contrast to MoSy_DefaultProcessor it allows to specify two signal sources for roll and pitch. It means that it is possible to // e.g. roll the top frame as combination of vehicle roll and lateral acceleration in specified proportions. // // rollValue: roll signal from the SIM // pitchValue: pitch signal from the SIM // heaveValue: heave signal from the SIM // yawValue: yaw signal from the SIM // surgeRotValue: surge signal from the SIM for top frame rotation (pitch) // surgeMovValue: surge signal from the SIM for top frame movement (surge) // swayRotValue: sway signal from the SIM for top frame rotation (roll) // swayMovValue: sway signal from the SIM for top frame movement (sway) // return: none // // Required global static configuration parameters (explained in section Signal filtering for racing games): // - rollLowPassFactor, rollHighPassFactor, rollOutputFactor, rollHighOutputFactor, rollMax, rollHighPassFilterCutOff, rollBumpMin // - pitchLowPassFactor, pitchHighPassFactor, pitchOutputFactor, pitchHighOutputFactor, pitchMax, pitchHighPassFilterCutOff, pitchBumpMin // - heaveLowPassFactor, heaveHighPassFactor, heaveOutputFactor, heaveHighOutputFactor, heaveMax, heaveHighPassFilterCutOff, heaveBumpMin // - yawLowPassFactor, yawHighPassFactor, yawOutputFactor, yawHighOutputFactor, yawMax, yawHighPassFilterCutOff, yawBumpMin // - surgeRotLowPassFactor, surgeRotHighPassFactor, surgeRotOutputFactor, surgeRotHighOutputFactor, surgeRotMax, surgeRotHighPassFilterCutOff, surgeRotBumpMin // - surgeMovLowPassFactor, surgeMovHighPassFactor, surgeMovOutputFactor, surgeMovHighOutputFactor, surgeMovMax, surgeMovHighPassFilterCutOff, surgeMovBumpMin // - swayRotLowPassFactor, swayRotHighPassFactor, swayRotOutputFactor, swayRotHighOutputFactor, swayRotMax, swayRotHighPassFilterCutOff, swayRotBumpMin // - swayMovLowPassFactor, swayMovHighPassFactor, swayMovOutputFactor, swayMovHighOutputFactor, swayMovMax, swayMovHighPassFilterCutOff, swayMovBumpMin // // It requires quick tunes parameters defined in profiles.ini (if user is allowed to adjust them) or defined as global variables (if user is not allowed to adjust them): // - Overall Intensity (as quick tune in profiles.ini) or tune_Overall_Intensity (global variable) // - Bumps Intensity (as quick tune in profiles.ini) or tune_Bumps_Intensity (global variable) // - Body Roll Gain (as quick tune in profiles.ini) or tune_Body_Roll_Gain (global variable) // - Body Pitch Gain (as quick tune in profiles.ini) or tune_Body_Pitch_Gain (global variable) // - Vertical G Force_Gain (as quick tune in profiles.ini) or tune_Vertical_G_Force_Gain (global variable) // - Turning Rate Gain (as quick tune in profiles.ini) or tune_Turning_Rate_Gain (global variable) // - Longitudinal G-Force Gain (as quick tune in profiles.ini) or tune_Longitudinal_G_Force_Gain (global variable) // - Lateral G-Force Gain (as quick tune in profiles.ini) or tune_Lateral_G_Force_Gain (global variable) function MoSy_DefaultProcessor2(rollValue, pitchValue, heaveValue, yawValue, surgeRotValue, surgeMovValue, swayRotValue, swayMovValue); // It is advanced telemetry processor that applies low pass filters and bumps extracting on telemetry signal received from the SIM. // // It uses inverse kinematics engine inside and the result (required top table positions) is in real world units, not abstract logical units. // It means that if e.g. required roll is 10 deg, then all motion platforms (e.g. PS-3TM-350 and PS-6TM-1500) will try to perform roll 10 deg. // In comparsion MoSy_DefaultProcessor2 specifies roll in logical units (percent of available maxium roll), so there result will be differet // for PS-3TM-350 and PS-6TM-1500. // // In contrast to MoSy_DefaultProcessor it allows to specify two signal sources for roll and pitch. It means that it is possible to // e.g. roll the top frame as combination of vehicle roll and lateral acceleration in specified proportions. // rollValue: roll signal from the SIM // pitchValue: pitch signal from the SIM // heaveValue: heave signal from the SIM // yawValue: yaw signal from the SIM // surgeRotValue: surge signal from the SIM for top frame rotation (pitch) // surgeMovValue: surge signal from the SIM for top frame movement (surge) // swayRotValue: sway signal from the SIM for top frame rotation (roll) // swayMovValue: sway signal from the SIM for top frame movement (sway) // return: none // // Required global static configuration parameters (explained in section Signal filtering for racing games): // - rollLowPassFactor, rollHighPassFactor, rollOutputFactor, rollHighOutputFactor, rollMax, rollHighPassFilterCutOff, rollBumpMin // - pitchLowPassFactor, pitchHighPassFactor, pitchOutputFactor, pitchHighOutputFactor, pitchMax, pitchHighPassFilterCutOff, pitchBumpMin // - heaveLowPassFactor, heaveHighPassFactor, heaveOutputFactor, heaveHighOutputFactor, heaveMax, heaveHighPassFilterCutOff, heaveBumpMin // - yawLowPassFactor, yawHighPassFactor, yawOutputFactor, yawHighOutputFactor, yawMax, yawHighPassFilterCutOff, yawBumpMin // - surgeRotLowPassFactor, surgeRotHighPassFactor, surgeRotOutputFactor, surgeRotHighOutputFactor, surgeRotMax, surgeRotHighPassFilterCutOff, surgeRotBumpMin // - surgeMovLowPassFactor, surgeMovHighPassFactor, surgeMovOutputFactor, surgeMovHighOutputFactor, surgeMovMax, surgeMovHighPassFilterCutOff, surgeMovBumpMin // - swayRotLowPassFactor, swayRotHighPassFactor, swayRotOutputFactor, swayRotHighOutputFactor, swayRotMax, swayRotHighPassFilterCutOff, swayRotBumpMin // - swayMovLowPassFactor, swayMovHighPassFactor, swayMovOutputFactor, swayMovHighOutputFactor, swayMovMax, swayMovHighPassFilterCutOff, swayMovBumpMin // // It requires quick tunes parameters defined in profiles.ini (if user is allowed to adjust them) or defined as global variables (if user is not allowed to adjust them): // - Overall Intensity (as quick tune in profiles.ini) or tune_Overall_Intensity (global variable) // - Bumps Intensity (as quick tune in profiles.ini) or tune_Bumps_Intensity (global variable) // - Body Roll Gain (as quick tune in profiles.ini) or tune_Body_Roll_Gain (global variable) // - Body Pitch Gain (as quick tune in profiles.ini) or tune_Body_Pitch_Gain (global variable) // - Vertical G Force_Gain (as quick tune in profiles.ini) or tune_Vertical_G_Force_Gain (global variable) // - Turning Rate Gain (as quick tune in profiles.ini) or tune_Turning_Rate_Gain (global variable) // - Longitudinal G-Force Gain (as quick tune in profiles.ini) or tune_Longitudinal_G_Force_Gain (global variable) // - Lateral G-Force Gain (as quick tune in profiles.ini) or tune_Lateral_G_Force_Gain (global variable) function MoSy_DefaultProcessorIK2(rollValue, pitchValue, yawValue, heaveRotValue, heaveMovValue, surgeRotValue, surgeMovValue, swayRotValue, swayMovValue); // This object calulates average value from N last samples. // // var surgeFilter = new MoSy_AverageCalculator(count); // function process() { // ... // var avgValue = surgeFilter.Update(new_sample); // ... // } // // count: number of samples to keep // Update: call this method to append new sample and get current average value function MoSy_AverageCalculator(count); this.Update = function(value); // It returns increased or reduced value, depending on value sign and tune_Weight_Transfer_Bias function MoSy_ApplyWeightTransferBias(value); // It returns angle between -PI/2 and PI/2 function MoSy_MotionFriendlyPRY_rad(x); // It returns angle between -90 and 90 function MoSy_MotionFriendlyPRY_deg(x); // It returns current roll (rad) or stored roll if pitch is close 90 deg (+-tune_Pitch_Threshold_For_Roll_Freeze) function MoSy_RollFeeze_rad(roll, pitch); // It returns current roll (deg) or stored roll if pitch is close 90 deg (+-tune_Pitch_Threshold_For_Roll_Freeze) function MoSy_RollFeeze_deg(roll, pitch); // It returns true if this is parking case, otherwise false function MoSy_FSMI_HandleParking(inputFlags);