erbmur Posted November 23, 2013 Share Posted November 23, 2013 Some testing is in order! Could you post the full code you use to get to 0 m/s and hover?It's not much:lock grav to sensor!grav().clearscreen.print "initiat hover".until verticalspeed = 0 { print grav at (0,2). print throttle at (0,3). lock throttle to (mass * grav)/maxthrust.}.I just started off with this and realized that the hover mechanic didn't seem to function so didn't go any further until i could work out why. With the local gravity and current throttle being printed you can see that the value for both the gravity and throttle are accurate to something like 10 decimal places and change very quickly. Seeing as using either my code or your code, the rate of acceleration either up or down is constant, which says it might actually be something inherent in the game.If it was something to do with the speed of calculation, surely the rate of acceleration wouldn't be constant and would fluctuate? Or am I on the wrong tracks here? Link to comment Share on other sites More sharing options...
Camacha Posted November 23, 2013 Share Posted November 23, 2013 didn't know we could use the sensors You can with Sensor Reporter, another mod anyways I would check by printing the grav from the formula and printing the sensor's readings and see if it is accurate?The returned values are very similar, but not exactly the same. Using them to hover produces the same result in my game though: a craft that will very slowly accelerate upwards.It appears that sensor inaccuracy is not the problem. Link to comment Share on other sites More sharing options...
Camacha Posted November 23, 2013 Share Posted November 23, 2013 If it was something to do with the speed of calculation, surely the rate of acceleration wouldn't be constant and would fluctuate? Or am I on the wrong tracks here?The fact that my acceleration is upwards while your acceleration is downwards irks me. I have a feeling that this means something relevant, but what I am yet to explain. Currently I am working on a problem that has kept me trying for a while now and I have the feeling that I am on the brink of a solution, so this will have to wait Link to comment Share on other sites More sharing options...
AbeS Posted November 23, 2013 Share Posted November 23, 2013 (edited) Also it will only work while pointing up, you need something to make it vary with inclination, so that your vertical acceleration is equal to gravity, will try to get something EDIT: this should take care of the inclination (this is very far from a perfectly working program)// Conversions to get the actual inclination (Maybe there's a better way I don't know about)lock tfv to velocity:surface.lock tfa to latitude.lock tfb to 0-up:yaw.lock tfe to 0 - tfv:x*cos(tfb) - tfv:z*sin(tfb).lock tfn to tfv:x*sin(tfa)*sin(tfb) + tfv:y*cos(tfa) + tfv:z*(0-sin(tfa)*cos(tfb)).lock tfu to tfv:x*(0-cos(tfa)*sin(tfb)) + tfv:y*sin(tfa) + tfv:z*cos(tfa)*cos(tfb).lock tfradius to (tfe^2 + tfn^2 + tfu^2)^0.5.lock incl to arcsin(tfu/tfradius).// Constantsset Gc to 6.67384*10^-11. // Grav Constantset PM to 5.97219*10^24. // Planet Mass (Real Solar System Mod Kerbin)set PR to 6371000. // Planet Radius (Real Solar System Mod Kerbin)lock alt to altitude + PR. // Real altitudelock grav to Gc*PM/(alt^2).// vertical acc = gravlock t to (mass*grav)/(maxthrust*sin(incl)).lock throttle to t.// I like seeing my numbers until 0 { print "Gravity: " + grav + " " at (0,5). print "Inclination: " + incl + " " at (0,7). print "Vertical Velocity: " + verticalspeed + " " at (0,9).}. Edited November 23, 2013 by AbeS Link to comment Share on other sites More sharing options...
Dunbaratu Posted November 23, 2013 Share Posted November 23, 2013 The fact that my acceleration is upwards while your acceleration is downwards irks me. I have a feeling that this means something relevant, but what I am yet to explain. Currently I am working on a problem that has kept me trying for a while now and I have the feeling that I am on the brink of a solution, so this will have to wait One possible explanation is that you two are deriving the TWR answer using slightly different math expressions that according to the rules of MATH are the same thing, but don't necessarily give the same result when storing intermediate values of the expression in the lossy storage format that computers tend to use. The fact that the gravitational parameter is derived from multiplying a very very tiny number by a very very big number in a way that cancels out their "bigness" to get a very medium number like 9.8 can mean that the exact order in which things are calculated makes a noted difference in error of the final answer depending on the order in which you perform the operations.Let bigNum = some really big number like 1.2345678 * 10^22let smallNum = some really small number like 1.2345678 * 10^(-22)In principle, bigNum * smallNum should give you exactly 1. And the following expressions should be the same:(bigNum / 1000) * 1000 * smallNumbigNum * smallNum * (1000/1000)(bigNum * 1000) * ( smallNum / 1000)But in practice on a computer they often are slightly different because you're storing intermediate values along the way in a format that can't store them *exactly* as they are, so that it matters which "lossy" operations happen when.That's just a guess. Link to comment Share on other sites More sharing options...
Dunbaratu Posted November 23, 2013 Share Posted November 23, 2013 I originally thought it was a casting issue, i'll blame that goose chase on insomnia. After i got some sleep i looked at the parsing itself and it was a simple fix. What's happening with that code is OR(AND will as well) forces a conversion to boolean. IF, WHEN..THEN and UNTIL have no issue with booleans. The real issue was the regex for the conditional forbids the usage of double quotes and braces. Doing 'status == "LANDED"' should have also converted to boolean but the bug prevented it getting that far.But... But... it *works* when I do it.See this example:set x to "bbb".if x = "aaa" { print "it is aaa". }.if x = "bbb" { print "it is bbb". }.it is bbbThat seems to be comparing to a string literal just fine. Link to comment Share on other sites More sharing options...
Dunbaratu Posted November 23, 2013 Share Posted November 23, 2013 set PM to 5.97219*10^24. // Planet Mass (Real Kerbin)set PR to 6371000. // Planet Radius (Real Kerbin)A warning to anyone who tries to use this code: When @AbeS said "Real Kerbin" that does NOT mean "this is the real data for Kerbin". If you use these numbers in a stock install of KSP, it WILL mess you up. What "Real Kerbin" means is this: "There is a Mod called 'Real Kerbin'. It changes the values of Kerbin to be similar in magnitude to Earth. These are the values to use when you have that Mod installed."Just seeing the words "Real Kerbin" in the code won't clue people in to that if they hadn't heard of the mod. Link to comment Share on other sites More sharing options...
AbeS Posted November 23, 2013 Share Posted November 23, 2013 Fixed it (Real Solar System Mod Kerbin) Link to comment Share on other sites More sharing options...
mileshatem Posted November 23, 2013 Share Posted November 23, 2013 I've tried searching but I must be looking in the wrong places because I'm coming up empty. Can anyone tell me how to access the individual components of the velocity vector? Or alternatively if there is an "orbitalspeed" equivalent to surface speed that would work as well.If you need context for what I'm using it for, here's what I'm attempting to do:wait until eta:apoapsis < abs(2287-<orbitalspeed>)/(maxthrust/mass).If I can access the individual components of "velocity" I figure I can just SRS them to get orbital speed. Link to comment Share on other sites More sharing options...
Dunbaratu Posted November 23, 2013 Share Posted November 23, 2013 I've tried searching but I must be looking in the wrong places because I'm coming up empty. Can anyone tell me how to access the individual components of the velocity vector? Or alternatively if there is an "orbitalspeed" equivalent to surface speed that would work as well.VELOCITY:ORBIT is a vector. All vectors allow you to perform these operations:somevector:xsomevector:ysomevector:zsomevector:magso you want VELOCITY:ORBIT:MAG. Link to comment Share on other sites More sharing options...
mileshatem Posted November 23, 2013 Share Posted November 23, 2013 so you want VELOCITY:ORBIT:MAG.Ah! Everything I was finding said that VELOCITY was the orbital velocity vector (which it also appears to be), and that you could do :MAG to get the magnitude of a vector. But when I tried doing VELOCITY:MAG it failed (along with VELOCITY:X etc.). Didn't realize I needed the :ORBIT in there, thanks! Link to comment Share on other sites More sharing options...
Dunbaratu Posted November 23, 2013 Share Posted November 23, 2013 Ah! Everything I was finding said that VELOCITY was the orbital velocity vector (which it also appears to be), and that you could do :MAG to get the magnitude of a vector. But when I tried doing VELOCITY:MAG it failed (along with VELOCITY:X etc.). Didn't realize I needed the :ORBIT in there, thanks!Yeah there's backward compatibility problems in how things are documented. Originally VELOCITY was orbital and there was no way to get the surface velocity and then you just used it without the suffix. Link to comment Share on other sites More sharing options...
Mulbin Posted November 24, 2013 Share Posted November 24, 2013 Ok... stuck right at the start here. Can someone tell me how I create a new file? In all the videos I have seen people are editing an existing program by typing "edit (filename)" but I have no files to edit, what is the command to create a new file? Cant find it anywhere! Link to comment Share on other sites More sharing options...
Camacha Posted November 24, 2013 Share Posted November 24, 2013 Ok... stuck right at the start here. Can someone tell me how I create a new file? In all the videos I have seen people are editing an existing program by typing "edit (filename)" but I have no files to edit, what is the command to create a new file? Cant find it anywhere!Just type the filename you want, that is how you make it Remember to save it before you return to the index.I would like to suggest you use the IDE instead of the built in editor. So much easier. Link to comment Share on other sites More sharing options...
Mulbin Posted November 24, 2013 Share Posted November 24, 2013 Just type the filename you want, that is how you make it Remember to save it before you return to the index.I would like to suggest you use the IDE instead of the built in editor. So much easier.Ok, not with you.So I turn on the part and I get....KOS Operating systemBlah blah blahProceed.What do I do now? Just typing a name here does nothing at all. Link to comment Share on other sites More sharing options...
Bizz Keryear Posted November 24, 2013 Share Posted November 24, 2013 You can with Sensor Reporter, another mod The returned values are very similar, but not exactly the same. Using them to hover produces the same result in my game though: a craft that will very slowly accelerate upwards.It appears that sensor inaccuracy is not the problem.actually native kOS lately supports sensors, too. usage SENSOR:GRAV // returns a vectorSENSOR:ACC // returns also a vectorThey might be turned on first with e.g. SENSOR:GRAV:ON.I haven't tested it so far. I only read it out of the sources. Link to comment Share on other sites More sharing options...
Mulbin Posted November 24, 2013 Share Posted November 24, 2013 Alternatively if noone can tell me how I create my own file is there somewhere I can download an existing one so I can use the edit command to get into the editor that way? Link to comment Share on other sites More sharing options...
Camacha Posted November 24, 2013 Share Posted November 24, 2013 What do I do now? Just typing a name here does nothing at all.Type in "Edit filename" and you will begin a file with the name filename. If you press F5 you will save it to the local disk, with F10 you go back to the main screen. By then typing "Run filename" you can run the program you just wrote. By typing "Copy filename to 0" you will save it to archive. You will need to do that last bit if you want to permanently save the program!You can use any name instead of filename, it is just an example! Link to comment Share on other sites More sharing options...
Sacred Aardvark Posted November 24, 2013 Share Posted November 24, 2013 (edited) Ok, not with you.So I turn on the part and I get....KOS Operating systemBlah blah blahProceed.What do I do now? Just typing a name here does nothing at all."edit FileYouWantToCreate." (e.g. "edit takeoff." or "edit banana." or whatever) without the quotes to bring up the editor for that file, and if said filename doesn't exist, it will be created after you save your edit with F5.[edit] curse my slow fingers, Camacha was faster x) Edited November 24, 2013 by Sacred Aardvark 'nathed Link to comment Share on other sites More sharing options...
razark Posted November 24, 2013 Share Posted November 24, 2013 what is the command to create a new file?"edit <filename>."When you finish, you can save it (F5, I think). To keep it beyond the current flight, use "copy <filename> to Archive." In later flights, you can "copy <filename> from Archive. run <filename>." Link to comment Share on other sites More sharing options...
Camacha Posted November 24, 2013 Share Posted November 24, 2013 I haven't tested it so far. I only read it out of the sources.Interesting. I can not get it to work, but that does not mean it does not work. I am running kOS 0.9.1. Link to comment Share on other sites More sharing options...
Bizz Keryear Posted November 24, 2013 Share Posted November 24, 2013 Ok, not with you.So I turn on the part and I get....KOS Operating systemBlah blah blahProceed.What do I do now? Just typing a name here does nothing at all.Just use edit TheFileNameIWantToUse. and it will create a (temporary) filenamed TheFileNameIWantToUse if you now save it with F5 its on the disk of the ship.Beware: Reverting the ship to VAB (or SPH) or to launch (short any save before your made the script) will delete it.But rejoice there is a way around the archive drive it saves the scripts physically on YOUR harddisk path *path to KSP*\Plugins\PluginData\Archive. They are saved as txt files.You can copy them to or from the archive with copy programName from 0. // for copying it from archive Link to comment Share on other sites More sharing options...
Mulbin Posted November 24, 2013 Share Posted November 24, 2013 Never mind, got it. "Edit" actually also means "create" if there is no such filename. Link to comment Share on other sites More sharing options...
Mulbin Posted November 24, 2013 Share Posted November 24, 2013 Just use edit TheFileNameIWantToUse. and it will create a (temporary) filenamed TheFileNameIWantToUse if you now save it with F5 its on the disk of the ship.Beware: Reverting the ship to VAB (or SPH) or to launch (short any save before your made the script) will delete it.But rejoice there is a way around the archive drive it saves the scripts physically on YOUR harddisk path *path to KSP*\Plugins\PluginData\Archive. They are saved as txt files.You can copy them to or from the archive with copy programName from 0. // for copying it from archiveNinja'd! Thanks anyway Link to comment Share on other sites More sharing options...
Camacha Posted November 24, 2013 Share Posted November 24, 2013 Never mind, got it. "Edit" actually also means "create" if there is no such filename.It was hard not to get, with four different explanations Link to comment Share on other sites More sharing options...
Recommended Posts