Diese Website verwendet Cookies. Wenn Sie die Website weiterverwenden, erklären Sie sich damit einverstanden und akzeptieren außerdem die Datenschutzrichtlinie.

Helicopter Scripts xLua Edition

Antworten
Benutzeravatar
Agi
Site Admin
Beiträge: 316
Registriert: Sa 29. Apr 2017, 01:42

Helicopter Scripts xLua Edition

Beitrag von Agi » Mi 1. Mai 2019, 19:43

The following scripts are designed for aircraft developers - If you are a user and want to add some of the functionality provided by the scripts to a helicopter please use the Tweak Utility. You find all the options including configuration and calibration parameters in the Helicopter Options submenu.



I have ported over my helicopter scripts from the Tweak Utility to xLua so they can be used and shipped in helicopters. This way developers can add the scripts' functionality to their aircraft without coding themselves and without the need of FlyWithLua or the Tweak Utility - the scripts just need xLua inside the aircraft's plugin folder and the scripts added to the scripts folder.



Some instructions


Force Trim

The code should be fine and the default values are usable for the most part but, depending on aircraft and flighmodel, some parameters have to be adjusted to the helicopter. Inside the force trim script you will find the following lines:

Code: Alles auswählen

local ftu_force_trim_heading_on = true 						
local ftu_force_trim_method = "trim"						

local ftu_force_trim_target_roll_multi = 1.6				
local ftu_force_trim_target_pitch_multi = 1.6				
local ftu_force_trim_target_heading_multi = 1.0		
		
local ftu_force_trim_center = 0.07							

local ftu_trim_sensitivity = 0.0010		
The first item "ftu_force_trim_heading_on" specifies if the yaw axis is taken into account for the force trim. If you just want to use cyclic controls (pitch and roll) set this to "false".

The force trim method can be changed to "cyclic" and if you do there will be a different method applied for the force trim process - the logic then controls the cyclic directly. This is a bit experimental and I suggest to use the trim method but if you get useful results with the cyclic method you can use this as well.

The block after you find translation multipliers for all three axes. They are needed because cyclic inputs don't translate into trim values directly, there has to be a multiplier to match. Sadly, those mutlipliers are different for most aircraft so you have to find a value which really holds the helicopter's attitude. The mulitpliers are used when method is set to "trim" and have no effect if you chose to use "cyclic".

The ftu_force_trim_center value defines the ceneter zone for the cyclic method, if you want to use the trim method this is irrelevant. The cyclic method depends on the joystick's center position and needs to detect this so this center zone defines when the joystick is considered centered by the logic. In most cases the default value should work.

The last item is the trim sensitivity for the trim buttons. Higher values increase senitivity, lower values decrease sensitivity. You should adjust the value slightly, for example in 0.0005 increments or similar.



Then you have to rename some buttons (if you like), In the lower section of the script you find some lines like this one:

Code: Alles auswählen

cmd_ftu_force_trim = create_command("FlyAgi/FTU_Force_Trim/Force_Trim", "Force Trim", ftu_force_trim_cmdh)

As it's unlikely you want your controls found under 'FlyAgi' in X-Plane I suggest to change this to match your company or aircraft name, for example:

cmd_ftu_force_trim = create_command("MY_AWESOME_HELO/FTU_Force_Trim/Force_Trim", "Force Trim", ftu_force_trim_cmdh)

In this case your aircraft is named "MY_AWESOME_HELO" and if your helicopter has a different name just change this highlighted part of the code in all the "create_command" functions.




Rotor Brake

In the rotor brake script you will find some customizable parameters as well:

Code: Alles auswählen

local ftu_rotor_brake_ratio_target = 500	
local ftu_prop_speed_rpm_target = 0.5		
local ftu_rotor_brake_auto = true			
local ftu_rotor_brake_enhanced = true		

The first one is crucial as this defines the strenght of the enhanced rotor brake. This value should be high enough to stop the rotors from spinning completely if rotor brake is applied but if it's too high the blades start jumping around so you have to find a value which works well with your helo.

The second value is the rpm threshold to apply the extended rotor brake. If the rotor stops suddenly and unexpected and does not run down smoothly lower this value, if the rotors never stop spinning no matter how high you set the strenght value increase this value.

Next there is a value "ftu_rotor_brake_auto" which sets the rotor brake active on flight start if cold and dark and releses autmatically as soon as the engine is running. If you don't want to set the brake automatically just set this value to "false".

If you want to disable the rotor brake script completely but not remove it from your aircraft you can set the " ftu_rotor_brake_enhanced" value to "false".




Auto Governor

The auto governor script automatically activates the governor when a certain rotor rpm is reached and disables the governor if the throttle is reduced to a ceratin value. The script is optimized for a single engine but it can handle two engines as well but in this case both engines are synchronized.

The auto governor uses the sweep wing axis (or the sweep forward/aft buttons) for the throttle control so this axis or the buttons have to be mapped to the joystick or keyboard if the user wants so have throttle control and use the auto governor. As I did not find other unsused axes which worked with this method this limits the engine handling to a synchronized behaviour on twin engine helicopters.

There are some parameters to configure:

Code: Alles auswählen

local ftu_auto_gov_on = true		
local ftu_auto_gov_min_thro = 0.20	
local ftu_auto_gov_min_rpm = 250	
local ftu_swdirqst_mapped = false	
The first line enables or disables the script, if you want to use the script in a helicopter you have to set this to 'true'. The parameter 'ftu_auto_gov_min_thro' defines the throttle threshold, if throttle is below this value the governor will disengage. The ' ftu_auto_gov_min_rpm' parameter specifies the rotor rpm at which the governor engages. Both values should be adjusted to match your helicopter's needs, the throttle value should be fine somewhere between 0.2 and 0.3 and the rpm value has to be slightly (let's say 20-30) below your helicopter's rotor rpm as reported by the dataref 'sim/cockpit2/engine/indicators/prop_speed_rpm' after completed runup with the governor enabled and stable.

If you want to use the script in your helicopter you should assign "sim/flightmodel/controls/swdirqst" to the throttle handle in your cockpit.obj as this is mapped to the real throttle by the governor logic. If this has been done set the ' ftu_swdirqst_mapped' parameter to 'true'. This parameter, if set to false, reverses the mapping from throttle [0] to the swdirqst dataref if the governor is not engaged so you can use the cockpit throttle levers if the assignment was not changed.







Downloads:

FTU_Force_Trim.zip

FTU_Rotor_Brake.zip

FTU_Auto_Governor.zip

Antworten