![](https://forum.kerbalspaceprogram.com/uploads/set_resources_17/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
![](https://forum.kerbalspaceprogram.com/uploads/set_resources_17/84c1e40ea0e759e3f1505eb1788ddf3c_default_photo.png)
alterbaron
Members-
Posts
65 -
Joined
-
Last visited
Content Type
Profiles
Forums
Developer Articles
KSP2 Release Notes
Everything posted by alterbaron
-
I need someone help me do some math for launch optimization
alterbaron replied to SaturnV's topic in Science & Spaceflight
Just a small update on this stuff: PSOPT is really hard to install on windows, so instead, I threw together a little pseudospectral optimal control solver in MATLAB (using fmincon from the optimization toolbox). I've tested it on the brachistochrone problem with good results: http://imgur.com/LjYLYdM. I should be able to modify the code to solve for an optimal ascent trajectory (fingers crossed). -
[Updated] Aerobraking Calculator
alterbaron replied to alterbaron's topic in KSP1 Tools and Applications
New Updates! Fixed a bug that would screw up results for retrograde encounters with Jool. Added circularization delta-V prediction. -
Here's a formula I just derived which should give you the ejection angle: Burn when you are behind the planet's prograde / retrograde direction by that angle. v is the velocity of the ship after the ejection maneuver (current orbital velocity + transfer dv) μ is the gravitational parameter of the planet (grab it from the wiki.) r is your orbital height above the planet's center (orbital altitude + planet radius from wiki.) Haven't tested it yet; hopefully I haven't made any mistakes .
-
I need someone help me do some math for launch optimization
alterbaron replied to SaturnV's topic in Science & Spaceflight
AFAIK, the error in this method will be on-par with regular velocity-verlet. There's a document which mentions this method here. Still looking into PSOPT stuff, but mostly working on reading up on the math. EDIT: A simpler and more practical problem would be to optimize on the parameters given to the mechjeb ascent guidance system. Results from this sort of investigation would be immediately useful to players as well. (Though the problem itself isn't as cool . . .) -
I need someone help me do some math for launch optimization
alterbaron replied to SaturnV's topic in Science & Spaceflight
Here's the code I use to do velocity verlet with velocity dependent forces. function [r v t] = vel_vert_term( F, m, r0, v0, dt, term_cond ) % VEL_VERT_TERM Integrate the equations of motion for a particle of mass % m being acted upon by a vector force F. Terminate when term_cond % is true. % % F - Function which returns the vector force acting on the particle, % as a function of position and velocity. % m - Particle mass % r0 - Initial position % v0 - Initial velocity % dt - Integration time step t = 0; r = r0; v = v0; a = @(rin, vin) F(rin, vin)./m; firstrun = true; while firstrun || (term_cond(r,v,t) == 0) r_old = r; v_old = v; a_t = a(r_old, v_old); r = r_old + v_old*dt + 0.5*a_t*dt.^2; v_est = v_old + 0.5*dt*(a_t + a(r,v_old+dt*a_t)); v = v_old + 0.5*(a_t + a(r,v_est))*dt; t = t + dt; firstrun = false; end end -
[Updated] Aerobraking Calculator
alterbaron replied to alterbaron's topic in KSP1 Tools and Applications
Thanks! I'm glad to hear that people are having success using this tool. -
Watch this video: If you'd rather read, here's a quick guide on how to rendezvous without using too much fuel: Set the other ship as your target in the map screen. Match target's inclination (burn at ascending or descending node to do this). Burn at apoapsis so that your periapsis lies on the orbit of the target. Burn at periapsis to make our apoapsis either a bit higher or a bit lower than your target's orbit. Time warp. Every orbit, your "closest approach" markers will move, eventually getting closer and closer together. On the orbit where you think the "closest approach" markers will pass each other, set a maneuver node at your periapsis and fiddle with it until you have a close encounter with your target. Make sure to burn at the maneuver node. Finally, once you are within a few km of your target, burn to make your relative velocity only a few m/s. Then coast to your target.
-
I don't know why I'm so happy that you did this, but I am. I'm assuming you took the LCM of the bodies' orbital periods?
-
Well, I think I've got this new type of landing figured out. Below is a plot of the landing periapsis that you need to put directly above your target to land there. I tested these results in-game, and got pretty good results. Here's an album of some test results: http://imgur.com/a/tKq8l Since the final landing site is so sensitive to small changes in the periapsis, the graph's hard to use for anything more than an overview. For actually using these results to land, here's the hard numbers: Landing PE Values for Kerbin =================================================== Orbit Altitude (m) Landing PE (m) Error per m (m) =================================================== 70000 48901 53 80000 45550 49 90000 43898 46 100000 42778 44 110000 41938 42 120000 41272 41 130000 40727 40 140000 40270 40 150000 39878 39 160000 39539 39 170000 39242 39 180000 38979 39 190000 38744 38 200000 38534 38 210000 38345 38 220000 38173 38 230000 38017 39 240000 37874 39 250000 37743 39 260000 37623 39 270000 37512 39 280000 37410 39 290000 37315 40 300000 37227 40 310000 37145 40 320000 37069 41 330000 36999 41 340000 36932 41 350000 36871 42 360000 36813 42 370000 36758 43 380000 36707 43 390000 36660 44 400000 36615 44 410000 36572 45 420000 36532 45 430000 36494 47 440000 36459 46 450000 36425 47 460000 36393 47 470000 36363 48 480000 36335 49 490000 36308 49 500000 36282 50 510000 36258 50 520000 36234 51 530000 36212 52 540000 36191 53 550000 36171 53 560000 36152 54 570000 36134 55 580000 36116 56 590000 36099 56 600000 36083 57 610000 36068 58 620000 36053 59 630000 36039 60 640000 36025 61 650000 36012 61 660000 36000 62 670000 35987 63 680000 35976 64 690000 35964 67 700000 35953 66 710000 35943 67 720000 35933 68 730000 35923 69 740000 35913 70 750000 35903 73 760000 35894 73 770000 35885 74 780000 35877 75 790000 35868 76 800000 35860 77 810000 35852 79 820000 35844 80 830000 35836 81 840000 35828 82 850000 35821 84 860000 35814 85 870000 35806 88 880000 35799 88 890000 35792 89 900000 35785 91 910000 35778 92 920000 35772 94 930000 35765 95 940000 35759 97 950000 35752 98 960000 35746 100 970000 35739 102 980000 35733 103 990000 35727 105 1000000 35721 107 Using RCS for fine adjustment would really make this landing method easy!
-
[Updated] Aerobraking Calculator
alterbaron replied to alterbaron's topic in KSP1 Tools and Applications
Maybe someday, though Mechjeb already does aerobraking prediction, so I'm not sure who the audience would be. -
[Updated] Aerobraking Calculator
alterbaron replied to alterbaron's topic in KSP1 Tools and Applications
New updates! The calculator can now make use of orbit direction information to calculate a much more accurate result. Unit support! Enter your orbit data in km or Mm for convenience. (Thanks to retoo on GitHub for this feature.) Minor formatting improvements. The new orbit direction feature increases the accuracy of the calculator substantially. In one of my tests, I was able to aerobrake from a hyperbolic Kerbin encounter to a 1000 km orbit to an accuracy of 8000m. That's an error of only 0.8%! The orbit direction info works best if you have a more-or-less equatorial encounter. If you're coming in with a polar encounter, you might get better results by choosing "ignore". -
Thanks Pyotor!
Also, you may be happy to hear the calculator has just been updated to be more precise.
-- Alterbaron
-
Here's a sample of what's to come: a landing chart without the need for protractors: Brusura, you said a landing PE (periapsis) of ~43km worked well for a 100,000m orbit. This is consistent with these preliminary calculations! I'll do some testing, and post the completed chart soon! EDIT: I looked into this a little be further. It seems that, theoretically, the "place PE over target" approach to landing is VERY difficult to do, since the final landing site is extremely sensitive to small changes in the landing PE. Here's a plot that shows just how bad the problem might be: The green line is an estimate of the landing site error for each meter your landing PE is off by. My calculations suggest that an error of a few hundreds of meters can send you tens of kilometers off target. My first attempts to land using this approach seemed to support this as well.
-
Stack separators and very small probes
alterbaron replied to Skorpychan's topic in KSP1 Gameplay Questions and Tutorials
If you want to be sure you won't impart any additional velocity to your probes, you could attach them with docking ports. You can attach the probe directly to the docking port (no port required on the probe). When the time comes, just click the docking port and choose "Decouple Node", and it will separate. -
Hi all, Here I'll show you how to rendezvous with another vessel using ONLY the IVA view (the in-cockpit view). The map view is completely unnecessary! This practice ship uses the MK1 cockpit to provide a nice, wide window, making life easier if controlling in IVA. IVA Rendezvous Trainer Ship Initial setup for demonstration. Two practice ships were flown up separately. One was placed into a 200km x 200km orbit, and the other into a 250km x 250km orbit. (Ships were flown up in IVA mode as well, but that's a walk in the park compared to rendezvous.) Note: The altimeter in IVA can't measure 100,000km increments, so figuring out your actual orbit altitude is an interesting exercise! Anyways, let's rendezvous the lower ship with the higher one. Instructions: Measuring Target Crossing Time Line up the navball so that the cross-hairs lie on the center of the blue hemisphere. Wait for the target to cross the center of the screen, while keeping the navball in position. When this happens, write down the time (displayed a the top left corner of the screen.) Call this time t0. I measured t0 = 1:01:09:15 A Bunch of Calculations Basically, we need to figure out at what time to burn to intercept our target. We also need to figure out the velocity we need to burn to. These formulas give us everything we need: Some notes: r1 is the orbital height of the lower ship, measured from the planet's center. This means we need to add the planet radius (600,000m for Kerbin). r2 is the orbital height of the higher ship, measured from the center of the planet again. t0 is our initial crossing time as measured in the last image. The funny "u" looking symbol is called "mu", and represents the gravitational parameter of the planet. For Kerbin, this is 3.5316 x 10^12 m^3/s^2. Calculations done! Using those formulas, I get: tR0 = 27522 seconds (This is how long until our ship and the target ship are lined up again.) tH = 1253 seconds deltaTheta = 0.1368 deltaTBurn = 26923 seconds We need to add this 26923 seconds to our time t0 to figure out when to burn. Converting to hours, minutes and seconds and adding, I get: TBurn = 1:08:37:58 This is the time (top left of screen) at which we need to burn to intercept our target. We'll burn prograde until our velocity is equal to Vtransfer = 2133m/s. About to burn . . . Burn complete! We're now within 20km of the target! At this point, you can take the controls and fine-tune the intercept. And that's it! Best of luck if you want to try this out! Let me know if you have any questions.
-
[Updated] Aerobraking Calculator
alterbaron replied to alterbaron's topic in KSP1 Tools and Applications
Warning: math post. Might be a bit long . . . The calculator works off of a simple principle: given the current orbital velocity, the current altitude, and the periapsis height, it is possible to figure out the shape of your orbit in the plane of orbit, along with a bunch of relevant orbital data. Here's a snippet of MATLAB code that does just that: function [ ep ec a hmag rpe rap ] = get_orbit_params( r, v, mu ) % Get useful orbit parameters from position vector, velocity vector, and % gravitational parameter. % specific orbital energy ep = dot(v, v)/2 - mu/norm(r); %specific angular momentum r3d = [r(1) r(2) 0]; v3d = [v(1) v(2) 0]; hmag = cross(r3d, v3d); hmag = hmag(3); %eccentricity ec = sqrt(1+2*ep*hmag.^2./(mu.^2)); %semi-major axis a = -mu/(2*ep); %periapse distance rpe = -a*(ec-1); % Apoapse distance (valid iff ec < 0) rap = (1+ec)*a; end Note that r and v are vectors, and have X and Y components. Mu is the gravitational parameter for the body (taken from the wiki). There's an ambiguity in orientation, so we can set the azimuthal (angular) position of r as we please. I use r = [orbit_altitude + planet_radius, 0] for simplicity. Some quick geometry gives the following expressions for the x and y components of the velocity: vy = (rpe/r)*sqrt(v^2+2*mu*(1/rpe-1/r)); vx = sqrt(v^2-vy^2); Of course, v = [vx, vy]. Now we can plug in r, v and mu into the earlier code to get all that other good stuff. Using this data, we can figure out the magnitude and direction of the ship's velocity when we hit the planet's atmosphere: % Calculate vcontact and rcontact where the orbit intersects the % atmosphere. cos_theta_contact = (1/ec)*(a*(1-ec^2)/Ratm - 1); theta_contact = acos(cos_theta_contact); vcontact_mag = sqrt(2*(ep + mu/Ratm)); theta_1 = asin(hmag/(Ratm*vcontact_mag)); vcontact = vcontact_mag * [-cos(theta_1+theta_contact), -sin(theta_1+theta_contact)]; rcontact = Ratm * [cos(theta_contact), sin(theta_contact)]; Where Ratm is the maximum extent of the atmosphere of the body (including the radius of the planet). Theta_contact is the angle with respect to our arbitrary coordinate system where the ship hits the atmosphere. Theta1 is some other angle between the position and velocity vectors, which I use to figure out the x and y components of the velocity (some tricky geometry, you'd need to try it on paper to see how it works). Anyhow, now that the ship is in the atmosphere, we can simulate its trajectory (affected by both drag and gravitational forces) until it either escapes the atmosphere, or crashes. This is done using a time-stepped method. Pretty much, at a given point in time, we calculate the gravitational and drag forces affecting the ship. These forces are used to update the velocity of the ship, which is used to update its position. This process is repeated until the ship hits the ground (vector length of r <= the planet radius) or it escapes the atmosphere (||r|| >= Ratm). Here's the simplified model used for the ship: function [ F ] = in_atmo_force( R0, P0, H0, d, mu, m, A ) % Returns a function which gives the total vector force in atmosphere % as a function of position and velocity. Kp = 1.2230948554874*0.008; % Total force = drag + gravity F = @(r,v) -0.5*Kp*P0*exp((R0-norm(r))/H0)*norm(v)*d*m*A*v - m*(mu/norm(r).^3)*r; end F is a function which takes the position and velocity vectors and returns the vector force due to both drag and gravitation. (Note that KSP uses an erroneous mass term in the drag part of the force which doesn't exist in real life.) To step the ship forward in time, one could use a simple approach like Euler's method. I used a variant of a method known as Velocity Verlet since it gives more accurate results with less computation time. Here's the code used to simulate the physics (Modified Velocity Verlet): function [r v t] = integrate_path( F, m, r0, v0, dt, Rmin, Ratm ) % Integrate the equation of motion to find the path in atmosphere. % Terminate on collision with surface (sea level) or atmosphere escape. t = 0; r = r0; v = v0; a = @(rin, vin) F(rin, vin)./m; firstrun = true; while firstrun || (norm(r) <= Ratm && norm(r) >= Rmin) r_old = r; v_old = v; a_t = a(r_old, v_old); r = r_old + v_old*dt + 0.5*a_t*dt.^2; v_est = v_old + 0.5*dt*(a_t + a(r,v_old+dt*a_t)); v = v_old + 0.5*(a_t + a(r,v_est))*dt; t = t + dt; firstrun = false; end end Note that F is our force function from before, which takes the position and velocity as arguments, and computes the vector force. Almost there! Once we've escaped the atmosphere, we simply take our final r and v vectors and plug them in to get_orbit_params( r, v, mu ) to figure out the apoapsis of our final orbit. Finally, we run all of this over and over again, varying the periapsis height that we plugged in way back at the start. We keep refining that PE value until the resulting AP is what we wanted. That's it! Just a little convoluted. Anyway, if you want to learn more about orbital mechanics, I'd check out the wonderful pages located HERE. I also have an (incomplete) Guide to Orbital Mechanics for KSP in the wors which I really should get around to finishing. Might help with getting started with orbital mechanics stuff if you want / need to. I've uploaded some similar code for computing atmospheric landings on Github Gist. The (awful) source code of the live site is available On Github if you like reading Javascript more than MATLAB. If you've made it this far, thanks for braving it through and reading! -
The problem with doing this for non-atmospheric bodies is that there's no atmosphere to slow you down. As a result, how & when you execute your burns makes all the difference. And how long your burns will take depends on the craft, making it near impossible to make a useful plot. (Luckily, at this time atmospheric drag doesn't depend much on the craft, making a universal plot possible in that specific case.) I don't want to leave you with nothing though, so here's a method you can use to quickly estimate how far the planet will rotate while landing. You only need a simple desktop calculator and a small table of values from the wiki: Calculating How Much a Planet Will Rotate During Landing (Easy) 1) Perform your landing burn. 2) Make sure you've passed your Apoapsis. 3a) If your trajectory is suborbital (no PE marker), read the time to apoapsis by mousing over the AP marker, and divide this by 2. 3b) If your trajectory is orbital (PE marker is there), read the time to periapsis by mousing over the PE marker. 4) Grab the so-called "sidereal rotation period" for the body from the wiki. 5) The angle the planet will rotate is given by: RotationAngle = 360 degrees x [Time from Step 3 in Seconds]/[sidereal Rotation Period] That's it, pretty straightforward. If you write down the "Sidereal Rotation Period" for each body in advance, it's easy to work this out in-game. Have fun!
-
I used a program called "screenscales". You can get it here: http://www.talon-designs.net/screen_scales.htm Mentioned on the forums here: http://forum.kerbalspaceprogram.com/showthread.php/21255-Screen-Scales-Freeware-%E2%80%93-Orbit-Transfer-Angles-made-(a-little)-easier It's an adobe air app, so click the "install now" button to download and install it. Side-note: As a future project, I'll look into making a chart where you set your periapsis directly above your target, and it spits out what periapsis height you need to land there. This could make planning landings even easier, no protractor required.
-
[Updated] Aerobraking Calculator
alterbaron replied to alterbaron's topic in KSP1 Tools and Applications
Ah, I'm glad you were able to sort out your issue. Aerobraking into an orbit with a large AP reliably can be quite tough, since the final AP is extremely sensitive to small changes in the aerobraking PE. This is a mathematical fact that comes out of the physics of aerobraking, so there's no real way around it (unless you use an in-game plugin that can gather perfect orbital info, of course, and even that won't be exact due to numerical stability issues.) The larger your final PE, the more careful you have to be when plugging in your numbers. The whole angle thing is confusing, I'll agree. Pretty much, you want to draw an imaginary circle on the navball that passes through the prograde and retrograde markers. The direction to thrust at lies on that circle, and at the given angle away from the top of the navball. Really, what you're doing is thrusting at 90 degrees between the prograde and retrograde markers. I should update the info on the page to make this more clear. -
It's easy to calculate the eccentricity from the apoapsis and periapsis distances: Just remember that you have to add the planet's radius to your AP and PE altitudes.
-
Did this a few months ago: Stock Apollo-Style Laythe Return Mission. Imgur Album EDIT: Crap, just realized the challenge said no docking. Oh well.
-
New, protractor-free landing method! A new, easier way of targeting landings in-game, without any external tools. Starting from a circular orbit, simply burn to lower your periapsis directly over your target. If you know what periapsis to use, you can land near your target, every time! Below is a plot of the landing periapsis that you need to put directly above your target to land there. The blue curve is the required periapsis height. The green curve is how much your landing site changes for every 1m change in the periapsis. This gives an estimate of how much precision is required to hit the target. I tested these results in-game, and got pretty good results. Here's an album of some test results: http://imgur.com/a/tKq8l Since the final landing site is so sensitive to small changes in the periapsis, the graph's hard to use for anything more than an overview. For actually using these results to land, here's the hard numbers: Landing PE Values for Kerbin =================================================== Orbit Altitude (m) Landing PE (m) Error per m (m) =================================================== 70000 48901 53 80000 45550 49 90000 43898 46 100000 42778 44 110000 41938 42 120000 41272 41 130000 40727 40 140000 40270 40 150000 39878 39 160000 39539 39 170000 39242 39 180000 38979 39 190000 38744 38 200000 38534 38 210000 38345 38 220000 38173 38 230000 38017 39 240000 37874 39 250000 37743 39 260000 37623 39 270000 37512 39 280000 37410 39 290000 37315 40 300000 37227 40 310000 37145 40 320000 37069 41 330000 36999 41 340000 36932 41 350000 36871 42 360000 36813 42 370000 36758 43 380000 36707 43 390000 36660 44 400000 36615 44 410000 36572 45 420000 36532 45 430000 36494 47 440000 36459 46 450000 36425 47 460000 36393 47 470000 36363 48 480000 36335 49 490000 36308 49 500000 36282 50 510000 36258 50 520000 36234 51 530000 36212 52 540000 36191 53 550000 36171 53 560000 36152 54 570000 36134 55 580000 36116 56 590000 36099 56 600000 36083 57 610000 36068 58 620000 36053 59 630000 36039 60 640000 36025 61 650000 36012 61 660000 36000 62 670000 35987 63 680000 35976 64 690000 35964 67 700000 35953 66 710000 35943 67 720000 35933 68 730000 35923 69 740000 35913 70 750000 35903 73 760000 35894 73 770000 35885 74 780000 35877 75 790000 35868 76 800000 35860 77 810000 35852 79 820000 35844 80 830000 35836 81 840000 35828 82 850000 35821 84 860000 35814 85 870000 35806 88 880000 35799 88 890000 35792 89 900000 35785 91 910000 35778 92 920000 35772 94 930000 35765 95 940000 35759 97 950000 35752 98 960000 35746 100 970000 35739 102 980000 35733 103 990000 35727 105 1000000 35721 107 Using RCS for fine adjustment should make this landing method really easy! Charts for other bodies. Using this method along with minor correctional burns in atmosphere allows for extremely precise landings. Such corrections are best made before dipping into the thickest part of the atmosphere. On kerbin, I've managed to land only a few steps from a flag using this method! Protractor Method Have trouble landing at your base from orbit? Want to transfer Kerbals from your Duna or Laythe station to the surface with precision? Then this is the chart for you! Big Version Imgur Album With Tutorial Here's how to use the chart: Start off in a circular orbit. (You must be more or less in a circular orbit before using the chart.) Look up your orbital altitude on the x-axis. The corresponding y-coordinate gives you your "landing phase angle". Basically, you want to burn so that your periapsis is at as close as possible to 0 meters, and at the given angle AHEAD of your target. (Make sure to view full resolution, or you'll never be able to read it! Also note that the x-axis is in 10^5 meters.) Take a peek at the Imgur album for a walkthrough! It's actually really easy. Let me know what you think! Edit: Updated plot with data for lower orbits.
- 27 replies
-
- 11
-
-
[Updated] Aerobraking Calculator
alterbaron replied to alterbaron's topic in KSP1 Tools and Applications
First of all, thanks for the feedback! It's really easy to let bugs slipped by unnoticed, so your comments are appreciated. I just looked into this: I need to revise my instructions that say to put your periapsis inside the planet's atmosphere. It turns out that this advise is flawed: you should put your periapsis at least a little bit outside the planet's atmosphere, or else the calculator may have problems. If you put your periapsis at around 80,000m before running the calculator, you should be fine. Details: The problem here is that the calculator looks for maneuvers that keep the magnitude of your velocity the same (this is an arbitrary constraint that makes searching for a solution easier). When your craft doesn't have a high enough velocity to get a PE high enough in the atmosphere without changing the magnitude of its velocity, then the calculator can't find a solution.