PapaJoesSoup / BDArmory

Gun turrets and other weapon systems for KSP
114 stars 57 forks source link

Surface to Surface Guidance #514

Open TheKurgan opened 6 years ago

TheKurgan commented 6 years ago

KSP 1.4.3

BDArmory.1.2.1_05042018

Win 10

Summary There currently isn't a working guidance mode that is suited to medium range surface to surface missiles (15 - 40km). The current missile we are working on, the Brimstone Sea Spear, has a max range of 20km. In order to hit a target at 20km with an STS missile, it has to reach an altitude of at least 260 - 300 meters ASL, before it levels off and starts it direct route to the target. (typical AGM behavior)

If a new, or fixed STS guidance mode would ensure that the missile reaches an altitude of (0.015 x distance to target) before it goes into AGM mode, I believe this would work well.

What do you think?

Opinions welcomed.

TheKurgan commented 6 years ago

0.015 x 20km = 300m, and in all my tests at different ranges, 1.5% of the distance to the target translated to the missiles altitude shortly after launch, always seemed to guarantee a hit.

Well for this particular missile... not sure if this will apply to all medium range STS missiles... but it would be a good place to start.

Gedas-S commented 6 years ago

Generalizing the problem a bit - there should really be an IBDMissileGuidance interface, so mods can implement their own guidances which BDA can then use, and creating new guidances is less of a hassle. I'll see what I can do... eventually. :)

Then you could just hack together a guidance, drop the dll into gamedata, and use it. I'm not saying it's not rocket science, but it could be more rocket and less science.

(I've actually looked into it a bit before, and this should be very feasible, the most boring part will be to refactor the existing guidances to fit.)

jrodrigv commented 6 years ago

I think this quite feasible, however during last two years I think I was the only one developing guidance algorithms so not sure how many modders will take advantage of the decoupling effort :)

Gedas-S commented 6 years ago

On one hand - probably not too many. On the other - building a guidance should be a fairly easy thing to do, and might be a gateway for some people to get into modding. ;)

And then it probably mostly depends on the documentation. :) If there is a template to base it off, and documented features on how to set it up, some might.

Also we have a few issues requesting different niche cases of guidance - #445, #323, sort of #129, apart from this one. And I'm not even sure if all our current guidances work. Even if nobody else uses it, BDA could have an additional_guidances.dll addon, so there can be a bunch of different guidances for those interested, without cluttering up the core BDA mod.

Tbh, I'm not too sure this is needed, but sounds like a fun thing to implement (for me, at least), and does not strike me as a bad idea in general. :)

PapaJoesSoup commented 6 years ago

For what it is worth, it falls in line with the discussions we have had about modularizing BDA. The question I have is do you see any improvements in performance being possible from the results of the effort?

Gedas-S commented 6 years ago

No, not really. :) It'd probably replace an else if block with a reference lookup, for negligible performance impact. And with the typical number of missiles in a scene, I don't think the guidance would even be a blip on a profiler to begin with.

If somebody mods in a missile barrage launcher, an optimized guidance might make a bit of a difference, but I don't think that's a scenario we're talking about here. :)

TheKurgan commented 6 years ago

Maybe not NEEDED, but would be very useful. IMO. There are many anti tank and anti ship or general SSM or GGM missiles that are not ballistic or cruise guided. For example the Brimstone Sea Spear and the RGM-84 Harpoon, both of which are Radar guided.

What guidance should you use? Both AAM and AGM are ok for targets at close range, say up to a max of 10km... BUT try to hit a target at 20km (which the Sea Spear is rated for) It's impossible... the missile will crash before it gets to the target, even if you launch it straight up... which you shouldn't have to do.

Launching the missile at a 45 degree angle, that missile needs to gain altitude first, then start it's turn and head for the target.

TheKurgan commented 6 years ago

The missile needs to get enough altitude, so that it's target is in LOS, then do the typical AGM behavior.

jrodrigv commented 6 years ago

@TheKurgan we all agree on the need of the STS guidance :)

@Gedas I agree with you, it would be interesting to implement and it should not be theorically hard. Shall we open s different ticket for this?

I have implemented pluggable architectures before using MEF. Not sure if it is supported by Mono though, I know is supported in Net Core.

Maybe the easiest would be to have each guidance as a separate assembly with its own concrete implementation of the interface, plus a Monobehaviour to register the instance in BDArmory IOC container