Jump to content

[WIP] [1.12.x] MOARdV's Avionics Systems - MAS Interactive IVA! (v1.3.7, 7 April 2023)


MOARdV

Recommended Posts

47 minutes ago, snakeru said:

I will, yes. If @MOARdV agrees, this will be a part of MAS, otherwise I guess I can publish a zip.

I'm pretty slow with it, probably averaging about 1-2 props a day, but it's nearing completion now. 

Really thanks ! 

1-2 props a day ! Is not very slow :wink: 

Link to comment
Share on other sites

I've put together a beta version of a Mk2 pod (from the "Making History" expansion).
The pod still has many dark spots from where the old instruments were. I will try to remove them.
Any feedback is welcome!

The pod has two seats:

  • right: ascent and launch abort
  • left: everything else (orbital, approach, docking, descent, landing)

 

Download at: https://github.com/MOARdV/AvionicsSystems/issues/264

Edited by snakeru
Link to comment
Share on other sites

Hi @MOARdV.

Since the "ascent autopilot" is disabled I was having the exactly same idea as @Geonovast in some other thread.

I guess, I can try the attitude autopilot + SAS modes to do the same thing.
I also guess, I'll be able to hard code a couple of MAS computer actions to action groups. However, it would be a shame to rigidly steal a couple of "traditional"action groups every time a specific pod is used. That would be very un-intuitive, especially since it won't be immediately visible in the UI.

Can we somehow expose some properties in the pod itself, so that they could be added to AGs? See the screenshot for an illustration.

---

EDIT: or, even more generically - it would be nice to expose this way just about any prop. That is - add a configuration similar to a collider action, except that it will be not a collider, but a hook for the AG menu.

 

image.png

Edited by snakeru
Link to comment
Share on other sites

6 hours ago, snakeru said:

EDIT: or, even more generically - it would be nice to expose this way just about any prop. That is - add a configuration similar to a collider action, except that it will be not a collider, but a hook for the AG menu.

Ironically, I removed that functionality just a couple of months ago...

Actually, it was not exactly like you are asking.  It was a part module that would add options to trigger a MAS function from the part action window (right-click part menu).  The reason I removed it is that MAS functionality is switched off in part when the player is not in IVA view, so it would be possible to trigger a function that doesn't work, or it doesn't work correctly.

I could add something to MAS that allows a custom option like you show in the screen shot mock-up, but it will have the same restrictions as the previous module - it may not work if the player is not in IVA mode.  It also requires adding part modules to the IVA's part (not the IVA itself, or a prop), but you already have to do that for the MASFlightComputer module anyway, so that's not a big problem.

Link to comment
Share on other sites

@MOARdV 

Not sure if this is possible, but in regards to an IVA you may like...  or not... The KSO Super 25* (the Ascension/ 2.5m shuttle) has an IVA that already mostly uses RPM.  At the moment it is well beyond my current abilities (but right now I'm unemployed so I may have time to learn?), would there be a way to convert it from RPM to MAS?

 

*No... that mod isn't dead yet...

EDIT: Re read the 1st page...  the better question is whom would be willing to help me learn how to do the conversion?

Edited by smotheredrun
I need to read more
Link to comment
Share on other sites

Hi @MOARdV.

How can I use a different model for a rotary switch? I want to use a 6-position switch.

1) I have edited this line:
"model = ASET/ASET_Props/Control/SwitchRotary/model/Switch_Rotary_3_Marks"
now it says:
"model = ASET/ASET_Props/Control/SwitchRotary/model/Switch_Rotary_6_Marks"

2) I have added 3 more text labels ("4 Mark", ...)

However, it seems that neither new, nor old labels work anymore (I get 6 error messages like these, one for each label):
[ERR 14:05:28.524] [AvionicsSystems] INITIALIZATION ERROR: Error configuring prop #120 (MAS_swRotary6_RotateSpeed)
[ERR 14:05:28.524] [MASComponent] Error configuring prop #120 (MAS_swRotary6_RotateSpeed)
[ERR 14:05:28.524] [MASComponent] Error in TEXT_LABEL 6 Mark:
[ERR 14:05:28.524] [MASComponent] System.NullReferenceException: Object reference not set to an instance of an object

 

Edited by snakeru
Link to comment
Share on other sites

-- post deleted. It was messy and not interesting to other readers. Instead of it a short summary below. --
I had a question about how best to do some repeated condition checking and have found out that it is to be done with LUA, using the TRIGGER_EVENT.

Edited by snakeru
Link to comment
Share on other sites

So I started using MAS and I added 3 MFD2 screens. But I'm getting this error in log and the screens stay black. I'm using the latest versions of MAS and ASET and KSP 1.6.1:

 

Spoiler

[ERR 23:47:11.321] [AvionicsSystems] INITIALIZATION ERROR: Failed to configure prop #16 (MAS_ALCOR_MFD2)

[ERR 23:47:11.321] [MASComponent] Failed to configure prop #16 (MAS_ALCOR_MFD2)

[ERR 23:47:11.321] [MASComponent] System.ArgumentNullException: Argument cannot be null.
Parameter name: Unable to find MASFlightComputer in part - please check part configs
  at AvionicsSystems.MASComponent.Start () [0x00000] in <filename unknown>:0 

[ERR 23:47:11.321] [AvionicsSystems] INITIALIZATION ERROR: MASMonitor configuration failed.

[ERR 23:47:11.322] [MASMonitor] Failed to configure prop #17 (MAS_ALCOR_MFD2)

[ERR 23:47:11.322] [MASMonitor] System.ArgumentNullException: Argument cannot be null.
Parameter name: Failed to find MASFlightComputer initializing MASMonitor
  at AvionicsSystems.MASMonitor.Start () [0x00000] in <filename unknown>:0 

 

 

Link to comment
Share on other sites

3 minutes ago, snakeru said:

@damonvv Your log says:


Unable to find MASFlightComputer in part

Did you check that you have it? You can search for this name in, say, Mk1Pod config. It's a module that you have to install in your pod.

Seems like I was missing the module in my parts config.

Link to comment
Share on other sites

8 hours ago, snakeru said:

How can I use a different model for a rotary switch? I want to use a 6-position switch.

It looks like you have the correct model name for the 6-mark switch.  It looks like the names for the labels are Pos_1_TextObj, Pos_2_TextObj, etc through Pos_6_TextObj (I get these from the JSILabel entries in ASET/ASET_Props/Control/SwitchRotary/6_pos/RES_DISP_ModeSelector.cfg).

I don't think I've used the 6-pos rotary switch, so I don't have any other guidance to suggest yet.

1 hour ago, damonvv said:

Seems like I was missing the module in my parts config.

MAS is a little stricter about module definitions compared to RPM.  Certain modules need to be explicitly added to parts / props / IVAs in order for MAS to initialize and function correctly.  For this particular case, I really ought to change the message to make it clearer in-game that it's something missing from the config file.

Link to comment
Share on other sites

1 hour ago, MOARdV said:

It looks like you have the correct model name for the 6-mark switch.  It looks like the names for the labels are Pos_1_TextObj, Pos_2_TextObj, etc through Pos_6_TextObj (I get these from the JSILabel entries in ASET/ASET_Props/Control/SwitchRotary/6_pos/RES_DISP_ModeSelector.cfg).

I don't think I've used the 6-pos rotary switch, so I don't have any other guidance to suggest yet.

MAS is a little stricter about module definitions compared to RPM.  Certain modules need to be explicitly added to parts / props / IVAs in order for MAS to initialize and function correctly.  For this particular case, I really ought to change the message to make it clearer in-game that it's something missing from the config file.

So far I've got the monitors showing up. But they keep stuck on the welcome screen. When I click a button you can year the sound but nothing happens. Logs don't show any errors either. I'm using the same config listed on the wiki. (I use the "MAS_IFMS_MFD")

 

Spoiler

obZPktN.png



Ok I got it working now. Seems like I did mess up the config file. 

Edited by damonvv
Link to comment
Share on other sites

5 hours ago, MOARdV said:

It looks like you have the correct model name for the 6-mark switch.  It looks like the names for the labels are Pos_1_TextObj, Pos_2_TextObj, etc through Pos_6_TextObj (I get these from the JSILabel entries in ASET/ASET_Props/Control/SwitchRotary/6_pos/RES_DISP_ModeSelector.cfg).

I don't think I've used the 6-pos rotary switch, so I don't have any other guidance to suggest yet.

Ah! I was looking at the "name" attribute whereas the right one was "transform". This is obvious now, in retrospect.

Thank you, @MOARdV!

BTW, I am having some success with LUA scripting. So far I have some primitive ascent autopilot and am about to improve it - moar lights, switches and rotary knobs %-)

Link to comment
Share on other sites

Hi @MOARdV
Yet another question: what technique can I use to reduce the CPU load?
I've got it that the LUA should be running as little as possible - but do I also take care of how I design the indicators?
My question is specifically this:

if I have 'variable = fc.GetPersistent("aaa")<5 and fc.GetPersistent("bbb")>0' - then would this variable be recalculated every world update or is MAS smart enough to figure out that it depends on two other variables and only run updates if one of these other two changes?

A side question: if MAS is smart enough to only recalculate if needed - if I want to do 'fc.SetPersistent("ccc",  fc.GetPersistent("aaa")<5 and fc.GetPersistent("bbb")>0)' - then I can use TRIGGER_EVENT to be efficient and not resort to LUA, right?

Edited by snakeru
Link to comment
Share on other sites

1 hour ago, snakeru said:

is MAS smart enough to figure out that it depends on two other variables and only run updates if one of these other two changes?

Short answer: yes.

Long answer: This is an overview of how MAS variable updating works.  There are 5 kinds of "variables":

  1. Lua Script - these are actual Lua functions.  These update every FixedUpdate by default.  There's a control on the MAS configuration window (accessible from the Space Centre view) to reduce that frequency.  Lua scripts are s-l-o-w.  My measurements show they take 10x - 15x longer to process, so you want to avoid using them for variables any time you can.  Save Lua variable for complex things.  (EDIT: Or as the action for colliders or TRIGGER_EVENT actions)
  2. Native MAS functions - these are MAS functions like 'fc.GetApoapsis()'.  These are updated every FixedUpdate, but they are also very fast.
  3. Dependent MAS functions - these are MAS functions, and mathematical operators like 'and' whose output is affected only by the inputs.  As long as no input is changed, the dependent function does not update.  Every FixedUpdate, MAS will ask the dependent function, "did any of your inputs change?", and skip it if the function says "no".
  4. Persistent Variable Queries ('fc.GetPersistent()' and 'fc.GetPersistentAsNumber()') - these go one step farther, and they only update when they're told their persistent variable changed, so when MAS asks them if they need updated, they always say "no".
  5. Constant Variables - they're technically variables, but they're never queries, and they never update.

MAS uses a parser to disassemble the 'variable' field to figure out whether MAS can handle it directly, or if it needs Lua to handle the variable.  In your example variable, there are 9 variables involved in the computation.  four of them are constants ("aaa", "bbb", "5" and "0").  Two are persistent variables, and the rest are dependent variables.  The only variables that change on their own are the two persistents, so the only time that variable gets evaluated (or partially evaluated) is when a persistent changes.

The evaluation of compound statements stops as soon as MAS finds a result that is unchanged.  For instance, if persistent "aaa" is 4, and it changes to 3, MAS will reevaluate fc.GetPersistent("aaa") < 5, and it will discover that the result did not change (aaa is still less than 5), so it won't worry about recomputing whether the result of the "and" has changed.

As for the side question: Yes, if your Lua script is only checking some values to see if they're in range, and using that knowledge to update another variable, a TRIGGER_EVENT will be much more efficient.

By the way, the parser is only semi-smart: as long as you use the same ordering of variables in your conditions, MAS won't generate new variables to handle each case.  For instance, mathematically, 'fc.Apoapsis() * 0.001' and '0.001 * fc.Apoapsis()' have the same value, but MAS will create two variables (and do the multiplication twice).  If you use the same order every time, MAS will create only one variable who will broadcast its results to all interested parties. - so, 'variable = fc.Apoapsis() * 0.001' and 'variable = (fc.Apoapsis() * 0.001) < 5' will both use the results of 'fc.Apoapsis() * 0.001' - it does not get computed twice for the two variables.

Edited by MOARdV
Link to comment
Share on other sites

Hi @MOARdV.

Sorry for bombarding you with questions. I am converting my LUA script into a set of TRIGGER_EVENT entries and have hit the following problem:

[ERR 20:26:12.932] [MASComponent] System.ArgumentException: Error parsing variable "fc.GetPeristentAsNumber("someVariableName") > 0" ---> System.NullReferenceException: Object reference not set to an instance of an object

Is this a bug or something on my part?

For the reference, here is the whole block:

                TRIGGER_EVENT
                {
                 name = Circularisation Assist logic
                 event = RunCA()
                 exitEvent = fc.SetSASMode(0)
                 autoRepeat = false
                 variable = fc.GetPeristentAsNumber("someVariableName") > 0
                }

Ah, and a side question while we are at it: If the "autoRepeat" set to false and the variable goes multiple times from false to true and back again - will the event fire multiple times?

Edited by snakeru
Link to comment
Share on other sites

18 hours ago, snakeru said:

Is this a bug or something on my part?

Is there any other context around that error statement?  By itself, I see nothing in the variable that would be a problem.

18 hours ago, snakeru said:

If the "autoRepeat" set to false and the variable goes multiple times from false to true and back again - will the event fire multiple times?

Yes.  "autoRepeat" means "While this variable is true, call 'event' every single FixedUpdate, not just when the variable becomes true."  You would use this, for instance, to repeatedly update something while the conditions in 'variable' are met.

If "autoRepeat" is false, if means "call 'event' as soon as the variable becomes true.  If it becomes false, call 'exitEvent' (if it exists).  If the variable becomes true again, call 'event'", et cetera.

Link to comment
Share on other sites

I am working on a MAS-based "ascent assist" autopilot. Would anyone volunteer to test it? You'll need a "Making History" mod for that.

The idea is to make launches more predictable in terms of orbit reached and dV remaining. I specifically didn't want to use MechJeb because for me it feels like it takes fun out of the game. You click "Launch" and then you can go away for a few minutes and still find yourself in a perfect orbit once you come back. So to avoid that experience the AA device is not really smart.

The device is very limited in its functionality. It can do, in this particular order: hold vertical attitude (initial ascent), hold near-vertical attitude (initial rotation), hold surface prograde (gravity turn), hold orbital prograde, hold near-horizontal attitude (final touches to your ascent, optional).

image.png

Link to comment
Share on other sites

  • 2 weeks later...

This is my first time using unity and had a few problems. I'm hoping someone here might be able to help me.

I installed Unity and the KSP part tools, and I can view, edit, and add props in the IVAs. My problem is I clicked the "save project" option, but it doesn't seem to save anything; when I reopen the project the next day, it opened the generic project start scene, with a light and camera. Is there a different option I need to click instead? My other issue is I can't figure out how to create the IVA cfg file so I can put it in the game. It's probably really obvious, but this is my first time trying any kind of modding, so any help would be really appreciated.

(Also any pointers or tips would help too.)

Link to comment
Share on other sites

Avionics Systems v0.97.0 is now available.  It has been tested against 1.6.0 and 1.7.0.  This release includes fixes for some potential (and actual) NREs, as well as a patch to replace the map of Kerbin on the Globus instrument with a map of Gael when GPP is installed (map courtesy of @snakeru).

On 4/22/2019 at 3:42 PM, Micro753 said:

I installed Unity and the KSP part tools, and I can view, edit, and add props in the IVAs. My problem is I clicked the "save project" option, but it doesn't seem to save anything; when I reopen the project the next day, it opened the generic project start scene, with a light and camera. Is there a different option I need to click instead? My other issue is I can't figure out how to create the IVA cfg file so I can put it in the game. It's probably really obvious, but this is my first time trying any kind of modding, so any help would be really appreciated.

@Micro753 - If you're able to add the props, you're most of the way there.  To save the IVA config is not obvious - you have to click on the root of the IVA in your Hierarchy window (not the top-most item, but the item that has the IVA model's name):

J8Mfgb.png

Then, the Inspector tab should look similar to this.  That last section is where you save.  The Space Name is the name of the IVA space.  Config Name is the name of the .cfg file that's created.  Dir URL is the folder where you want the config file to be saved.

KHvj81.png

To save your work so you can continue later, you want to Save Scene (or Save Scene As...).

Link to comment
Share on other sites

I have a couple of questions:
 

  1. Were MFDs ever finished?
  2. Did you integrate kOS into MAS, or have plans to do so? I see some references to kOS in the configs but no actual linking.
  3. Is integrating from another mod going to be a PITA? Not that I'm not used to such pains. If there's no official way I'll just hack my way in.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...