Thread Tools
This thread is privately moderated by Miami Mike, who may elect to delete unwanted replies.
Apr 04, 2019, 06:15 PM
Pompano Hill Flyers
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!

Latest blog entry: How To Get a Custom AMA Number
Sign up now
to remove ads between posts
Apr 04, 2019, 06:23 PM
Pompano Hill Flyers
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
Pompano Hill Flyers
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.
Latest blog entry: How To Get a Custom AMA Number
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
Pompano Hill Flyers
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.
Latest blog entry: How To Get a Custom AMA Number
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
Jan 16, 2020, 05:10 AM
Registered User
Love the sim mike but some of the sim controls are opposite to my actual glider, is there a way of fixing this? My guess is my mixers are opposite to yours so I need to swap -100 to +100 for those going the wrong way and then reverse servo directions in outputs on my TX to get the glider to respond correctly?
Jan 16, 2020, 07:28 AM
Pompano Hill Flyers
Miami Mike's Avatar
Thread OP
There's no need to alter your setup; if you upload your otx / eepe file here I'll be glad to customize the script for it. Just make sure the servo channels are labeled on the Outputs and Mixers pages so that I'll know what's what, and let me know which control surfaces are going the wrong way on the display.

If you do decide to alter your setup, the convention I use and recommend, and the one that works with the script as written, is the one I learned from Mike Shellim: A positive mix causes a control surface to go up or to the right, and a negative mix causes a control surface to go down or to the left. That means that on your Mixers page your rudder, right aileron, and both flaps will have positive weights, and your elevator and left aileron will have negative weights.

(All stick inputs on the Inputs page need positive weights, else your trims will work backward.)
Last edited by Miami Mike; Jan 16, 2020 at 07:59 AM.
Jan 19, 2020, 11:30 PM
Registered User
Thanks for the offer and quick reply Mike. I’ve just changed my setup, makes way more sense your way anyway.
Jun 15, 2020, 04:28 PM
Entropy is happening!
Jim.Thompson's Avatar
Quote:
Originally Posted by scruffy1
added to my list of clever things i will probably never get sophisticated enough to use, but want to anyway
...........................
That is exactly my position too Scruff!
Thanks to Mike from me too, for sharing this and explaining it all so well.
Jun 14, 2021, 07:40 AM
Registered User
robonave's Avatar
Is there a version for the Horus (I have the X-10E)?
Jun 14, 2021, 08:36 AM
Pompano Hill Flyers
Miami Mike's Avatar
Thread OP
I'm not aware of one. OpenTX radios with 480x272 screens use widgets instead of telemetry screens, and I've never gotten into widgets because I don't own one of those radios. But I did relay your request in a thread where all of the guys I know who write scripts like that are subscribed. Maybe one of them will be interested.
Latest blog entry: How To Get a Custom AMA Number


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