ThrottleControlledAvionics icon indicating copy to clipboard operation
ThrottleControlledAvionics copied to clipboard

Multi-vessel deorbit is broken.

Open jrodrigv opened this issue 7 years ago • 10 comments

I have seen this exception looking at my logs. KSP 1.2.2. & TCA 3.4.1.

ArgumentOutOfRangeException: Argument is out of range. Parameter name: capacity System.Collections.Generic.List1[ThrottleControlledAvionics.AtmosphericConditions]..ctor (Int32 capacity) ThrottleControlledAvionics.LandingTrajectory.GetAtmosphericCurve (Double dT, Double endUT) ThrottleControlledAvionics.DeorbitAutopilot.Update () ThrottleControlledAvionics.TCAModule.OnFixedUpdate () ThrottleControlledAvionics.ModuleTCA.<FixedUpdate>m__D (ThrottleControlledAvionics.TCAModule m) System.Collections.Generic.List1[ThrottleControlledAvionics.TCAModule].ForEach (System.Action`1 action) ThrottleControlledAvionics.ModuleTCA.FixedUpdate ()

jrodrigv avatar May 07 '17 12:05 jrodrigv

I'm trying to deorbit a vessel that is not the "active vessel". I've everything set on the vessel that I want to deorbit and then I switch to a different vessel.

jrodrigv avatar May 07 '17 12:05 jrodrigv

I will debug TCA so see what is failing, I guess it should be something around here:

public List<AtmosphericConditions> GetAtmosphericCurve(double dT, double endUT = -1) { if(!Body.atmosphere) return null; var atmoR = Body.Radius+Body.atmosphereDepth; var startUT = StartPos.magnitude < atmoR? StartUT : TrajectoryCalculator.NearestRadiusUT(Orbit, atmoR, StartUT); if(endUT < 0) endUT = BrakeEndUT; if(startUT > endUT) return null; var samples = (int)Math.Ceiling((endUT-startUT)/dT)+1; var curve = new List<AtmosphericConditions>(samples); dT = (endUT-startUT)/samples; for(int i = 1; i <= samples; i++) { var cond = new AtmosphericConditions(Orbit, startUT+dT*i); cond.Duration = dT; curve.Add(cond); } return curve; }

jrodrigv avatar May 07 '17 12:05 jrodrigv

Sorry for the long absence. One question to be able to reproduce this: How do you activate the Deorbit from another vessel? Squadron Mode, or you first initiate the deorbit and then switch from it?

In any case, this may be not a good idea since non-active vessels in atmosphere should remain in loading range, or they'll be destroyed by KSP.

allista avatar Jun 05 '17 15:06 allista

I found this issue using this mod implemented by me.

http://forum.kerbalspaceprogram.com/index.php?/topic/158344-ksp-13x-physics-range-extender-v140/

https://github.com/jrodrigv/PhysicsRangeExtender

I have to say that I have manage to land a vessel using TCA and Mechjeb however only when the deorbit burn has been executed.

If I switch to a different vessel (warp mode always deactivated) and and I wait for TCA to execute the deorbit maneaver, then I can see TCA throwing exceptions.

I understand this is corner case for TCA because I'm playing beyond the known limits of KSP it self :)

jrodrigv avatar Jun 05 '17 15:06 jrodrigv

BTW if you watch this video you will realize exactly what I'm trying to achieve.

https://www.youtube.com/watch?v=1wGF0BplHVI

jrodrigv avatar Jun 05 '17 15:06 jrodrigv

Ok. I've tested it a bit and see that it totally breaks TCA; even without exceptions the autopilot behaves unpredictably. I need to investigate this much more.

allista avatar Jun 05 '17 15:06 allista

Thanks! I think it would be very funny to be able to use some of the functions of TCA remotely from a different vessel!

However I know there are some limitations. For example, StageManager will not work unless you are the active vessel (the code is highly couple with the Stage UI) so it will not be possible to put something in orbit remotely.

jrodrigv avatar Jun 05 '17 15:06 jrodrigv

Well, TCA is actually able to activate stages remotely: e.g. you can activate Rendezvous autopilot from the launchpad, then watch as the rocket takes off from another ship nearby. It is also capable of piloting many VTOLs in wedge formation, and of independent path navigation. Most atmospheric functions are intended for multi-ship usage. But orbital stuff is a different matter: since the stock game is very restrictive with regard to unfocused vessels, it never occurred to me to develop these autopilots with multiple vessels in mind.

allista avatar Jun 05 '17 15:06 allista

*here's how: https://github.com/qfeys/ThrottleControlledAvionics/blob/master/VesselWrapper.cs#L355

allista avatar Jun 05 '17 15:06 allista

Nice code!

GameEvents.onStageActivate.Fire(next_stage); vessel.parts.ForEach(p => p.activate(next_stage, vessel)); vessel.currentStage = next_stage; vessel.ActionGroups.ToggleGroup(KSPActionGroup.Stage);

I used a similar approach for multi-stage missiles for BDArmory. However that approach is even better because I did not think about the possibility of using staging using the stage group.

I will have to re-implement it using that code!

jrodrigv avatar Jun 05 '17 15:06 jrodrigv