Nadrek
Members-
Posts
82 -
Joined
-
Last visited
Content Type
Profiles
Forums
Developer Articles
KSP2 Release Notes
Everything posted by Nadrek
-
[0.22-0.23.0] Payload Fraction Challenge
Nadrek replied to mhoram's topic in KSP1 Challenges & Mission ideas
First off, this is a great challenge - in particular, I feel that payload fraction is the most critical metric for any lifter you're using to ascend from an off-Kerbin body. Here's my rather mild entry - it started out as a technology demonstrator for subassemblies, normal engines used in radial mode, multi-layered 8-way symmetry, extended asparagus staging, and minor amounts of Mechjeb ascent path staging. 126.8t payload 752.05t including launch clamps on the launchpad. 16.86% payload fraction. 16/17 propellant stages. On the launchpad: In orbit: Craft file: http://pastebin.com/f77asuZY Mechjeb hands-off after launch settings: Orbit altitude 75.05km Orbit inclination 0 degrees Prevent Overheats on Limit to Terminal Velocity on Limit accel to 22.5m/s on Corrective steering on Autostage on, delays .15 pre, .2 post Ascent path: Turn start 8km, Turn end 60km, Final flight path angle 0 degrees, turn shape 40% Before physics kicks in, engage Mechjeb ascent autopilot. As soon as physics kicks in, press R and space to enable RCS and launch. There's obviously a long way to improve by cutting the X200-64's down to smaller tanks and more stages, and dropping the second central Mainsail. There's almost certainly too many struts, the regular size decouplers weigh too much, and the engines and ascent profile can almost certainly be tuned further. -
My thanks to you, Kasuha - I now know more about 0.22 fuel flow than I did before - it sounds like my technique is being killed by a minor fuel code optimization. Your suggestion does solve the unbalancing problem, and I appreciate that - unfortunately, it does mean I can't use this technique to replace radial engines in asparagus configurations, so I do still need other engines for the final stage. One question - if I'm drawing fuel lines from the L and R tanks directly to the radial decoupled engines, for what reason do you suggest drawing them directly to the engines instead of the tank above them? Those little tanks are there solely as an attachment point for the engines that's far enough out from the C tank and won't have any issues I'd heard about with cubic octagonal struts, not because I wanted extra mass along for the ride.
-
I'm now very confused - trying to get a decent payload fraction, I've set up a normal Asparagus (on I-beams) setup, outer tanks flowing to each other, then to the inner tank. Then I put boosters right on the inner tank, drawing fuel from the inner tank, and it's fine. Then I put a stage below it that feeds the outermost asparagus stage above it... and the inner booster ring is not only drawing fuel from the asparagus ring, but from only one side of it! KSP 0.22, Mechjeb 2.1, Kerbal Flight Engineer 6.1.4. Craft file: http://pastebin.com/zjrE0r5t
-
Body.maxAtmosphereAltitude as in local Orbits = script.call("Planetarium.Orbits") if PlanetIndex == nil then -- Kerbol print("Nameindex nil") Body = Orbits[2].referenceBody elseif MoonIndex1 == nil then -- Planet print("Nameindex " .. PlanetIndex) Body = Orbits[2].referenceBody.orbitingBodies[PlanetIndex] elseif MoonIndex2 == nil then -- Moon of a Planet print("Nameindex " .. PlanetIndex .. "," .. MoonIndex1) Body = Orbits[2].referenceBody.orbitingBodies[PlanetIndex].orbitingBodies[MoonIndex1] else -- Moon of a Moon of a Planet print("Nameindex " .. PlanetIndex .. "," .. MoonIndex1 .. "," .. MoonIndex2) Body = Orbits[2].referenceBody.orbitingBodies[PlanetIndex].orbitingBodies[MoonIndex1].orbitingBodies[MoonIndex2] end
-
My apologies - I didn't know the errors could happen at any time, as I'd only seen them on the wait() loops and I hadn't delved deeper. I was running my Isp test routine; a much newer version which I'll release once I've finished adding Delta-V vector burn code. In-progress beta: Som http://pastebin.com/dt7wsq2Z Skom http://pastebin.com/AnDhqQvP Skoo http://pastebin.com/FiDgeSZy require "SimpleKSPOrbitalOperations" cotestSkooIspFromTmbiTmbtwnNsMpcsMnottbsMnst(0.08, 0.15, 250, 0.01, 20000, 12) With clumsier ships, it'll typically die during the "figure out if we're done pointing yet" phase. If it gets past that, then it's likely to due during the very fine-grained throttle settings. Note that "make them able to resume" is not nearly as easy as it sounds, and it's even more difficult because of the limited amount of output before the Autom8 windows stops showing output altogether. Combined with being able to create files, but not write to them (in any of my tests, at least), this provides several challenges, even for work that's not timing sensitive. Regardless, thank you for Autom8 and for reducing the frequency of sync errors! Is there any kind of error trapping we can do in lua?
-
r4m0n, would you like a new report on the Userecho/whatever new place? MechJeb 1.9.3 is still vulnerable to the out of sync errors on wait(), which makes any precision control very difficult, to say the least. 0.187329864501953 loop 166 Coroutine exception: InvalidOperationException - out of sync at System.Collections.Generic.Dictionary`2+Enumerator[SharpLua.LuaTypes.LuaValue,SharpLua.LuaTypes.LuaValue].VerifyState () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+Enumerator[SharpLua.LuaTypes.LuaValue,SharpLua.LuaTypes.LuaValue].MoveNext () [0x00000] in <filename unknown>:0 at System.Collections.Generic.Dictionary`2+KeyCollection+Enumerator[SharpLua.LuaTypes.LuaValue,SharpLua.LuaTypes.LuaValue].MoveNext () [0x00000] in <filename unknown>:0 at SharpLua.LuaTypes.LuaTable.GetKey (System.String key) [0x00000] in <filename unknown>:0 at SharpLua.LuaTypes.LuaTable.GetValue (System.String name) [0x00000] in <filename unknown>:0 at SharpLua.LuaTypes.LuaTable.GetValueFromMetaTable (System.String name) [0x00000] in <filename unknown>:0 at SharpLua.LuaTypes.LuaTable.GetValue (System.String name) [0x00000] in <filename unknown>:0 at SharpLua.LuaTypes.LuaTable.GetValueFromMetaTable (System.String name) [0x00000] in <filename unknown>:0 at SharpLua.LuaTypes.LuaTable.GetValue (System.String name) [0x00000] in <filename unknown>:0 at SharpLua.AST.VarName.Evaluate (SharpLua.LuaTypes.LuaTable enviroment) [0x00000] in <filename unknown>:0 at SharpLua.AST.Operation.InfixBinaryOperation (SharpLua.AST.Term LeftOperand, System.String Operator, SharpLua.AST.Term RightOperand, SharpLua.LuaTypes.LuaTable enviroment) [0x00000] in <filename unknown>:0 at SharpLua.AST.Operation.Evaluate (SharpLua.LuaTypes.LuaTable enviroment) [0x00000] in <filename unknown>:0 at SharpLua.AST.FunctionCall+<Evaluate>c__AnonStorey9.<>m__B (SharpLua.AST.Expr arg) [0x00000] in <filename unknown>:0 at System.Collections.Generic.List`1[SharpLua.AST.Expr].ConvertAll[LuaValue] (System.Converter`2 converter) [0x00000] in <filename unknown>:0 at SharpLua.AST.FunctionCall.Evaluate (SharpLua.LuaTypes.LuaValue baseValue, SharpLua.LuaTypes.LuaTable enviroment) [0x00000] in <filename unknown>:0 at SharpLua.AST.PrimaryExpr.Evaluate (SharpLua.LuaTypes.LuaTable enviroment) [0x00000] in <filename unknown>:0 at SharpLua.AST.Operation.InfixBinaryOperation (SharpLua.AST.Term LeftOperand, System.String Operator, SharpLua.AST.Term RightOperand, SharpLua.LuaTypes.LuaTable enviroment) [0x00000] in <filename unknown>:0 at SharpLua.AST.Operation.Evaluate (SharpLua.LuaTypes.LuaTable enviroment) [0x00000] in <filename unknown>:0 at SharpLua.AST.Assignment+<Execute>c__AnonStorey4.<>m__5 (SharpLua.AST.Expr expr) [0x00000] in <filename unknown>:0 at System.Collections.Generic.List`1[SharpLua.AST.Expr].ConvertAll[LuaValue] (System.Converter`2 converter) [0x00000] in <filename unknown>:0 at SharpLua.AST.Assignment.Execute (SharpLua.LuaTypes.LuaTable enviroment, System.Boolean& isBreak) [0x00000] in <filename unknown>:0 at SharpLua.AST.Chunk.Execute (System.Boolean& isBreak) [0x00000] in <filename unknown>:0 at SharpLua.AST.Chunk.Execute (SharpLua.LuaTypes.LuaTable enviroment, System.Boolean& isBreak) [0x00000] in <filename unknown>:0 at SharpLua.AST.WhileStmt.Execute (SharpLua.LuaTypes.LuaTable enviroment, System.Boolean& isBreak) [0x00000] in <filename unknown>:0 at SharpLua.AST.Chunk.Execute (System.Boolean& isBreak) [0x00000] in <filename unknown>:0 at SharpLua.AST.Chunk.Execute () [0x00000] in <filename unknown>:0 at SharpLua.AST.FunctionBody+<Evaluate>c__AnonStorey8.<>m__A (SharpLua.LuaTypes.LuaValue[] args) [0x00000] in <filename unknown>:0 at SharpLua.AST.FunctionCall.Evaluate (SharpLua.LuaTypes.LuaValue baseValue, SharpLua.LuaTypes.LuaTable enviroment) [0x00000] in <filename unknown>:0 at SharpLua.AST.PrimaryExpr.Evaluate (SharpLua.LuaTypes.LuaTable enviroment) [0x00000] in <filename unknown>:0 at SharpLua.AST.LocalVar+<Execute>c__AnonStorey7.<>m__9 (SharpLua.AST.Expr expr) [0x00000] in <filename unknown>:0 at System.Collections.Generic.List`1[SharpLua.AST.Expr].ConvertAll[LuaValue] (System.Converter`2 converter) [0x00000] in <filename unknown>:0 at SharpLua.AST.LocalVar.Execute (SharpLua.LuaTypes.LuaTable enviroment, System.Boolean& isBreak) [0x00000] in <filename unknown>:0 at SharpLua.AST.Chunk.Execute (System.Boolean& isBreak) [0x00000] in <filename unknown>:0 at SharpLua.AST.Chunk.Execute () [0x00000] in <filename unknown>:0 at SharpLua.AST.FunctionBody
-
So far I've been editing my original post, and posting a new reply to point people there and let them know the changes. r4m0n, is there something else we should do to qualify for being listed on the front page/first post?
-
Do you have the equation for that handy, based on the data in the CelestialBody class?
-
I'd have to say that a Mechjeb profile is at least repeatable and if the rocket is stable, consistent.
-
Approximate delta-V on what trajectory, with what approximate TWR's? On what flight path?
-
Celestial Body information updated - now includes Kerbol, Kerbin G's at sea level, atmosphere limits, and a few other values. All information pulled directly out of the interface via Mechjeb Autom8, with thanks to the KSP team for the addon interface and the Mechjeb team for the Autom8 interface. http://kerbalspaceprogram.com/forum/showthread.php/19573-Get-Celestial-Body-Orbital-%28etc-%29-Elements-from-KSP-itself?p=277387&viewfull=1#post277387
-
Second pass complete; added several body parameters, including atmosphere values and GeeASL (Kerbin G's at sea level), time warp altitude limits, and a few other values. Also included basic information on Kerbol! This variant still has all angles in degrees, since more of them are commonly used as degrees than as radians. http://pastebin.com/DfH5rSmU Code and explanations are at the end.
-
maltesh put together a spreadsheet of celestial body orbits that might be useful for this: http://kerbalspaceprogram.com/forum/showthread.php/21251-17-Planet-information?p=272764&viewfull=1#post272764
-
[1.3.0] Kerbal Engineer Redux 1.1.3.0 (2017-05-28)
Nadrek replied to cybutek's topic in KSP1 Mod Releases
Thank you for taking up this amazing mod; I hope you choose to work out complex fuel line based rocket staging. My best designs have an onion shape, and lose fuel tanks (and every 3 sets of tanks, a set of engines) in pairs and quads for the main rocket. Massive booster stages for getting entire interplanetary missions up, well, those aren't as elegant. -
We're working on it. Doing it right (efficient launch windows and vectors) is a lot of math.
-
I'm going to go with some simple things: 1) Toggle vertical snap in the VAB/SPH - even the current snap to center would be fine, though a few settings (top, 25% down, center, 75% down, bottom) would be even better, just like the current symmetry options. 2) Increased strength large radial decoupler. 3) Standoff fuel line - right now, connecting staged fuel stacks sometimes requires using a small hardpoint between the fuel tank and the fuel line so the fuel line can get past certain items, like decouplers. 4) Even longer landing legs (I have to use two small hardpoints to get the large legs to reach ground past the nuclear engine) - no larger in diameter than the current large ones, unless 5) and 7) are also done. 5) All landing legs should allow strut reinforcement (see 4) ) 6) Longer radial decouplers - sometimes I just need more distance so I can pack things in between, or put parts below others and not have exhaust blow them up. 7) Long hardpoints (see 6) ) 8) Septcouplers - in particular, so I can place 7 engines under a large fuel tank (assuming they don't guarantee explosions). Alternate: Anything more than 4. 9) Fixed Aerospike placement. Now I have to put FL-200 fuel tanks under the tricoupler to get the Aerospikes to "attach", and that gives me fuel line headaches. 10) Finer grained rotation. When placing the separator rocket on top of a hex symmetry outer set of fuel tanks, it's not possible to point them all at the center. octo symmetry would be worse! And on the "I'd like it, but I doubt it" list: A) "Symmetry applies to [Current part/Overall rocket]". I.e. when I build some rockets, I can use symmetry to put tanks around the center. Then symmetry applies to the overall rocket automatically. If I have to hand-place those tanks (absolutely required sometimes), then symmetry applies to the current part... even if I created a 6x symmetric rocket, and wished I could use symmetry every again. Yes, I love big rockets.
-
Personally, I'd love realistic or near-realistic ion engines! Your pacing and my pacing are different; I'm _quite_ happy to leave KSP running in the background for hours at a time - and the new physics warps will help that immensely. I've been doing that since playing Harpoon when it first came out - set up your scenario, give your commands, watch the first few launches of the main battle... and go to sleep. Check it in the morning and by the following evening, perhaps you can do something else again. Remember, we all play KSP differently. Sometimes only a tiny bit differently, sometimes it's as if it were N completely different games. Now, I do have to agree that long-term powered flights running while not the focus would be awesome (and would allow the solar powered satellite users options to "keep the panels pointed at the sun" and comm/spy sats to keep antennas oriented at their targets), but I can see that it's not real high on the list right now.
-
Purely from observation, I think Mechjeb perhaps tries to lower your thrust whenever your drag losses exceed your gravity losses; i.e. don't lose more to drag than you do to gravity. Some other forum users have stated that Mechjeb ascent autopilot defaults are not the most efficient way to get to Kerbin orbit, however. I have yet to do serious testing. As far as the OP goes, yes, balancing increased drag vs. more staging is critical. For those who prefer LFE's to SRB's, make sure your fuel always goes from outer (i.e. early dropped, higher number) stages to inner (i.e. late dropped, lower number) stages.
-
I can confirm this; autostaging does not work when the separator rockets are on the next stage (at least). Example .craft at http://pastebin.com/zrxpHF4m - be warned, it's a few hundred part rocket. The very first stage dropping off (the turbojets) is _not_ autostaged by the Mechjeb Ascent Autopilot, all other stages are fine. That stage was fine prior to the little tiny separator rockets being put on (four total, two each on the jet assembly directly below the 3200L tanks. All stages after the stage with the separator rockets also work fine with autostaging.
-
Try typing mechjeb.controlRelease() If that doesn't work, I've had 100% success with backing out to the Start Game menu and then going back in. There's likely a middle ground somewhere, but I don't know what it is yet.
-
First, next time, please include more of the lua error messages. SharpLua (the version used in Autom8) has an interesting habit of putting the _actual_ line number farther down - in this case, line 31. Second, I see the problem - I had the same issues with anonymous functions and eventually abandoned the practice. No guarantees, but try replacing line 31, wait(function() return vessel.altitudeASL < 5000 end) with local Function1 = function() return vessel.altitudeASL < 5000 end wait(Function1)
-
Thank you - I'll update my comments with your information. Any ideas on the units they're in? I understand about the Radians comment, but note this was generated with procedure "reportSkomKSPCurrentOrbitalElementsDegreesFromObt" - every angular measure is in degrees. Another variant is planned, where every angular measure will be in radians. I don't believe that mixed degrees and radians is a good way of reporting data; nor do I believe that mixed meters and kilometers is a good way of reporting data. One unit for angle, one for length, one for time, and so on, always consistent - users can convert as they wish... if they know the source unit. If the source units different field to field, that's hard to keep track of for new users who haven't memorized any particular convention... and I have some doubts that there is only one worldwide convention. Even if there is, I'm targetting brand new users, so I stand by consistency - anyone else can take my SimpleKSPOrbitalMechanics.lua and either change it directly, or write a function and converts some fields to one unit and some to another unit.
-
As Peewee said, to do neat things, we have to work out the neat math first, and then code it, and then test it, and then go back to the math, and then change the design, and so on. The neat stuff isn't quite as trivial as it appears - it is, in fact, rocket science*. Once we have a really good, solid foundation, then all Autom8 using Kerbal engineers and scientists will have more building blocks to work with. Also, don't sell yourself short - look at Peewee's tour script; I bet you can spend less than ten minutes, and modify it so that it goes on the tour in reverse order. You could also take FlyMeToTheMun, and alter it to be FlyMeToTheMinmus. All it takes is a little trial and error, and a few brave Kerbals. *: Two body simplification thereof.
-
With great thanks to the developers of KSP and Mechjeb and r4m0n in specific (and MonoDevelop_ to get some more parameters, I've compiled an initial draft of Celestial Body parameters in KSP. http://pastebin.com/DfH5rSmU (older, less complete but still 100% accurate data at http://pastebin.com/4wXDzBdG) and snippets of the initial draft lua code for Autom8 - units are in the comments where I know them. function guessSomBodyFullnameFromShortname(Shortname) -- added in v0.003 --print("guessSomBodyFullnameFromShortname got shortname " .. Shortname) localFullName = "Unknown_Full_Name" if Shortname == "Kerbin" then return "KSP_Galaxy1_Kerbol_Kerbin" elseif Shortname == "Mun" then return "KSP_Galaxy1_Kerbol_Kerbin_Mun" elseif Shortname == "Minmus" then return "KSP_Galaxy1_Kerbol_Kerbin_Minmus" elseif Shortname == "Moho" then return "KSP_Galaxy1_Kerbol_Moho" elseif Shortname == "Eve" then return "KSP_Galaxy1_Kerbol_Eve" elseif Shortname == "Gilly" then return "KSP_Galaxy1_Kerbol_Eve_Gilly" elseif Shortname == "Duna" then return "KSP_Galaxy1_Kerbol_Duna" elseif Shortname == "Ike" then return "KSP_Galaxy1_Kerbol_Duna_Ike" elseif Shortname == "Jool" then return "KSP_Galaxy1_Kerbol_Jool" elseif Shortname == "Laythe" then return "KSP_Galaxy1_Kerbol_Jool_Laythe" elseif Shortname == "Vall" then return "KSP_Galaxy1_Kerbol_Jool_Vall" elseif Shortname == "Tylo" then return "KSP_Galaxy1_Kerbol_Jool_Tylo" elseif Shortname == "Bop" then return "KSP_Galaxy1_Kerbol_Jool_Bop" elseif Shortname == "Sun" then return "KSP_Galaxy1_Kerbol" elseif Shortname == nil then return nil end end globalRadiansToDegreesMultiplier = 180/math.pi -- in pure units. Multiply radians by this to get degrees. globalDegreesToRadiansMultiplier = 1/(180/math.pi) -- in pure units. Multiply degrees by this to get radians. function reportSkomKSPCurrentOrbitalElementsDegreesFromObt(Orbit) -- added in v0.003, variables renamed/updated in v0.004 and (orbit) passin added -- possible sources of Orbit: -- mechjeb.core.targetVessel.orbit (select target Vessel or Debris, NOT Bodies, in Rendevous Module GUI) -- mechjeb.core.targetBody.orbit (select target Celestial Body in Rendevous Module GUI) -- mechjeb.core.part.vessel.orbit (your own current vessel, but .name shows your craft name) -- mechjeb.core.part.orbit (your own current vessel, but .name shows mumech.mechjeb) -- local Orbits = script.call("Planetarium.Orbits") -- local i = 1 -- for i = 1, 4 do -- <whatever you want, with Orbits[i]> -- end -- Simply returns a set of variables for other use. -- Apa is the Apoapsis from sea level in meters -- Apr is the Apoapsis from the center of the body (radius) in meters -- Pea is the Periapsis from sea level in meters -- Per is the Periapsis from the center of the body (radius) in meters -- Sop is the sidereal orbital period in seconds -- Tmtoap is the time to Apoapsis in seconds -- Tmtope is the time to Periapsis in seconds -- Lan is the Longitude of the Ascending Node in degrees -- Ape is the Argument of Periapsis in degrees -- Lpe is the Longitude of Periapsis in degrees -- Ma is the Mean Anomaly in degrees -- Maae is the Mean Anomaly at Epoch in degrees -- Ta is the True Anomaly in degrees -- Ea is the Eccentric Anomaly in degrees -- Epch is the Epoch in seconds since the start of the KSP universe (i.e. since time 0 in persistence.sfs or vessel.time, etc.) -- Strtut is the Start of UT in seconds... someone tell me what this is, please? -- Inc is the Inclination of the orbit in degrees -- Ecc is the eccentricity of the orbit -- a is the semi-major axis in meters -- Posvec3[1] is the position vector ?x? ?? -- Posvec3[2] is the position vector ?y? ?? -- Posvec3[3] is the position vector ?z? ?? -- Velvec3[1] is the velocity vector ?x? ?? -- Velvec3[2] is the velocity vector ?y? ?? -- Velvec3[3] is the velocity vector ?z? ?? -- l is the semi-latus rectum in meters -- Os is the ?? Unknown type does not match navball ?? orbital velocity in m/s -- Oe is the ?? Unknown ?? orbital energy in ?? -- Altunk is the ?? Unknown type - not true, ASL, or bottom ?? altitude in meters -- Rfcb is the Radius From Central Body in meters, the distance in meters from the orbiting -- object to the center of gravity it's orbiting (i.e. the center of the planet) -- Obt is the ?? -- Obtae is the ?? at epoch -- Sevp is the ?? -- Sevs is the ?? -- E is the ?? -- V is the ?? -- Frme is the ?? -- Frmv is the ?? -- Toe is the ?? -- Tov is the ?? -- Utappr is the ?? -- probably encounter related -- Utsoi is the ?? -- probably hill sphere of influence related -- Refbodnamefull is the fully qualified name of the body it's orbiting, i.e. Universe_Galaxy_Solarsystem_Planet_Moon, i.e. KSP_Galaxy1_Kerbol_Kerbin_Mun or RL_MilkyWay_Sol_Earth -- Refbodnameshort is the short name of the body its orbiting, i.e. "Mun" or "Jupiter" -- Clappr is the ?? -- probably encounter related -- Clectr1 is the ?? -- probably encounter related -- Clectr2 is the ?? -- probably encounter related -- Crappr is the ?? -- probably encounter related -- Eccvec3[1] is the ?? -- Eccvec3[2] is the ?? -- Eccvec3[3] is the ?? -- Hvec3[1] is the ?? -- Hvec3[2] is the ?? -- Hvec3[3] is the ?? -- Fevp is the ?? -- Fevs is the ?? -- mag is the ?? -- Clsencbodynamefull is the fully qualified name of the closest encounter body, or nil -- Clsencbodynameshort is the fully qualified name of the closest encounter body, or nil -- TODO - a few more items, including next patch and previous patch. --[[ example: require "SimpleKSPOrbitalMechanics" do local Orbits = script.call("Planetarium.Orbits") local i = 1 -- planet local j = 1 -- moon local localApa, localApr, localPea, localPer, localSop, localTmtoap, localTmtope, localLan, localApe, localLpe, localMa, localMaae, localTa, localEa, localEpch, localInc, localEcc, locala, localStrtut, localEndut, localPosvec3, localVelvec3, locall, localOs, localOe, localAltunk, localRfcb, localObt, localObtae, localSevp, localSevs, localE, localV, localFrme, localFrmv, localToe, localTov, localUtappr, localUtsoi, localRefbodnamefull, localRefbodnameshort, localClappr, localClectr1, localClectr2, localCrappr, localEccvec3, localHvec3, localFevp, localFevs, localMag, localClsencbodynamefull, localClsencbodynameshort -- these are for planets -- = reportSkomKSPCurrentOrbitalElementsDegreesFromObt(Orbits[2].referenceBody.orbitingBodies[i].orbit) = reportSkomKSPCurrentOrbitalElementsDegreesFromObt(Orbits[2].referenceBody.orbitingBodies[i].orbitingBodies[j].orbit) -- = reportSkomKSPCurrentOrbitalElementsDegreesFromObt(mechjeb.core.part.vessel.orbit) -- print("Nameshort " .. Orbits[2].referenceBody.orbitingBodies[i].name) -- print("Namefull " .. guessSomBodyFullnameFromShortname(Orbits[2].referenceBody.orbitingBodies[i].name)) -- --print(Orbits[2].referenceBody.orbitingBodies[2].gravParameter .. " " .. Orbits[1].referenceBody.orbitingBodies[2].name) -- print("Gm " .. Orbits[2].referenceBody.orbitingBodies[i].gravParameter) -- print("Hsoi " .. Orbits[2].referenceBody.orbitingBodies[i].hillSphere) -- print("Radius " .. Orbits[2].referenceBody.orbitingBodies[i].Radius) -- --print("Rotates " .. Orbits[2].referenceBody.orbitingBodies[i].rotates) -- print("RotationPeriod " .. Orbits[2].referenceBody.orbitingBodies[i].rotationPeriod) -- print("Soi " .. Orbits[2].referenceBody.orbitingBodies[i].sphereOfInfluence) print("Nameshort " .. Orbits[2].referenceBody.orbitingBodies[i].orbitingBodies[j].name) print("Namefull " .. guessSomBodyFullnameFromShortname(Orbits[2].referenceBody.orbitingBodies[i].orbitingBodies[j].name)) print("Nameindex " .. i .. "," .. j) --print(Orbits[2].referenceBody.orbitingBodies[2].gravParameter .. " " .. Orbits[1].referenceBody.orbitingBodies[2].name) print("Gm " .. Orbits[2].referenceBody.orbitingBodies[i].orbitingBodies[j].gravParameter) print("Hsoi " .. Orbits[2].referenceBody.orbitingBodies[i].orbitingBodies[j].hillSphere) print("Radius " .. Orbits[2].referenceBody.orbitingBodies[i].orbitingBodies[j].Radius) --print("Rotates " .. Orbits[2].referenceBody.orbitingBodies[i].orbitingBodies[j].rotates) print("RotationPeriod " .. Orbits[2].referenceBody.orbitingBodies[i].orbitingBodies[j].rotationPeriod) print("Soi " .. Orbits[2].referenceBody.orbitingBodies[i].orbitingBodies[j].sphereOfInfluence) print("Apa " .. localApa) print("Apr " .. localApr) print("Pea " .. localPea) print("Per " .. localPer) print("Sop " .. localSop) print("Tmtoap " .. localTmtoap) print("Tmtope " .. localTmtope) print("Lan " .. localLan) print("Ape " .. localApe) print("Lpe " .. localLpe) print("Ma " .. localMa) print("Ta " .. localTa) print("Ea " .. localEa) print("Maae " .. localMaae) print("Epch " .. localEpch) print("Inc " .. localInc) print("Ecc " .. localEcc) print("a " .. locala) print("Strtut " .. localStrtut) print("Endut " .. localEndut) print("Pos[1] " .. localPosvec3[1]) print("Pos[2] " .. localPosvec3[2]) print("Pos[3] " .. localPosvec3[3]) print("Vel[1] " .. localVelvec3[1]) print("Vel[2] " .. localVelvec3[2]) print("Vel[3] " .. localVelvec3[3]) print("l " .. locall) print("Os " .. localOs) print("Oe " .. localOe) print("Altunk " .. localAltunk) print("Rfcb " .. localRfcb) print("Obt " .. localObt) print("Obtae " .. localObtae) print("Sevp " .. localSevp) print("Sevs " .. localSevs) print("E " .. localE) print("V " .. localV) print("Frme " .. localFrme) print("Frmv " .. localFrmv) print("Toe " .. localToe) print("Tov " .. localTov) print("Utappr " .. localUtappr) print("Utsoi " .. localUtsoi) print("Refbodnamefull " .. localRefbodnamefull) print("Refbodnameshort " .. localRefbodnameshort) print("Clappr " .. localClappr) print("Clectr1 " .. localClectr1) print("Clectr2 " .. localClectr2) print("Crappr " .. localCrappr) print("Eccvec3[1] " .. localEccvec3[1]) print("Eccvec3[2] " .. localEccvec3[2]) print("Eccvec3[3] " .. localEccvec3[3]) print("Hvec3[1] " .. localHvec3[1]) print("Hvec3[2] " .. localHvec3[2]) print("Hvec3[3] " .. localHvec3[3]) print("Fevp " .. localFevp) print("Fevs " .. localFevs) print("Mag " .. localMag) if localClsencbodynamefull ~= nil then print("Clsencbodynamefull " .. localClsencbodynamefull) print("Clsencbodynameshort " .. localClsencbodynameshort) else print("Clsencbodynamefull nil") print("Clsencbodynameshort nil") end end ]] local localClosestEncounterBodyNameshort = nil if Orbit.closestEncounterBody ~= nil then localClosestEncounterBodyNameshort = Orbit.closestEncounterBody.name end return Orbit.ApA, Orbit.ApR, Orbit.PeA, Orbit.PeR, Orbit.period, Orbit.timeToAp, Orbit.timeToPe, Orbit.LAN, Orbit.argumentOfPeriapsis, calcSomLpeFromLanApe(Orbit.LAN, Orbit.argumentOfPeriapsis), (Orbit.meanAnomaly * globalRadiansToDegreesMultiplier), (Orbit.meanAnomalyAtEpoch * globalRadiansToDegreesMultiplier), Orbit.trueAnomaly, (Orbit.eccentricAnomaly * globalRadiansToDegreesMultiplier), Orbit.epoch, Orbit.inclination, Orbit.eccentricity, Orbit.semiMajorAxis, Orbit.StartUT, Orbit.EndUT, Orbit.pos, Orbit.vel, Orbit.semiLatusRectum, Orbit.orbitalSpeed, Orbit.orbitalEnergy, Orbit.altitude, Orbit.radius, Orbit.ObT, Orbit.ObTAtEpoch, Orbit.SEVp, Orbit.SEVs, Orbit.E, Orbit.V, Orbit.fromE, Orbit.fromV, Orbit.toE, Orbit.toV, Orbit.UTappr, Orbit.UTsoi, guessSomBodyFullnameFromShortname(Orbit.referenceBody.name), Orbit.referenceBody.name, Orbit.ClAppr, Orbit.ClEctr1, Orbit.ClEctr2, Orbit.CrAppr, Orbit.eccVec, Orbit.h, Orbit.FEVp, Orbit.FEVs, Orbit.mag, guessSomBodyFullnameFromShortname(localClosestEncounterBodyNameshort) localClosestEncounterBodyNameshort end
-
Peewee, what license or licenses are you releasing your code under? If you're willing to go the user's choice of GPLv2, GPLv3, or CC-BY-SA 3.0 or a license compatible with all three of them (MIT, etc.), then I'd love to get my grubby little hands on your (working) code (particularly the anomaly conversions) to include in the SimpleOrbitalMechanics and related libraries with attribution to you as the original author. It'd save me some time writing abd documenting exactly the same mathematics, though since they're pure math, I'll need to write some assert() statements for the test harness. dAkshEN3, you're in luck - I just finished the second of my major "waiting" general functions, and had to test it. I assume a test based on altitude would be of interest to you? That's the very last function below. If anything's confusing (or wrong) please ask - this is the rough draft, copied from another function that waits for a set of two variables to quit changing too much per timeslice (i.e. wait until the pitch and heading settle down after a mechjeb.attitudeTo() call before firing engines), and I may well have some comments from the previous version in there. It's also a little chatty still, but that may help you visualize what's happening. -- Original Work Copyright 2012, Nadrek, insofar as any elements that aren't obvious, trivial, or mathematics are concerned (none of which are copyrightable) -- licensed under your choice of GPLv2, GPLv3, or Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) http://www.gnu.org/licenses/gpl-2.0.html or http://www.gnu.org/licenses/gpl.html or http://creativecommons.org/licenses/by-sa/3.0/ function waitSkomForMinimumToPassFn1TmbtwnMnot(Function1, TimeBetween, MaxNumberOfTries) -- added in v0.004 -- NOTE: Because this has wait() statements, it must be run synchronously with whatever uses the data it returns -- NOTE: Because this has wait() statements, it must be run asynchronously with the main game and any control processes! -- Function1 is a function that takes no arguments, and returns one numeric values that will be tested -- to see if the return value is greater than or equal to the previous return value. -- TimeBetween is the time in seconds between initial and final measurements for each test -- MaxNumberOfTries is how many times we should wait for TimeBetween to elapse and test -- This is so we don't get into an infinite loop with an ever increasing value -- returns 0 if we timed out (got to MaxNumberOfTries without ever passing a minimum point -- and 1 if we successfully ended up just past than the minimum. -- For example, this is very useful to wait for some measurement to reach a minimum, i.e. -- one use is to use this to wait until the Mean Anomaly, or the Longitude, or the Altitude is at its lowest. -- Alternately, wait for math.abs(MeanAnomaly-2.3) to wait until the MA is just past 2.3 -- quit moving "too much", using that to determine when the vessel is indeed no longer oscillating too much. -- Ex. USE WITHIN ANOTHER COROUTINE function!!! -- waitSkomForMinimumToPassFn1TmbtwnMnot(reportSkomKSPLatitude, 30, 725) -- Ex. see SimpleKSPOrbitalOperations, function ??? -- locals would be ideal; however, in one other test locals didn't update in the while loop, so uniquely named globals were used. This was as of SharpLua 1.1 globalFuncPrevi_waitSkomForMinimumToPassFn1TmbtwnMnot = 1 -- now for some _really_ stupid local/global kludges. local variables get a 1:1 replacement, but don't work in a prior while loop try. -- global variables, however, get an index out of range exception on the timeout, but do work in the while loop. local localFuncPrev1_waitSkomForMinimumToPassFn1TmbtwnMnot = Function1() globalFuncPrev1_waitSkomForMinimumToPassFn1TmbtwnMnot = localFuncPrev1_waitSkomForMinimumToPassFn1TmbtwnMnot -- First, wait a time unit after the initial "previous" wait(TimeBetween) -- now for some _really_ stupid local/global kludges. local variables get a 1:1 replacement, but don't work in a prior while loop try. -- global variables, however, get an index out of range exception on the timeout, but do work in the while loop. local localFuncCur1_waitSkomForMinimumToPassFn1TmbtwnMnot = Function1() globalFuncCur1_waitSkomForMinimumToPassFn1TmbtwnMnot = localFuncCur1_waitSkomForMinimumToPassFn1TmbtwnMnot -- Now we can enter our "checking" while loop. -- If the return value is over our threshold and we aren't finished, let's keep waiting. globalFuncDiff = (globalFuncCur1_waitSkomForMinimumToPassFn1TmbtwnMnot - globalFuncPrev1_waitSkomForMinimumToPassFn1TmbtwnMnot) print(globalFuncDiff .. " loop " .. globalFuncPrevi_waitSkomForMinimumToPassFn1TmbtwnMnot) -- The difference will be negative while the values are decreasing over time. while (globalFuncDiff <= 0) and (globalFuncPrevi_waitSkomForMinimumToPassFn1TmbtwnMnot <= MaxNumberOfTries) do -- the "Cur" we've currently got is now "Prev" - make it so. globalFuncPrev1_waitSkomForMinimumToPassFn1TmbtwnMnot = globalFuncCur1_waitSkomForMinimumToPassFn1TmbtwnMnot wait(TimeBetween) -- Gather a new "Cur" with our kludgy local/global tricks. local localFuncCur1_waitSkomForMinimumToPassFn1TmbtwnMnot = Function1() globalFuncCur1_waitSkomForMinimumToPassFn1TmbtwnMnot = localFuncCur1_waitSkomForMinimumToPassFn1TmbtwnMnot -- increment the loop counter so we can exit if it's taking too many tries. globalFuncPrevi_waitSkomForMinimumToPassFn1TmbtwnMnot = globalFuncPrevi_waitSkomForMinimumToPassFn1TmbtwnMnot + 1 globalFuncDiff = (globalFuncCur1_waitSkomForMinimumToPassFn1TmbtwnMnot - globalFuncPrev1_waitSkomForMinimumToPassFn1TmbtwnMnot) print(globalFuncDiff .. " loop " .. globalFuncPrevi_waitSkomForMinimumToPassFn1TmbtwnMnot) end if globalFuncPrevi_waitSkomForMinimumToPassFn1TmbtwnMnot >= MaxNumberOfTries then print "Wait for minimum timed out" return 0 else print "Successful Minimum passage" return 1 end end function testSkomKSPWaitForMinAltitudeDriver() -- added in v0.004 -- purely a test function to verify that waitSkomForMinimumToPassFn1TmbtwnMnot works -- and to demonstrate that functions can be created on the fly, as it were. local Function1_testSkomKSPWaitForMinAltitudeDriver = function() return mechjeb.core.part.vessel.orbit.altitude end local retval = waitSkomForMinimumToPassFn1TmbtwnMnot(Function1_testSkomKSPWaitForMinAltitudeDriver, 5, 20) if retval == 0 then print "Did not ever pass Periapsis (the minimum altitude)" else print("Either was already ascending, or just passed minimum altitude of " .. mechjeb.core.part.vessel.orbit.altitude .. " no more than 10 seconds before time " .. mechjeb.core.part.vessel.orbit.epoch) end end function cotestSkomKSPWaitForMinAltitude() -- added in v0.004 --[[ ex. Warp to less than 100 seconds before periapsis, then run: cotestSkomKSPWaitForMinAltitude() ]] local coTest = coroutine.create(testSkomKSPWaitForMinAltitudeDriver) coroutine.resume(coTest) end Note that in Mechjeb 1.9.1, there's still some synchronization errors with the wait() statement - if you get one, just re-run it. At this time, I don't know if they're correlated with number of wait()s or time spent wait()ing, but since r4m0n is aware of the issue already, I'm hoping Mechjeb 1.9.2 transparently resets the wait() when they happen, which would render further investigation from the lua side pointless.