Jump to content

[WIP] [Plugin] KerbCom Avionics - Analytical engine and RCS thrust balancing


ZRM

Recommended Posts

Right now it's a DLL that gets attached to most of the stock command pods. probably a better solution would be to make a dedicated part for it, but that's not there yet.

I don't really like adding dedicated parts for features that are purely computational - i.e. no additional physical effects. Hence I am quite happy with the recent integration of SAS into command pods.

This MOD is absolutely necessary for the Kerbin Orbiter I'm working on.

I'd been wanting an FCS (Flight Control System) like the real shuttles have for a while. SAS, ASAS, Avionics haven't really worked too well. Your mod seems to be exactly what I needed.

Would it be alright if I incorporated into the Avionics part of the Kerbin Shuttle?

How does your mod work? Is it loaded on a part? Or is it a DLL, or?

Shuttles are actually one of the key reasons I am developing this mod, and may I say, your shuttle looks very Kerbal, which is a good thing.

You can integrate it quite easily. You just need to add

MODULE
{
name = ModuleKCAvionics
}

to the config for the cockpit part (or a different part if you wish). Make sure to list KerbCom Avionics as a dependency. Also be aware that the (hopefully soon) next release will improve performance, reliability and functionality greatly, so bear that in mind while evaluating KCA. The current version also has some known issues if RCS or engines are on the same part as the one ModuleKCAvionics is installed on, so if that is the case in your shuttle you may want to wait.

Of course you could use KCA as an optional dependency, using a Module Manager script.

Edit: Also note that the current version does not support SRBs. This will change in the next version.

Edit: Gimbaling/thrust vectoring is also coming in the next version.

Edited by ZRM
Link to comment
Share on other sites

Progress Update:

The combined control mode is now working really well. It uses main engines, gimbals, reaction wheels and RCS ports to maintain the vessel's heading under thrust, and when the throttle is at zero it then uses purely RCS ports and reaction wheels to control translation and rotation exactly for docking. This should mean that you hardly ever need to change settings during a flight. I am now going to add a few utility features, like the ability to disable gimbal control if you so desire, and clean up the interface. Then it should be just bugfixing and SRB support to add before the release. The bugs I know of are related mainly to docking control logic (i.e. which avionics module gets control when undocking/docking) and engine state (sometimes engines fool themselves into thinking that they have run out of fuel).

Link to comment
Share on other sites

Awesome. Can't wait to try it out.

I also really can't wait to play with it properly, instead of coding and debugging it. I should really make some screenshots of what this is capable of. With some recent changes to the solver logic the control is much more stable than it ever was. The new SAS in 0.21 is a great complement to it as well. The new "combined" mode can cope with pretty much every conventional design I can throw at it - single engine rocket, multi-engine rocket, mun lander, space station, VTOL, spaceplane, even a piggy-backed shuttle. All this at even better performance than the last release, with engine gimbal and reaction wheel support. The non-conventional designs I can think of that would need some tweaks to the logic would be VTOLs with dedicated VTOL engines and main thrust engines, and crazy massive stations/vessels that need to use combustion engines for RCS control. I am considering making the combined mode turned on by default.

The main downside right now is that it will be Windows only until I figure out how to get P/Invoke working robustly on Linux and Mac. The other downsides (which I am in the process of fixing), which are holding me back from release, are the lack of SRB support and the bugs I mentioned in my previous post.

Link to comment
Share on other sites

I think what ZRM is trying to do is to have the code be aware of SRB thrust and to include that into the calculation without having the code try to throttle the unthrottleable. Though I wonder, how would the code react to an engine that can't throttle down past a certain point without shutting off like real engines do?

Link to comment
Share on other sites

Well, what he probably needs to do is to include control for the SRB gimbals, but what I am saying is, the plugin would still probably be useful if it only ignored SRBs for now. Most designs only include them as boosters for the early part of the flight.

Link to comment
Share on other sites

Is it possible to just ignore the SRBs for now, and let it have the stock engine control?

I think it would still be very usable if it only did that.

Any space shuttle replica with SRBs would be not able to use my plugin. If I release the current development version (minus the work I have so far put towards SRB support), a space shuttle would likely crash and burn if my plugin was enabled at any point where the SRBs were active, as it would be trying to use them as regular throttleable engines. However I am considering releasing without SRB support, as I have realised it is not a small amount of work.

I think what ZRM is trying to do is to have the code be aware of SRB thrust and to include that into the calculation without having the code try to throttle the unthrottleable. Though I wonder, how would the code react to an engine that can't throttle down past a certain point without shutting off like real engines do?

You're exactly right about the SRBs. Engines with cut-offs is a related feature that is not yet implemented (such engines are treated as regular engines right now), and it would require approximately as much work as with SRBs, though quite a few of the changes to be made to accommodate SRBs would be the same as with engines with cut-offs, so the work is shared. The main change is the reorganisation of the logic and additional solver calls to cope with the possibility of there being a minimum thrust that the vessel must be subjected to. Previously I relied on that being zero. One thing to note is that engines with cut-offs would be handled as engines that cannot go below a certain thrust at all, not even to zero (unless disabled or out of fuel). It is definitely possible to add support for zero thrust on engines with cut-offs, but that would require a considerable change to the solver interface to allow integer variables.

So, I think I may well release this after I have done a bit more testing and made the GUI a bit nicer. For example, there is not really a need anymore for "Enable RCS control", "Enable Engine control", "Enable Reaction Wheel control" buttons or actions. These things should just activate when a mode requiring them is active. I should get time to do that today. I would also like to test the plugin on Mac and Linux at some point.

Link to comment
Share on other sites

Just a quick Progress Update: I think I have now finally squashed the RCS FX glitch, once and for all. So the woraround is no longer required. You will want to revert any config changes you made to RCS parts for the new version.

Link to comment
Share on other sites

Right, everything seems to be in working order, so now I will see if I can get this to work on my Mac as well. Then I will release version 0.3.

BTW, from the download statistics apparently 93% of users downloaded the previous versions on Windows, 4% on Mac and 1.8% on Linux, with the rest presumably using unusual download methods.

Link to comment
Share on other sites

Oops, reposting this from the release thread. I think you wanted bug reports in this thread...

So is there a way to disable certain control methods? Say I wanted to disable differential thrust control and rcs and use only reaction wheels and gimbals... Is this possible? Because it would be super useful to have. In combined mode it seems to tinker with the thrust levels more than I would like. Also, I disabled reaction wheels on the pod but the craft was still able to turn on its own with engines and RCS off, depending on whether or not I had the combined control menu open. The behaviour seemed inconsistent so I'm not sure exactly what was happening.

E: I'm a bit confused about the logic of the interface as well. Is kerbcom active whenever the menu is open, regardless of the submenues? Because I seem to have gimbal roll control even when none of the modes are active, and reaction wheels seem to be still running even when I disable them on the pod. Also, kerbcom seems to interfere with mechjeb's smart a.s.s. (mechjeb does not respond to pressing prograde or retrograde buttons for example), but inconsistently.

E2: Even when I take mechjeb off my ship (I only have the mechjeb config installed, so kerbcom should disappear), I still have always-on reaction wheels and gimbal roll authority. I then made a whole new craft and never put mechjeb on it and I still get the same behaviour.

E3: Restarted KSP, started a new save file, made a craft without mechjeb case. Still have always-on reaction wheels and gimbal roll. Plus I noticed the extra bonus of zero electricity usage whether pod torque is enabled or disabled.

Edited by pina_coladas
Link to comment
Share on other sites

Oops, reposting this from the release thread. I think you wanted bug reports in this thread...

...

I have replied to your bug report in the release thread, as it seems others are reporting there regardless, so I might as well try to keep the discussion in one place.

Regarding the differential thrust and RCS usage, if you lower the guidance torque strength enough the solver will be able to stop using differential torque and RCS to control your heading/attitude. This should then behave as you expect, as long as the craft is capable of relying purely on gimbals and reaction wheels. The solver always finds the most efficient solution, so with lower torque requirements it can rely purely on reaction wheels and gimbals to do so, and so save RCS fuel.

Link to comment
Share on other sites

Tested the latest one with Mechjeb, still very shaky using Smart ASS. Fiddling with attitude adjustment settings helped a little, but not much.

For MechJeb you will want to decrease the torque strength settings in KCA for it to work well. Hopefully MechJeb's Smart ASS will get "smarter" at some point so that you don't have to do this.

Link to comment
Share on other sites

Thanks for the reply. This plugin seems pretty vital to KSP so I`m happy to do a bit of testing.

Regarding the differential thrust and RCS usage, if you lower the guidance torque strength enough the solver will be able to stop using differential torque and RCS to control your heading/attitude. This should then behave as you expect, as long as the craft is capable of relying purely on gimbals and reaction wheels. The solver always finds the most efficient solution, so with lower torque requirements it can rely purely on reaction wheels and gimbals to do so, and so save RCS fuel.

Last night when I was testing, combined mode loved to flutter the engine thrust pretty much whatever strength the slider was on, even when I edited some engines to have 10 degrees of gimbal. I had a rocket lander thing with four radial engines, and even without touching the controls the engines would be pulsing very rapidly (which seemed to cause a bit of lag). When throttled up fully and without touching the controls, two engines would be at full thrust and the other two would be jittering around at a few percent below full thrust.

Even with improvements that lower the priority of differential thrust, I would still really appreciate being able to turn it off entirely on a craft-by-craft basis.

Also, I second the request for more detailed descriptions of the different modes. What exactly does simple engine mode do for example?

Link to comment
Share on other sites

Thanks for the reply. This plugin seems pretty vital to KSP so I`m happy to do a bit of testing.

Last night when I was testing, combined mode loved to flutter the engine thrust pretty much whatever strength the slider was on, even when I edited some engines to have 10 degrees of gimbal. I had a rocket lander thing with four radial engines, and even without touching the controls the engines would be pulsing very rapidly (which seemed to cause a bit of lag). When throttled up fully and without touching the controls, two engines would be at full thrust and the other two would be jittering around at a few percent below full thrust.

Even with improvements that lower the priority of differential thrust, I would still really appreciate being able to turn it off entirely on a craft-by-craft basis.

Also, I second the request for more detailed descriptions of the different modes. What exactly does simple engine mode do for example?

There are 3 sliders for torque strength - pitch, roll and yaw. Did you try lowering all of them? Was SAS turned on? All of my test cases tend to not jitter very much. Could you post a picture of the craft with the problem, along with the KCA settings you are using?

Edit: Sorry for not replying to everything. Here's a fuller response:

I could add the ability to disable differential thrust, however it may take quite a bit of time to implement. I will see how easy it would be to add.

Simple engine mode? Do you mean stock engine mode? There is a description in the help mode for it. Here is the description from the in-game help:

Stock engine control:

This mode behaves identically to normal engine control, with each engine following the master throttle. The exception is that this mode also provides a strength multiplier. This is useful for avoiding overheating, for example.

Edited by ZRM
Link to comment
Share on other sites

  • 2 months later...

Bug report video for you, in a few hours when it finishes uploading:

http://youtu.be/Qs49pu112Eg

This actually is showing several problems.

- Despite being only at a tiny amount of throttle, KCA goes wild with engine pulsing, gimbles, and reaction wheels, and drains my battery in seconds.

- When the battery runs flat, it doesn't seem to notice, and the ship starts to spin.

- The ship spins in the direction where it's completely symmetrical and balanced. So KCA is actually creating an imbalance in that direction which would not exist otherwise.

I recorded this with a test setup with only KCA, LLL, and MechJeb installed.

Edited by Maeyanie
Link to comment
Share on other sites

  • 4 weeks later...
Bug report video for you, in a few hours when it finishes uploading:

http://youtu.be/Qs49pu112Eg

This actually is showing several problems.

- Despite being only at a tiny amount of throttle, KCA goes wild with engine pulsing, gimbles, and reaction wheels, and drains my battery in seconds.

- When the battery runs flat, it doesn't seem to notice, and the ship starts to spin.

- The ship spins in the direction where it's completely symmetrical and balanced. So KCA is actually creating an imbalance in that direction which would not exist otherwise.

I recorded this with a test setup with only KCA, LLL, and MechJeb installed.

I thought I had dealt with that issue in a previous bugfix. You're definitely using the latest version? Regardless, I am not in a position to work on this project right now so bug fixing will have to wait for the time being.


For some reason the GUI doesn't show up in the game even with mechjeb for me. I am using 0.22 but I used it in 0.21 as well and it had the same problem. Though I am probably being stupid as I usually do when trying to find things.

Did you follow the installation instructions in the README to the letter? I haven't tested it in 0.22 yet (or even played 0.22 for that matter), but it should work in 0.21.

Link to comment
Share on other sites

Did you follow the installation instructions in the README to the letter? I haven't tested it in 0.22 yet (or even played 0.22 for that matter), but it should work in 0.21.

Just in case you want some reports of how KCA fares in 0.22, it seems to work just as fine as it did in 0.21. Although it apparently has some issues with the latest MechJeb's automatic docking function:

For some reason when activate dock auto pilot here, the ship just aling with the docking port but don't fire the RCS.
Found the problem: Kerbcom Avionics. Removed that and worked as before.
Link to comment
Share on other sites

I thought I had dealt with that issue in a previous bugfix. You're definitely using the latest version? Regardless, I am not in a position to work on this project right now so bug fixing will have to wait for the time being.

Fairly certain it's the latest. It was definitely no earlier than 0.3.0.5 as that seems to be the oldest version I have downloaded, but pretty sure it was 0.3.0.6.

From your Bitbucket, it looks like the ReactionWheelController.cs was last changed for 0.3.0.1, so it's definitely newer than that. I don't see any reason the power check in there wouldn't work, though.

Is there a minimum thrust for rockets? Possibly it's just when the battery is dead, it can't keep things balanced, so it starts to spin. I don't see anything in your code suggesting that, but I don't know KSP's code well enough.

Edited by Maeyanie
More thoughts...
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...