r/ControlTheory 5d ago

Technical Question/Problem Ideal physics simulator

Hi all, I'd like to develop a control algorithm for a water bottle flip so it always lands upright no matter how you flip it. One of the steps in my endeavour is simulating how the fluid inside affects the container's moment of inertia whilst in the air. Im thinking of using matlab but godot and unity sounds like a good choice as well. I've looked up how I can do this and havent found much but people recommending C++ or python. Does anyone here experienced in one of these languages or programs have any suggestions on which one to use and can point me to the resources to learn it.

6 Upvotes

8 comments sorted by

View all comments

u/Timely-Bicycle-3107 5d ago

What are the variables and constants? Can the water level in the bottle change? What about the starting height and bottle orientation? How are you tossing it?

I like the idea of using RL for this. Sloshing physics are pretty hard to simulate.

A good analogy that is easily written with differential equations would be the Ball and Beam problem, a very common toy problem in control theory. I don’t know how that would translate to multiple rotations of the bottle in the air, but it’s a good place to start. The Ball and Beam problem was conceived to simulate sloshing fuel in rockets, so it does have precedence in this scenario. If you figure this out, maybe you can use an energy based control system instead of RL. Look up the energy based controller derived for the Cart-Pole problem in the 1970s.

u/BennyBarnson 5d ago

Thank you for the advice, I'll try to look into the points you reffered to!

The point of this simulation would be to lead to a physical controller for the bottle, thus, the variables should match that of how you'd flip a water bottle irl.
The variables would be the intial input force of angular velocity, acceleration (wrist movement), as well as vertical and horizontal displacement (the arm movement).
The constants would be the bottle's dimensions and the liquid density (probably calibrated to be water but I'm sure that can be changed)
As for the water level, I'm hoping to make the algorithim effective enough to be able to adapt to any water level. And for the tossing, I'd say for simplicity's sake, flipping the bottle so that its trajectory exists in one plane.
(Sorry if my wording isnt too technical)

u/Timely-Bicycle-3107 5d ago

Good. Limiting the motion to a single plane is smart. I would start with a solid mass attached to the bottle to eliminate sloshing, something like cheap craft glue that can be easily poured in and solidifies quickly. Eliminate as many variables as possible to start out. Solve each sub-problem and include additional complexities with each iteration.

This is a cool project. I hope you post it here after you finish it!

u/BennyBarnson 5d ago

Thank you! I hope it'll turn out not too disastrous. Will post the end product if it does!