Jump to content

Speedy Copilot


XPJavelin
 Share

Recommended Posts

34 minutes ago, XPJavelin said:

NOTE : to declutter the code you can transform

if os.clock() > r_trigger_start_time +1 then
w_acft_flap = 0.5
end 

into

if os.clock() > r_trigger_start_time +1 then w_acft_flap = 0.5 end 

Thanks - and with all the thinking my brain can do, I do not know why i've done it as per my original note. 

Just putting some more lines together in my lunch (for my shutdown routine) looks much neater per your suggestion :- (I've intentionally put the same time on some actions - I want my first officer using all fingers when he can! :) 

 

if r_includeIRS then 
if os.clock() > r_trigger_start_time + 1 then w_acft_irsL = 0 end
if os.clock() > r_trigger_start_time + 2 then w_acft_irsR = 0 end 
end 

if os.clock() > r_trigger_start_time + 4 then w_acft_fuelLfwd = 0 end
if os.clock() > r_trigger_start_time + 4 then w_acft_fuelLaft = 1 end -- leave on for apu 
if os.clock() > r_trigger_start_time + 5 then w_acft_fuelRfwd = 0 end
if os.clock() > r_trigger_start_time + 5 then w_acft_fuelRaft = 0 end

if os.clock() > r_trigger_start_time + 6 then w_acft_winheat_l_side = 0 end
if os.clock() > r_trigger_start_time + 6 then w_acft_winheat_l_fwd = 0 end
if os.clock() > r_trigger_start_time + 7 then w_acft_winheat_r_side = 0 end
if os.clock() > r_trigger_start_time + 7 then w_acft_winheat_r_fwd = 0 end
if os.clock() > r_trigger_start_time + 8 then w_acft_pitot_a = 0 end
if os.clock() > r_trigger_start_time + 9 then w_acft_pitot_b = 0 end

if os.clock() > r_trigger_start_time + 10 then w_acft_hydELEC2 = 0 end
if os.clock() > r_trigger_start_time + 11 then w_acft_hydELEC1 = 0 end

if os.clock() > r_trigger_start_time + 14 then w_acft_seatbelt = 0 
if os.clock() > r_trigger_start_time + 15 then w_acft_beaconLIGHT = 1

 

Link to comment
Share on other sites

The problem with the above code is that you cannot have it in a function which is only executed once... you will never get to most of the steps.

The current code has a conditional check for PREFLIGHT to see that preflightproc_trigger == 0 and beforestartproc_trigger == 0 and OXYTEST == 1

Now this means that the actual code inside the function will only execute once. On the second pass all the above variables will not meet the condition again. So you will never get to os.clock() > r_trigger_start_time + 4 and further.

So one possible solution is to change the conditional check to make sure that the code inside the function is repeated until all steps have been completed. This is what is adding to the clutter because now you have to make sure that you don't repeat a previously executed step and and that all steps are still done in the right order.

Anyhow, I will upload my lua file (once done) with my modified code for the PREFLIGHT procedure and you guys can then have a look to see if it's not too much clutter in the code.

 

  • Upvote 1
Link to comment
Share on other sites

1 hour ago, jfjoubert said:

The problem with the above code is that you cannot have it in a function which is only executed once... you will never get to most of the steps.

The current code has a conditional check for PREFLIGHT to see that preflightproc_trigger == 0 and beforestartproc_trigger == 0 and OXYTEST == 1

Now this means that the actual code inside the function will only execute once. On the second pass all the above variables will not meet the condition again. So you will never get to os.clock() > r_trigger_start_time + 4 and further.

So one possible solution is to change the conditional check to make sure that the code inside the function is repeated until all steps have been completed. This is what is adding to the clutter because now you have to make sure that you don't repeat a previously executed step and and that all steps are still done in the right order.

Anyhow, I will upload my lua file (once done) with my modified code for the PREFLIGHT procedure and you guys can then have a look to see if it's not too much clutter in the code.

 

Mmm :huh: Well said.

Link to comment
Share on other sites

As promised...

IMPORTANT NOTE TO ALL: This file is not a complete replacement for the original code from @XPJavelin. It simply shows a way of applying some randomness in the procedure steps.

Please also note:

  • The code was only modified for the PREFLIGHT Procedure (start with OXYGEN test switch)
  • You can easily change the min and max time (in seconds) for the random delay in the code
  • I re-enabled some of the datarefs and made some "readonly" to be able to do some conditional checks
  • If you don't know FlyWithLUA or LUA or you don't care about the underlying code then wait for an official update from @XPJavelin
  • This will only happen if @XPJavelin wants to incorporate this into his code

@XPJavelin I did add comments as far as possible to the code so hopefully it will make sense. Shout if anything is unclear.

IXEG_proc.lua

Edited by jfjoubert
  • Like 1
Link to comment
Share on other sites

thanks @jfjoubert,I will investigate your work, in the mean time, I was working on a revision of my script to include after landing flow with and without APU.

I also added altitude constraint for flaps retraction, compatible with the go around triggers,  and runway Entry procedure is triggered by left inboard landing light instead of left outboard.

Both as suggested by @blocks_off

Link to comment
Share on other sites

3 hours ago, jfjoubert said:

The problem with the above code is that you cannot have it in a function which is only executed once... you will never get to most of the steps.

Yes that is true of the code I posted earlier, but not if taking this into account i.e. it's part of a function as described here.

 

2 hours ago, XPJavelin said:

Mmm :huh: Well said.

As above

Link to comment
Share on other sites

@blocks_off Correct me if I'm wrong but won't your code execute the same steps multiple times until the 22 seconds have passed and r_trigger_shooting_approaches is set to false?

It should work if you conditionally check each item and only set it once like this:

if os.clock() > r_trigger_start_time +1 then
	if w_acft_flap ~= 0.5 then w_acft_flap = 0.5 end
end 

Otherwise you might end up hearing all the click sounds in the cockpit when switches are set to a specific position, even though they might already be in that position from a previous loop through the function.

Anyway, it could work. I just felt like typing a lot of code... ;)

Link to comment
Share on other sites

Hi @jfjoubert

You are correct with what you say and it is great fun testing when you move a switch to a different position, then it moves it back :) but i digress..... I do not hear repeated clicks, there are a few steps where I check for the state and then only set if it is not in the correct position for that routine such as gear handle, start switches.

I've had a quick look at your code, and as much as I like the randomness idea, I will park it for now :) Well done though with that achievement... did you drink a lot of your favorite drink whilst writing it ;) ?

Thanks for your reply and interest

-Carl

Edited by blocks_off
Link to comment
Share on other sites

I am looking for something simple in my code.

It was very convenient to read the FCOM and just translate in a few command lines, in a very straighforward way. I am not sure I am ready to sacrifice simplicity for human delay of actions.

12 hours ago, jfjoubert said:

if os.clock() > r_trigger_start_time +1 then if w_acft_flap ~= 0.5 then w_acft_flap = 0.5 end end

I like that way of doing however.

I will think about it.

In the mean time, I was thinking of implementing a GUI menu to set options (F30 of F40, with or without APU...)

Link to comment
Share on other sites

During last week end, the download has been corrected and updated to version 3. I suggest you do a full download again for v3.0. (I might upload version 3.1 soon with bug fixes  as I have more tests to do, and then you will only have to download the small lua script update) . 

Options2.png.9bb179a5c15fd79a0620243f7aa7a84c.png

Now it is possible to set copilot options like flaps settings for landing. 

It is now possible to set them in the xplane menu. 

Also, we have now slowed down the copilot for various procedures at some steps, using os.clock without totally removing simplicity in the mean time... :-) 

Change log
* v 3 : Copilot works in a more realistic way, with delays between actions.
* v 3 : Options are now changed in X-Plane menu → Fly with Lua entry, instead of cockpit knobs.
* v 3 : New option : user can deactivate flaps and gear by F/O.

Speedy Copilot_3.pdf

Edited by XPJavelin
new documentation added
Link to comment
Share on other sites

I have uploaded the stable version 3.15 !

I had time to test it tonight, find & repair some bugs, both severe and minors.

I am confident I have reached a stable state (without severe bug) with nice features now. Therefore, from now on, I will reduce the updates rate ! From version 1 to version 3, I have implemented various ideas thanks to feedback from users (Jean Joubert , Carl) . With this fully operational version 3.15, it's time to freeze the features1.

Hope you'll like it.

1Of course, if any user finds a bug, I can certainly publish code revisions as I am fully open to comments.

Edited by XPJavelin
  • Like 1
Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...