hvacengi Posted December 3, 2016 Share Posted December 3, 2016 Or we could expose a way to get a "max scalar", since you can probably reliably know that you won't overflow the double precision floating point number, and if you do you'll break all the math in kOS anyways. Link to comment Share on other sites More sharing options...
Dunbaratu Posted December 3, 2016 Share Posted December 3, 2016 1 minute ago, Waz said: So, for consistency, STRING:ISNUMBER? Yeah I had that idea as I was editing my previous response. I was reluctant because it means pointlessly doing the work of parsing the string to a number twice. (That's also one of my arguments for why nulls are superior to having all these HASwhatever suffixes all over... grumble grumble.... doing the work to find out *if* a value is obtainable usually means doing the work to attempt to obtain the value and then noticing it failed, so testing first with HASwhatever, followed by then getting the value, ends up repeating that work pointlessly). But it's now such a deeply embedded design decision that I'm reluctant to go back and change it. But at any rate, efficiency isn't exactly a big deal with kOS. We're so many layers removed from the raw hardware anyway that parsing a string to number twice instead of once is probably not that big a deal, so we can probably add ISNUMBER. Link to comment Share on other sites More sharing options...
Waz Posted December 3, 2016 Share Posted December 3, 2016 (edited) Alpha8 of the GUI is up. I've been slowly tweaking the API for best usability, but still keen to here anything you feel is awkward or strange. Specifically, STYLE:BG_FOCUSED is now STYLE:FOCUSED:BG and there is also STYLE:FOCUSED:TEXTCOLOR (and the same for ACTIVE, NORMAL, HOVER, etc.). This release also includes a tutorial on making a self-contained TabWidget (see the GameData/kOS/html directory), and minor bugfixes for radiobuttons over comm delay. https://github.com/WazWaz/KOS/releases/ Edited December 3, 2016 by Waz Link to comment Share on other sites More sharing options...
Dunbaratu Posted December 3, 2016 Share Posted December 3, 2016 4 minutes ago, hvacengi said: Or we could expose a way to get a "max scalar", since you can probably reliably know that you won't overflow the double precision floating point number, and if you do you'll break all the math in kOS anyways. Exposing max and min numbers probably isn't such a bad idea. They make good sentinel values for other purposes. Link to comment Share on other sites More sharing options...
kcs123 Posted December 3, 2016 Share Posted December 3, 2016 1 hour ago, Steven Mading said: I suppose we could extend the HASwhatever model and introduce a means to query if the string *would* be translatable to a number without actually returning that number. String:ISNUMBER or something like that. I proposed additional suffix to check if string have valid number or not in first post where I discovered need for conversion of string to number. It was possible for me to change kOS function for conversion string to scalar because kOS accept any kind of data to be assigned to varable. Doing that trough C# is probably bad idea, so additional suffix ISNUMBER or HASNUMBER, whatever you think is better to call it to fit with other keywords used in kOS, would be much better. Simple true/false value is sufficient with it. It is not absolutely need, but it will be good if such thing can be extended to expressions. Probably a lot harder than with string conversion, but once it is included in string we could use something like this: set MyScalar to 0. if MyScalar:ISNUMBER(1/0) = true then { print "Expression is valid number". } else { print "Expression does not return number". }. That could possibly cover all needs to check out does it something NaN or not. User than can use that info in code to deal something in one way or another. defaultError value to return from Mystring:TONUMBER(defaultError) can stay like it is, it could be useful in some situations to "reset" values to some defaults in cases of error. Link to comment Share on other sites More sharing options...
TK-421 Posted December 3, 2016 Share Posted December 3, 2016 In Galileo's planet pack, there is a moon named Eta. This makes the eta alias unusable. print BODY("Eta"):apoapsis. 11708000 print eta:apoapsis. 11708000 Is there an alternate way to get at the ETA? Link to comment Share on other sites More sharing options...
hvacengi Posted December 3, 2016 Share Posted December 3, 2016 18 minutes ago, TK-421 said: In Galileo's planet pack, there is a moon named Eta. This makes the eta alias unusable. This was noticed just the other day, and there is already a fix in the works. There is no work around however until that gets merged. But it should be in the next release (which we keep saying will be "soon", but I think it really be soon). https://github.com/KSP-KOS/KOS/issues/1887 Link to comment Share on other sites More sharing options...
Waz Posted December 4, 2016 Share Posted December 4, 2016 Making nodes and looking at their eta might be a workaround. Link to comment Share on other sites More sharing options...
Geschosskopf Posted December 4, 2016 Share Posted December 4, 2016 I have what is probably a stupid question.... Using 1.0.2-pre2, I did the traditional "copy scriptname from 0." and while this worked, I got a warning saying the syntax had changed. Now I'm supposed to do this: "copypath(0:/"scriptname") Egad, that's difficult to type quickly, requiring actual thought, which breaks the mood when I'm "in the zone" coding. Not a fan but I guess I'll have to live with it. HOWEVER, next time I ran kOS, I tried doing it the new way to get in the habit, and then I tried all permutations of quotes or not and their positions, and all sorts of other variations on the above theme, and NONE of them worked. So what am I doing wrong? Has this change not really taken effect yet? Or is there some trick to getting the proper syntax? Do you really need the quotes? Thanks. Link to comment Share on other sites More sharing options...
kcs123 Posted December 4, 2016 Share Posted December 4, 2016 (edited) 2 hours ago, Geschosskopf said: I have what is probably a stupid question.... Using 1.0.2-pre2, I did the traditional "copy scriptname from 0." and while this worked, I got a warning saying the syntax had changed. Now I'm supposed to do this: "copypath(0:/"scriptname") HOWEVER, next time I ran kOS, I tried doing it the new way to get in the habit, and then I tried all permutations of quotes or not and their positions, and all sorts of other variations on the above theme, and NONE of them worked. So what am I doing wrong? I was wandering by myself too with new stuff. Asked same thing here. Found answer by myself on page 185 of this thread. Anyhow, you missing destination parameter. Assuming you have opened desired kOS CPU and you have switched archive to local kOS CPU you need to do this: copypath("0:/scriptname",""). That will copy desired script from permanent archive to local CPU. Of course, if you have more than one kOS CPU, you can be more specific and add full path to destination archive like this: copypath("0:/scriptname","2:/script_changed_name"). In your example you have missplaced begining doublequote. I ended up creating task specific bootscripts that copy desired files on launch and when in flight, you only need to run desired script if it is not already set to autorun. Like this: // Example 1 runpath("MyScript_with_parameters",90,20000). // Example 2 runpath("MyScript_no_parameters"). // Example 3 - legacy command when no parameters required run MyScript_no_parameters. Edited December 4, 2016 by kcs123 Link to comment Share on other sites More sharing options...
kcs123 Posted December 4, 2016 Share Posted December 4, 2016 (edited) @hvacengi and @Waz, I was able to create another kOS interpretrer breaking script. Alpha8 with GUI fork is used. I don't think that is releated with GUI stuff as I was having similar even without usage of GUI Here is how script look like: Spoiler // external libraries used RUNONCEPATH("/lib_navball"). RUNONCEPATH("/lib_circle_nav"). set MyHeading to 213. set seekVelocity to 10. set ThrottlePID to PIDLOOP( 0.15, 0.01, 0.1, -1.0, 1.0 ). set terminate to false. set output to "". set AutopilotDrive to true. // -------- initialization of script before main loop clearscreen. SAS on. wait 0. //SET SASMODE TO "STABILITYASSIST". // initial info on screen print "kOS autopilot Keys: ". // Row 0. print " Action Group 4 : Toggle GUI ". print " ". print " ". print " Press CTRL + C to terminate program ". print "--------------------------------------------". print " ". // Row No:6 print " ". // Row No:7 print " ". // Row No:8 print " ". // Row No:9 print " ". // Row No:10 print " ". // Row No:11 print " ". // Row No:12 print " ". // Row No:13 print " ". // Row No:14 print " ". // Row No:15 // Cursor ends here after CTRL + C - that is reason for empty lines // GUI creation set Rover_GUI to GUI(280,400). // (width,height) set Rover_GUI:x to 515. // set GUI window position to X set Rover_GUI:y to 60. // set GUI window position to Y // Elements of GUI - title and output status from various functions set TitleLabel to Rover_GUI:ADDLABEL("GUI for "+SHIP:NAME). set OutputLabel to Rover_GUI:ADDLABEL("Autopilot output"). // Radiobuttons to select autopilot mode set AutopilotModeBox to Rover_GUI:ADDVBOX. set AutopilotRB_Off to AutopilotModeBox:ADDRADIOBUTTON("Autopilot Off",false). set AutopilotRB_Drive to AutopilotModeBox:ADDRADIOBUTTON("Autopilot drive",true). // New vertical box for velocity and heading set VerticalBox01 to Rover_GUI:ADDVBOX. set HorisontalBox01 to VerticalBox01:ADDHBOX. // --- set VelocityLabel to HorisontalBox01:ADDLABEL("Velocity:"). set VelocityData to HorisontalBox01:ADDTEXTFIELD(seekVelocity:TOSTRING). set VelocityButton to HorisontalBox01:ADDBUTTON("Set"). set VelocityButton:STYLE:ALIGN to "RIGHT". set HeadingInputBox to VerticalBox01:ADDHBOX. set HeadingLabel to HeadingInputBox:ADDLABEL("Heading:"). set HeadingData to HeadingInputBox:ADDTEXTFIELD(MyHeading:TOSTRING). set HeadingButton to HeadingInputBox:ADDBUTTON("Set"). set HeadingButton:STYLE:ALIGN to "RIGHT". // -- set CloseButton to Rover_GUI:ADDBUTTON("Close"). // -- end of GUI creation // GUI and AG triggers // Uncomenting any of additional triggers breaks kOS interpreter // Main autopilot mode triggers ON AutopilotRB_Off:PRESSED{ // Switch off everything if AutopilotRB_Off:PRESSED = false { set AutopilotDrive to false. unlock ALL. SAS on. wait 0. SET SASMODE TO "STABILITYASSIST". set output to "Switching off". set SHIP:CONTROL:PILOTWHEELTHROTTLE to 0. BRAKES ON. }. preserve. }. // ON AutopilotRB_Drive:PRESSED{ // if AutopilotRB_Drive:PRESSED = false { // SAS off. // wait 0. // set AutopilotDrive to true. // BRAKES OFF. // lock WHEELSTEERING to MyHeading. // ThrottlePID:RESET(). // }. // preserve. // }. // -- end of main autopilot mode trigers // input data triggers // ON VelocityData:CONFIRMED { // if VelocityData:TEXT:TONUMBER(-9999) <> -9999 { // set seekVelocity to VelocityData:TEXT:TONUMBER(-9999). // } else { // set VelocityData:TEXT to seekVelocity:TOSTRING. // }. // preserve. // }. // ON VelocityButton:PRESSED { // if VelocityData:TEXT:TONUMBER(-9999) <> -9999 { // set seekVelocity to VelocityData:TEXT:TONUMBER(-9999). // } else { // set VelocityData:TEXT to seekVelocity:TOSTRING. // }. // preserve. // }. // ON HeadingData:CONFIRMED { // if HeadingData:TEXT:TONUMBER(-9999) <> -9999 { // set MyHeading to HeadingData:TEXT:TONUMBER(-9999). // } else { // set HeadingData:TEXT to MyHeading:TOSTRING. // }. // preserve. // }. // ON HeadingButton:PRESSED { // if HeadingData:TEXT:TONUMBER(-9999) <> -9999 { // set MyHeading to HeadingData:TEXT:TONUMBER(-9999). // } else { // set HeadingData:TEXT to MyHeading:TOSTRING. // }. // preserve. // }. // --- // --- ON CloseButton:PRESSED { Rover_GUI:hide(). // --- // for debug set AutopilotDrive to false. //unlock all. // --- preserve. }. // ------------------------- // ------------------------------------------- on AG4 { Rover_GUI:show(). // for debug BRAKES OFF. set AutopilotDrive to true. // --- preserve. // ensurance that AG is triggered again on demand }. // ------ // function to display data on terminal and GUI function display_block { parameter output. parameter startCol is 0. parameter startRow is 6. // define where the block of text should be positioned print " " at (startCol,startRow). print output at (startCol,startRow). // output from GUI print " " at (startCol,startRow+1). print "Velocity Setpoint/Ship:"+round(seekVelocity,2) +" / "+round(ship:groundspeed,2) at (startCol,startRow+1). set OutputLabel:TEXT to output. //print round(seekAlt,2) + "(m) / "+ round(alt:radar,2)+" (m) " at (startCol+32,startRow+2). print "--------------------------------------------" at (startCol,startRow+3). print "Craft Heading: "+round(compass_for(ship), 1) + "(deg) " at (startCol,startRow+4). }. // -- main program until terminate = true { display_block("Rover_test"). // Rover autopiloting in desired direction and velocity until (AutopilotDrive = false) or (AutopilotRB_Off:PRESSED = true){ set ThrottlePID:SETPOINT to seekVelocity. // new way to set PID property with built in ThrottlePID:UPDATE(TIME:SECONDS, ship:groundspeed). set myThrottle to ThrottlePID:OUTPUT. LOCK WHEELTHROTTLE TO myThrottle. // ---- wait 0. set output to "Driving to ("+seekVelocity+" m/s)". display_block(output). }. }. // ----- "lib_navball" and "lib_circle_nav" were taken from kOS library on github. I was just started to build Rover autopilot script with GUI. Current state work just fine, for debug purposes I added commands on AG4 to start rover. It holds throttle properly, but steering is not locked at all. As soon as I unlock one "ON AutopilotRB_Drive:PRESSED" block ore any other, or even put some more commands on AG4 event, kOS interpreter breaks with same error as previously reported - not enough parameters. I can't figure out what I wrote inside script that breaks kOS interpreter. I was using notepad++ for script writing, file is saved as UTF8 without BOM. If any of those info is relevant. This script is realy most simple as it could be, I just started to build GUI and possible rover driving modes when it started to break, so it is almost impossible to continue with it. Edited December 4, 2016 by kcs123 Link to comment Share on other sites More sharing options...
Waz Posted December 4, 2016 Share Posted December 4, 2016 53 minutes ago, kcs123 said: I can't figure out what I wrote inside script that breaks kOS interpreter. I was using notepad++ for script writing, file is saved as UTF8 without BOM. If any of those info is relevant. This script is realy most simple as it could be, I just started to build GUI and possible rover driving modes when it started to break, so it is almost impossible to continue with it. You really can't simplify it any further than that? The first step to tracking down problems is to remove stuff which doesn't matter to the error. It's far better that you do that than me, because it might turn out to be a problem in your code, or in kOS (I'm sure in this case it is in kOS, but a simpler example of the problem is a lot easier to process). You should also show the actual error message you are getting, and logs (especially if you submit it as an Issue on the github). Link to comment Share on other sites More sharing options...
kcs123 Posted December 4, 2016 Share Posted December 4, 2016 (edited) 52 minutes ago, Waz said: You really can't simplify it any further than that? The first step to tracking down problems is to remove stuff which doesn't matter to the error. It's far better that you do that than me, because it might turn out to be a problem in your code, or in kOS (I'm sure in this case it is in kOS, but a simpler example of the problem is a lot easier to process). You should also show the actual error message you are getting, and logs (especially if you submit it as an Issue on the github). Troubleshooting as well as reporting. Managed to create even more simple script, without GUI at all. I was just about to create more convinient outputlog. Starting game, loading savegame point, switching to rover on Mun and try to run script. Here is more simple script that produce described error as before: Spoiler // external libraries used RUNONCEPATH("/lib_navball"). RUNONCEPATH("/lib_circle_nav"). set MyHeading to 213. set seekVelocity to 10. set ThrottlePID to PIDLOOP( 0.15, 0.01, 0.1, -1.0, 1.0 ). set terminate to false. set output to "". set AutopilotDrive to false. set AutopilotSteering to false. // -------- initialization of script before main loop clearscreen. SAS on. wait 0. //SET SASMODE TO "STABILITYASSIST". // initial info on screen print "kOS autopilot Keys: ". // Row 0. print " Action Group 4 : Toggle autopilot ". print "AG5 / AG6 - set velocity ". print "AG7 - Toggle WheelSteering lock ". print " Press CTRL + C to terminate program ". print "--------------------------------------------". print " ". // Row No:6 print " ". // Row No:7 print " ". // Row No:8 print " ". // Row No:9 print " ". // Row No:10 print " ". // Row No:11 print " ". // Row No:12 print " ". // Row No:13 print " ". // Row No:14 print " ". // Row No:15 // Cursor ends here after CTRL + C - that is reason for empty lines // ------------------------------------------- on AG4 { if AutopilotDrive = false { set AutopilotDrive to true. } else { set AutopilotDrive to false. unlock all. BRAKES ON. }. // --- preserve. // ensurance that AG is triggered again on demand }. // ------ on AG5 { set seekVelocity to seekVelocity - 1. // --- preserve. // ensurance that AG is triggered again on demand }. // ------ on AG6 { set seekVelocity to seekVelocity + 1. // --- preserve. // ensurance that AG is triggered again on demand }. // ------ on AG7 { if AutopilotSteering = false { set AutopilotSteering to true. set MyHeading to round(compass_for(ship), 1). lock wheelsteering to MyHeading. } else { set AutopilotSteering to false. unlock wheelsteering. }. // --- preserve. // ensurance that AG is triggered again on demand }. // ------ // function to display data on terminal and GUI function display_block { parameter output. parameter startCol is 0. parameter startRow is 6. // define where the block of text should be positioned print " " at (startCol,startRow). print output at (startCol,startRow). // output from GUI print " " at (startCol,startRow+1). print "Velocity Setpoint/Ship:"+round(seekVelocity,2) +" / "+round(ship:groundspeed,2) at (startCol,startRow+1). //set OutputLabel:TEXT to output. //print round(seekAlt,2) + "(m) / "+ round(alt:radar,2)+" (m) " at (startCol+32,startRow+2). print "--------------------------------------------" at (startCol,startRow+3). print "Craft Heading: "+round(compass_for(ship), 1) + "(deg) " at (startCol,startRow+4). print "Heading setpoint: "+MyHeading + "(deg) " at (startCol,startRow+5). }. // -- main program until terminate = true { display_block("Rover_test"). // Rover autopiloting in desired direction and velocity until (AutopilotDrive = false) or (AutopilotRB_Off:PRESSED = true){ set ThrottlePID:SETPOINT to seekVelocity. // new way to set PID property with built in ThrottlePID:UPDATE(TIME:SECONDS, ship:groundspeed). set myThrottle to ThrottlePID:OUTPUT. LOCK WHEELTHROTTLE TO myThrottle. // ---- wait 0. set output to "Driving to ("+seekVelocity+" m/s)". display_block(output). }. }. // ----- And give me couple of more minutes to upload log, script and savegame file. EDIT: Here is link for required archive with log, script and savegame file. Under spoiler is relevant part of log. Spoiler (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary`2[System.String,System.Int32].get_Item (System.String key) [0x00000] in <filename unknown>:0 at kOS.Safe.Compilation.ProgramBuilder.ReplaceLabels (System.Collections.Generic.List`1 program) [0x00000] in <filename unknown>:0 at kOS.Safe.Compilation.ProgramBuilder.BuildProgram () [0x00000] in <filename unknown>:0 at kOS.Safe.Execution.ProgramContext.AddParts (IEnumerable`1 parts) [0x00000] in <filename unknown>:0 at kOS.Function.FunctionRun.Execute (kOS.SharedObjects shared) [0x00000] in <filename unknown>:0 at kOS.Function.FunctionBase.Execute (kOS.Safe.SafeSharedObjects shared) [0x00000] in <filename unknown>:0 at kOS.Safe.Function.FunctionManager.CallFunction (System.String functionName) [0x00000] in <filename unknown>:0 at kOS.Safe.Execution.CPU.CallBuiltinFunction (System.String functionName) [0x00000] in <filename unknown>:0 at kOS.Safe.Compilation.OpcodeCall.StaticExecute (ICpu cpu, Boolean direct, System.Object destination, Boolean calledFromKOSDelegateCall) [0x00000] in <filename unknown>:0 at kOS.Safe.Compilation.OpcodeCall.Execute (ICpu cpu) [0x00000] in <filename unknown>:0 at kOS.Safe.Execution.CPU.ExecuteInstruction (IProgramContext context, Boolean doProfiling) [0x00000] in <filename unknown>:0 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) Code Fragment File Line:Col IP label opcode operand ==== ====:=== ==== ================================ (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) kOS: Stack dump: stackPointer = -1 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) kOS: Popping context 2 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) kOS: Removed Context File Line:Col IP label opcode operand (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) kOS: Deleting 0 pointers and restoring 0 pointers (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) kOS: New current context File Line:Col IP label opcode operand (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) kOS: At interpreter, line 2 run rover. ^ (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) kOS.Safe.Exceptions.KOSArgumentMismatchException: Number of arguments passed in didn't match the number of DECLARE PARAMETERs. Too many arguments were passed to run at kOS.Safe.Function.SafeFunctionBase.AssertArgBottomAndConsume (kOS.Safe.SafeSharedObjects shared) [0x00000] in <filename unknown>:0 at kOS.Function.FunctionRun.Execute (kOS.SharedObjects shared) [0x00000] in <filename unknown>:0 at kOS.Function.FunctionBase.Execute (kOS.Safe.SafeSharedObjects shared) [0x00000] in <filename unknown>:0 at kOS.Safe.Function.FunctionManager.CallFunction (System.String functionName) [0x00000] in <filename unknown>:0 at kOS.Safe.Execution.CPU.CallBuiltinFunction (System.String functionName) [0x00000] in <filename unknown>:0 at kOS.Safe.Compilation.OpcodeCall.StaticExecute (ICpu cpu, Boolean direct, System.Object destination, Boolean calledFromKOSDelegateCall) [0x00000] in <filename unknown>:0 at kOS.Safe.Compilation.OpcodeCall.Execute (ICpu cpu) [0x00000] in <filename unknown>:0 at kOS.Safe.Execution.CPU.ExecuteInstruction (IProgramContext context, Boolean doProfiling) [0x00000] in <filename unknown>:0 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) Code Fragment File Line:Col IP label opcode operand ==== ====:=== ==== ================================ 0:0 0000 jump +27 [built-in] 0:0 0001 @LR00 pushscope -999 0 [built-in] 0:0 0002 @LR01 push $runonce [built-in] 0:0 0003 @LR02 swap [built-in] 0:0 0004 @LR03 storelocal [built-in] 0:0 0005 @LR04 push $filename [built-in] 0:0 0006 @LR05 swap [built-in] 0:0 0007 @LR06 storelocal [built-in] 0:0 0008 @LR07 push _KOSArgMarker_ [built-in] 0:0 0009 @LR08 push $filename [built-in] 0:0 0010 @LR09 eval [built-in] 0:0 0011 @LR10 push True [built-in] 0:0 0012 @LR11 push null [built-in] 0:0 0013 @LR12 call load() [built-in] 0:0 0014 @LR13 br.false +6 [built-in] 0:0 0015 @LR14 push $runonce [built-in] 0:0 0016 @LR15 br.false +4 [built-in] 0:0 0017 @LR16 pop [built-in] 0:0 0018 @LR17 push 0 [built-in] 0:0 0019 @LR18 return 1 deep [built-in] 0:0 0020 @LR19 push $entrypoint [built-in] 0:0 0021 @LR20 swap [built-in] 0:0 0022 @LR21 storelocal [built-in] 0:0 0023 @LR22 call $entrypoint [built-in] 0:0 0024 @LR23 pop [built-in] 0:0 0025 @LR24 push 0 [built-in] 0:0 0026 @LR25 return 1 deep interpreter 1:1 0027 @0001 push _KOSArgMarker_ interpreter 1:11 0028 @0002 push 0 interpreter 1:11 0029 @0003 call switch() interpreter 1:11 0030 @0004 pop interpreter 2:1 0031 @0005 push _KOSArgMarker_ interpreter 2:1 0032 @0006 push _KOSArgMarker_ interpreter 2:5 0033 @0007 push rover interpreter 2:5 0034 @0008 push null interpreter 2:5 0035 @0009 call run() <<--INSTRUCTION POINTER-- interpreter 2:5 0036 @0010 pop interpreter 2:5 0037 @0011 pop 0:0 0038 EOF (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) kOS: Stack dump: stackPointer = -1 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) [SCANsat] Height Map Of [Minmus] Completed... (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) [SCANsat] All Height Maps Generated (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) [UIMasterController]: ShowUI (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) Game Paused! (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) Flight State Captured (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) Saving Achievements Tree... (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) Saving Achievements Tree... (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) Saving Achievements Tree... (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) Saving Achievements Tree... (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) FF: saving hall of fame scenario module (at 648186.353610805) (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) FF: saving hall of fame (453 logbook entries) (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) FF: hall of fame saved in 1ms (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) [MessageSystem] Save Messages (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) Game State Saved to saves/121_Career/persistent (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) ScaleModList: listSize 574 maxListSize 706 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) 12/4/2016 10:56:40 PM,KerbalAlarmClock,AppLauncher: Destroying Button-Button Count:19 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) ScaleModList: listSize 574 maxListSize 706 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) ScaleModList: listSize 574 maxListSize 706 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) ScaleModList: listSize 574 maxListSize 706 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) ScaleModList: listSize 574 maxListSize 706 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) ScaleModList: listSize 574 maxListSize 706 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) ScaleModList: listSize 574 maxListSize 706 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) ScaleModList: listSize 574 maxListSize 706 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) 12/4/2016 10:56:40 PM,KSPAlternateResourcePanel,AppLauncher: Destroying Button-BEFORE NULL CHECK (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) 12/4/2016 10:56:40 PM,KSPAlternateResourcePanel,AppLauncher: Destroying Button-Button Count:19 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) ScaleModList: listSize 574 maxListSize 706 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) 12/4/2016 10:56:40 PM,KSPAlternateResourcePanel,AppLauncher: Destroying Button-AFTER NULL CHECK (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) ScaleModList: listSize 574 maxListSize 706 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) ScaleModList: listSize 574 maxListSize 706 (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) kOS: KOSToolBarWindow: PROOF: CallbackOnHide() (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) kOS: KOSToolBarWindow: PROOF: Close() (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) [UIMasterController]: HideUI (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) FF: EventObserver:: OnGameSceneLoadRequested: SPACECENTER current=FLIGHT (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) [HighLogic]: =========================== Scene Change : From FLIGHT to SPACECENTER (Async) ===================== (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) Unloading 2 Unused Serialized files (Serialized files now loaded: 3) 12/4/2016 10:56:40 PM,KerbalAlarmClock,Scene Change from 'FLIGHT' to 'SPACECENTER' (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) 12/4/2016 10:56:41 PM,KerbalAlarmClock,Destroying the KerbalAlarmClock-KACFlight (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) 12/4/2016 10:56:41 PM,KerbalAlarmClock,API Cleaned up (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) IR: [ServoController] OnVesselUnloaded, v=Contract ScanSat kOS probe (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) kOS: kOSVesselModule OnDestroy()! (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42) KbApp.OnDestroy Planet Resources Edited December 4, 2016 by kcs123 Link to comment Share on other sites More sharing options...
Dunbaratu Posted December 4, 2016 Share Posted December 4, 2016 58 minutes ago, kcs123 said: Troubleshooting as well as reporting. Managed to create even more simple script, without GUI at all. I was just about to create more convinient outputlog. Starting game, loading savegame point, switching to rover on Mun and try to run script. There's some bugs we just found just a couple of weeks ago with using one of the four cooked steering locks (throttle, steering, wheelthrottle, wheelsteering) from inside a trigger like ON or WHEN, if those locks exactly match the same expression used elsewhere for the same variable. In other words, if you do a Lock Steering To 0 in two places, one of which is in a trigger, that's the sort of thing that makes the bug occur. It works as long as the expressions differ. It's confusing the mechanism the compiler uses to identify unique functions by their compile hash signature. There's a fix in the works, but in the meantime just do Lock [whatever] to MyVariable once up at the top, and then use Set MyVariable to whatever in the trigger code (don't re-run the lock statement there). Link to comment Share on other sites More sharing options...
hvacengi Posted December 5, 2016 Share Posted December 5, 2016 18 hours ago, kcs123 said: As soon as I unlock one "ON AutopilotRB_Drive:PRESSED" block ore any other, or even put some more commands on AG4 event, kOS interpreter breaks with same error as previously reported - not enough parameters. 15 hours ago, Steven Mading said: In other words, if you do a Lock Steering To 0 in two places, one of which is in a trigger, that's the sort of thing that makes the bug occur. I ran the attached scripts with the debugger, and there is indeed a different error in this instance. 1st, the notable error isn't the "declare parameter" error, instead it's a "replace label" error. 2nd, it isn't a problem with steering locks but rather with an attempt to "unlock all", which is trying to set the user function "dislplay_block" to a default value (which doesn't exist, because functions don't have default value and they should be unlocked). I'll try to find some additional detail and post to github. I honestly didn't know that unlock all was still valid. Link to comment Share on other sites More sharing options...
kcs123 Posted December 5, 2016 Share Posted December 5, 2016 Thanks for clarification, I will try to change whole script in different manner to make workaround of this until proper fix is provided. How (un)lucky I am, I will probably brake something else Link to comment Share on other sites More sharing options...
hvacengi Posted December 5, 2016 Share Posted December 5, 2016 34 minutes ago, kcs123 said: Thanks for clarification, I will try to change whole script in different manner to make workaround of this until proper fix is provided. How (un)lucky I am, I will probably brake something else As long as you don't call "unlock" of any kind from within a trigger ("on" or "when") you should be fine. Link to comment Share on other sites More sharing options...
kcs123 Posted December 5, 2016 Share Posted December 5, 2016 1 hour ago, hvacengi said: As long as you don't call "unlock" of any kind from within a trigger ("on" or "when") you should be fine. I just thinking of creating workaround with additional variable in ON / WHEN events. For example, like this: set terminate to false. set done to false. set MyHeading to 270. ON AG4 { if done = false { set done to true. // unlock will be done inside until loop } else { set done to false. lock wheelsteering to MyHeading. }. preserve. }. ON AG5 { set MyHeading to SomeOtherValue. preserve. }. // main part of script to run in endless loop until terminate = true { // main part of script to do something here if done = true { // part of code outside of trigger that will return command to pilot unlock wheelsteering. }. }. Have yet to try iin game to see how it will work or it will break something. Or I will just have to break script with CTRL +C and run another script to unlock pilot commands on demand. Link to comment Share on other sites More sharing options...
hvacengi Posted December 5, 2016 Share Posted December 5, 2016 5 minutes ago, kcs123 said: Have yet to try iin game to see how it will work or it will break something. Or I will just have to break script with CTRL +C and run another script to unlock pilot commands on demand. In theory, as long as the unlock statement isn't within the triger's "{ }" braces, it should work fine. So you should be able to use a user function to call unlock instead. Link to comment Share on other sites More sharing options...
danielboro Posted December 6, 2016 Share Posted December 6, 2016 i get a black screen and wait forever on KAC jump to ship https://www.dropbox.com/s/620ivaeiv0gr1j4/kspKACjumpfreez.log?dl=0 this is the last lines of the ksp.log i see KOS there alot so i mentioning it hir Link to comment Share on other sites More sharing options...
hvacengi Posted December 6, 2016 Share Posted December 6, 2016 2 hours ago, danielboro said: i get a black screen and wait forever on KAC jump to ship https://www.dropbox.com/s/620ivaeiv0gr1j4/kspKACjumpfreez.log?dl=0 this is the last lines of the ksp.log i see KOS there alot so i mentioning it hir I would need to see the full log in order to tell anything. From the portion you have shown, I don't see any errors with kOS. You're right, there are a large number of kOS messages, but that should be normal if you have a large number of vessels in flight (KSP is set up so that it destroys and re-creates vessel modules on every scene change, our logging is there for tracking the life cycle of the vessel module). If KSP is hanging though, it is possible that the last few log messages are not getting written to the log file. I'll see if I can find some time to install KAC and check out the feature myself. Link to comment Share on other sites More sharing options...
EmbersArc Posted December 6, 2016 Share Posted December 6, 2016 Hey everyone, while writing a script I noticed that it's not possible to take the output of the steering manager's Torque PID (does not change ship:control:pitch and directly controls the steering). So I attempted to write one myself based on the output of the Rotational Velocity PID. According to this the output should be the desired rotational velocity. However this only gives me an extremely low number (~10^-17). Am I misinterpreting it or is that just what it does and it has to be multiplied by 10^17 before it can be used? Link to comment Share on other sites More sharing options...
kcs123 Posted December 6, 2016 Share Posted December 6, 2016 19 minutes ago, EmbersArc said: Hey everyone, while writing a script I noticed that it's not possible to take the output of the steering manager's Torque PID (does not change ship:control:pitch and directly controls the steering). So I attempted to write one myself based on the output of the Rotational Velocity PID. According to this the output should be the desired rotational velocity. However this only gives me an extremely low number (~10^-17). Am I misinterpreting it or is that just what it does and it has to be multiplied by 10^17 before it can be used? I'm not sure if I understand properly, but you want to create your own custom pair of PIDs for raw control, right ? If that is case, then you can't use readings from cooked control steeringmanager. Cooked controled steering manager need to be active (PID that it use) so readings from steering manager can provide sane values. What you need is readings from vesel properties and based on that use data to feed input of nested PID that set final raw control. You probably want to use angular momentum or angular velocity for intermediate data. You have to put in consideration that those are vcectors, so you should need to do some math, relative to ship facing vector to get desired values for each axis: pitch, yaw,roll. Might be even enough to use vector X,Y,Z data. I have also to remind myself of orientation of vectors used in KSP, does that represent absolute vector in KSP universe, or it is relative to ship facing, so I can't give you exact answer on that. I did similar thing for altitude based hovering script. First PID use desired Altitude setpoint and gives output in vertical velocity in range -10,+10. Output for that one is used to feed throttle PID that set engine trottle between ranges 0,+1. Link to comment Share on other sites More sharing options...
hvacengi Posted December 6, 2016 Share Posted December 6, 2016 45 minutes ago, EmbersArc said: Hey everyone, while writing a script I noticed that it's not possible to take the output of the steering manager's Torque PID (does not change ship:control:pitch and directly controls the steering). So I attempted to write one myself based on the output of the Rotational Velocity PID. According to this the output should be the desired rotational velocity. However this only gives me an extremely low number (~10^-17). Am I misinterpreting it or is that just what it does and it has to be multiplied by 10^17 before it can be used? What are you trying to do with the output from the Torque PID? I have a suffix for "actuation" on the structure, but it's only enabled for debugging mode. It simply returns a vector of the [-1...1] control output of the steering manager. I don't see why we couldn't move that to be user accessible if you need it for something. I didn't expose it initially because I can't think of a reason outside of debugging that it would be needed. @kcs123 is right, the rotational velocity PID won't update unless steering is locked. Even then, you can't get a good idea of the torque applied because it depends on available torque and moment of inertia, neither of which are exposed to the user. Link to comment Share on other sites More sharing options...
EmbersArc Posted December 6, 2016 Share Posted December 6, 2016 @kcs123, @hvacengi thanks! I'm trying to make a script to use differential throttling to control a Dragon v2 capsule for a point landing. I thought there might be a way to just tune the steering manager and use its output to adjust the thrust limit on the individual engines. Access to the output might or might not be helpful for that, just thought I'd try that first. It even somewhat works with the output from the rotational velocity PID but it's not very elegant. It looks like the best way is to make it from scratch after all. Link to comment Share on other sites More sharing options...
Recommended Posts