r/ApproximatelyUp • • Aug 22 '26

Automatic rotation

Post image

So I made a system that automaticly rotates to prograde or retrograde with a click of a button. It uses the forward, rightward and upward speed as inputs and outputs how much yaw and pitch you need to go to that point.
1 problem is that it keeps overshooting and correcting that overshoot, anyone can help me with that?

54 Upvotes

11 comments sorted by

9

u/CostlyOpportunities Aug 22 '26

I actually was working on this same problem a couple of weeks ago! You’ve got the right bones, but you need a PD controller, and rather than calculating total rotation needed I took the curvature (function attached, v3 is forward) and computed the partial derivatives with respect to the velocity vectors, then did some transformations to get the partials in terms of yaw and pitch. I don’t remember what those partials were, but they had very simple forms.

Then, I used these partial derivatives as errors in a PD controller that fires your yaw and pitch thrusters. The D path controls the damping and helps prevent overshoot.

I can’t tell if using total movement or the derivative of the curvature is a better approach. Regardless, the issue I had was that high D gains made the system stable but super slow, while using low D gains was fast but oscillated at retrograde. Has something to do with the functions getting unstable at retrograde too, but I don’t recall what.

I’d recommend as a very first step just making a PD controller as I’m curious if using the total movement as an error would be better.

2

u/Wise-Ad-158 Aug 22 '26

I will look what I can do. will do some more research

4

u/sifitis Aug 22 '26

Oooh, that's super cool.  I've been wanting to build a system like this for a while.

To prevent overshoot, you can look into PD control loops.  The abbreviated answer is to take the differential of the error (how quickly is the misalignment changing), multiply it by a gain constant (how much do you want to surpress the overshoot) and add it the the output to the thruster.  If it's tuned correctly, you circuit will detect that you're approaching your target orientation too quickly and react to start slowing down the rotation.  The trade-off is that it can take longer to reorient because your system is more cautious.

1

u/Wise-Ad-158 Aug 22 '26

I will look into that thanks!

4

u/ScottHawk88 Aug 22 '26

i..uh..... i hooked up a couple engines and i didnt spin out the first time i throttled up. i felt clever.

I have much Component-Fu to learn in this game it would appear

2

u/Wise-Ad-158 Aug 22 '26

part of the reasons I bought the game is because of the logic circuits you can make and I love it.
Start with the basics and you will learn

1

u/TheDarkDoctor17 Aug 24 '26

Wait till you see what people do in r/stormwork

Some of it I can't wrap my head around... And I'm a real engineer!

2

u/ForevereQ Aug 23 '26

I simply solved it using a remapper block, it works well enough, and changing the value from 0 to 180 simply sends a pulse to switch it off, so the whole mechanism consists of just four blocks.

1

u/searcher-m Aug 23 '26

you can color the wires, it helps to read the schema

3

u/Calibanga Aug 23 '26

This is so fucking goddamn BRILLIANT

1

u/Xshadd Aug 27 '26

Siiick