Jump to content

[1.8.1 - 1.10.1] BoostGuidance v1.0.1


oyster_catcher

Recommended Posts

Thanks. The landing burn should say "too heavy" if have insufficient thrust, and it looks like you have sufficient thrust, but its applied too late. Also go to Advanced and increase "touchdown margin" by 10m. The vessel should think the ground is higher and slow down earlier above the ground. It should then descend at "touchdown speed" of 2m/s default. Looking at your video it definitely looks like increasing "touchdown margin" should help. 

Link to comment
Share on other sites

On 12/17/2020 at 6:40 AM, oyster_catcher said:

This may not be new but here's my mod which aims to autonomously guide a Booster to land on a drone ship or the launch site (or anywhere else) using a combination of Boostback, Re-entry Burn, Aerodynamic Descent and Landing Burn, i.e. SpaceX Falcon 9 style. Select your landing point either by clicking on it, typing the latitude+longitude+altitude or selecting a target (e.g. drone ship). Its aimed to be reliable and fairly easy to use. I've also made it work in Realism Overhaul where limited throttle able engines and limited ignitions mean you can't play fast and lose with your engines. With suitable engines and using the right number active you can achieve this is Realism Overhaul which gives a real feeling of satisfaction.

The mod relies on accurately simulating the entire trajectory to landing including burns later in the flight which means guidance should be accurate without the need for any heroic manoeuvres as the impact of say the reentry burn is properly factored in. BoosterGuidance will continuously monitor the target error and aim to reduce it in boostback, re-entry burn, aerodynamic descent and in the landing burn steering either via engines or via grid-fins depending on the phase of flight. You can set the steering gains during the flight to give the grid fins more/less to do, and configure the reentry burn via altitude and target velocity. Some more advanced settings allow you to set safety margins, speed of final descent, at what height to give up steering and more. You can also log the whole flight and plot it to examine in detail what happened and how closely you could copy SpaceX.

Released under GLP v3.

Here's some videos showing it working with a single stage Falcon 9 booster

In Realism Overhaul with a 2-stage Falcon 9 rocket where I make a half-hearted attempt to get the 2nd-stage to orbit.

This mod is very usable and lots of fun now but has a few limitations I'm working on.

- Clicking the target only works  close to the terrain or there are physical structure (some KSP/Unity Raycast limitation I don't understand)

- In Realism Overhaul you may need to manually reduce the gain close to landing to avoid large oscillations

- Landing legs deployment is unreliable

- Guiding more than one booster simultaneously should be possible but is currently unreliable. My goal is a Falcon Heavy two booster landing. That will be awesome!

- It should work on other planets too though the trajectory should be sub-orbital to impact the ground within about 10 minutes as simulation time is limited for CPU reasons

Get the mod via GitHub here: https://github.com/oyster-catcher/BoosterGuidance/releases

or on SpaceDock here: https://spacedock.info/mod/2587/BoosterGuidance

Released under GPL v3

Maybe my KSP installed FAR and principia, there are something wrong. When my Vessel got the landingburn, he just made a little throttle until touchdown, all it BOOM. So I use Mechjeb2 Landing Guidance to redeem them when it landingburn... But it a WONDERFUL mod, I like its aerodynamic simulation and accuracy, these is what MJ's didn't do.

Link to comment
Share on other sites

@TheKurganYes I should think I could add triggering by an action group. Perhaps then I could be triggered immediately on staging. I've seen a bit of this part of the API but I'm not familiar without so I'll need to work it out. The best bet is probably for me to look at the MechJeb code so thanks for that tip.

5 hours ago, SuiBoyang said:

Maybe my KSP installed FAR and principia, there are something wrong. When my Vessel got the landingburn, he just made a little throttle until touchdown, all it BOOM. So I use Mechjeb2 Landing Guidance to redeem them when it landingburn... But it a WONDERFUL mod, I like its aerodynamic simulation and accuracy, these is what MJ's didn't do.

Hmm. Sorry about the loss of your vessel. The mod does only simulate the Stock aerodynamics, as I couldn't get FAR to link, but that probably doesn't make a major difference. A few people have found the thrust comes in too late. There are quite a few tweak factors here since getting the height of the bottom of the vessel above the ground is rather tricky as the vessel origin moves around a bit but you need to know where the bottom of the vessel is relative to that, and this will change is landing gear is lowered. So please increase "touchdown margin" in the Advanced tab by 10m or so for now, the vessel will treat the ground is being higher which provides a safety margin.

Link to comment
Share on other sites

Thank yo so much for the great work!!! Here is my test footage. Clearly much better than my kOS landing script.

I have few ideas to fix the landing burn in RO.

1 Add an option so the mod knows it is RO, even add the option of Principia (But I don't think Principia is the trouble here.)

2 In RO Mod, only calculate the Landing Burn Start Altitude after approaching Mach 1. Or certain altitude. given by player (Since in the RO, to find the best design, suidice burn is adored by many, the extreme TWR usually allows landing burn start after aerobraking to Mach 1).

3 The Target Altitude defines what in game? Does player need to consider the vessel height and target vessel height plus target altitude? I am just curious, and it would be nicer to add those option in the mod.

Once again, thank you for this incredible mod!

Link to comment
Share on other sites

47 minutes ago, alexv86 said:

Just downloaded v1.0.3a and I don't see the dll. The gamedata folder only has the icon and a .cfg file.

Sorry. It looks like I forgot to upload the packaged zip file to GitHub for v1.0.3a, only the sources. Fixed up now, or use spacedock.info. You are looking for BoosterGuidance-v1.0.3a.zip

Edited by oyster_catcher
Link to comment
Share on other sites

10 hours ago, rhZhao said:

I have few ideas to fix the landing burn in RO.

1 Add an option so the mod knows it is RO, even add the option of Principia (But I don't think Principia is the trouble here.)

2 In RO Mod, only calculate the Landing Burn Start Altitude after approaching Mach 1. Or certain altitude. given by player (Since in the RO, to find the best design, suidice burn is adored by many, the extreme TWR usually allows landing burn start after aerobraking to Mach 1).

3 The Target Altitude defines what in game? Does player need to consider the vessel height and target vessel height plus target altitude? I am just curious, and it would be nicer to add those option in the mod.

Once again, thank you for this incredible mod!

Thanks so much for the video. Its very helpful.

1. I can see that the landing burn came in quite early as the thrust was as at minimum for the whole landing burn. Thats disappointing. The mod does try to give the latest suicide burn taking aero-braking into account. It does this by finding a maximum velocity for each altitude assuming no air resistance. It also calculates a falling trajectory with no engine thrust which includes air resistance. When these lines cross at the lowest possible altitude determines when the landing burn is started. This has mostly worked well in RO too, but I've tested very few vessels, and there is a safety margin added (perhaps this is too much). The landing burn altitude is extremely sensitive to the weight. If you use HyperEdit and tweak the fuel quantity you will see the landing burn altitude change radically. But anyway it looks quite badly wrong for your craft. Could you provide me a craft file please so I can test?

Also the vessel was steered in the wrong direction. This is because the lift provided by the vessel is balanced against the thrust. In v1.0.3a I make an estimate of the lift as a proportion of the drag, and this was clearly wrong. BoosterGuidance assumed the engine thrust would dominate hence it steered to thrust towards the target, but the aero forces pulled it away from the target so the target error grew from 200m to 800m. This lift estimate will be gone in the next version, and the lift is calculated correctly (though only with Stock aerodynamics, not FAR so far). So the vessel should be steered towards the target even when some engine thrust is applied.

2. In principle I need the altitude of the suicide burn for the boostback since they depend on each other. In practice this is a rough estimate at boostback anyway due to fuel consumption being ignored and reducing the weight. So calculating the landing burn altitude later is probably fine and your suggestion will work quite well I think. It will avoid continuously calculating it which isn't ideal other but I didn't want to add extra parameters, it could probably calculate it once when starting the aero descent. I'm not too keen on the mod having to be told its in RO. I think the mod should be able to do without that or work it out. I'll consider this more.

3. Yes. I could probably drop that. Its used to find the height above ground. Its really a hangover from the HopperGuidance mod where targets can be at height rather than on the ground. It think it would be a good idea to drop it entirely as it is redundant. Also the target altitude can be wrong if you land somewhere nearby if there is a slope, it would be better to consider height about the terrain where you are. So the player doesn't need to consider the vessel height, the target is for the bottom of the vessel.

Thanks. I'll definitely incorporate some of your suggestions.

Link to comment
Share on other sites

On 1/2/2021 at 5:28 PM, oyster_catcher said:

Thanks so much for the video. Its very helpful.

1. I can see that the landing burn came in quite early as the thrust was as at minimum for the whole landing burn. Thats disappointing. The mod does try to give the latest suicide burn taking aero-braking into account. It does this by finding a maximum velocity for each altitude assuming no air resistance. It also calculates a falling trajectory with no engine thrust which includes air resistance. When these lines cross at the lowest possible altitude determines when the landing burn is started. This has mostly worked well in RO too, but I've tested very few vessels, and there is a safety margin added (perhaps this is too much). The landing burn altitude is extremely sensitive to the weight. If you use HyperEdit and tweak the fuel quantity you will see the landing burn altitude change radically. But anyway it looks quite badly wrong for your craft. Could you provide me a craft file please so I can test?

Also the vessel was steered in the wrong direction. This is because the lift provided by the vessel is balanced against the thrust. In v1.0.3a I make an estimate of the lift as a proportion of the drag, and this was clearly wrong. BoosterGuidance assumed the engine thrust would dominate hence it steered to thrust towards the target, but the aero forces pulled it away from the target so the target error grew from 200m to 800m. This lift estimate will be gone in the next version, and the lift is calculated correctly (though only with Stock aerodynamics, not FAR so far). So the vessel should be steered towards the target even when some engine thrust is applied.

2. In principle I need the altitude of the suicide burn for the boostback since they depend on each other. In practice this is a rough estimate at boostback anyway due to fuel consumption being ignored and reducing the weight. So calculating the landing burn altitude later is probably fine and your suggestion will work quite well I think. It will avoid continuously calculating it which isn't ideal other but I didn't want to add extra parameters, it could probably calculate it once when starting the aero descent. I'm not too keen on the mod having to be told its in RO. I think the mod should be able to do without that or work it out. I'll consider this more.

3. Yes. I could probably drop that. Its used to find the height above ground. Its really a hangover from the HopperGuidance mod where targets can be at height rather than on the ground. It think it would be a good idea to drop it entirely as it is redundant. Also the target altitude can be wrong if you land somewhere nearby if there is a slope, it would be better to consider height about the terrain where you are. So the player doesn't need to consider the vessel height, the target is for the bottom of the vessel.

Thanks. I'll definitely incorporate some of your suggestions.

Thank you for your response, gave me a lot of thoughts.

I ran the guidance once again this morning, I have some other thought, maybe during the booster back burn, the overshoot point can be adjusted a little further away from the target point? I think the landing burn height becomes TOO HEAVY may be the result of undershooting, unless the vessel pitches over 45 degree then it will reach the target "theoretically".

Sorry, I have no experience in Unity or C# or even coding. I just start to learn coding with kOS and other people landing script. ,In my kOS script, I set vessel to wait until reaching 4242m or Mach <1, then start to calculate the Landing Burn Altitude. Because before the mission,  I just calculated the estimated shortest burning distance when the vessel performs maxThrust,, then I multiple that number by 1.20 to 1.4 (because my engine has 65% down throttle range) plus the distance rocket travel when engine is starting up. I used 4242 because it is composed by this luck number twice. That's how I avoid the overvalued Landing Burn Start Point.

Here is a video, Start at 2:33:0 please.

So the kOS calculate landing burn starts at 2914m, so it is far accurate. But I did not even know the different between retrograde and surfaceRetrograde in the kOS, so I was struggled to control the horizontal velocity.

Space is hard. 

I will upload my video tonight when I get home:

Here is the link of my craft and the .cfg files I changed in my RealismOverhaul folder. 

https://drive.google.com/drive/folders/1gyhwvmfFk_szJfZRfIgvUMq7R8rbT_we?usp=sharing

Edited by rhZhao
Link to comment
Share on other sites

@rhZhaoThanks for your videos and craft file, it really helps and inspires me to make the mod better. I've discovered that the use of FerramAerospaceResearch is the reason for the early landing burn. It seems it does make a quite significant difference to the terminal velocity and can drastically change the height of the landing burn.

I've also improved the steering when under engine thrust and aerodynamic forces. Rather than approximating lift I can now calculate it directly. This should mean the rocket steers in the correct direction.

In this video you can see the temporary button "use FAR" which can switch between stock and FAR aerodynamics, I do this a few times and you can see the landing burn altitude change. Also the rocket now steers correctly during the landing burn, whereas previously I had most success setting the steering to 0 degrees. However, the gains look very high so the rocket over-steers a lot but it does land within 9m of the target. Also note that the green line shows the orientation the rocket is trying to steer towards, which helps me to work out whether the rocket is trying to steer correctly but cannot.

I hope to release this in a day or two. I will probably remove the "use FAR" toggle, and hopefully stop the over-steering in RO.

I was able to download your craft and engine part, but it seems I'm missing quite a few required mods. I'll need to spend some more time testing your craft. But anyway, I think the improvements I'm making will make it work better for your craft too even if I can't test it. To answer your questions...

     I think the landing burn height becomes TOO HEAVY may be the result of undershooting, unless the vessel pitches over 45 degree then it will reach the target "theoretically".

It is true that if the vessel is pitched over it would more thrust to slowdown since the vertical component is lower (it will compensate for this). But actually I don't think "too heavy" could result from that as the calculation made for the landing burn is simpler. Its almost certainly that the stock aero-dynamics give less drag hence too much thrust is estimated to be required.

   So the kOS calculate landing burn starts at 2914m, so it is far accurate. But I did not even know the different between retrograde and surfaceRetrograde in the kOS, so I was struggled to control the horizontal velocity.

Thanks for showing me that. It looks like you are really close. For the landing burn I basically compute a steering vector = -vel_air + 20*up.  Where  -vel_air means surfaceRetrograde. up is a normalised vector pointing straight up. This calculation means any vertical and horizontal velocity is cancelled until the velocity becomes low and then just staying vertical begins to dominate. I also add a small correction so thrust can be used to steer towards the target point. But almost all steering is done aerodynamically rather than with the engines since this dominates when travelling > ~100 m/s.

If you out grow kOS you might like to try kRPC which allows you to write much more complex code in Python and other languages and interface it to KSP.

Link to comment
Share on other sites

As well as fixing some of the problems with RO I've refactored the code quite a bit to make it cleaner and more reliable when saving BoosterGuidance settings with craft and in saved games. The major breakthrough is the use of FerramAerospaceResearch as I finally managed to link with it, even though I could not get the way the Trajectories mod does this to work for me so I tried an alternative method. I changed how the steering gains work which means much better landing accuracy in Realism Overhaul. A droneship landing with RO is definitely possible, though I've had trouble getting one out to sea in RO. (Any tips on this greatly appreciably since HyperEdit won't work )

I think RO users will enjoy the improvements. Its recommended to lower the aero-dynamic steer max angle to 1-5 degrees to avoid over-steering. In Stock you can have this at 30 degrees with no problems.

I'm calling this a pre-release, though I think its good. I'd just like others to try it and report any bugs, as the code has changed quite a lot internally. Enable guidance with multiple vessels works well in Stock KSP but I've encountered some strange issues with this in RO which I don't yet understand.

Download from here https://github.com/oyster-catcher/BoosterGuidance/releases

Pre-release v1.0.4

- Will now always use FerramAerospaceResearch for aerodynamic calculations if its available. FAR seems to predict higher drag so landing burn alt often way lower
- Better calculation of lift which means vessels should steer in the correct direction in landing burn (mostly!)
- Considers aerodynamic lift in re-entry burn so if this lasts to the thick atmosphere steering will reverse
- Only sign of gain (steer direction), rather than value is calculated by aerodynamic lift vs thrust. This means that gains are more stable between different vessel, RO, FAR, etc... and leads to less over-steering. Steer gain is still best set to max angle of 1-5 degrees with FAR though (for a typical Falcon-9 with gridfins) otherwise over-steers
- Will cutout engine in final landing burn if too much minimum thrust. Only occurs in RO. This is hit and miss due to the time to throttle down engine
- Major re-factoring to use BoosterGuidanceCore (the vessel part) as a central class. Code is cleaner and more reliable and fewer bugs for load/save/switch vessel
- Target error is reported in km when >100km
- Bug fixes to show/hide prediction/target
- Size of prediction/target on map reduced
- Click through prevention for pick target when under window
- Many minor bug fixes
- Stores engine ignite delay with BoosterGuidanceCore

Link to comment
Share on other sites

22 minutes ago, NateDaBeast said:

Just saw this mod, looks really neat.

 

One question though: How well would this work with a Starship-type vehicle for reentry/guidance? I'm not that good at doing the body flip for starship ;.;

Thanks. Currently it would steer the vehicle retrograde all the way down like a Falcon 9 so it wouldn't do the belly flop. Its definitely possible to extend the mod to do the belly flop though. It would require a different 'plug-in' for the belly flop and different re-entry. Its quite a big change and the keeping the UI simple would be a challenge but I'd be up for trying it!

Link to comment
Share on other sites

11 hours ago, oyster_catcher said:

Thanks. Currently it would steer the vehicle retrograde all the way down like a Falcon 9 so it wouldn't do the belly flop. Its definitely possible to extend the mod to do the belly flop though. It would require a different 'plug-in' for the belly flop and different re-entry. Its quite a big change and the keeping the UI simple would be a challenge but I'd be up for trying it!

Well I am glad you may do it in the future. I'm sure it would be popular as I don't know of any other mod that would land your rocket for you doing a belly flop.

 

I do not know that much of modding, but maybe making it a separate mod may help with keeping the UI simple if that's a goal for you.

Link to comment
Share on other sites

On 1/1/2021 at 10:31 AM, oyster_catcher said:

@TheKurganYes I should think I could add triggering by an action group. Perhaps then I could be triggered immediately on staging. I've seen a bit of this part of the API but I'm not familiar without so I'll need to work it out. The best bet is probably for me to look at the MechJeb code so thanks for that tip.

@TheKurgan I've added Enable and Disable BoosterGuidance action groups in v1.0.4a. See https://github.com/oyster-catcher/BoosterGuidance/releases. I missed out Toggle BoosterGuidance but that will be in the next version with other improvements

Link to comment
Share on other sites

v.1.1.0 released

- Finally fixed steer gain calculation (perhaps) as several bugs discovered. Further improvement that mean craft should steer in the correct direction during landing burn (or not steer at all)
- Added action group to toggle guidance
- Added language localization tags for all text. Included en-us.cfg
- Reports messages to screen from controller such as phase changes
- Landing burn gain reduced so steering less aggressive
- Fixed bug where target position wasn't copied to all cores, so target was lost on staging
- Stopped slowness of 40-50ms of computation time for some vessels by stopping very frequent calls in simulate

Released under GPL v3. Download from https://spacedock.info/mod/2587/BoosterGuidance or https://github.com/oyster-catcher/BoosterGuidance/releases/tag/v1.1.0

13 hours ago, Helvica_Ring_Scientist said:

Help me, please.
I tried to land my booster in the launchpad, but it ends up going too far. Any tips?

If it is slowing down but hits the ground a little too fast, SN8 like(!) then increase "touchdown margin" in the advanced tab by 10m or so, which means at will slow down earlier and then slowly descent at "touchdown speed" from there on. So it gives a safety margin.

If you see "too heavy" then the vessel has insufficient thrust for its weight to slow down enough.

You might also see an improvement with v1.1.0 I just uploaded. Previously it would re-compute the required thrust only 10 times/sec. This might be insufficient if you have really high thrust engines where all the deceleration happens in the last second. v1.1.0 will compute the thrust every frame, like 20-60 times/sec when near landing. This might help. It'd be great if you tell me if any of this works for you

Link to comment
Share on other sites

15 hours ago, Helvica_Ring_Scientist said:

It hits the ground too fast in a way that it falls on its own, or if on a water landing, it breaks apart. Is this an old issue that is fixed on the new update (sorry I didn't check out the new update so I'm going)

I'm not sure. Could you make a short video? That would help see the problem.

Even the earlier version shouldn't have a bug that appears this big

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...