Jump to content

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


Diazo

Recommended Posts

Version 1.5.1 bugfix is out.

The text in the B9 mod should no longer get changed by my mod.

Re-download not required if you are not seeing this bug.

Still looking into KAS, I should have something that allows the Undocked plug for a sky crane in a day or two.

D.

Link to comment
Share on other sites

I plan on installing this right now (Been humming and haw'n about using this or writing/borrowing/stealing someone elses script for kOS) but this won out for this purpose. The question I have though is it possible to add your config to change the +/- settings to a decimal number? My nuke engines are extremely close to the ground and I'm worried that if I hit anything harder than 0.5m/s that I'll crush 'em. heh

[edit]

I read the code. Seems as though line 192, 198, 207 and 213 are the lines of interest. I'm going to dig through how you're reading the configs and make an EDIT 2.

Edited by Pontiac
Link to comment
Share on other sites

Ya, that will be a simple tweak.

I'll add it to the .cfg file so the current 1m/s is the default, but you can change the increment to whatever you want.

Almost got the KAS stuff working, so next version should be tomorrow hopefully.

D.

Link to comment
Share on other sites

Okay, version 1.6 out.

Increment Size

This adds the ability to set the increment size. The default is 1m/s which is what has been used until now. If you want a custom increment, go into the TWR1.cfg and change the TWR1Step from 1 to what you want. (0.5 for 0.5m/s steps, etc.).

I'm going to be adding a settings screen in the next few versions that will allow setting this from in-game.

Skycrane Mode

This version also adds Skycrane support. Right now skycrane mode is automatically added only when KAS is installed, but it can be forced. (See end of this post.)

KAS allows both Docked and Undocked connections.

If you use the Docked connection type, the two ships become one ship as far as my mod is concerned. The mass of both connected ships is accounted for and the engines on both ships are controlled. (If normally active.)

If you connect with Undocked mode, that is where this mode comes into play.

How Skycrane mode works is that nearby 'vessels' (storage containers, rovers, other things you'd want to lift) are checked and if they are flying, they are assumed to be carried by your currently active vessel.

This means that when taking off you can set an ascent speed of 2m/s and the mod will automatically use the mass of only your Skycrane until the load is off the ground when it will compensate for the mass and keep the 2m/s ascent going after the load has lifted off.

The same on descent, set it to 1m/s downwards and the mod will control the throttle so that the Skycrane does not shoot upwards once the load has touched down and its mass is no longer being carried.

There are two big limitations at the moment however.

First, KSP has wonky detection on when a vessel is landed or not. I had to add a 15 second delay to compensate so a load (not your controlled vessel) can only switch between 'landed' and 'flying' once every 15 seconds.

So if you brush the ground by accident, the mod thinks you are trying to land your load and so will throttle back as now only your active vessel is flying.

The other limitation is that the mod assumes every nearby vessel is a potential skycrane load. If you have another mod that has Helium Blimps or some other vessel that can float while not being controlled, the mod will assume it is attached to your current vessel and assume it has to carry it's mass. Note that this only applied to vessels not touching the ground, as long as even a dinky little strut is touching the ground, KSP considers that vessel as landed and it will not cause problems.

If you want skycrane support without KAS installed, go into the TWR1.cfg and set TWR1KASForce to true. If you have KAS installed and don't want Skycrane mode to activate, in the TWR1.cfg file set TWR1KASDisable to true.

Again, watch for an in-game settings screen in the next few versions to set all this from in-game.

D.

edit: Ugh, typos. My initial upload of version 1.6 was bad. I've uploaded the corrected version. This only lasted a couple hours so I'm not going to upload a version 1.6.1 for this.

Edited by Diazo
Link to comment
Share on other sites

  • 2 weeks later...

I've noticed quite a lot of exceptions in my output_log.txt:


NullReferenceException
at (wrapper managed-to-native) UnityEngine.Component:InternalGetGameObject ()
at UnityEngine.Component.get_gameObject () [0x00000] in <filename unknown>:0
at Vessel.recurseCoMs (.Part part) [0x00000] in <filename unknown>:0
at Vessel.findWorldCenterOfMass () [0x00000] in <filename unknown>:0
at VerticalVelocity.TWR1.TWR1Skycrane () [0x00000] in <filename unknown>:0
at VerticalVelocity.TWR1.Update () [0x00000] in <filename unknown>:0

Link to comment
Share on other sites

Odd.

I've been in there finalizing my tweaks for my next release and have not seen those.

I'll look into in it.

D.

edit: Found it. That means there is no active vessel in the flight scene somehow, as in FlightGlobals.ActiveVessel is null. I will admit I assumed that was impossible and did not error trap it. It should not affect anything as if there is no active vessel there is no engines to control.

Please confirm that this only happens when there is no active vessel (such as after a crash or similar) and not during normal flight.

edit the second: Fix is in for the bug I found, will be out in the next version (which I hope to have out very soon).

edit the third: And found another NullRef exception, grrrr. Next release will be tomorrow (or as soon as I can squash this one).

Edited by Diazo
Link to comment
Share on other sites

Okay, version 1.7 out. Grab it at the spaceport.

Note: Version 1.7 changes the TWR1.cfg file format. You must overwrite your existing TWR1.cfg file when installing.

The only thing you will lose is your screen position, it will reset to the top left corner.

Changelog:

Added a settings screen: You can now change all your settings from in-game. This includes the key the mod uses, the size of the velocity step and the Skycrane mode. Open this with the Wrench icon in the lower right. (Yes that is a wrench, there's a reason I do a model-less plugin mod.)

This change also opens up the option of using anything instead of the mod key. You can use any key on the keyboard, a mouse button, a joystick button or a controller button. Just be aware that there is no check for a conflicting keybind. If the key (or button) you bind to already does something else in the game, both commands will execute. (My first try was the C key, switching to IVA and back got confusing fast.)

Note that when entering the step size, limitations in the Unity Text Box function mean that it must always be a number. This means that to enter 0.5, you must type the 5 and then cursor back to enter the decimal point. If you type just the decimal point, KSP will delete it because it 'auto-corrects' 0. to just 0 and deletes the decimal point.

Aerodynamic Lift Compensation: The mod now has limited capability to compensate for lift generated by wings. Notably in my testing using the stock Kerbal 2 rocket a relatively slow horizontal speed of only 10 to 20 m/s was generating 0.2 to 0.4m/s^2 acceleration from the 3 control winglets that rocket mounts. (Yes, even though they are 90° perpendicular to the direction of movement, those winglets are generating lift.) As you now have the capability to set your own velocity step size, that 0.4m/s^2 acceleration could really throw things off if you had a step smaller then 1m/s. This feature is compatible with FAR for those that use it.

Toolbar is now optional: As the Toolbar is not my mod and I now had the option of making Toolbar support optional, I have done so. Therefore the Toolbar mod is no longer included in my mod's download file.

Bugfixes: What would a release be without bugfixes? Notably, I got rid of a couple of NullReference errors that the Skycrane mode could throw under unusual conditions.

So there you go, have fun and happy rocketing! :D

D.

Link to comment
Share on other sites

  • 1 month later...

Version 1.8 released for KSP 23.5 compatibility.

No code changes to the mod itself, although I removed the CompatibilityChecker component.

This mod is small enough that it is not likely to break when KSP updates and I can't guarantee immediate updates anymore due to real life so I don't want to be warning players the mod is out of date when they can't do anything about it because there is no update available.

D.

Link to comment
Share on other sites

Version 1.8 released for KSP 23.5 compatibility...

Thanks for the notes! I intended to test this mod in a new install last night but got suckered into trying to run a Starbound server for friends. I'm still trying to sneak some time to play with the new update!

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 weeks later...

Diazo,

I love your mod. Unfortunately I have a bug to report. By the way, the mod is fantastic.

Using LazarousLuan's Laztek SpaceX mod I found that the Mono-propellant engines attached to capsules start behaving like a squid. The governor is broken on the engines. They try to regulate by opening and closing the throttle from 0 to 100% and start to oscillate. (0-100-0-100-0-100...) Usually the capsule will eventually fly upwards uncontrollably until you start adjusting "minus ones" until you find you're bouncing up-down on the same range of altitude or you start a descent in oscillation.(fast-slow-fast-slow...) I have tested both air/mono-propellant and also pure mono-propellant engines.

I have no clue if the error for the mod is on your end or if it is on LazrousLuan's mod. Please help me determine.

Regards and best wishes...

Edited by Prowler_x1
Link to comment
Share on other sites

  • 4 weeks later...

Just checking in to let people know I'm still alive. Real life got nuts but things are settling down.

I've move the download link to my Google drive for now as a host, please let me know if it works or if I need to rehost elsewhere.

@Prowler: Are you experiencing this in Velocity Control mode or Altitude Control mode (or both)? I should have time to look at this in the next week hopefully and the more info you can give me the better.

D.

Link to comment
Share on other sites

Okay, version 1.9 released to support MonoPropellent engines, such as those on the SpaceX mod capsules.

The exact issue was that my mod was only looking at engines that used the "ModuleEngines" module in code. However, an engine using MonoPropellent for fuel can use the "ModuleEnginesFX" module in code, which the SpaceX capsules do.

My mod now recognizes the "ModuleEnginesFX" module and the SpaceX capsules, and all other mod parts that use it, should now work correctly.

D.

Link to comment
Share on other sites

  • 2 weeks later...

Version 1.10 Release

If you have Davon's Throttle Control mod installed, only engines on Throttle 0 (the default) will be controlled by this mod.

For best use, also ensure that only engines on Throttle 0 are in Center Thrust mode.

For a VTOL, that means the vertical lift engines should be left on Throttle 0, the horizontal thrust engines moved to Throttle 1. Take off using the Velocity Control mod then once you reach your desired altitude, set your vertical speed to 0m/s and engage your horizontal engines. As your horizontal speed increases and wings start to generate lift, the Velocity control mod should compensate to keep your vertical speed roughly zero (or whatever your vertical speed setpoint is.)

If you do not have Davon's Throttle Control mod installed, this feature will not engage and will have no effect.

The other change is that I tweaked the height display on the mod so that it displays the height to ground from the bottom of your vessel instead of from your vessel's center of mass.

D.

Link to comment
Share on other sites

  • 3 weeks later...

I really like your plugin and have gotten so used to it that landing with manual throttle seems quite difficult now.

I do have a couple of suggestions/request for you to consider.

You're probably aware that your plugin doesn't work well with jet engines because of the spool up lag. You plugin appears to link the throttle to the vertical speed indicator.

Suppose you had another mode for jets where your vertical speed controls were just throttle presets. You'd have to tune it for each plane, but it could be a semi-automatic process. You'd start on the runway and apply just enough throttle to climb. After a few seconds the plugin notes the throttle setting and vertical speed. It then reduces the throttle by 2%, waits for the engines to catch up and makes a note of the new throttle setting and climb rate. It keeps doing this till it finds the throttle setting for hover and records that preset. Then it slowly increases the throttle till it finds the preset for +5ms. It keeps repeating the process till it's got throttle presets from -25 m/s to +25 m/s in 5 m/s increments. It saves that config and you're ready to fly.

You'd still have the throttle lag in jet engines so you'd still have to anticipate your throttle changes, but with the presets you'd spend less time overcontrolling the throttle.

I was also wondering about having 2 different increment rates in the setting screen and a toggle on the main panel to switch between them. You could do your early descent in 10 or 20 m/s increments then easily switch to 1 or .5 m/s for the final descent and landing.

Finally, have you ever considered doing a companion plugin to control pitch and roll?

It could use the same layout as your vertical control but have an extra row of buttons for the extra axis it controls. Perhaps you could even have an option for it return the craft to vertical when the surface speed reachs a preset point. For instance if you're pitched back to slow down it could go vertical when the speed hits 0 to keep you from overshooting and end up going backwards.

Like this plugin you should be able to override it with manual control, but that shouldn't disengage the plugin. If it's set to hold the craft vertical and you pitch forward, it should return to vertical when you let go of the key. If you want to go manual control it's easy enough to click the off button.

I think something like this would not only be handy for landers, but that it would make a nice aid for flying planes.

Anyways, I realize you're probably busy with life. (everyone is in the summer) Perhaps when you get bored and start looking for a new project you could keep this stuff in mind. :^)

Link to comment
Share on other sites

Interesting thoughts you have there.

-Throttle control for jet engines and presets.

This sounds like a good idea, but it is something that should be a separate mod. This vertical velocity mod makes the basic assumption that the engines it controls are pointing downwards, not backwards as the jet engine control you are talking about would.

From your descriptions I assume you are talking about using the lift from your wings to go up or down based on the speed you are traveling forwards. If you are talking about jet engines pointing downwards, the mod as it currently exists should work, just it will bounce up and down around the desired altitude while the throttle catches up.

I'm not adverse to writing something like that, I myself am moving from pretty much a pure rocket flyer to starting to mess around with spaceplanes as it is. No guarantees though, I have a couple other mod ideas that are coming first.

-Swap between two increment sizes

Have you looked at the altitude control? Between the revised control code and the new way of calculating altitude in the recent versions, this should be pretty safe to use near the ground. Rather then stepping your speed down it 10 or 20m/s steps, have you tried putting a fly-to altitude of 100meters (or even 30 meters) in and seeing how that works for you?

While not what you are asking for, the altitude control is intended to be used for large altitude changes instead of large velocity control steps. Or are you flying some other mission profile I have not thought of?

Note I don't recommend trying to land with altitude control mode. It can probably land you correctly, especially with a high TWR vessel, but as this mod does nothing for your sideways speed you will need to cancel your sideways momentum through other means before touchdown.

-Pitch and roll plug in

As you talk about, this is not going to happen. Rather, one of the plugins that I'm currently planning to make is an RCS sideways velocity control.

So the main engines do your vertical velocity, the RCS does your sideways velocity and the SAS keeps your vessel pointed upright.

The RCS control will have the ability to zero out your sideways speed or the ability to hover over a point you select on the ground.

Note that this will be a while, I have not even started coding it yet. I have another project in the queue that is almost done (an on-screen joystick for flying spaceplanes with the mouse) that I am going to finish first.

And those are my current thoughts on this.

D.

Link to comment
Share on other sites

Thanks for the quick reply.

I was actually thinking of the presets for jet powered VTOL's.

While your plugin does work with jet engines I find you need to be pretty close to a hover before you engage it. If you're dropping at 20 m/s and you set your plugin to hover it will go full throttle and stay there till you start to climb. Then it cuts the throttle but it takes a bit of time for the engine to spool down. By the time it does you're climbing again and as your upward velocity drops it won't get back on the throttle till you start to fall. You end up in this up and down oscillation that you need to manually damp out.

My thinking was that it would be up to the pilot to anticipate and switch to hover thrust at the proper time. The plugin would just quickly go to that preset when told.

I've tried the altitude control, but not at the low altitudes you suggested. Crashing into the surface too many times has made me pretty conservative about landings. ;^)

What I usually do for landings is use a MechJeb function called "Time to Suicide Burn"

My understanding is that this is the latest point where full throttle will save you from a crash. I let the ship drop till this gets to about 15 seconds then manually apply just enough throttle for it to reduce to about 5 seconds. Then I start using your plugin to more precisely manage my descent rate. I keep the increment of your plugin set a 1m/s for nice soft landings so there can be a lot of mouse clicking.

I do quicksave before my de-orbit burn so I should probably try your suggestion to use altitude control close to the ground.

Your RCS plugin sounds interesting and to a small degree it will do what I was looking for in the pitch/roll plugin.

When I was building my Munbase I landed a couple of solar collector towers. It's got a low COM, but is a pretty tall structure with solar panels mounted on it. I noticed that if I put RCS thrusters only at the very top and use IJKL to operate them, not only would the RCS slow me down it would also cause the ship to pitch back a bit so the main engine helped slow me as well. Soon as the RCS thruster stops firing SAS returns the craft to vertical. Your plugin sounds like it would enhance this system quite a bit.

No worries if the pitch/roll plugin doesn't interest you. I can get the same function from MechJeb's surface panel. The one thing I don't like about it is the need to click in a number field and enter a value. And while your focus is in that field you have no control over your craft. That was the main annoyance that caused me to switch to your program from the translatron.

Anyways, I can't wait to see what you come up with next, but don't forget to enjoy your summer. :^)

Edited by Kerba Fett
Link to comment
Share on other sites

Thanks for the quick reply.

I was actually thinking of the presets for jet powered VTOL's.

While your plugin does work with jet engines I find you need to be pretty close to a hover before you engage it. If you're dropping at 20 m/s and you set your plugin to hover it will go full throttle and stay there till you start to climb. Then it cuts the throttle but it takes a bit of time for the engine to spool down. By the time it does you're climbing again and as your upward velocity drops it won't get back on the throttle till you start to fall. You end up in this up and down oscillation that you need to manually damp out.

My thinking was that it would be up to the pilot to anticipate and switch to hover thrust at the proper time. The plugin would just quickly go to that preset when told.

Hmm, so vertical jet engines. I'm not what to do here.

The issue is that adding in any sort of dampening or slowing the throttle response will conflict with the lift detection from wings. It sounds like that is what is happening now to make the jet engine control so poor.

As it stands I can get compensation for lift from wings so that lifting forces are correctly compensated for, or you can have jet engine spooling compensation so that the slow throttle response of the jet engine is allowed for.

Throttle presets would not work either as he mass of your vessel is going to change as you burn fuel.

What I need to do it somehow add a fudge factor for the difference between a jet engine's throttle setting and actual produced thrust somehow but I'm not sure where to start on that. I'll mull it over and see if I have a brain wave.

I've tried the altitude control, but not at the low altitudes you suggested. Crashing into the surface too many times has made me pretty conservative about landings. ;^)

What I usually do for landings is use a MechJeb function called "Time to Suicide Burn"

My understanding is that this is the latest point where full throttle will save you from a crash. I let the ship drop till this gets to about 15 seconds then manually apply just enough throttle for it to reduce to about 5 seconds. Then I start using your plugin to more precisely manage my descent rate. I keep the increment of your plugin set a 1m/s for nice soft landings so there can be a lot of mouse clicking.

I do quicksave before my de-orbit burn so I should probably try your suggestion to use altitude control close to the ground.

In the altitude control I was trying to program what is effectively a suicide burn to the desired altitude. I've gotten it pretty close and now that as of the most recent version it uses the distance from your landing legs to ground (not from vessel center of mass), it should be safe pretty close to the ground. I have not actually tested this specifically however and the higher TWR your vessel has, the safer any attempts you make will be.

Your RCS plugin sounds interesting and to a small degree it will do what I was looking for in the pitch/roll plugin.

When I was building my Munbase I landed a couple of solar collector towers. It's got a low COM, but is a pretty tall structure with solar panels mounted on it. I noticed that if I put RCS thrusters only at the very top and use IJKL to operate them, not only would the RCS slow me down it would also cause the ship to pitch back a bit so the main engine helped slow me as well. Soon as the RCS thruster stops firing SAS returns the craft to vertical. Your plugin sounds like it would enhance this system quite a bit.

No worries if the pitch/roll plugin doesn't interest you. I can get the same function from MechJeb's surface panel. The one thing I don't like about it is the need to click in a number field and enter a value. And while your focus is in that field you have no control over your craft. That was the main annoyance that caused me to switch to your program from the translatron.

The biggest thing that the pitch/roll does not seem to have a point to me. The original version way back when was simply an assist to stop me crashing skycranes because I have a sucky keyboard and the lightest touch I could do on the throttle was 10-15% changes in thrust. I don't have that problem with WASD on pitch/yaw and can control that within a degree or two manually.

That still leaves cancelling out horizontal thrust as the biggest issue I have with landings and I'm currently using RCS manually to do so which gives me a pretty good idea how to program a mod to do it for me.

Anyways, I can't wait to see what you come up with next, but don't forget to enjoy your summer. :^)

Ah, summer, the time of hiding inside from the heat and playing on the computer. :) Hit 28°C here today, going to be 31° on the weekend.....(83° and 88°F)

I'll keep chugging away, this base won't assembly itself after all.

D.

Link to comment
Share on other sites

Diazo, I just found this mod today, and coupled with the Davon Throttle Control as you suggested, it opens up so many possibilities! The hamster wheel in my brain is only just beginning to turn. You sir, are a genius! From reading the threads, I found that MechJeb has something similar, but I found it to be lacking, compared to your mod. Very well done! I have one question, and forgive me if I accidentally skipped over it, but am I correct in understanding that the "Control From Here" element must be pointing skyward, like a Munar lander, for instance? I've taken to adding probe cores on my atmospheric VTOL ships for this purpose, but that leaves me unable to control the craft from the cockpit. Is there a workaround for that? In any case, thanks for the mod! :)

EDIT: Yes, you already covered this, and in my excitement, I totally missed it. :confused: Nevertheless, thanks again.

Edited by Voculus
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...