Jump to content

[1.1.3] Orbital Decay v1.5.2 (17/07/2016) - Total Overhaul


Whitecat106

Recommended Posts

About the lag issues, what if you updated one vessels orbit per X seconds? You'd get a few frames dropped, but by avoiding batch operations you're mitigating lag. And same as with batch operations, you'd get all 200 vessels updated after the same time span. 

X could be set in some configuration file  for so that we can change it for laggy computers. 

Link to comment
Share on other sites

  • 4 weeks later...
3 hours ago, hraban said:

Basically, a good idea of this plugin, but when will that be usefully applied?
Lives the idea and the plugin yet?

Only then asked: When does KSP a reasonable atmospheres system?

I have smoothed out most of the lag issues occurring (mainly due to bad coding on my part of UI's and timings), however the mod is on hold until KSP 1.1 since this update is likely to break any further work I put into it. 

Of course the change to 1.1 may even break the system of updating background vessel positions and we might be back to square one...

I have discovered a few new tricks to background resource processing and UI trickery that will make this mod much more usable. Once I have more time I will try and release a 1.0.5 compatible version (if 1.1 gets pushed back anymore!). I also have plans for a configurable version compatible with RSS and Kopernicus. 

 

In the mean time the mod is still alive... just laggy with..... lots of.....some ....any.... vessels... Soon I promise everyone! Real life has been busy lately so no updates for a little while :(

Whitecat106 :)

Link to comment
Share on other sites

  • 2 months later...

Hello everyone,

It has been a while but I thought I would release a quick update, this fixes lag and is the result of a complete rewrite of the code, station keeping is also fixed..hopefully!

Active vessel decay and the UI have been temporarily removed in preparation for KSP 1.1 and subsequently version 1.1.0 of Orbital Decay. I will be working on a more accurate decay simulation, smooth UI menus with decay predictions, maybe some pretty conics in the map view and hopefully a 'Station Keeping Module' part for the game!

I hope you enjoy this small update which makes the Mod playable again, however for this to function properly you will have to switch to each vessel you currently have in game to allow the vessel to be registered by the decay code - this will be fixed in 1.1.0 too!

I have not given up; have hope! 

Whitecat106 :)

Link to comment
Share on other sites

On 3/23/2016 at 4:56 PM, Whitecat106 said:

Hello everyone,

It has been a while but I thought I would release a quick update, this fixes lag and is the result of a complete rewrite of the code, station keeping is also fixed..hopefully!

Active vessel decay and the UI have been temporarily removed in preparation for KSP 1.1 and subsequently version 1.1.0 of Orbital Decay. I will be working on a more accurate decay simulation, smooth UI menus with decay predictions, maybe some pretty conics in the map view and hopefully a 'Station Keeping Module' part for the game!

I hope you enjoy this small update which makes the Mod playable again, however for this to function properly you will have to switch to each vessel you currently have in game to allow the vessel to be registered by the decay code - this will be fixed in 1.1.0 too!

I have not given up; have hope! 

Whitecat106 :)

YAY

Link to comment
Share on other sites

Hello everyone,

I have just released version 1.0.6 which fixes many issues that popped up in 1.0.5. This version adds the UI again and a partial working version of the Active Vessel Decay (More for 1.7.0 or 1.1 (whichever comes first!)).

I am now currently working on a version of the Active Decay which mimics the earlier versions of this mod but without the lag!

I hope you enjoy this, more functional version, of the mod. I apologize for my hasty 1.0.5 release and any damage caused to your save games caused by the code. This version is much more stable (after two days of error testing and bug fixing).

Enjoy!

Whitecat106 :)

Link to comment
Share on other sites

Would there be any way to add the function of a config file where we could add what fuels we wanted to allow for station keeping? This way it isn't hard-coded and could appease literally anyone. 

Link to comment
Share on other sites

11 hours ago, FiiZzioN said:

Would there be any way to add the function of a config file where we could add what fuels we wanted to allow for station keeping? This way it isn't hard-coded and could appease literally anyone. 

That's a very good idea! I will add in this feature today for a 1.7.0 version!

Thanks!

Link to comment
Share on other sites

I've found a bit strange bug on Linux RSS-RO install. This mod conflicts with something (KSPAPIExtensions?) with the next string in KSP.log:

[LOG 13:56:18.217] System.NullReferenceException: Object reference not set to an instance of an object
  at KSPAPIExtensions.UIPartActionChooseOption.UpdateItem () [0x00000] in <filename unknown>:0
[EXC 13:56:25.195] NullReferenceException: Object reference not set to an instance of an object
    System.Guid.BaseToString (Boolean h, Boolean p, Boolean b)
    System.Guid.ToString ()
    WhitecatIndustries.VesselData.FetchStationKeeping (.Vessel vessel)
    WhitecatIndustries.StationKeepingModule.OnStart (StartState state)
    Part.ModulesOnStart ()
    Part+.MoveNext ()

This appears, when I take some command modules in VAB and try to put some fuel in their internal tank: GUI of RealFuels is not working and Tweakscale-like field appears in right-click menu of this module, but this field is empty so I can't do anything. Filling an external tank works fine.

Link to comment
Share on other sites

1 hour ago, Einkleinermensch said:

I've found a bit strange bug on Linux RSS-RO install. This mod conflicts with something (KSPAPIExtensions?) with the next string in KSP.log:

[LOG 13:56:18.217] System.NullReferenceException: Object reference not set to an instance of an object
  at KSPAPIExtensions.UIPartActionChooseOption.UpdateItem () [0x00000] in <filename unknown>:0
[EXC 13:56:25.195] NullReferenceException: Object reference not set to an instance of an object
    System.Guid.BaseToString (Boolean h, Boolean p, Boolean b)
    System.Guid.ToString ()
    WhitecatIndustries.VesselData.FetchStationKeeping (.Vessel vessel)
    WhitecatIndustries.StationKeepingModule.OnStart (StartState state)
    Part.ModulesOnStart ()
    Part+.MoveNext ()

This appears, when I take some command modules in VAB and try to put some fuel in their internal tank: GUI of RealFuels is not working and Tweakscale-like field appears in right-click menu of this module, but this field is empty so I can't do anything. Filling an external tank works fine.

Hmm this is interesting, the part module for Station Keeping is barely used and only used in flight, it could even be removed come to think of it.... But the module does not use any fuel or resources so I don't see why tweakscale or real fuels would have an issue with it. I will see what I can look into module manager wise and see if KSPAPI requires anything else in the Module. Thanks for this report!

 

1.0.7 should be released today, no more reliance on just monoprop or hydrazine, each resource is toggle-able by the Settings menu in the ui. I should have fixed the Active vessel issues, and this Module issue by then too!

Link to comment
Share on other sites

Hello everyone,

I have just released 1.0.7 which fixes the Active Decay during timewarp, and adds the ability to use any KSP resource (within reason) as a station keeping fuel. (Use the Settings Menu to choose these). 

1.0.8 shall be a balancing release to assign a proper "ISP" to each resource, and to balance the mod in general. I will also introduce a stockalike decay formula as well as the realistic formula. 

As for the KSPAPIExtensions error I shall look into this for the next update, if anyone else encounters this (preferably on a Windows system), please let me know here and Ill see what I can do, at the moment I'm a bit stumped!

Enjoy,

Whitecat106 :)

Link to comment
Share on other sites

@Whitecat106it is pretty easy to reproduce the KSPAPI error. I have captured a log for it <LINK REMOVED>.

Mods used:

  • Community Resource Pack [0.4.9]
  • Module Manager [2.6.20]
  • Real Fuels [10.8.4]
  • Realism Overhaul [10.9.6]
  • Orbital Decay [1.0.7]

Reproduction steps:

  1. Launch KSP with the above mods installed.
  2. Enter either the SPH or the VAB
  3. Select a Pod part
  4. Right - click the part. The RF options for opening it's GUI and/or removing the tank contents will be broken.

Tested on a Windows OS environment with a clean installation of KSP (version 1.0.5.1028).

Also, from a preliminary test while using RSS, Orbital Decay tends to simply erase any craft from orbit (test launch on a 750 km polar orbit, both the satellite and the upper stage were deleted upon returning to the Space Center).

Edited by Phineas Freak
Removed log link
Link to comment
Share on other sites

27 minutes ago, Phineas Freak said:

@Whitecat106it is pretty easy to reproduce the KSPAPI error. I have captured a log for it here.

Mods used:

  • Community Resource Pack [0.4.9]
  • Module Manager [2.6.20]
  • Real Fuels [10.8.4]
  • Realism Overhaul [10.9.6]
  • Orbital Decay [1.0.7]

Reproduction steps:

  1. Launch KSP with the above mods installed.
  2. Enter either the SPH or the VAB
  3. Select a Pod part
  4. Right - click the part. The RF options for opening it's GUI and/or removing the tank contents will be broken.

Tested on a Windows OS environment with a clean installation of KSP (version 1.0.5.1028).

Also, from a preliminary test while using RSS, Orbital Decay tends to simply erase any craft from orbit (test launch on a 750 km polar orbit, both the satellite and the upper stage were deleted upon returning to the Space Center).

Thanks for that,

Okay I am updating the mod now to work without the need for the Module, so KSPAPI shouldn't be a problem. As for RSS I will look into this too, 750km is well above the threshold that the mod uses for a 'Hard Atmosphere' which would cause vessels to be destroyed upon scene changes, maybe some new changes (since version 1.0.4 of this mod) to RSS/RO might have caused this. I will be looking into this thoroughly for 1.0.8 (Tonight possibly!).

Sorry for destroying anyones vessels!

Whitecat106 :(

Link to comment
Share on other sites

Would there be any way to allow the area where we can choose different station keeping resources to be a bit bigger? The picture that I included shows how much of an issue it is to choose them. I also might just be a dunce and not know how to enlarge it.

AcmtXyL.png

Edited by FiiZzioN
Link to comment
Share on other sites

7 hours ago, FiiZzioN said:

Would there be any way to allow the area where we can choose different station keeping resources to be a bit bigger? The picture that I included shows how much of an issue it is to choose them. I also might just be a dunce and not know how to enlarge it.

I am increasing the size of this for 1.0.8 so not to worry!

I have also addressed some major bugs in the RSS version, removed the station keeping module (abit redundant due to the UI) fixing issues with KSPAPI extensions and I am currently working towards fixing the RSS switch to-from vessel issues causing vessel deletions.

Before I release 1.0.8 I hope to have a more accurate RSS decay formula (based on a less 'kerbalised' orbital decay equation). But this will be done soon! If anyone is having issues with the mod in RSS currently, I would recommend switching back to 1.0.6 of this mod before I added greater resource variety or simply wait until this evening or tomorrow for 1.0.8. I will also be releasing 1.0.8 onto Ckan along with Historic Missions 1.9.0.

Link to comment
Share on other sites

Nice work!

Question: how difficult would be to calculate the drag factor via the mass & area that a craft presents? As i understand, the current model only takes into account a hard-coded decay factor.

Or maybe i am a bit ignorant and that the better model that you mentioned is exactly what i was asking...

Link to comment
Share on other sites

11 minutes ago, Phineas Freak said:

Nice work!

Question: how difficult would be to calculate the drag factor via the mass & area that a craft presents? As i understand, the current model only takes into account a hard-coded decay factor.

Or maybe i am a bit ignorant and that the better model that you mentioned is exactly what i was asking...

I am just about to test a new model which will be the realistic decay model, this uses information from here, and uses the drag factor via area and mass, although somewhat rudimentary since I am limited to the functions I can use with unloaded vessel and part information, at the moment I am thinking of using the KSP aerodynamic area of the root part +- a balancing amount (since in real life a spacecraft would be orientated to reduce drag as much as possible), this seems as close to realistic as I can think of at the moment. 

Link to comment
Share on other sites

Hello everyone,

I have just released 1.0.8 which fixes the RSS crash on launch issues, fixes RSS resources and adjusts UI menus.

Sadly I am having great difficulty in implementing the new decay model (there is so little useful/accurate documentation on orbital decay online, hopefully I will get a chance to look at the information in the University library this week), hopefully I will release a 1.0.9 asap with more fixes (probably with rendezvous issues), UI additions, and with the new decay formula. (Currently I am thinking of using Orbital Energy formulas based on the Drag Force. 1.0.9 will also be on Ckan.

    I was using the rate of change of Period to determine the Semi Major Axis at a certain atmospheric density, but the 'Kerbal' version of the Orbital Period does not seem to be the Mathematical version... (why am I not surprised?...) But anyway!

Enjoy,

Whitecat106 :)

 

Link to comment
Share on other sites

1 hour ago, the_pazter said:

does Station Keeping take power then?


It does not take power as in Electric Charge (since this would be constantly changing in the background), but it requires fuel such as Mono Propellant, Liquid Fuel or pretty much any other fuel (this is select-able in the Settings tab on the UI).

 

Still working on the Decay Formulas, now for some reason these simple Semi Major Axis - Energy formulas   fail to work in KSP. The orbital energy can be calculated from the Semi Major Axis but manipulating the orbital energies to get back to the SMA fails? If anyone has any suggestions; the code I currently have is included below.

Spoiler

	double InitialSemiMajorAxis = VesselData.FetchSMA(vessel);
            double GravitationalConstant = Math.Pow(6.674 * 10, -11);
            Orbit orbit = vessel.orbitDriver.orbit;
            CelestialBody body = orbit.referenceBody;
            double InitialOrbitalVelocity = orbit.vel.magnitude;
            double StandardGravitationalParameter = GravitationalConstant * (body.Mass + VesselData.FetchMass(vessel));
            double CartesianPositionVectorMagnitude = orbit.getRelativePositionAtT(Planetarium.GetUniversalTime()).magnitude;
            double InitialOrbitalEnergy = (((InitialOrbitalVelocity * InitialOrbitalVelocity) / 2) - (StandardGravitationalParameter / CartesianPositionVectorMagnitude));

            double InitialDensity = body.atmDensityASL;
            double BoltzmannConstant = Math.Pow(1.380 * 10, -23);
            double AltitudeEquivalent = 0;
            if (body.atmosphere)
            {
                AltitudeEquivalent = InitialSemiMajorAxis - (body.Radius + body.atmosphereDepth);
            }
            else
            {
                AltitudeEquivalent = InitialSemiMajorAxis - (body.Radius);
            }
            double GravityASL = body.GeeASL;
            double ParticleMass = Math.Pow(4.8079 * 10, -26);
            double VesselArea = VesselData.FetchArea(vessel);
            if (VesselArea == 0)
            {
                VesselArea = 1;
            }
            double DistanceTravelled = InitialOrbitalVelocity;

            double AtmosphericDensity = Math.Pow(2.84 * 10, -10); // Will be formulated for each body. 
            
            double DragForce = 0.5 * AtmosphericDensity * VesselArea * 2.2 * (InitialOrbitalVelocity * InitialOrbitalVelocity);
            double DragWork = DragForce * InitialOrbitalVelocity;
            double FinalOrbitalEnergy = InitialOrbitalEnergy - DragWork;
            double FinalSemiMajorAxis = (StandardGravitationalParameter / (2 * FinalOrbitalEnergy));

            double CalSMA = (GravitationalConstant * body.Mass / (2 * (InitialOrbitalEnergy / Math.Pow(1*10, 9)))); // Energy in GJ? -- Nope? Peculiar...

            print("Vel " + InitialOrbitalVelocity);
            print("AtmosDensity " + AtmosphericDensity);
            print("DragForce " + DragForce);
            print("DragWork " + DragWork);
            print("InitialOrbitalEnergy" + InitialOrbitalEnergy);
            print("FinalOrbitalEnergy " + FinalOrbitalEnergy);
            print("Initial SMA " + InitialSemiMajorAxis);
            print("Final SMA " + FinalSemiMajorAxis);
            print("Cal SMA " + CalSMA);

 

 

Link to comment
Share on other sites

  • 2 weeks later...

Hello everyone,

I have just released 1.0.9, this fixes many bugs (including the blackscreen on startup bug), adds old style tracking station views (visually apparent decay in conics) and tweaks decay formulas to factor in vessel area and mass. This version has not been compiled for 1.1 (still on 1.0.5 here) but I believe everything should work fine, if anyone has any issues please let me know!

Next up will be 1.1.0 this will include:

- Adding toggled Realistic Decay Formulas and Predictions. Including Solar Radiation Pressure on all objects (Expect asteroids to decay into the sun in around 10000 years....!) - (Ready just needs some more testing!)
- Adding menu option to Update decay formulas every x no of seconds up to 500 to reduce lag in game.
- Adding batch Settings and VesselData fetches to limit fps drops (to around 24FPS) every x no of seconds (as above)
- Adding fuel efficiency and UI beautification.

- And anything else anyone would like to suggest!

 

Whitecat106 :)

Edited by Whitecat106
Link to comment
Share on other sites

2 hours ago, Whitecat106 said:

Hello everyone,

I have just released 1.0.9, this fixes many bugs (including the blackscreen on startup bug), adds old style tracking station views (visually apparent decay in conics) and tweaks decay formulas to factor in vessel area and mass. This version has not been compiled for 1.1 (still on 1.0.5 here) but I believe everything should work fine, if anyone has any issues please let me know!

Next up will be 1.1.0 this will include:

- Adding toggled Realistic Decay Formulas and Predictions. Including Solar Radiation Pressure on all objects (Expect asteroids to decay into the sun in around 10000 years....!) - (Ready just needs some more testing!)
- Adding menu option to Update decay formulas every x no of seconds up to 500 to reduce lag in game.
- Adding batch Settings and VesselData fetches to limit fps drops (to around 24FPS) every x no of seconds (as above)
- Adding fuel efficiency and UI beautification.

- And anything else anyone would like to suggest!

 

Whitecat106 :)

If 1.1.0 will still be for 1.0.5 I would be very grateful! Thanks @Whitecat106 for continuing an awesome mod!

Link to comment
Share on other sites

19 hours ago, Svm420 said:

If 1.1.0 will still be for 1.0.5 I would be very grateful! Thanks @Whitecat106 for continuing an awesome mod!

Thank you! I don't think that KSP 1.1 has/will break anything so the mod should be compatible between both, but just incase there are changes, I will release a 1.1.0 on SpacePort compiled against 1.0.5 and a 1.1.1 compiled against KSP 1.1.

Still working on some the decay formulas, at the moment the Realistic Decay Formula (Drag) works fine for altitudes between 225Km and 3000Km, but is somewhat too steep all round for example at low altitudes (A rate of 0.0102 m/s (SMA height) for 400km altitude, whereas a realistic drag rate at this height (experienced by the ISS) is around 0.0007716 m/s (altitude)). Shouldnt be too difficult to tweak this (Divide by 1000 here or there), however for altitudes lower than 225Km some major issues arise, the decay rate suddenly reduces and fluctuates... here is the code so far:

float AtmosphericDensity = (Mathf.Pow(1.020f * 10, 7) * Mathf.Pow((float)((EquivalentAltitude) / 1000), -7.172f)); // Kg/m^3 // 

                    double MolecularMass = 27 - 0.0012 * ((EquivalentAltitude / 1000) - 200);

                    double DeltaPeriod = (3 * Math.PI * InitialSemiMajorAxis * AtmosphericDensity * ((VesselArea * 2.2) / MolecularMass)); // Unitless
                    double InitialPeriod = orbit.period;
                    double FinalPeriod = InitialPeriod - DeltaPeriod;

                    double FinalSemiMajorAxis = Math.Pow((Math.Pow(((double)FinalPeriod / (double)(2 * 3.14159265359)), (double)2)) * (double)StandardGravitationalParameter, ((double)1.0 / (double)3.0));

                    double DecayValue = InitialSemiMajorAxis - FinalSemiMajorAxis; 

The issue is within the DeltaPeriod line, as semi major axis reaches a certain value, the MolecularMass, AtmosphericDensity and SMA all 'cancel out' reducing the DeltaPeriod to close to zero, this happens multiple times (most obviously at around 192Km and 222Km (probably again around 162Km))... it would be easier to describe with a graphical representation and intersections but I'm far too lazy for that...

As for the radiation pressure drag, well this comes up with a nice +Infinity meters when it should be around -3*10^-23 m... here's the code anyway:

double SolarEnergy = Math.Pow(3.86 * 10, (double)26); // W
                double SolarDistance = vessel.distanceToSun; // m
                double SolarConstant = 0;
                SolarConstant = SolarEnergy / (4 * Math.PI * Math.Pow((double)SolarDistance, (double)2.0)); // W/m^2
                double InitialSemiMajorAxis = VesselData.FetchSMA(vessel);
                double StandardGravitationalParameter = body.gravParameter;
                double MeanAngularVelocity = Math.Sqrt((double)StandardGravitationalParameter / (Math.Pow((double)InitialSemiMajorAxis, (double)3.0)));
                double SpeedOfLight = Math.Pow(3 * 10, (double)8); 

                double VesselArea = VesselData.FetchArea(vessel);
                if (VesselArea == 0)
                    {
                        VesselArea = 1;
                    }

                double VesselMass = VesselData.FetchMass(vessel);   // Kg
                if (VesselMass == 0)
                    {
                        VesselMass = 1;
                    }

                double VesselRadius = Math.Sqrt((double)VesselArea/(double)Math.PI);
                double ImmobileAccelleration = ((double)Math.PI * Math.Pow((double)VesselRadius, (double)2.0) * (double)SolarConstant) / ((double)VesselMass * (double)SpeedOfLight * Math.Pow((double)SolarDistance, (double)2.0));
                double ChangeInSemiMajorAxis = -(6 * Math.PI * ImmobileAccelleration * InitialSemiMajorAxis) / (MeanAngularVelocity * SpeedOfLight);
                double FinalSemiMajorAxis = InitialSemiMajorAxis + ChangeInSemiMajorAxis;

   If anyone has any suggestions please let me know.

As for everything else, I will be optimising the code for less lag in 1.1.0; it'll be annoying to code but its worth it! I have also noticed a bug in the vessel mass / aerodynamic area input (sometimes always being fixed at 1, and with the aerodynamic area never being calculated in the first place - (Ksp and the few things you can do whilst the vessel is inactive!))

Whitecat106:)

 

 

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...