Space Engineers

Space Engineers

Vector Thrust 2 [old]
 This topic has been pinned, so it's probably important
Lynnuxx 4 Jan, 2018 @ 3:46am
Bug reports / issues
Hello 1wsx10,

in case of heavy ships with a lot of smaller nacelles this script is not working.
Mainly because of two reasons:

1) The desired thrust (vector) will be (evenly) distributed over all nacelles of a nacelle group. Later in Nacelle.go() this "small" desired thrust per nacelle will be effectively compared to the mass of the ship which is quite heavy (6000 tons). This comparison will never be true and therefore the thrusters will never be switched on.


foreach(List<Nacelle> g in nacelleGroups) {
Vector3D req = g[0].requiredVec / g.Count; <- required vector is divided by number of nacelles
for(int i = 0; i < g.Count; i++) {
g[i].requiredVec = req;
// Echo(g[i].errStr);
g[i].go(jetpack, dampeners, shipMass);
total += req.Length();

To temporarily solve this I also divide the shipMass by the number of nacelles:

g[i].go(jetpack, dampeners, shipMass / g.Count);

Nacelles may provide different thrust, so dividing the thrust equally amongst them may also lead to problems. But that's another possible issue not affecting my ship ;-)


2) In case the dampeners are on and the thrusters are off the nacelles won't be rotated (much) in case a movement control key is pressed. This is again due to the high ship mass. I noticed that the thrusters stayed in the 45° (downwards/back) position and just rotated a little bit on pressing a key. This was the problem I reported in the comments.


if(!thrustOn) {// Zero G
// errStr += "\nnot much thrust";
Vector3D direction = Vector3D.Zero;
if(program.mainController != null) {
direction = (program.mainController.WorldMatrix.Down + program.mainController.WorldMatrix.Backward) * zeroGAcceleration / 1.414f;
} else {
direction = (program.usableControllers[0].WorldMatrix.Down + program.usableControllers[0].WorldMatrix.Backward) * zeroGAcceleration / 1.414f;
}
if(dampeners) {
angleCos = rotor.setFromVec(direction * shipMass + requiredVec); <- requiredVec is neglectable small compared to direction * shipMass
} else {
angleCos = rotor.setFromVec((requiredVec - program.shipVelocity) + direction);
}
// errStr += $"\n{detectThrustCounter}";
// rotor.setFromVecOld((controller.WorldMatrix.Down * zeroGAcceleration) + requiredVec);
} else {// In Gravity
// errStr += "\nlots of thrust";
angleCos = rotor.setFromVec(requiredVec);
// rotor.setFromVecOld(requiredVec);
}

To get rid of this behaviour I removed the ship mass from the multiplication with the direction vector but maybe after dividing the mass it can be put back in.
Last edited by Lynnuxx; 4 Jan, 2018 @ 7:39am
< >
Showing 1-15 of 56 comments
Vermillion  [developer] 5 Jan, 2018 @ 6:50am 
thanks for your explanations.

first, the nacelles providing different thrust: i have known about this for a long time but never got around to fixing. i do intend to do that eventually though.

the system that culls the thrust at low levels is still pretty new, i haven't had too much thought about it so ill probably change that in the future too. its simply there to replace the old system which caused nacelles to spin wildly when they had no power. if you like you can get an older version from the github which doesn't have this new behavior.

a good solution would be one that changes rotor power based on the thrust requirements. but that would need tweaking so it still gets a good amount of power in most situations. the current rotor class just leaves the rotor at whatever torque setting it is at, so normally 100%. (although this would take some freedom away from the end user)
Last edited by Vermillion; 5 Jan, 2018 @ 6:57am
Vermillion  [developer] 5 Jan, 2018 @ 6:54am 
with that said, the current hysteresis system could probably also be tweaked to work nicely. but would also need information about the number of nacelles.

Vermillion  [developer] 5 Jan, 2018 @ 6:55am 
this has been a passion project, which has sort of died out since the physics changes, introducing that bug. since it means most designs people would like now require a mod for them to work properly. keen seems to think its unavoidable if they design the game to not have 'drag' from subgrids.

i don't know when ill get around to fixing these things. but if you wanted to make a pull request that fixes it without introducing more issues than its solving, ill happily accept it.
Last edited by Vermillion; 5 Jan, 2018 @ 6:56am
Lynnuxx 5 Jan, 2018 @ 5:00pm 
Oh, forgot that you did this on github. So far I modified this script so that it's working in case of the small nacelles in that 6000 ton ship now. I also added support for nacelles mounted on two (or theoretically even more, e.g. hinges) rotors since that ship has such nacelles.
I've got two remaining problems:
- The rear nacelles with large ship atmo thrusters in one and ion thrusters in the other direction activates the correct thrusters but will always point into the wrong (opposite) direction.
- The ship is descending with 4 to 5 m/s in atmosphere / gravity (just tested on Earth-like planet).

Anyways, I like your solution of using world directions to point the thrusters (I tend to do everything in grid coordinate system). I learned how to use the vector projection, rejection and cross product.

I want to modify this script further:
1) Create 4 thruster groups per nacelle, one for each direction, for easier calculation of the dominant effective thrust direction.
2) Seperate rotating the nacelle into it's "ideal" position from firing thrusters when they are in the "activation window". This way, even weaker thrust directions of the nacelle can contribute temporarily when they rotate through the "activation window".
3) The possible problem of the even thrust distribution over the nacelles can be overcome by using ThrustOverridePercentage, I think.
Vermillion  [developer] 7 Jan, 2018 @ 2:49am 
1) Create 4 thruster groups per nacelle, one for each direction, for easier calculation of the dominant effective thrust direction.

as it stands, the game has the thrust direction hardcoded for the thruster class as worldmatrix.backward

while this would work for the current game, since its in beta and being polished, they might change this to allow the thruster to define its direction. to allow for diagonal thrusters or something. so a system which assumes this would break. that said, i think i do still make assumptions about that. so it would have to be changed anyway.


2) Seperate rotating the nacelle into it's "ideal" position from firing thrusters when they are in the "activation window". This way, even weaker thrust directions of the nacelle can contribute temporarily when they rotate through the "activation window".

sounds like a good idea

3) The possible problem of the even thrust distribution over the nacelles can be overcome by using ThrustOverridePercentage, I think.

the script can get most of the needed values from the thruster now, the very useful ones being 'MaxThrust' and 'MaxEffectiveThrust'. since you set the thrustoverride as a straight value (in newtons too!, not how it used to be), you have to compensate for the thrust being less effective. simply:

thrustValue = desiredThrust * thruster.MaxThrust / thruster.MaxEffectiveThrust

if you were to make the nacelles account for different thrust amounts, you would add up the MaxEffectiveThrust value for each nacelle, then take that into account when you calculate the nacelle groups.
Vermillion  [developer] 7 Jan, 2018 @ 2:56am 
thinking about #2 a little more, you would need to change the whole system that keeps track of which thrusters are usable. since the script keeps track of all thrusters, even the ones it shouldn't use.
Carbondatez 10 Feb, 2018 @ 12:14am 
Hello!

I was testing this awesome script and it has been working great, until now...

My newest build has nothing new into it (than the last 2 ships wouldn't have, well maybe large cargo containers), but the script doesn't recognize my fighter cockpit for some reason...or atleast i think thats what this is about?!

No mods, vanilla only, and ship is build only using small blocks. This is what the text in programmable block says "ERROR: No usable ship controller found (my cockpit name here) ShowInTerminal not set, init failed.

All ownership is "my", everything powered etc. I build this ship in space, programmable block said everything was fine. Then i loaded it into my test world (earthlike planet,vanilla), and then the programmable block says that sh*t.

Also tried to remove cockpit and place in a new one, this helped usually until loaded into the game again.
Tried to remove rotors + thrusters and place them back in, usually helped aswell until loaded game.
Tried to do both at the same time (replaceing cockpit + rotors + thrusters), usually helped but again when loaded game, boom.

Rotors try to turn when i press W,A,S,D,but only rear rotor is pointing the right direction, while
left is pointing thrusters downwards, and right one is pointing them upwards (like a mirror all the time) and none of the thrusters are on,no matter what, they are off.
And yes,i tried spamming the standby and jetpack buttons to make sure its not because of either of those =)

The entire message in programmable block says this:

Running (numbers scrolling on)
No screen available (I HAVE A SCREEN and it works! :D)
Initialising..
Getting Blocks for thrusters & rotors
Getting Rotors
Getting Thrusters
ERROR: no usable ship controller found
Fighter cockpit Forward TRIPOLD (My cockpit name) ShowInTerminal not set

Init failed.
Last edited by Carbondatez; 10 Feb, 2018 @ 12:18am
Lynnuxx 10 Feb, 2018 @ 5:52am 
All blocks used by the script have to be visible in the Terminal, they shall not be hidden.
Check if this is the case with the cockpit. Otherwise it looks like you've found a new bug in SE...
Carbondatez 10 Feb, 2018 @ 5:59am 
Well son of a....that did it :D!

I must missed the part somewhere saying that all the blocks used has to be visible, so my bad.

Thank you so much, everything works like a charm now!

<3
Vermillion  [developer] 10 Feb, 2018 @ 6:30pm 
sorry about that. i really should mention that in the instructions...

im actually planning on disabling that feature. its not very intuitive and people set blocks to not show in terminal more than i thought they would.

edit: new update!
this includes removing the ignoring of hidden blocks :P
Last edited by Vermillion; 10 Feb, 2018 @ 11:46pm
Carbondatez 11 Feb, 2018 @ 10:58am 
Yippii! :D
Papa 21 Feb, 2018 @ 12:26pm 
Awesome script. but i need some help. I have a large drilling ship weighing just under 400,000kg.
It has 16 atmospheric thrusters on rotors and 13 static thrusters.
Everything works fine until i save and quit the game (hosted game on survival mode), when i reload i cannot get the thrusters to work. If i leave the script alone as default, the engines are dead and no settings will do anything.
I have tried modifying the script to load up with thrusters on and standby off which results in the engines being on but they do not rotate.
The standby command, jetpack command and keyboard key, and also the reset command do nothing to help.
the only way around it is to remove the programmable block, dismantle all the rotors and thrusters and then replace it all. Then it works fine again.
Any ideas? am i missing anything obvious?
Vermillion  [developer] 22 Feb, 2018 @ 5:40pm 
@Papa that is very strange, could you upload the world so i can reproduce the issue?
Vermillion  [developer] 26 Feb, 2018 @ 5:19pm 
@Tontow ill take a look

edit: i can't reproduce the issue. it works fine for me. could you upload the world rather than the blueprint?
Last edited by Vermillion; 26 Feb, 2018 @ 6:51pm
< >
Showing 1-15 of 56 comments
Per page: 1530 50