Jump to content

[1.3](Jun04/17) Automate Vertical Velocity and Altitude Control


Diazo

Recommended Posts

@linuxgurugamer: It depends on what is engaged. This mod and my landing aid mod only try to control the vessel when they are engaged. So as long as they are not engaged MechJeb will behave the same as it always has.

I assume MechJeb works the same, as long as it's "landing assist" or "ascent controller" is not enabled, this mod (and the landing aid mod) can control the vessel without issue. Note I am not sure on the module names in MechJeb. For the vertical velocity mod to work, nothing that changes engine thrust can be enabled in MechJeb. For the landing aid mod to work, nothing that changes the pitch/roll/yaw the vessel, or anything that affects SAS, can be enabled in MechJeb.

If both are engaged at the same time, I'm not sure what would happen so make sure you have a quicksave made if you try. :)

D.

Link to comment
Share on other sites

Version 1.16a

-Add Stocktool bar support.

Whoops, this is a few days late as Version 1.16a has been out for a bit now. No functionality changes, I just added the ability for the mod to display it's icon on the stock toolbar if Blizzy's toolbar is not installed.

D.

Link to comment
Share on other sites

  • 2 weeks later...

Version 1.17

Download here.

-Vertical velocity is now controlled on a per vessel basis. Set a vessel to hover (vertical velocity setpoint 0) and that vessel will try to keep hovering when you switch to another vessel/kerbal.

Caution: There is no stability functions on this mod. Other mods are recommended, although you can trusts the stock SAS system for a short time.

I am revising my Horizontal Landing Aid for this exact purpose, but I do not have that version ready for release yet.

Caution: There is no fuel monitoring or warning. If you switch away and forget about your hovering vessel, it will hover until it runs out of fuel and crashes.

-Revise excess lift/drag module to be automatic. Now lift from any sources and extra mass attached to the vessel via a mod such as KAS, will be detected and compensated for without any player input.

Note that while this compensation is fast, it is not instant. Leave a safety buffer of at least a few meters to give it time to adjust in when attaching/detaching loads, unless you are feeling very Kerbal that day. :)

D.

Link to comment
Share on other sites

Diazo,

Another suggestion, although I'm not sure how difficult it would be:

Have two sets of numbers:

Maximum Altitude to activate at

Desired descent rate at max altitude

Altitude to stop working at (location hover height)

Desired descent rate at this altitude

The idea would be to not start the engine until the maximum altitude is reached. Then to start slowing the ship down. Scale the descent rate from the first rate to the second rate along the flight path.

For example, I'm landing on the Mun, from an orbit which is 45,000m high. I do my deorbit burn and start descending.

I set the max altitude to 5000m, and a descent rate of 100m/s

I set the min altitude to 10m, and a descent rate of 0m/s

So, at 5000m, the control would start the engine and slow the ship to 100m/s. I'll list some values below, my feeling would be that the descent rate would be continously calculated depending on the height:

At 4000m, the control would calculate a descent rate of 80m/s

At 3000m, 60m/s

at 2000m, 40m/s

at 1000m, 20m/s

at 10m, 0m/s, and in a hover mode.

If altitude was set to 0m, then it would be a landing mode

The calculation could be:

maxAGL = max altitude above ground level

maxAGLv = descent velocity at the maxAGL

minAGL = min altitude above ground level

minAGLv = descent velocity at the minAGL

Assuming that current AGL is <= maxAGL:

targetV = ((maxAGLv - minAGLv)*(curAGL / (maxAGL -minAGL))) + minAGLv

This calculation would also work (if desired) for altitudes above the maxAGL, it would be proportional.

Again, thanks for all your hard work.

Edited by linuxgurugamer
Link to comment
Share on other sites

This is what Orbit Drop mode is intended for, although it works a little differently then you describe.

Now that you mention it I realize I didn't actually test this in 0.90, but I assume it is still working.

For your 10m stop example above, here is how Orbit Drop mode should work.

First, we are going to do our initial stop at 100m just to give us some ground clearance to cancel our horizontal velocity fully.

So, in orbit, enter a target height of 100m in the desired height text box. The control button next to it should say "Height Control (Orbit)", click on it. Note that if the button says (Now) instead, it will not engage the orbit drop, it will engage normal height control and immediately take control of the engine.

The button will change to say "Free Pitch", at this point while the mod is engaged, it does nothing and you are also free to control the ship as normal, so do your deorbit burn as you normally do. Touching the throttle controls will not disengage the mod as it does normally while the "Free Pitch" button is displayed.

As you descend, at some point the button will change to "Thrust Warning", at this point you have 20 seconds to return your vessel to close to upright so the mod can take over the engine and bring you to a stop at your target height, in this case 100m.

Finish canceling your horizontal velocity and delete a 0 in the height target box to bring craft down to 10m. Note that the target height box uses the vessel's Center of Mass, even a medium sized vessel will probably land before it reaches 10m height as displayed in the height target box.

For this Orbit Drop mode, the mod updates in real time at what altitude it needs to engage the engine at 80% thrust in order to bring you to a stop at your desired height, and then 20 seconds before that displays the Thrust Warning so the player has time to react before it grabs control of the engine.

By only using 80% thrust, this still allows for the vessel to be tipped up to 30° off vertical and not overshoot your altitude target so you can still use that to control the horizontal movement of your craft.

Now, the big question is does that actually work? Both in the technical sense of the mod working correctly, but also in the sense of whether this works for the flight plan you are flying.

D.

Link to comment
Share on other sites

This is what Orbit Drop mode is intended for, although it works a little differently then you describe.

Now that you mention it I realize I didn't actually test this in 0.90, but I assume it is still working.

For your 10m stop example above, here is how Orbit Drop mode should work.

First, we are going to do our initial stop at 100m just to give us some ground clearance to cancel our horizontal velocity fully.

So, in orbit, enter a target height of 100m in the desired height text box. The control button next to it should say "Height Control (Orbit)", click on it. Note that if the button says (Now) instead, it will not engage the orbit drop, it will engage normal height control and immediately take control of the engine.

The button will change to say "Free Pitch", at this point while the mod is engaged, it does nothing and you are also free to control the ship as normal, so do your deorbit burn as you normally do. Touching the throttle controls will not disengage the mod as it does normally while the "Free Pitch" button is displayed.

As you descend, at some point the button will change to "Thrust Warning", at this point you have 20 seconds to return your vessel to close to upright so the mod can take over the engine and bring you to a stop at your target height, in this case 100m.

Finish canceling your horizontal velocity and delete a 0 in the height target box to bring craft down to 10m. Note that the target height box uses the vessel's Center of Mass, even a medium sized vessel will probably land before it reaches 10m height as displayed in the height target box.

For this Orbit Drop mode, the mod updates in real time at what altitude it needs to engage the engine at 80% thrust in order to bring you to a stop at your desired height, and then 20 seconds before that displays the Thrust Warning so the player has time to react before it grabs control of the engine.

By only using 80% thrust, this still allows for the vessel to be tipped up to 30° off vertical and not overshoot your altitude target so you can still use that to control the horizontal movement of your craft.

Now, the big question is does that actually work? Both in the technical sense of the mod working correctly, but also in the sense of whether this works for the flight plan you are flying.

D.

Thank you for a great explanation. I'll test this when I get home.

What happens if the 80% thrust isn't enough to do it?

Link to comment
Share on other sites

If 80% thrust isn't enough, the "Auto Height (Orbit)" button should never appear and will only offer the "Auto Height (Now)" button.

If you are still able to engage it for some reason (blow your landing stage and lose some engines), the throttle will max out trying to adjust.

The 80% thrust limit is only used for the prediction calculation on how much time is needed, once the mod actually takes control of the throttle it will set the throttle to max if it needs to because you are coming in a bit hot.

D.

Link to comment
Share on other sites

If 80% thrust isn't enough, the "Auto Height (Orbit)" button should never appear and will only offer the "Auto Height (Now)" button.

If you are still able to engage it for some reason (blow your landing stage and lose some engines), the throttle will max out trying to adjust.

The 80% thrust limit is only used for the prediction calculation on how much time is needed, once the mod actually takes control of the throttle it will set the throttle to max if it needs to because you are coming in a bit hot.

D.

Ah, that explains a lot.

My ship has the Mark1-2 Pod, which from what I can tell has SAS (please tell me if I'm wrong).

The engine is an RMA-3 orbital achievement device (from NovaPunch2), which, while efficient, is not super powerful (I think it has a maxthrust of 75), so it is possible that it does need more than 80% to slow down.

Link to comment
Share on other sites

If the engine does not have sufficient thrust, you should be seeing a "TWR LOW" warning label in place of the height control button.

The actual math check the mod uses is if 80% throttle has a TWR of less then 1 it will not engage.

Or it is supposed to, I just realized that check is using the modified thrust for vessel tilt so if you are pointing horizontal in preparation for your deorbit burn, the check will see you have no vertical thrust and think your TWR is too low.

The workaround for now is to point your engines straight down, engage Orbit Drop, then tip the vessel back over for the deorbit burn, that should leave the Orbit Drop engaged.

I'll push a fix tonight when I get home after work.

On the SAS thing, I do not believe the Mark 1-2 pod has SAS. In 0.90, SAS comes from either a Kerbal on board who has the Pilot ability, or from a high enough level probe core (I'm not sure which cores have it and which don't).

D.

Edited by Diazo
Link to comment
Share on other sites

If the engine does not have sufficient thrust, you should be seeing a "TWR LOW" warning label in place of the height control button.

The actual math check the mod uses is if 80% throttle has a TWR of less then 1 it will not engage.

Or it is supposed to, I just realized that check is using the modified thrust for vessel tilt so if you are pointing horizontal in preparation for your deorbit burn, the check will see you have no vertical thrust and think your TWR is too low.

The workaround for now is to point your engines straight down, engage Orbit Drop, then tip the vessel back over for the deorbit burn, that should leave the Orbit Drop engaged.

I'll push a fix tonight when I get home after work.

On the SAS thing, I do not believe the Mark 1-2 pod has SAS. In 0.90, SAS comes from either a Kerbal on board who has the Pilot ability, or from a high enough level probe core (I'm not sure which cores have it and which don't).

D.

Ok. I won't be doing anything with this until either late tonight or tomorrow night. I usually use CKAN to do all my updates, but will do this by hand if it isn't there yet.

So, I remember that I usually don't see the "TWR LOW" label, so assume that the engine does have enough thrust. I do see it when I've oriented the wrong direction, so I know thats working.

Thanks

Link to comment
Share on other sites

This is what Orbit Drop mode is intended for, although it works a little differently then you describe.

Now that you mention it I realize I didn't actually test this in 0.90, but I assume it is still working.

For your 10m stop example above, here is how Orbit Drop mode should work.

First, we are going to do our initial stop at 100m just to give us some ground clearance to cancel our horizontal velocity fully.

So, in orbit, enter a target height of 100m in the desired height text box. The control button next to it should say "Height Control (Orbit)", click on it. Note that if the button says (Now) instead, it will not engage the orbit drop, it will engage normal height control and immediately take control of the engine.

The button will change to say "Free Pitch", at this point while the mod is engaged, it does nothing and you are also free to control the ship as normal, so do your deorbit burn as you normally do. Touching the throttle controls will not disengage the mod as it does normally while the "Free Pitch" button is displayed.

As you descend, at some point the button will change to "Thrust Warning", at this point you have 20 seconds to return your vessel to close to upright so the mod can take over the engine and bring you to a stop at your target height, in this case 100m.

Finish canceling your horizontal velocity and delete a 0 in the height target box to bring craft down to 10m. Note that the target height box uses the vessel's Center of Mass, even a medium sized vessel will probably land before it reaches 10m height as displayed in the height target box.

For this Orbit Drop mode, the mod updates in real time at what altitude it needs to engage the engine at 80% thrust in order to bring you to a stop at your desired height, and then 20 seconds before that displays the Thrust Warning so the player has time to react before it grabs control of the engine.

By only using 80% thrust, this still allows for the vessel to be tipped up to 30° off vertical and not overshoot your altitude target so you can still use that to control the horizontal movement of your craft.

Now, the big question is does that actually work? Both in the technical sense of the mod working correctly, but also in the sense of whether this works for the flight plan you are flying.

D.

OK, I'm looking at it. My ship is in orbit at about 42000m high. I've positioned it so that it is vertical to the surface.. The Vertical Velocity box has an entry field for "Fly to:" with a button next to it which says "auto height (free)", and a button below which says "Control Off". If I click the "auto height" button, it goes away and text "free pitch" shows up, and the button at the bottom shows "Height Control". Both of these are green. If I then click the green "Height Control", the Auto Height button comes back and the button at the bottom changes to a green "Velocity Control". This does not sound like what you described above.

According to CKAN, it is version 1.17

Edit: Is it possible that the text is wrong, and where I see "Auto Height (free)" is what you said should be "Height Control (orbit)"?

Edited by linuxgurugamer
Link to comment
Share on other sites

Ugh, yes. Everywhere I said "Auto Height (Orbit)", replace it with (Free) instead.

I was correct with the (Now) though, if the button says that it will take the engine control over immediately when you press it.

The "Free Pitch" showing up is correct though. That means you are in orbit drop mode and are free to move your vessel around as you see fit, including controlling the engines, until the "Thrust Warning" shows up.

D.

Link to comment
Share on other sites

Ugh, yes. Everywhere I said "Auto Height (Orbit)", replace it with (Free) instead.

I was correct with the (Now) though, if the button says that it will take the engine control over immediately when you press it.

The "Free Pitch" showing up is correct though. That means you are in orbit drop mode and are free to move your vessel around as you see fit, including controlling the engines, until the "Thrust Warning" shows up.

D.

OK. Being in the software business myself, I was concerned that we were talking about the same thing.

- - - Updated - - -

Success!

Both landing assistant and vertical velocity are now working, thank you!

Link to comment
Share on other sites

Heh, glad to hear things are working for you.

However, thanks to this conversation I went back and looked at the orbit drop code and promptly ripped it out to rewrite it from scratch.

I don't know what past me was thinking, but I apparently threw random numbers at things and somehow came up with something that sort of worked.

However, it was not very tolerant of players doing things I didn't expect so I'm currently going back and actually using real math this time, not numbers that are "ehh, close enough" so no matter what players throw at it, it will behave as expected.

I'm also going to rename the buttons to make it clearer what is going on and will have screenshots showing things with the next release.

D.

Link to comment
Share on other sites

FYI Version 1.17 is not playing nice with MJ,when i updated from 1.16 first thing i noticed was, when i choose any cockpit in VAB my log is spammed with

NullReferenceException: Object reference not set to an instance of an object
at VerticalVelocity.TWR1Data.FixedUpdate () [0x00000] in <filename unknown>:0

(Filename: Line: -1)

and MJ have no control over vessel when launched.

Link to comment
Share on other sites

Version 1.17a

-Fix NullRef bug in editor.

Download here.

Caution: Contains rewrite of the Height Control code (specifically the orbit drop mode.) Inital tests work but it is not yet fully tested. I will have a fully tested version out tomorrow night.

I rushed this release to fix a bug that essentially screwed over any mods trying to run code in the VAB, such as mechjeb.

@sebi.zzr: Ugh, how did that slip bug through? Yes, that was a problem in my code. Version 1.17a fixes it.

Sorry about that,

D.

Edited by Diazo
Link to comment
Share on other sites

Version 1.17a

-Fix NullRef bug in editor.

Download here.

Caution: Contains rewrite of the Height Control code (specifically the orbit drop mode.) Inital tests work but it is not yet fully tested. I will have a fully tested version out tomorrow night.

I rushed this release to fix a bug that essentially screwed over any mods trying to run code in the VAB, such as mechjeb.

@sebi.zzr: Ugh, how did that slip bug through? Yes, that was a problem in my code. Version 1.17a fixes it.

Sorry about that,

D.

Is it going to work the same? I must confess, that when I was finally able to do the landing last night, I was somewhat nervous because it essentially did a suicide burn (ie: it just fell until it was able to do a full power burn to stop at just the right altitude). While I know that is probably more fuel efficient, it does cause a problem if you need to stage during the descent as I did. I had a stage with a Skipper engine which had enough to do most but not all of the landing, so about 5 seconds before I hit the target altitude it ran out and I had to stage, next stage had a much smaller engine and while I had the target altitude set to 200m, it actually got to within 5m before it actually stopped.

Link to comment
Share on other sites

Yes, it will work the same, I am just rewriting the math behind the scenes so that it can handle a wider range of vessels. Note that the text on the buttons has changed, but the mechanics have not.

Notably in the 1.17 version, really high and really low TWR vessels could give it issues.

However, the scenario you describe in dropping the Skipper could still be problematic. The mod updates it's "I need to start burning" math in realtime based on your current vessel mass and currently active engines. If that changes abruptly during descent, such as when you stage, I can't guarantee it won't overshoot the target altitude.

Specifically if the smaller vessel (after staging) has a lower TWR then the vessel did in orbit (before staging) it will overshoot the target. By how much depends on how big a difference there is between the two TWR's and how close to the target altitude you stage at. This is something the mod will never be able to compensate for, it always uses your current vessel state for all calculations, including the orbit drop predictions.

Note that the target height can be changed while in height control (and orbit drop) mode. For the scenario you describe, set a higher altitude for the skipper to stop at, then once the skipper has been detached via staging, enter the actual target altitude you want. You will have to estimate the temporary higher altitude necessary yourself based on the TWR difference between the stages, but this will keep you from crashing.

In this scenario, the skipper never reaches it's temporary target altitude, that number is just there to get the skipper to start it's burn earlier to compensate for the lower TWR after you stage.

D.

Edited by Diazo
Link to comment
Share on other sites

Hey Diazo, pretty nifty mod. Couple things - it would be nice if it were possible to set the desired vertical velocity rate without spooling up the engines when the mod is turned on.

Also, I got a contract to test the Kerbodyne KR-2L big engine on the launchpad, so I tossed a pod on with that engine, and upon launch got a kraken black screen. Some mod troubleshooting later (admittedly I use a lot of them) I removed vertical velocity controller and the problem went away. Here's the last output_log information I see before the output_log is spammed with "Look rotation viewing vector is zero"


.
.
.
NullReferenceException: Object reference not set to an instance of an object
at VerticalVelocity.TWR1Data.FixedUpdate () [0x00000] in <filename unknown>:0

(Filename: Line: -1)

1/15/2015 5:37:04 PM,KerbalAlarmClock,Setting App Button True

(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)

1/15/2015 5:37:04 PM,KerbalAlarmClock,Vessel Change from 'No Vessel' to 'Untitled Space Craft'

(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)

1/15/2015 5:37:04 PM,KSPAlternateResourcePanel,setting true

(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)

1/15/2015 5:37:04 PM,KerbalAlarmClock,Contracts System Ready

(Filename: C:/BuildAgent/work/d63dfc6385190b60/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)

NullReferenceException: Object reference not set to an instance of an object
at VerticalVelocity.TWR1Data.FixedUpdate () [0x00000] in <filename unknown>:0

(Filename: Line: -1)

NullReferenceException: Object reference not set to an instance of an object
at VerticalVelocity.TWR1Data.FixedUpdate () [0x00000] in <filename unknown>:0

(Filename: Line: -1)

Look rotation viewing vector is zero

.
.
.

Edit: This is with the CKAN-installed version (1.17a) on 0.90 32-bit KSP.

Edited by Thrombo
add ver
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...