Jump to content

Common Launch Script (CLS) [kOS Script] v2.0.0


Qwarkk

Recommended Posts

Common Launch Script (CLS)

What is it?

CLS is an auto-launch script that will put most rockets into a circular orbit of any desired apoapsis and inclination. It attempts to be a 'one-size-fits-all' script. If it takes off vertically and has more than one stage, this script can launch it (hopefully).  I finally feel its in a state that I am confident sharing with the KSP community so that it can be enjoyed / modified / improved by the rest of this amazing community.

Download Link:  Github

Changelog 

Dependencies:  kOS

 

What can it do?

Below is a list of it's main features:

General

  • Launches any 2+ stage rocket into any circular orbit within Kerin SOI (apoapsis & inclination can be configured).
  • Allows a specific launch time (to the second) to be set either by inputting "hh:mm:ss" or number of seconds until launch.
  • Can be set to achieve the highest possible circular orbit for the vehicle's dV and CLS's ascent trajectory.
  • Restricts time warp for code stability based on ascent phase.

Staging

  • Detailed staging logic that handles automatic staging, including those that use ullage separation.
  • Detects impending staging and steers towards prograde for those Korolev style separations we all love.
  • Auto jettisons LES or fairings on ascent based on atmospheric pressure, but not during staging.

Display

  • Provides incremental readouts of vehicle altitude and speed.
  • Continuous display for a range of data.
  • Uses scrolling print for rolling text display.
  • 'Immersive' readouts during countdown, ascent and circularisation.

Engines

  • Throttles down main engines on ascent to limit twr (configurable).
  • Throttles down central booster in 3 booster lifters such as Delta Heavy. Throttles them back up on side booster separation.
  • Throttles down upper stage engines to limit twr (configurable).
  • Throttles to achieve a specific twr at liftoff (configurable).
  • Throttling during ascent is gradual.
  • Accounts for SRBs with thrust curves. Throttles up main engines to account for reducing SRB thrust and jettisons SRBs once thrust < 20%.

Abort / Countdown Holding

  • Continuously checks abort conditions (RUDs, loss of steering control, insufficient thrust, loss of electrical charge) and activates abort action group if a condition is met.
  • Holds launch if electric charge is low, staging is incorrect, liftoff TWR is too low, action groups are incorrect or any background script initialization is not nominal (to avoid mid-ascent errors as much as possible).
  • Holds launch if user input is incorrect (eg target apoapsis within the atmosphere).
  • Launch holds give the user the option to continue the launch, scrub the launch or recycle the countdown depending on the severity of the issue. This uses pilot input (A and N) keys to determine your response. You will need to click off of the kOS terminal for this to work.

Circularisation

  • Continuously monitors data to calculate the best method to achieve orbit and will switch automatically to the most efficient method.  
  • Automatically creates, performs and removes maneuver nodes for circularisation with a high degree of accuracy.

Ascent Profile / Steering

  • Locks orientation of vehicle during ascent (aka the orientation the rocket leaves the VAB in is how it will remain the entire way to space).
  • Uses a standard ascent profile for consistency. Launch profile is only adjusted (automatically) for low TWR vehicles.
  • Continuously monitors the vehicle's time to apoapsis and controls throttle and pitch accordingly.

 

What can't it do?

This script was always written for my own personal use - I have adapted it for a public release. Therefore it has not received testing using any variety of mods or vehicle designs other than my own. As people use this with weird and wonderful designs or different assortments of mods, I'm sure bugs will emerge. Please refer to the bug reporting section below for what to do in this situation to help development.

I also want to say that my kOS writing skills are self-taught and I have no background in doing anything like this. There are probably better ways to write this script, and there are absolutely better kOS writers than me. If you do have any suggestions of how to change the script, please feel free to comment on this post or open an issue on github.

 

Installation Instructions

Copy everything from the zip into your main Kerbal Space Program folder.

 

Future Development

I use the issue tracker on Github to document any features to be added, bugs to be fixed or other general changes to make. You can refer to it here.

 

Usage Instructions

CLS can be run from the archive. If you dont have the 'start on the archive' setting enabled, switch to the archive with the kOS command 'switch to 0.' and then you will be able to run CLS.

More specific instructions for running CLS can be found at the top of CLS.ks.

Many aspects of the script are configurable. Those that are can be found at the top of CLS.ks in the USER CONFIGURATION section.

 

Bug Reporting

If this script fails for you, please either comment on this post or open an issue on github in the issue tracker. In both cases I will need to see a picture of the kOS terminal, the launch parameters inputted and when during ascent it failed. In some cases I may also need a modlist or craft file for further testing.

 

Licensing

This script is distributed under the CC-BY-SA-4.0 license, except where noted below, where those elements are distributed under their own license.

License text can be found here.

 

Licensing Exceptions

lib_navball.ks | lib_lazcalc.ks | lib_num_to_formatted_str.ks - KSLib - MIT.

See license_exceptions for more information.

 

Special Thanks

A huge thank you to /u/only_to_downvote / mileshatem for writing and sharing his amazing launchtoCirc script. CLS is based on his work. I taught myself kOS by deconstructing launchtoCirc bit by bit to understand it and how it works. Then I set about creating my own, but some of mileshatem's original code is in CLS. When i hit a roadblock with ascent profiles, I messaged him on reddit and received some fantastic help.

The kOS dev team for writing their fantastic tutorials and documentation for kOS. Incredibly useful for a new kOS user and taught me a lot.
The kOS dev team (again) for their amazing KSlib libraries. CLS uses them, and seeing how their libraries work taught me a lot.

The fantastic kOS subreddit/community. I hit many roadblocks writing this script and I always found help there. Whether it was reading responses to other's troubles or posting myself, I always found someone with a suggestion. /u/Dunbaratu provided the compass_for_vect function.

Edited by Qwarkk
v2 released
Link to comment
Share on other sites

  • 4 weeks later...

CLS v1.2.0 is now available to download from Github!

This is a pretty big update that I have been working on over the past few weeks. I have tested it as thoroughly as I can, but I may not have caught everything. If you do find any issues, please either comment on this post or open an issue on github in the issue tracker.

ChangeLog

Major Changes:

  • New GUI system for adjusting launch parameters, handled by a new CLS_parameters library. Instead of running 'CLS(250,90 etc).' all that is needed now is 'run cls.'
  • Rewrote the ascent program to use the square root method. This new system improves reliability but may not be as efficient.
  • It is now recommended to avoid a target apoapsis below 100km, as an apoapsis this low is reached too early in ascent, causing the first stage to be discarded and a high dV circularisation burn.
  • Added a new azimuth function for fine tuning inclination. Thanks to u/BriarAndRye for his Instantaneous Azimuth Function. Initial testing suggests this code can reach a target inclination to within 0.001 degrees.
  • Added maxStages as a script parameter allowing more flexibility for SSTOs and 3+ stage rockets.
  • Added a logging function which can log data each 0.5 seconds to a csv file in the logs directory if the user wishes.
  • Redesigned the countdown hold function to use kOS's GUI system and give the user on screen buttons rather than the improvised pilot input method.
  • Rewrote the Abort script steering code. The pod will now perform a slow pitch maneuver away from the rocket to ensure it is clear from any RUDs.
  • Added pre-launch check which determines if there is crew present and holds the launch if there is nothing in the abort action group. This is configurable.
  • Added a contingency if the vehicle loses attitude control and cannot orientate itself for circularisation burn. Engines will throttle up a tiny amount and gimbal to the correct attitude prior to the burn.
  • Limited CLS to a maximum apoapsis of 500km. This fixes an error where direct launches to higher orbits miscalculated the azimuth needed.

Minor Changes:

  • Fixed an error in CLS_hud which occurred when an abort was triggered.
  • CLS_hud new shows remaining fuel as seconds rather than percent.
  • Changed twr calculations during countdown/liftoff to be more accurate.
  • Changed default inclination to 0 rather than 0.1.
  • CLS now automatically removes the circularisation maneuver node before the script completes.
  • Rewrote script initialisation to keep as many variables 'local' to their functions as possible. Should improve initial performance.
  • Much more robust error detection for user input. Previous script was very weak at catching incorrect user input and holding the launch.
  • Tidied up functions and libraries.
  • Changed the method of detecting imminent staging to use fuel flow. This fixed an issue where CLS miscalculated remaining fuel in certain rocket configurations.
  • Vehicle will now pitch gradually to surface prograde just prior to staging. This ensures discarded stages are not subject to unpredictable aero forces.
  • Tuned the script to achieve target apoapsis more accurately. The script now attempts to achieve an apoapsis within 0.02% of its target.
  • Implemented a control to limit upper stage engines to the same max TWR as first stage engines.
  • Various tweaks to make the launch and ascent more efficient.
  • Abort action group only fires if there is crew is on the vehicle.
  • Multi-stage vehicles (Not SSTOs) that reach the target apoapsis without staging will now stage at once out of the atmosphere so that upper stages handle circularisation.
  • Fixed an error in calculating circularisation burn time if the script is waiting to leave the atmopshere before staging (as explained above). Script will now wait until after staging before creating the maneuver node.
  • Removed the throttle down prior to stage seperation. This was in place to limit sudden g-force spikes but interfered with other throttle up/down code in the script.

Enjoy!

Link to comment
Share on other sites

  • 3 months later...

'Under the hood' update for CLS (v1.3.0) is now available to download from Github!

This update changes a lot of things behind the scenes for CLS. It's two major goals were to tidy the code up in order to make it run smoother and to ensure CLS was as compatible as possible with as many mods so that it performs as expected for everyone who tries it. In terms of new features, this update really offers very little.  

Changelog

Compatibility

  • CLS can now automatically determine the fuel type and mass, even for non-stock resources. This allows CLS to work (theoretically) with any resource pack such as realFuels.
  • Ensured CLS is compatible with all rescale mods and planet packs by altering how it handles atmospheric calculations, gelocation and time variables
  • Ensured any calls for the vessel's geolocation will be accurate across rescale mods and planet packs.
  • Reworked part module searches to maximise compatibility with mods that replace stock modules. This was done specifically with realFuels' moduleEnginesRF in mind.
     

Tidy Up

  • Widespread tidy and reformat of a lot of code. Things look tidier, are easier to understand and will hopefully run smoother. 
  • Increased the use of local variables to reduce long, single line equations / calculations.
  • Finally learned how to use BIDMAS to get rid of unnecessary brackets in the formulas.
  • Rewrite of the scrollprint function to make it concise & run a smoother.
  • Removed ‘steerto’ and ‘throt’ variables for steering and throttle control (this was originally done in response to a bug in early kOS versions).
  • Added a separate loop to handle the HUD and monitor resources in Abort script. This removed the need to call those functions multiple times throughout the script.
  • Removed the ‘vess’ parameter from cls_nav functions.
  • The staging check during countdown is now a function instead of one line of messy code.
     

TWR

  • Overhaul of defualt TWR values (all user configurable). Mininimum take off TWR has been increased to 1.3, Upper stage TWR has been increased to 0.8 and max TWR has increased to 4. These changes were made so that CLS can function across stock and rescaled installs in its default configuration.
  • The central engine in a 3-booster configuration now throttles down to 55% slightly different. If the rocket can do this and maintain TWR (by increasing overall throttle) it will do so as early as possible. If not, it will do so when it can maintain a TWR above 2.1 throughout the throttle down. 
     

New Features

  • CLS now gives two new hud readouts during ascent (experiencing max-q and passed through max-q). The code behind this is lightweight, 'hacky' and may not always show up.
  • The abort script is now activated in response to a manual abort during CLS.
  • Any hold scenario that occurs during countdown now gives the option to scrub, continue to launch & abort. Originally it did not give the option to continue in some scenarios. This was a mistake, the player should have final say over whether the rocket launches.
     

Bug fixes

  • Fixed the bug where dV and burn time calculations were inaccurate for vessels with multiple upper stage fuel tanks.

 

Enjoy!

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...
On 8/13/2021 at 10:18 AM, adm-frb said:

Not sure what I've got wrong with my abort procedure... During the launch readiness poll a 'flight controller' keeps calling a 'Hold Hold Hold' at 6 seconds. 

Included craft file and output logs

Output Log

Player Log

Craft File

Apologies its taken so long to get back to you, I've had an extended break from KSP and the forums.

At T-6 seconds the script checks the abort procedure is suitable. Basically, it checks if there is crew on board, and if there is, it checks if you have parts in your abort action group.

I can see from your craft file that you have parts in the abort action group so clearly something isn't working as intended. I will take a look and see what I can find.

Thank you for the info!

On 8/19/2021 at 6:41 PM, jefferyharrell said:

This script is terrific. I've been using it constantly in my JNSQ game.

It's not perfect, though. I've forked it on Github to make a few little tweaks.

https://github.com/jefferyharrell/CLS

I've been away from KSP and the forum for a while but i'm so happy to hear someone getting some good use out of it! 

I have seen your tweaks, how are you finding the script handles 4x warp? The reason it was limited to 2x was that an early version of the script would struggle to execute time-critical commands if in 4x warp. Also are there any features missing from the script you'd like to see added?

Q

Link to comment
Share on other sites

7 hours ago, Qwarkk said:

I have seen your tweaks, how are you finding the script handles 4x warp?

It works fine on my computer, but I've really only used it for testing.

7 hours ago, Qwarkk said:

Also are there any features missing from the script you'd like to see added?

The big thing that's keeping me from using CLS right now is the fact that it can't handle a vehicle with only solids in the first stage. I have a big dumb booster with a giant inline SRB (from Bluedog) as its first stage, and CLS doesn't know what to do with that. I went back to using MechJeb's PVG ascent tool, which works well enough in JNSQ and doesn't have a problem with solid-fueled first stages.

Don't mistake me, though. It's a very good script. I've gotten a lot of use out of it.

Link to comment
Share on other sites

7 hours ago, jefferyharrell said:

The big thing that's keeping me from using CLS right now is the fact that it can't handle a vehicle with only solids in the first stage. I have a big dumb booster with a giant inline SRB (from Bluedog) as its first stage, and CLS doesn't know what to do with that. I went back to using MechJeb's PVG ascent tool, which works well enough in JNSQ and doesn't have a problem with solid-fueled first stages.

This shouldnt be too hard for me to implement - I have a few other things planned for CLS but i'll definitely look into this too.

Link to comment
Share on other sites

On 8/13/2021 at 10:18 AM, adm-frb said:

Not sure what I've got wrong with my abort procedure... During the launch readiness poll a 'flight controller' keeps calling a 'Hold Hold Hold' at 6 seconds. 

Included craft file and output logs

Output Log

Player Log

Craft File

I have managed to recreate your issue and found an interesting problem with CLS. Basically the script wasn't detecting anything in the Abort Action Group, but there are parts there. The problem is that the parts in the abort action group also appear in other action groups. As soon as I removed them from the other action groups, the script works perfectly. 

Kos has some strange logic here. It only recognises the part as belonging to the action group it was added to first. So in your case, the abort parts were probably in one of the other AGs first and then added to Abort afterwards, causing kos not to recognise them as belonging to the abort action group.

 

Edited by Qwarkk
Link to comment
Share on other sites

Hi @Qwarkk:

SOLVED: The problem was the absence of launch clamps.

Trying to use your script, and KOS, for the first time, but running into some trouble, that is probably my fault or interference with another mod.

The problem is that when I launch, the main engine starts to ramp up, but after a few seconds it stages the second stage. It is a simple rocket with just a main engine (Skipper) and a insertion engine (terrier).

Thx

Edited by Tacombel
Link to comment
Share on other sites

4 hours ago, Tacombel said:

Hi @Qwarkk:

SOLVED: The problem was the absence of launch clamps.

Trying to use your script, and KOS, for the first time, but running into some trouble, that is probably my fault or interference with another mod.

The problem is that when I launch, the main engine starts to ramp up, but after a few seconds it stages the second stage. It is a simple rocket with just a main engine (Skipper) and a insertion engine (terrier).

Thx

Hi Tacombel - glad you sorted the issue. This is actually super useful to know, I hadn't thought of making CLS accommodate rockets without launch clamps / fail safes if people try to launch without them. This will be a feature for the next release.

Q

Link to comment
Share on other sites

On 10/4/2021 at 5:13 PM, jefferyharrell said:

The big thing that's keeping me from using CLS right now is the fact that it can't handle a vehicle with only solids in the first stage. I have a big dumb booster with a giant inline SRB (from Bluedog) as its first stage, and CLS doesn't know what to do with that. I went back to using MechJeb's PVG ascent tool, which works well enough in JNSQ and doesn't have a problem with solid-fueled first stages.

So I have spent many hours over the past few days looking into this. As I thought, changing CLS to launch a vehicle with a solid-fuel first stage was relatively easy. However, essentially all of the logic, calculations and script features are designed for liquid fuel stages. The script makes a few core presumptions about the launch vehicle, such as being bi-propellant and having throttling capability. I found that to fully adapt CLS to solid fuel first stages, I was essentially going through CLS's thousands of lines of script and functions and basically saying "if its a solid fuel first stage, just ignore all of this and all of that".  I found myself writing hundreds of new lines specific for this vehicle design and forking the script at almost every turn to either run solid fuel or liquid fuel modes - I didn't like the result. The way I want CLS to function is that no matter the vehicle design the script runs through the same set of instructions and functions, and not that it runs through different instructions and functions for each vehicle design. This is hard enough with SRBs!

I definitely want CLS to be able to handle solid rocket first stages, and it remains a feature i intend to add, but I need to find a new approach to do it. 

Link to comment
Share on other sites

Is it really a problem to launch to a orbit below 250km? I usually launch my rockets to 100km.

Edit: I just went to 100km without problem.

Also, the script stages the second stage when  70km are reached and immediately points to the circularization node, creating a small caos. It would be more beautiful if there where some time between the two events. Staging as soon as target apoapsis is reached would be ok.

Edited by Tacombel
Link to comment
Share on other sites

2 hours ago, Tacombel said:

Is it really a problem to launch to a orbit below 250km? I usually launch my rockets to 100km.

Edit: I just went to 100km without problem.

Also, the script stages the second stage when  70km are reached and immediately points to the circularization node, creating a small caos. It would be more beautiful if there where some time between the two events. Staging as soon as target apoapsis is reached would be ok.

It isn’t a problem, earlier versions of the script just had varying results launching to lower orbits. It’s more of a warning to expect results to vary, but it won’t stop you launching. I can probably review how good the newer script is at hitting these orbits and remove that warning - will do that for the next release.

Can you elaborate more on the situation it stages in at 70km? What is the eta to apoapsis? How many stages does the vessel have in total? What is your target orbit? Is it staging from first to second stage or from second to third stage? There are numerous reasons it may be staging at that point, help me narrow it down and I’ll have a look at changing it slightly  

Link to comment
Share on other sites

Another try failed, this time to 75km. It reduced the throttle to 0.1twr and never reached the target altitude, finally giving a failure message.

On the other matter, is a two stage rocket with a target Ap of 250km. The first one is enough to reach target Ap, so the engine cuts. It keeps coasting until 70km and then stages and simultaneously turns towards the circularization node, creating some confusion.

Link to comment
Share on other sites

7 minutes ago, Tacombel said:

Another try failed, this time to 75km. It reduced the throttle to 0.1twr and never reached the target altitude, finally giving a failure message.

On the other matter, is a two stage rocket with a target Ap of 250km. The first one is enough to reach target Ap, so the engine cuts. It keeps coasting until 70km and then stages and simultaneously turns towards the circularization node, creating some confusion.

75km is a challenge, but I will look into improving this in the next release.

As for the other matter, i will look into it and get back to you.

Link to comment
Share on other sites

2 hours ago, Tacombel said:

Another try failed, this time to 75km. It reduced the throttle to 0.1twr and never reached the target altitude, finally giving a failure message.

On the other matter, is a two stage rocket with a target Ap of 250km. The first one is enough to reach target Ap, so the engine cuts. It keeps coasting until 70km and then stages and simultaneously turns towards the circularization node, creating some confusion.

As it turns out, the first issue is already fixed in the next release of CLS. The next version drastically changes how it handles low orbits so it will definitely be able to cope with 75km orbits. Also, the throttle down when approaching target apoapsis has been scrapped.

As for the second issue, I have now tweaked the procedure the rocket goes through upon achieving target apoapsis. The staging will now be a lot less chaotic but will happen as soon as target apoapsis is reached - it wont even wait until 70km.

Edit: The next release of CLS is 1 or 2 days away. Its quite an update too.

Edited by Qwarkk
Link to comment
Share on other sites

  • 2 weeks later...

CLS v1.4.0 is now available from Github!

This update has been a long time in the works and I have taken some extensive breaks from KSP which slowed its release. Every time I release a new version of CLS, I always feel like its the finished product with little left to add, and then a few weeks later, a new idea will hit me and mass changes will be made. This time though, I really do think CLS is on the home stretch to be finished. There are one or two features I want to implement, but apart from those I think most of the changes from this point onwards will be bug fixing.  

Changelog

Abort

  • The abort procedure included in CLS v1.3.0 relied upon another script (ChuteDescent.ks) which I completely forgot to upload. Apologies!
  • ChuteDescent handles chute deploy on the aborted capsules descent. I split it into it's own script as it can also be used for a capsule re-entering the atmosphere.

Minor Changes

  • Improved CLS logic for detecting incorrect staging where SRBs are incorrectly placed in first stage.
  • CLS now has a system of excluding hullcam parts from its staging checks and part counts.
  • CLS can now detect the presence of fuel cells on the vehicle and will activate them automatically if EC is below 25%.
  • I can't spell separation/separated/separate it seems. Corrected the spelling (thank you jefferyharrell)
  • Added a check to confirm engines are throttling correctly at T-0. I found that the script was aborting some launches when it didn't need to due to throttle 'lag'.
  • The ship will hold pitch a for 3 seconds after staging to ensure the next stage is clear of the previous stage before pitching.
  • Staging will now occur when SRBs are below 25% thrust, not 20% (for SRBs with thrust curves).
  • More accurate launch throttle calculations and ascent throttling when using SRBs with thrust curves.
  • Warp limit increased during coast phases. The script will also reduce the warp level progressively approaching a burn.
  • CLS will now hold the launch if launch clamps aren't detected and suggest a scrub (Thanks go to Tacombel for highlighting this issue)
  • Staging at ascent completion has been adjusted to make it smoother and less chaotic.
  • Removed throttle down when approaching target apoapsis.
  • General script writing tweaks
  • Ascent profile is more aggressive resulting in improved efficiency.
  • CLS now checks if the circularising engine has an unlocked gimbal before using it for attitude control if the vessel isn't correctly orientated for circularisation burn. Also only throttles to 0.1twr rather than 10% thrust (which may have been overkill for upper stages with high thrust engines)
  • Pretty extensive renaming of variables and functions so that their names indicate what they do.
  • CLS logs are now named with the real world time of launch.

EC Consumption 

  • Complete review of the script in an attempt to reduce the amount of electrical charge CLS requires to run.
  • 33% reduction in EC consumption during launch and ascent.
  • 50% reduction in EC consumption during coast due to CLS now entering a 'low-power' mode.
  • CLS will now also put all control parts into hibernation mode during the coast phase.

HUD

  • Complete redesign of the bottom HUD elements.
  • During pre-launch, if a scrub/hold occurs there is now a 'More info' button which will explain the cause of the hold to assist you in solving the issue and successfully recycling the launch sequence.
  • Added a readout to show which runmode the script is in next to the Mission Elapsed Time on the HUD.
  • The fuel readout has been updated. It used engine fuel flow to calculate remaining fuel - accurate when the engines are burning, but inaccurate during coast phases when fuel flow is 0. So now it will show remaining fuel if engines were to burn at 100% thrust while in coast phases.
  • Time to apoapsis/periapsis readout now shifts over to show minutes when it would exceed 999 seconds.
  • CLS will now detect precise moment of Max Q rather than a time frame in which it happens.
  • CLS now gathers more information for the HUD during pre-launch.

dV changes on Orbit

  • The concern here is that boil-off or use of fuel cells will reduce the vehicles remaining dV which means it will not be able to complete circularisation burns.
  • CLS accounts for this by ensuring the vehicle has around a 5% dV margin for upcoming burns. 
  • 1.4.0 adds a fail safe so that if boil-off or fuel cell usage has reduced the vehicle's dV to below a burn's dV requirement, it will not cause script failure. This is done by recalculating vehicle dV just before a burn and amending the maneuever node's properties if necessary.
  • In these scenarios, the final orbit achieved by CLS will not be circular.

Achieving Orbit

  • This is a major change and the code to implement this system is spread all through CLS and its libraries - I will summarise what it does below.
  • Previous versions of CLS were very basic in that the vehicle would burn until apoapsis reached a target orbit altitude, cut-off its engines and then burn at apoapsis to circularise the orbit. This presented issues with low orbit altitudes just outside the karman line or situations where it left the upper stages with unrealistic circularisation burns.
  • Now, the script has multiple methods of circularising:
  1.    As before, circularising at apoapsis.
  2.    First burn is longer and stops when periapsis reaches the target orbit altitude. Then at periapsis, the vehicle burns retrograde to achieve a circular orbit.
  3.    Same approach as number 2, but the script sees the apoapsis is getting extremely large, so it cuts the engine, burns at apoapsis to raise the periapsis to target orbit, and then burns retrograde at periapsis to circualrise the orbit.
  • The script continuously monitors multiple data streams to determine which approach is best.
Link to comment
Share on other sites

3 hours ago, Tacombel said:

At the same time that I was testing, I was changing the absolute paths of your scritp to relative paths, because I prefer to have all your files in a subdirectory, so perhaps I screwed something, but I am getting this when launching the script

Nothing to do with the paths, just a complete oversight on my behalf. CLS presumed that all engine parts have the module 'ModuleEnginesFX' and this isn't the case. I've corrected it in CLS v1.4.1 now available to download. 

Thank you for the feedback and providing me with the screenshot.

Link to comment
Share on other sites

  • 3 weeks later...

This doesn't appear to be working for me. I'm completely new to kOS so I have no idea what's going on. I accidentally told it to launch my rocket in 10 years instead of seconds, and while trying to figure out how to kill the script, I accidentally staged and dropped my rocket on the ground. The console spit out this.

A0KoOdQ.png

EDIT: by the way, this script does not play nice with the case-sensitive file system on Linux.

lrw974C.png

Edited by ruiluth
Link to comment
Share on other sites

On 11/14/2021 at 12:48 PM, ruiluth said:

This doesn't appear to be working for me. I'm completely new to kOS so I have no idea what's going on. I accidentally told it to launch my rocket in 10 years instead of seconds, and while trying to figure out how to kill the script, I accidentally staged and dropped my rocket on the ground. The console spit out this.

A0KoOdQ.png

EDIT: by the way, this script does not play nice with the case-sensitive file system on Linux.

lrw974C.png

Thanks for the feedback - manually staging your craft while CLS is running is a deal breaker and will always cause errors. From the kOS output, it looks like by staging the vehicle, the part CLS was monitoring fuel levels for was jettisoned and it threw an error. Is the script working as normal when you dont stage? 

As for the Linux file system, im on windows so I cant test or change this - can you tell me which files Linux drops into those two folders?

Link to comment
Share on other sites

15 hours ago, Qwarkk said:

As for the Linux file system, im on windows so I cant test or change this - can you tell me which files Linux drops into those two folders?

I looked through all the non-source releases of CLS on github, and they all have consistent capitalization of that folder name. The first thing I suspected was that maybe different versions had used different capitalizations, and he'd unpacked a newer version over an older one, but that rules that out, so about the only thing I can imagine is if files are being dropped into the folder at runtime.

With a quick search through the folder tree, I found the following locations where files are referenced with an all-lowercase path (filename:line-number:text-of-matching-line):

Ships/Script/Abort.ks:53:runpath("0:/cls_lib/lib_num_to_formatted_str.ks").
Ships/Script/Abort.ks:54:runpath("0:/cls_lib/lib_navball.ks").
Ships/Script/Abort.ks:55:runpath("0:/cls_lib/CLS_nav.ks").
Ships/Script/CLS.ks:49:runpath("0:/cls_lib/CLS_parameters.ks").
Ships/Script/CLS.ks:89:runpath("0:/cls_lib/CLS_dv.ks"). 
Ships/Script/CLS.ks:90:runpath("0:/cls_lib/CLS_gen.ks").
Ships/Script/CLS.ks:91:runpath("0:/cls_lib/CLS_hud.ks").
Ships/Script/CLS.ks:92:runpath("0:/cls_lib/CLS_nav.ks").
Ships/Script/CLS.ks:93:runpath("0:/cls_lib/CLS_res.ks").
Ships/Script/CLS.ks:94:runpath("0:/cls_lib/CLS_twr.ks").
Ships/Script/CLS.ks:95:runpath("0:/cls_lib/CLS_ves.ks").
Ships/Script/CLS.ks:96:runpath("0:/cls_lib/lib_instaz.ks").
Ships/Script/CLS.ks:97:runpath("0:/cls_lib/lib_lazcalc.ks").
Ships/Script/CLS.ks:98:runpath("0:/cls_lib/lib_navball.ks").
Ships/Script/CLS.ks:99:runpath("0:/cls_lib/lib_num_to_formatted_str.ks").
Ships/Script/CLS.ks:100:runpath("0:/cls_lib/CLS_log.ks").
Ships/Script/ChuteDescent.ks:3:runpath("0:/cls_lib/lib_num_to_formatted_str.ks").
Ships/Script/ChuteDescent.ks:5:runpath("0:/cls_lib/lib_navball.ks").
Ships/Script/ChuteDescent.ks:6:runpath("0:/cls_lib/CLS_nav.ks").

It's a bit odd, because it doesn't look like those files are being written to, but if they're just being read, I'd expect that A) It wouldn't create the files referenced, and B) CLS would fail to find the files and wouldn't work, but it seems it's managing to use the wrong-case filename to reference the files in the right-case directory, and is then creating the wrong-case directory and copying the files to it.

About the only thing I can imagine is if something in the middleware stack between Linux and CLS (most likely Mono, maybe KSP itself) is aware that it may be run on multiple platforms and, when it doesn't find a file, is proactively looking for files that exist with mismatched case, then copying them to the path that's being referenced. I'm not sure that's the best solution; what if the user unpacks a new version of CLS over the right-case folder tree? That won't update the wrong-case files, and they'll likely be referenced instead of the right-case ones, so I wish it would just choke early on the bad filename rather than saving the day now and potentially causing subtle and tricky problems later, but that's not anything you can fix. All you need to do is make sure that you're always referencing files with the same case that they have on the filesystem, and then it doesn't matter what the middleware is doing on the back end.

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...