Thread Tools
This thread is privately moderated by Miami Mike, who may elect to delete unwanted replies.
Apr 04, 2019, 06:15 PM
Meerkats: Cuter than mere cats
Miami Mike's Avatar
Thread OP
Announce

OpenTX Glider Simulator V2.0


I've updated my gldsim.lua Glider Simulator script with a new look, a new feature, and compatibility with all of the "Taranis" line of FrSky/OpenTX radios running OpenTX version 2.2, while maintaining compatibility with OpenTX version 2.1.



It not only works with the Taranis X9D, X9D+, and X9E...



it also works with the Q X7...



and X-Lite.



It supports cross-tail and v-tail gliders with four-servo wings, and can display channel values as either percentages or integers. Channel values that exceed 100% will flash, indicating that the mix is being clipped to within 100% before it reaches the output stage.

Since I wrote the first version a couple of years ago, gldsim.lua has become an indispensable tool to me for developing and testing new glider setup ideas.

Instructions are at the beginning of the script but I'll include them in the following post along with the script itself. Be sure to monitor the thread below for changes or updates, and please feel free to add your own questions and comments.

Enjoy!

Sign up now
to remove ads between posts
Apr 04, 2019, 06:23 PM
Meerkats: Cuter than mere cats
Miami Mike's Avatar
Thread OP

Instructions and The Script


Code:
--[[ gldsim.lua Glider Simulator, Version 2.01, by Miami Mike, 4/5/2019.   
This is a glider simulator for six-servo gliders with or without motors,
with dual flaps, ailerons, and either cross-tails or v-tails. The
script is compatible with Taranis X9D, X9D+, X9E, X7, and X-Lite radios,
using OpenTX Version 2.1 or 2.2.

It's meant for developing, modifying, and testing model setups with or without
being connected to the model, and works in Companion simulator or the radio itself. 

This is a telemetry script, so it should be stored in the SCRIPTS/TELEMETRY folder
of Companion's SD Structure Path on your computer and/or your radio's SD card, and
set up as a telemetry screen for each of your gliders.
]]
-------------- Begin user-adjustable parameters --------------

local RtAile, LtAile, RtFlap, LtFlap = "ch1", "ch2", "ch3", "ch4"
local Elev, Rudder, RtVee, LtVee = "ch5", "ch6", "ch5", "ch6"
-- Optional CH7 & CH8:
-- local Aux1, Name_of_Aux1 = "ch7", "Motor"
-- local Aux2, Name_of_Aux2 = "ch8", "MotArm"

local mode = 1 -- Starting display mode.
--[[
Click ENTER to step through the four display modes. They are:
Mode 1: cross-tail, values show as percentages (-100% to +100%).
Mode 2: v-tail, values show as percentages (-100% to +100%).
Mode 3: cross-tail, values show as integers (-1024 to +1024).
Mode 4: v-tail, values show as integers (-1024 to +1024).
]]
local flap_offset = 512 -- Channel value where flaps are neutral.
--[[
Set the radio controls to where the flaps on the model are neutral. If the display
doesn't show the flaps at neutral then short-click EXIT to correct the display,
based upon the assumption that the right flap is in its neutral position.

If you switch to display mode 3 or 4 and note the right flap's integer value at
neutral, you can edit the flap_offset value above to make that the new default value.
]]
-------------- End of user-adjustable parameters --------------
The file below is named "gldsim.txt". Download it and edit the user-adjustable parameters with any text editor, rename it to "gldsim.lua", and follow the instructions to set it up.

Change log:
  • Version 2.03, 4/8/2019: Re-covered the v-tail with opaque Monocote.
Last edited by Miami Mike; Apr 08, 2019 at 05:50 PM.
Apr 07, 2019, 09:29 AM
Registered User
mikeshellim's Avatar
Nice work - graphics look cool and genuinely useful.

My only issue is the need to edit the script for different models, it means making a copy, reading the documentation etc and if you enhance the script then it has to be repeated for all the copies. How about auto-detecting the layout and channel assignments, e.g. by looking for common strings in the channel names? Also you could designate a key press (say long Menu) to set the display offset for the flap neutral. That way it could be more or less fit and forget.

[edit: okay I see you can cycle through the layout modes by pressing Enter... but it would still be handy to have auto channel configuration]
Apr 07, 2019, 12:14 PM
Meerkats: Cuter than mere cats
Miami Mike's Avatar
Thread OP
That sounds like an interesting idea but I'd need more details on how it should work. The way I figured it, you might have some elevator/rudder gliders and v-tail gliders with channels that are otherwise ordered the same way, but all you'd have to do in that case would be to make two copies with names like "v-tail.lua" and "x-tail.lua" and different default mode settings.

I could also separate the cross-tail/v-tail setting from the percentage/integer setting, but then I'd have to either find another button event that's common to all Taranis-type radios, or make the instructions a little more complex and dependent upon the type of radio. It seems they all have ENTER and EXIT buttons of one form or another.

Anyway, I'm very open to suggestions and anticipate making changes to the script over time, which is why I separated the instructions and script from the introductory post.
Apr 08, 2019, 03:47 AM
Registered User
mikeshellim's Avatar
Was thinking about this... one way would be to make it table driven, by storing the preset modes in a table along with their servo assignments. Then specify an additional mode 'autoconfig' in the same table, initially empty. Populate it at run time (in init()?) based on best guess from reading channel names. If it doesn't work then the user can still cycle through the modes without any special processing. Might be a good half way house between preset and fully configurable (which would require input screens).

Code:
local outputName = string.lower(model.getOutput(i).name)
if string.find (outputName, 'ail') and string.find (outputName, 'r') then 
   -- good chance it's a right aileron, do something 
elseif ...
Last edited by mikeshellim; Apr 08, 2019 at 03:54 AM.
Apr 08, 2019, 07:20 PM
Meerkats: Cuter than mere cats
Miami Mike's Avatar
Thread OP
Okay Mike, I've made some changes, inspired by your comments and some thoughts of my own. One thing I've realized is that the choice between cross-tail and v-tail should be set up for each model along with its channel assignments, while the choice between integers and percentages should remain selectable with a button. So now, all the ENTER button does is toggle between percentages and integers with the initial mode determined by "integer = false" or "integer = true" in the configuration file below.

This version uses a configuration file named gldcfg.lua that resides along with gldsim.lua in the SCRIPTS/TELEMETRY folder. It scans the model names in the file and looks for one that matches the current model name. If it doesn't find a match then it uses the default settings in the gldsim.lua script. Later I might work on an interactive "Wizard" one-time script to create and edit these files.

Code:
-- Use this file to configure each of your gliders for gldsim.lua. You can set up any number of models. 
gldcfg = {
	{
	Model = "EP glider 1",
	RtAile = "ch1",
	LtAile = "ch2",
	RtFlap = "ch3",
	LtFlap = "ch4",
	Ele_RtV = "ch5",
	Rud_LtV = "ch6",
	Aux1 = "ch7", -- Set to nil if no need to monitor channel 7.
	Name1 = "Motor", 
	Aux2 = "ch8", -- Set to nil if no need to monitor channel 8.
	Name2 = "MotArm", 
	vtail = false, -- False for cross-tails, true for v-tails.
	integer = false, -- The default setting used when the script starts.
	flap_offset = 512 -- Set this to the flap integer value displayed when the radio controls are set for flap neutral.
	},{
	Model = "EP glider 2",
	RtAile = "ch1",
	LtAile = "ch4",
	RtFlap = "ch2",
	LtFlap = "ch3",
	Ele_RtV = "ch5",
	Rud_LtV = "ch6",
	Aux1 = "ch7",
	Name1 = "Motor",
	Aux2 = "ch8",
	Name2 = "MotArm",
	vtail = false,
	integer = false,
	flap_offset = 512
},{
	Model = "PureGlider 1",
	RtAile = "ch1",
	LtAile = "ch2",
	RtFlap = "ch3",
	LtFlap = "ch4",
	Ele_RtV = "ch5",
	Rud_LtV = "ch6",
	Aux1 = nil, -- Do not show. 
	Name1 = nil,
	Aux2 = nil, -- Do not show.
	Name2 = nil,
	vtail = true,
	integer = false,
	flap_offset = 512
	}
}
Download both gldcfg.txt and gldsim.txt, change their extensions to "lua", edit gldcfg.lua, and store them together in SCRIPTS/TELEMETRY.
Jun 15, 2019, 09:29 PM
looking up, down under
scruffy1's Avatar
added to my list of clever things i will probably never get sophisticated enough to use, but want to anyway

thanks mike


Quick Reply
Message:
Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion Migrate models from Taranis (OpenTx 1.?) to Taranis Plus (OpenTx 2.2.0) Mr Rowl FrSky 1 Aug 23, 2017 08:33 AM
Question OpenTX-9x128-2.0.19 + Idle Up switch yaoweic Radios 1 Jun 01, 2016 08:34 AM
Help! Turngy 9XR Pro opentx 2.0.8 to 2.1.7 upgrade failed robinzeng Radios 0 Jan 14, 2016 07:58 AM
Question Hex build: HK mwc pro 2.0, OpenTx, Frsky, Hex DONT FLY!!? Acting erratically? husamwadi Scratchbuilt Multirotor Drones 2 Mar 10, 2015 10:01 PM