xeger / kos-ramp

Relatively Adequate Mission Planner: a rudimentary, scriptable autopilot for kOS.
Other
55 stars 23 forks source link

utilFaceBurn ruins otherwise working script (node.ks) #36

Open ghost opened 6 years ago

ghost commented 6 years ago

I am working on node.ks and have working version, but once I add utilFaceBurn it stops working correctly. I do not even have the necessary sensors, but it seems to slow things so much, that there is no time for the CPU to do what is needed.

  1. JSON? Why? Why not global variable? Why reading it in LOCK EXPRESSION?! Over and over again?
  2. WAIT INSIDE LOCK EXPRESSION?! KOS WARNS NOT TO DO THAT!!! ....but that is not the problem in my current testing because it actually never reaches this point.

If it is helping in some scenairo then it either has to work properly or needs some opt-in mechanism.

P.S.: Something like that should, in my opinion, be handled by balancing the engines - adjust throttle limits to make the thrust vector in line with CoM.

ghost commented 6 years ago
  1. Should use global variable (utilFaceBurnOSS/Data).

  2. Needs quick test (e.g. HasSensors) to return the argument ASAP, if doing nothing. Separate global variable for this would be best (utilFaceBurnInUse/Usable or something like that, maybe tri-state: true, false, "init").

  3. Either must not contain WAIT, or the description has to be changed. LOCK and WAIT cannot be used together.

  4. I would separate initialization (containing check wether to use it or not) and saving/loading the JSON:

    • utilFaceBurnInit loading JSON and returning true if requirements met, false to signalize that you need not to call utilFaceBurn (as it would return the argumant ASAP anyway).
    • utilFaceBurnFinish to store JSON (added at the end of script, no big harm if somebody forgets to call it)
  5. A test rocket/shuttle would be good. Maybe we should create a set of test rockets packed with test scripts.

fellipec commented 6 years ago

Coming back after some time.

ghost commented 6 years ago

@fellipec To be honest with you, I have already left this repository and do not plan to return. I have my own set of scripts and even my own version of kOS: https://github.com/firda-cze/KOS and some accepted and some pending PR's in official kOS e.g. https://github.com/KSP-KOS/KOS/pull/2256

If I remember correctly, utilFaceBurn is not inherently bad, but contains some heavy instructions and WAIT and therefore should never be used inside LOCK. Could be fine outside, but I didn't fully understand how it works and was thus unable to use it. Try putting it back into https://github.com/xeger/kos-ramp/blob/master/node.ks