pellinor Posted April 3, 2016 Share Posted April 3, 2016 10 hours ago, Gaiiden said: So I don't really even understand why the output looks the way it does. Completely lost right now. Anyone able to help me get back on track? Many thanks Vectors live in a coordinate system where the ship is the origin. For example the position (0,0,1) is always 1m from the ship's CoM. I'm not sure about the orientation, that might also change over time. So if you log positions at different times things might get wonky. Have you tried logging latitude, longitude and height? These are safer for storing over time, so I would log the data in this form and convert them to a position when drawing the vectors. Link to comment Share on other sites More sharing options...
Drew Kerman Posted April 3, 2016 Share Posted April 3, 2016 2 hours ago, Steven Mading said: Your code snippets don't show how you built the vecList in the first place, making it hard to verify if what you're seeing in the vecdraws is wrong or if the vecdraws are correctly reflecting wrong values in the vecList. the vecList is just a list of vectors like so: set vecList to list(V(3.87888068688335, 0.0080018920485827, -2.69312801863998), V(3.87837466818746, 0.00800085040384602, -2.69277950405376), V(3.87783656315878, 0.00799974275787463, -2.69240888993954), V(3.87733771902276, 0.00799871589470058, -2.69206531660166), V(3.87683587119682, 0.00799768281399338, -2.69171967514558), the values are all logged directly from ship:geoposition:position. I don't think what I'm seeing is wrong, I just don't really understand why I'm seeing what I'm seeing (lack of proper understanding of how vectors work). 29 minutes ago, pellinor said: Have you tried logging latitude, longitude and height? These are safer for storing over time, so I would log the data in this form and convert them to a position when drawing the vectors. Yes, I have lat, lng and alt all stored as part of my normal telemetry logging. I don't have a clue as to how to use this as you suggest but I also didn't know for sure that I could so I didn't bother wasting any time on it. I'll try to figure something out later today but any guidance you can offer would be appreciated. Link to comment Share on other sites More sharing options...
pellinor Posted April 3, 2016 Share Posted April 3, 2016 13 minutes ago, Gaiiden said: Yes, I have lat, lng and alt all stored as part of my normal telemetry logging. I don't have a clue as to how to use this as you suggest but I also didn't know for sure that I could so I didn't bother wasting any time on it. I'll try to figure something out later today but any guidance you can offer would be appreciated. It should be something like LATLNG(latitude,longitude):ALTITUDEPOSITION(altitude) Taken from the example here: https://ksp-kos.github.io/KOS_DOC/math/geocoordinates.html?highlight=latlng#attribute:GEOCOORDINATES:ALTITUDEPOSITION Link to comment Share on other sites More sharing options...
Horman Posted April 3, 2016 Share Posted April 3, 2016 Is it possible to transfer resources by using kOS? Link to comment Share on other sites More sharing options...
surge Posted April 3, 2016 Share Posted April 3, 2016 (edited) On 29/3/2016 at 7:08 AM, hvacengi said: Unfortunately our general backwards compatibility message has to be that we simply don't offer support for previous versions of KSP, nor for previous versions of kOS. This is an unfortunate oversight on our part with regard to the version checker details, as I did have it fixed at one point. Understood. Although after combing through your buglist several times, there seems to be someone in your midst that doesn't understand how rcs works, and keeps committing changes without updating their version first - you seem to have alot of problems with lost code. Or is that just a natural thing with git? I don't know, I've always used non-distributed rcs stuff like cvs, svn, etc. Seems pretty annoying. Your choice, I guess... I'm happily using 0.18.1 for now though, so no worries until KSP 1.1. And frankly you made the old releases as they were. Warts and all. I was simply trying to suggest that in future you put the correct version checking info in. I advise against trying to change previous versions - it can cause alot of problems. Edited April 3, 2016 by surge Link to comment Share on other sites More sharing options...
Dunbaratu Posted April 3, 2016 Share Posted April 3, 2016 6 hours ago, Horman said: Is it possible to transfer resources by using kOS? Yes: https://ksp-kos.github.io/KOS_DOC/commands/resource_transfer.html Link to comment Share on other sites More sharing options...
Drew Kerman Posted April 3, 2016 Share Posted April 3, 2016 (edited) stuck again. But closer maybe? HOLY CRAP I DID IT - here was the process. Here is my logged data: set pathData to lexicon(). set altData to list(). set geoData to list(). set vecData to list(). pathData:add("alt", altData). pathData:add("geo", geoData). pathData:add("vec", vecData). ... // once a second geoData:add(ship:geoposition). altData:add(ship:altitude). vecData:add(ship:facing:vector). ... writejson(pathData, "path.json"). first I just tried to play connect the dots using the geoposition: clearscreen. set pathData to readjson("path.json"). clearvecdraws(). from { local index is 0. } until index = pathData["geo"]:length-1 step { set index to index + 1. } do { vecdraw(latlng(pathData["geo"][index]:lat, pathData["geo"][index]:lng):altitudeposition(pathData["alt"][index]), latlng(pathData["geo"][index+1]:lat, pathData["geo"][index+1]:lng):altitudeposition(pathData["alt"][index+1]), rgb(0,1,0), "", 1.0, true, 40). }. which gave me: so then I tried the adding thing I did last time: clearscreen. set pathData to readjson("path.json"). clearvecdraws(). set currVec to latlng(pathData["geo"][0]:lat, pathData["geo"][0]:lng):altitudeposition(pathData["alt"][0]) from { local index is 1. } until index = pathData["geo"]:length step { set index to index + 1. } do { vecdraw(currVec, latlng(pathData["geo"][index]:lat, pathData["geo"][index]:lng):altitudeposition(pathData["alt"][index]), rgb(0,1,0), "", 1.0, true, 10). set currVec to currVec + latlng(pathData["geo"][0]:lat, pathData["geo"][index]:lng):altitudeposition(pathData["alt"][index]) }. and that gave me this: way too steep. It should look similar to the green line on this Excel plot: so I tried using the facing vector like so: clearscreen. set pathData to readjson("path.json"). clearvecdraws(). from { local index is 0. } until index = pathData["geo"]:length-1 step { set index to index + 1. } do { vecdraw(latlng(pathData["geo"][index]:lat, pathData["geo"][index]:lng):altitudeposition(pathData["alt"][index]), pathData["vec"][index], rgb(0,1,0), "", 1.0, true, 40). }. and got this: I feel like this is on the right track, that arc looks good but it seems I need to set the magnitude of the vectors to make them longer and extend the arc downrange further. I'm not sure how to do that though. Edit: right after posting this I had an epiphany and I changed the code to add the difference in the current and next geoposition vectors: clearscreen. set pathData to readjson("path.json"). clearvecdraws(). from { local index is 0. } until index = pathData["geo"]:length-1 step { set index to index + 1. } do { vecdraw(latlng(pathData["geo"][index]:lat, pathData["geo"][index]:lng):altitudeposition(pathData["alt"][index]), pathData["vec"][index] + (latlng(pathData["geo"][index+1]:lat, pathData["geo"][index+1]:lng):altitudeposition(pathData["alt"][index+1]) - latlng(pathData["geo"][index]:lat, pathData["geo"][index]:lng):altitudeposition(pathData["alt"][index])), rgb(0,1,0), "", 1.0, true, 40). }. which gave me: I dunno... arc seems okay but it still seems too short and I would expect it to extend further downrange. I'm testing it now against a path generated by Persistent Trails RESULT!!! OMG OMG OMG The trail I logged is so short because I realize now I mistakenly put the JSON data write into the event where the SRBs flameout rather than where the main engine flames out (end of the recorded green line by persistent trails). 'scuse me while I go off to do a happy dance. Thanks all for the guidance! Even better (real-time vecdraw): Edited April 4, 2016 by Gaiiden FTW Link to comment Share on other sites More sharing options...
Drew Kerman Posted April 5, 2016 Share Posted April 5, 2016 (edited) Here's a boot script for anyone who wants to use it: Verbose script (5136 bytes)Minimized script (2596 bytes) Based loosely off what Kevin Gisi did on his KSProgramming youtube series and is compatible with RemoteTech My favorite feature is the backup script. So if you're playing with storage limits and can't upload your launch script and orbital maintenance script at the same time, you would plan to upload the orbital script after your launch script completes. But what happens if you fly out of range before the launch script ends? The backup script can contain instructions to just keep the probe alive until it comes back in comms range for you to upload your full set of next instructions. Edited April 5, 2016 by Gaiiden Link to comment Share on other sites More sharing options...
Dunbaratu Posted April 5, 2016 Share Posted April 5, 2016 (edited) v0.19.3 Last (intended) 1.0.5 update. Obtain from : curse: http://mods.curse.com/ksp-mods/kerbal/220265-kos-scriptable-autopilot-system#t1:other-downloads spacedock: https://spacedock.info/mod/60/kOS:%20Scriptable%20Autopilot%20System github: https://github.com/KSP-KOS/KOS/releases/tag/v0.19.3 (This is the last planned update to work with KSP 1.0.5 unless it breaks something big that requires an emergency patch.) BREAKING CHANGES * Triggers may now go beyond the limits of the IPU (https://github.com/KSP-KOS/KOS/pull/1542) but are no longer guaranteed to execute within a single update frame. See http://ksp-kos.github.io/KOS_DOC/general/cpu_hardware.html#triggers and http://ksp-kos.github.io/KOS_DOC/general/cpu_hardware.html#cpu-update-loop for more details. NEW FEATURES * Profiling output via `ProfileResult()` (https://github.com/KSP-KOS/KOS/pull/1534) BUG FIXES * Removed delay when enabling/disabling auto changeover for multi mode engines (https://github.com/KSP-KOS/KOS/pull/1451) * Improve performance of various math functions (https://github.com/KSP-KOS/KOS/issues/1553 https://github.com/KSP-KOS/KOS/pull/1523 https://github.com/KSP-KOS/KOS/pull/1563) * `on` logic now evaluates expressions and suffixes, instead of requiring a raw variable (https://github.com/KSP-KOS/KOS/issues/1376 https://github.com/KSP-KOS/KOS/pull/1542) * Documentation no longer inserts a space around highlighted search terms (https://github.com/KSP-KOS/KOS/pull/1548) * You can now use lock objects with the same identifier from within compiled scripts, like `lock throttle...` (https://github.com/KSP-KOS/KOS/issues/691 https://github.com/KSP-KOS/KOS/issues/1253 https://github.com/KSP-KOS/KOS/issues/1557 https://github.com/KSP-KOS/KOS/pull/1561) * The script parsing logic has been updated to improve compile times by roughly 50% (https://github.com/KSP-KOS/KOS/pull/1566) Edited April 5, 2016 by Steven Mading I gave up trying to fight the forum software's "what you see isn't remotely similar to what you told it to do" interface. Link to comment Share on other sites More sharing options...
Polnoch Posted April 5, 2016 Share Posted April 5, 2016 (edited) I've started a new Career in hard level with kOS and RemoteTech mod(+ some another mods to get really hard and interesting game, including supplies to the Kerbonauts). I got some money, writing a 2 little scripts for launching tourist to the orbit and landing. Now I want to start my first unmanage mission to the Mun, but can't use in script maneuver node. Script from http://ksp-kos.github.io/KOS_DOC/tutorials/exenode.html page returns errors: run node. Attempted to make a function call on a non-invokable object: nextnode __________________________________________ VERBOSE DESCRIPTION Attempted to make a function call on a non-invokable object: nextnode__________________________________________ __________________________________________ At node on 1, line 3 set nd to nextnode(). Also, very little script: set nd to nextnode(). print "Node in: " + round(nd:eta) + ", DeltaV: " + round(nd:deltav:mag). //calculate ship's max acceleration set max_acc to ship:maxthrust/ship:mass. set burn_duration to nd:deltav:mag/max_acc. print "Crude Estimated burn duration: " + round(burn_duration) + "s". Returns same error: run node1. Attempted to make a function call on a non-invokable object: nextnode __________________________________________ VERBOSE DESCRIPTION Attempted to make a function call on a non-invokable object: nextnode__________________________________________ __________________________________________ At node1 on 1, line 1 set nd to nextnode(). However, I have one maneuver node. Does it wrong syntax in help page in examples? Or I don't know something important things? Edited April 5, 2016 by Polnoch Link to comment Share on other sites More sharing options...
Dunbaratu Posted April 6, 2016 Share Posted April 6, 2016 nextnode isn't a function call. It's just a raw variable name. try it without the parentheses "()". Link to comment Share on other sites More sharing options...
Polnoch Posted April 6, 2016 Share Posted April 6, 2016 Is this language object-oriented? Very interesting if we assign variable to raw object Link to comment Share on other sites More sharing options...
Horman Posted April 6, 2016 Share Posted April 6, 2016 are there any language-files for notepad++ to support kOS? Link to comment Share on other sites More sharing options...
Polnoch Posted April 6, 2016 Share Posted April 6, 2016 1 minute ago, Horman said: are there any language-files for notepad++ to support kOS? I think, you know, but may be not. I'm sorry, if it is stupid advice for you: I using for my gedit and vim c-syntax. Probably it works fine for KerboScript. Link to comment Share on other sites More sharing options...
kcs123 Posted April 6, 2016 Share Posted April 6, 2016 1 hour ago, Horman said: are there any language-files for notepad++ to support kOS? Yes. There is several. Only keyword highlights, but those are also useful. Sorry, I no longer recall from where I downloaded those that I use. I think that there is some links on kOS github or in documentation. There is some links on redit too. Also someone posted language definition for notepad++ on this thread several months ago, could be even a year, before forum migration. Google is your best friend, let me know if you don't find anything, I will try to search trough my downloaded files if there is traces of link from where I downloaded those. Link to comment Share on other sites More sharing options...
Wuwuk Posted April 7, 2016 Share Posted April 7, 2016 (edited) Why engines sometimes do not work at full capacity, while the throttle stick to the maximum? This occurs during the rotation .This is a bug? Here is my script: clearscreen. lock throttle to 1.0. set countdown to 3. until countdown = 0 { print countdown. set countdown to countdown - 1. wait 1. } stage. wait 1. set st to 2. set max to ship:maxthrust. when status <> "landed" and (ship:maxthrust < max or ship:maxthrust < 1) then { stage. set max to ship:maxthrust. set st to st - 1. if st > 0 { preserve. } } wait until ship:altitude > 1000. lock steering to heading(0,90) + r(0,-20,0). wait until ship:altitude > 10000. lock steering to heading(0,90) + r(0,-45,0). wait until ship:altitude > 40000. lock steering to heading(0,90) + R(0,-90,0). wait until apoapsis > 100000. lock throttle to 0.0. lock steering to prograde. set warp to 3. wait until eta:apoapsis < 35. set warp to 0. wait until eta:apoapsis < 10. lock throttle to 1.0. wait until periapsis > 99000. lock throttle to 0.0. Edited April 7, 2016 by Wuwuk Link to comment Share on other sites More sharing options...
Warp11 Posted April 7, 2016 Share Posted April 7, 2016 I am trying to write a raw control script that rotates my vessel to a certain attitude (e.g. a maneuver node burn vector) by firing the rcs once, coast and then fire them again to kill the rotation. I cant find a way to judge the way I should be rotating though. All Operations i found do not take the roll of my ship into account. I need something that tells the script how many degrees it needs to pitch and yaw to get to the attitude and then I could scale the ship:control:pitch and yaw by that. Does anyone know a way to do that or is there an entirely different way of getting that behaviour? Thanks a lot Link to comment Share on other sites More sharing options...
pellinor Posted April 7, 2016 Share Posted April 7, 2016 27 minutes ago, Warp11 said: I am trying to write a raw control script that rotates my vessel to a certain attitude (e.g. a maneuver node burn vector) by firing the rcs once, coast and then fire them again to kill the rotation. I cant find a way to judge the way I should be rotating though. All Operations i found do not take the roll of my ship into account. I need something that tells the script how many degrees it needs to pitch and yaw to get to the attitude and then I could scale the ship:control:pitch and yaw by that. Does anyone know a way to do that or is there an entirely different way of getting that behaviour? Thanks a lot some ideas in pseudocode, likely with the wrong sign here and there: v1=Facing:ForeVector v2=nodeVector then axis=Vcrs(v1,v2) is the axis of rotation, and therefore the rotational impulse you need. Since rotational impulse behaves as a vector, you can split this into pitch=Vdot(axis,pitchAxis) and yaw=Vdot(axis, yawAxis) (with pitchAxis=Facing:StarVector and yawAxis=Facing:TopVector) which should give you the ratio (and sign) of pitch and yaw that are needed to rotate around this axis. (roll naturally stays out of the equation because rollAxis=v1 and therefore Vdot(axis,rollAxis)=0 ) Link to comment Share on other sites More sharing options...
Warp11 Posted April 7, 2016 Share Posted April 7, 2016 (edited) 4 hours ago, pellinor said: some ideas in pseudocode, likely with the wrong sign here and there: Thank you that sounds very promising! I spent my afternoon trying to figure out a hugely complicated way of doing it via the rotations by putting the pitch and yaw angles on a kartesian grid and doing some clever trigonometry. I kinda gave up on it though. I'll try your approach tomorrow, thank you. EDIT: Actually after thinking this thrue it seems so elegant. I didn't know the meaning of forevector, starvector and topvector and we're just learning about Vectors in school now and haven't even got to crossproducts yet, this is great. Edited April 7, 2016 by Warp11 Link to comment Share on other sites More sharing options...
Wuwuk Posted April 9, 2016 Share Posted April 9, 2016 Why engines are beginning to run rough at full throttle while turning like this: LOCK STEERING TO HEADING(0,90) + R(0,-20,0)? Link to comment Share on other sites More sharing options...
pellinor Posted April 9, 2016 Share Posted April 9, 2016 Fun with maneuver nodes: have you seen these glitches when the deltaV of the node flickers, and the node jumps between partly-executed states even without thrusting? I think I've also seen this in stock. In kOS the node:Prograde/RadialOut/Normal values seem to be conserved and the node:DeltaV vector does strange things. A discrepancy of 0.1 seems completely normal, but sometimes things really glitch out. Removing the node and readding it in the next frame does not seem to help. Anyone knows what triggers this or how it can be avoided? Link to comment Share on other sites More sharing options...
alacrity Posted April 10, 2016 Share Posted April 10, 2016 I am a long time Remote tech user and have decided I need to take my hard mode Modded install to a new level. Some notes on this that are prolly relevant. 1. I am really good setting and designing relays for Remote tech, specializing in minmum sats needed for coverage. 2. I have near zero coding experience ... so yeah. The problem I hope to correct is related to my Mars Direct mission. Remote tech makes this a unique problem in that I can't send ahead unmanned probe driven payloads to set up my station. The delay makes getting them into orbit as near to impossible as I can imagine. And forget landing an unmanned MAV. Being able to load an orbital insertion and landing program into my probe is better than sacrificing a pilot so I am going to have to learn kOS... I just had a few questions for the pros. 1. How reliable are these for running to completion? Even peppering a planetary system with sats will occasionally leave comms holes. 2. Can I run programs on separate ships simultaneously? If I send 4 ships to Duna, 3 of them probes running kOS, can they all have "Run Next Node" programs going with out them being the active vessel? Not a deal breaker... will just space the nodes out over a couple of days. 3. I have been looking at the sample codes in the thread (159 pages... sheesh not even including the reddits) and the syntax and lexicon seem fairly friendly, but how deep a hole am I digging for myself? Thanx Alacrity Link to comment Share on other sites More sharing options...
Warp11 Posted April 10, 2016 Share Posted April 10, 2016 (edited) @alacrity 1. They are perfectly reliable IF there are no bugs in them. Generally you will have bugs. So what I usually do is test it a couple of time with a quick safe and call it a simulation and then do one "real" run and if something goes wrong there thats that. 2. This only works if they are within physics range. So no. There could be an option to have the craft boot a program when you load it I'm not aware of though. That would be great, if anyone knows about one please post it. You can turn Remote Tech of for kOS though. So I work around this by turning it off when I load the craft, start the program and then turn it back on. Since I can't get the probe to keep running a program when its unloaded I don't view this as cheating. 3. It is pretty friendly. I had no idea about coding before and kinda taught it to myself using example codes and videos that go with them. It still took me like an intense holiday week to get to a point where I could do stuff and I have to learn new things every time I code something new. What you wanna do seems fairly ambitious to me but certainly doable. Propulsive landings are something I'm still struggling with. So you will have to put in some effort but it should be ok. Here's a video series i used to learn kOS: I hope this will help you and best of luck. Edited April 10, 2016 by Warp11 Link to comment Share on other sites More sharing options...
Dunbaratu Posted April 10, 2016 Share Posted April 10, 2016 On 4/7/2016 at 9:54 AM, Wuwuk said: Why engines sometimes do not work at full capacity, while the throttle stick to the maximum? This occurs during the rotation .This is a bug? Looking at your code the only thing I can think of is that maybe you left the thrust limiter on for the engine? I can't see any explanation for the behaviour inside the script. Link to comment Share on other sites More sharing options...
pellinor Posted April 10, 2016 Share Posted April 10, 2016 3 hours ago, Warp11 said: 2. This only works if they are within physics range. So no. There could be an option to have the craft boot a program when you load it I'm not aware of though. That would be great, if anyone knows about one please post it. You can turn Remote Tech of for kOS though. So I work around this by turning it off when I load the craft, start the program and then turn it back on. Since I can't get the probe to keep running a program when its unloaded I don't view this as cheating. You can set a boot file which auto-starts on load. If there is a file boot.ks, you can set it as boot file in the editor (the kos parts have a tweakable for this). Link to comment Share on other sites More sharing options...
Recommended Posts