Board index FlightGear Support Flying

Autostart from command line

Controlling your aircraft, using the autopilot etc.

Autostart from command line

Postby jonititan » Wed Oct 04, 2017 10:23 am

I've done a little messing around and written a script to start flightgear as I wish
https://github.com/jonititan/FlightGear-Customisations/blob/master/CommandLineStart.py

However I currently haven't found a way to use the autostart feature from the command line.

My backup plan is to just step through the checklist after startup using telnet as I'm not really interested in flying personally but just starting the sim in arbitrary situations and then writing AI to use with it.

I've been over the wiki and the Nasal stuff but can't currently see anything obvious regarding calling the the autostart function from systems.nas

Thanks in advance for any help.
Joni P
Flight Data guy.
Ask me about artificial immune systems for health management of unmanned aircraft...
jonititan
 
Posts: 15
Joined: Fri Sep 29, 2017 2:04 pm

Re: Autostart from command line

Postby Thorsten » Wed Oct 04, 2017 11:17 am

There's no such thing as an autostart function in FG - such a feature may or may not be present in different aircraft and usually the way it works internally is different from aircraft to aircraft.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Autostart from command line

Postby jonititan » Wed Oct 04, 2017 11:40 am

Yes I do understand that there is no autostart function. However for the specific aircraft I am using A320 there is an autostart menu item which I have to manually click after startup has finished. As I understand it the functionality there is given through some some nasal code in Aircraft/A330-200/Nasal/systems.nas and I wondered if there was a way to trigger it from the command line.

I would just prefer to use the existing Nasal code instead of replicating it over telnet after startup.

Edit: Specifically on line 214 of the version I have.
Joni P
Flight Data guy.
Ask me about artificial immune systems for health management of unmanned aircraft...
jonititan
 
Posts: 15
Joined: Fri Sep 29, 2017 2:04 pm

Re: Autostart from command line

Postby Thorsten » Wed Oct 04, 2017 1:08 pm

No, you can not call arbitrary Nasal from the commandline (what mess that would make...). You can write code that polls a property inside the aircraft Nasal and based on that autostarts or not, but you have to prepare the aircraft Nasal to do that.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Autostart from command line

Postby jonititan » Wed Oct 04, 2017 2:00 pm

Can arbitrary nasal be called from telnet or over UDP then? (Or does flightgear messiness prevent that also?)

I can quite easily poll properties so perhaps I just call the function from telnet after flightgear has finished starting up.

Over telnet using the provided example python code from https://sourceforge.net/p/flightgear/flightgear/ci/next/tree/scripts/python/
"run A320-200.systems.autostart" fails
"run nasal A320-200.systems.autostart" returns <completed> but doesn't actually have any visible effect in the cockpit.

Edit:
"run nasal aircraft.systems.autostart" also returns <completed> but doesn't actually have any visible effect in the cockpit.

"run nasal A320-200.systems.startup" also returns <completed> but doesn't actually have any visible effect in the cockpit.

"run nasal aircraft.systems.startup" also returns <completed> but doesn't actually have any visible effect in the cockpit.
Joni P
Flight Data guy.
Ask me about artificial immune systems for health management of unmanned aircraft...
jonititan
 
Posts: 15
Joined: Fri Sep 29, 2017 2:04 pm

Re: Autostart from command line

Postby legoboyvdlp » Wed Oct 04, 2017 2:08 pm

You *may* wish to use the IDG-A32X. It has a dedicated startup system, where you can either have the aircraft ready for takeoff, ready for taxi, or ready to startup.
Run acconfig.takeoff(); to be configured with engines running, lights on, speedbrakes armed, flaps deployed etc.
Run acconfig.taxi(); to be configured with engines running only.


Bear in mind that the IDG-A32X is a very complicated aircraft, and it may or may not suit your purposes.
User avatar
legoboyvdlp
 
Posts: 7981
Joined: Sat Jul 26, 2014 2:28 am
Location: Northern Ireland
Callsign: G-LEGO
Version: next
OS: Windows 10 HP

Re: Autostart from command line

Postby Thorsten » Wed Oct 04, 2017 2:20 pm

Can arbitrary nasal be called from telnet or over UDP then? (Or does flightgear messiness prevent that also?)


Not that I would know of (by the way, the ability to start arbitrary Nasal would potentially make a mess imo, it's not prevented by messiness).
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Autostart from command line

Postby jonititan » Wed Oct 04, 2017 2:28 pm

Thanks for the tip legoboyvdlp I'll have a look.

Thorsten I thought that was the point of Nasal? Isn't that why you have a Nasal console I can bring up from within the flightgear instance? The problem here is not that the routine doesn't exist already it's just trying to understand how to trigger it programatically and what structures there are to assist with that.
Joni P
Flight Data guy.
Ask me about artificial immune systems for health management of unmanned aircraft...
jonititan
 
Posts: 15
Joined: Fri Sep 29, 2017 2:04 pm

Re: Autostart from command line

Postby Thorsten » Wed Oct 04, 2017 2:35 pm

Thorsten I thought that was the point of Nasal?


To be started from the commandline? Hardly.

Isn't that why you have a Nasal console I can bring up from within the flightgear instance?


That's for debugging, as evident from the fact that it's grouped under that menu heading.

I suppose the point is that what you ask can easily be accomplished by... coding some Nasal (in fact, a single line). It's not clear to me why that is not an option.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Autostart from command line

Postby jonititan » Wed Oct 04, 2017 2:56 pm

Thorsten wrote in Wed Oct 04, 2017 2:35 pm:can easily be accomplished by... coding some Nasal (in fact, a single line). It's not clear to me why that is not an option.


It is an option? It just isn't immediately obvious from the documentation how that would be done as something separate.
http://wiki.flightgear.org/Using_Nasal_functions is great I guess but if this need to startup an aircraft in flight is quite so simple and from reading the forums seems quite requested it isn't obvious why it isn't on the wiki as an example.
Joni P
Flight Data guy.
Ask me about artificial immune systems for health management of unmanned aircraft...
jonititan
 
Posts: 15
Joined: Fri Sep 29, 2017 2:04 pm

Re: Autostart from command line

Postby Octal450 » Wed Oct 04, 2017 2:58 pm

I'm planning to add a property to the IDG-A32X and IDG-A33X which when true, the plane loads in with the config in the Ready for Taxi and another for Ready for Takeoff configuration. That you can set this property from the command line, before FGFS loads, and once the initialization is complete, the config will automatically startup the aircraft.

Kind Regards,
Josh
Skillset: JSBsim Flight Dynamics, Systems, Canvas, Autoflight/Control, Instrumentation, Animations
Aircraft: A320-family, MD-11, MD-80, Contribs in a few others

Octal450's GitHub|Launcher Catalog
|Airbus Dev Discord|Octal450 Hangar Dev Discord
User avatar
Octal450
 
Posts: 5583
Joined: Tue Oct 06, 2015 1:51 pm
Location: Huntsville, AL
Callsign: WTF411
Version: next
OS: Windows 11

Re: Autostart from command line

Postby Thorsten » Wed Oct 04, 2017 3:13 pm

It is an option?


Well, the autostart function is called from a Nasal GUI binding - rather than doing that, you can also add a line calling it right in the *.nas file where the function is defined (you might have to use a timer for a delay for the FDM to start up) - then the plane will always execute autostart upon startup.

You can call aircraft Nasal function from the aircraft Nasal, yeah. You can also add a Nasal file to your own FGData directory that calls the aircraft autostart function (using the aircraft namespace). You can also put in a condition on a property such that autostart gets only run whenever you set a property upon startup (same as Josh plans it).
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Autostart from command line

Postby jonititan » Wed Oct 11, 2017 1:14 pm

As discussed it was reasonably straightforward once I dug into the Nasal.
I set a property with a listener in acconfig.nas for the IDG-A33X aircraft and then just activated it using Telnet.
This is my code.
Code: Select all
setprop("/systems/acconfig/autostart-taxi", 0);
setlistener("/systems/acconfig/autostart-taxi", func {
   if (getprop("/systems/acconfig/autostart-taxi") == 1 ) {
      taxi();
                setprop("/systems/acconfig/autostart-taxi", 0);
   }
});


I used the python telnet example from jam007. https://forum.flightgear.org/viewtopic.php?p=307251# It works better than the one in the flightgear src.

My code to start the airliner at cruise was as follows
Code: Select all
fgtn=FGTelnet()
print(fgtn.host)
fgtn.setprop("/systems/acconfig/autostart-taxi", "1")
while True:
    current_val = fgtn.getprop("/systems/acconfig/autoconfig-running")
    print('Waiting '+current_val)
    if fgtn.getprop("/systems/acconfig/autoconfig-running") == '0':
        print('Autoconfig Finished!\nSetting Flight Details')
        break
fgtn.setprop("/position/altitude-ft", "36000")
fgtn.setprop("/controls/gear/gear-down", "false")
fgtn.setprop("/velocities/airspeed-kt", "270")
fgtn.setprop("/velocities/glideslope", "1")
fgtn.setprop("/orientation/heading-deg", "0")
fgtn.setprop("/orientation/roll-deg", "0")
fgtn.setprop("/orientation/pitch-deg", "0")
fgtn.setprop("/it-autoflight/input/alt", "36000")
fgtn.setprop("/it-autoflight/input/spd-kt", "270")
fgtn.close()


I haven't fully figured out the autopilot logic to set it steady but it's only a matter of time and I can always just disable fdm etc and drive things directly over UDP apparently.
Joni P
Flight Data guy.
Ask me about artificial immune systems for health management of unmanned aircraft...
jonititan
 
Posts: 15
Joined: Fri Sep 29, 2017 2:04 pm

Re: Autostart from command line

Postby Octal450 » Wed Oct 11, 2017 4:38 pm

Hi jonititan
Nice work.

I'll add something similar soon.

You can see the IT-AUTOFLIGHT SDK on the wiki: http://wiki.flightgear.org/IT-AUTOFLIGHT#SDK

It explains how to send commands to and from IT-AUTOFLIGHT. The A33X uses a customized version of IT-AUTOFLIGHT as it's autoflight system.

I must warn about disabling the the FDM, the aircraft's systems use many properties from it, and many instruments and logic is tightly connected to the FDM, it would be a major reprogramming task.

Kind Regards,
Josh
Skillset: JSBsim Flight Dynamics, Systems, Canvas, Autoflight/Control, Instrumentation, Animations
Aircraft: A320-family, MD-11, MD-80, Contribs in a few others

Octal450's GitHub|Launcher Catalog
|Airbus Dev Discord|Octal450 Hangar Dev Discord
User avatar
Octal450
 
Posts: 5583
Joined: Tue Oct 06, 2015 1:51 pm
Location: Huntsville, AL
Callsign: WTF411
Version: next
OS: Windows 11


Return to Flying

Who is online

Users browsing this forum: No registered users and 8 guests