Advertisement

Stupid ideas + lack of time

Started by October 19, 2009 04:27 AM
16 comments, last by PureBlackSin 15 years, 1 month ago
Hey people. I'm having a big problem, I'm making this "game engine" from scratch (C++/Physx/DirectX) and the main idea for a demo (to show off the engine) was this hover-tank game, well, I wanted to be a simulation so I made this model and added Physx forces to where the model's turbines should be and used joystick to control tubine's directions (which had the forces attatched to it) etc... and it works perfectly The thing is, after 5 seconds of "flight" the model starts to loose stability, and eventually ends up falling to the ground. Using the joystick I can change the directions of the 4 tubines (together) and a global force vector multiplier (with the thruster axis) but I don't have (and don't want) control over the individual force intensities at each turbine's force vector, I needed some algorithm for a quad-turbine-hovertank (=p) stabilization, lot of people mentioned I should look into neural networks and some other said I should look into control theory, does anyone has any advice? as the title says, I don't have a lot of time, right now I'm cheating by making the object's global orientation fixed, but I want something smooth and that actually behaves as a real hovertank would =p Thanks anyway, sorry if everything sounds a little rubish, but it's kinda hard to explain the problem I think =O/
Unfortunately, even if there is a solution to the specific kind of controller you're looking for, I think it'll take you too long to tweak and get stable. If you're short on time I recommend you cheat and use some kind of interpolation to a known stable position, or only using the controller to set the X/Z position and calculate the rest procedurally...

Join us in Vienna for the nucl.ai Conference 2015, on July 20-22... Don't miss it!

Advertisement
My suggestion would be to implement simple PID controllers for the 4 turbines. The mathematics behind them is a bit complex but the implementation can be something like 10 lines of code per variable you're controlling. But I agree with Alex that it may take too long for you to get the correct values for the algorithm, especially since it's not entirely clear where your instability is coming from.
Well you have a very difficult problem, that even a mechanical engineer would think difficult. The advantage is you have a game, thus you can cheat.

Fist thing: If all thrusters are pointing in the same direction and are at the same relative position to the center of mass, you can reduce the forces to one at the center of mass. This reduces the chance for different numeric errors by the 4 thrusters.

What you are modeling is basically a helicopter. By definition a helicopter is unstable, like a marble on a board. You need to actively change the tilt to keep the marble at the center of the board. Any small error will send it off in one direction.

My best guess would be to implement a "simple" PID controller that tries to keep the tank level. The input is the difference form the up vector to the desired up.

input = (0,0,1) - up;

And the output is the correction to the "idle" thrust.

thrust = output + idle_thrust;

You then need to change the idle thrust and desired up depending on where you want to go. But for a start you should try to by able to keep you tank hovering idle for a couple of hours.

Edit:
@Kylotan sorry posted about at the same time...
Rioki - http://www.rioki.org
I'm wondering if you can just tweak your model to make it passively stable without requiring an active controller.

So you have 4 turbines that point... forward, back, left, and right? And the net effect of these is only to thrust in a direction you want to move in? What about down? Do you have thrusters pointing down? What causes your hovertank to hover?
My guess is he has four thrusters pointing down, in which case the control problem becomes very close to that of a quadcopter. A friend of mine actually built one of those, and the control problem is not that difficult. It's basically a pair of inverted pendulums to control pitch and roll. PID controllers do work well enough. The difficult problems in the real machine are that the sensors are noisy, the accelerometer doesn't really point "down", the gyros have drift and the motors don't react instantaneously, but none of those shouldn't be a problem in a simulation.

I can post details of how to use PID controllers for this tonight.

Advertisement
Since it sounds like alvaro has a nice introduction to PID control to share with you I won't say a ton...

If you do decide to use an active controller, it really doesn't need to be hard. It's probably sufficient to,

1 - Write down your vehicle dynamics in state-space form.
2 - Linearize them.
3 - Adjoin an integrator to the system.
4 - Pick gains for a state-feedback controller for the linearized system by either,
a - Doing pole placement.
or
b - Solving the Ricatti equation for optimal LQR gains.

I know this just threw a bunch of words at you, but my hope is that together with alvaro's introduction and what you find on Wikipedia this will give you enough to piece the solution together.
Ok, here's the 3d model so you can get a picture, each turbine has 2 angles of freedom, they can pitch (outer ring) and they can roll (inner engine) they all perform the same rotation at the same time, they cannot be controlled separetly

Just as an example, the back-left engine has a 30degrees pitch + a 30 degrees roll (as I said they cannot be turned separetly, but it's an example so you guys can get the idea of the degrees of freedom I have)

Then, I use the Y (up) vector of each of the engines (inner round thing) as the direction of my force and multiply a constant to it

Also, my main problem is that my aircraft is flipping and falling, even tho the same 4 forces are applied in the same directions and they have the exact same distance from the center of mass of my object, some people might have understood that I wanted altitude stabilization, I would love that, but for now I wanted it to stay leveled

I'm not THAT short on time, the thing is, I have tons of things to do for the game and I can't shoot in the dark with various tecniques I know nothing about, if there's a general consensus on a good way of doing it I'll be happy to implement it.

Thanks again

Screenshot (3ds render)
I'm not sure your system is controllable. Are your turbines all equidistant from the center of mass? If so, it looks like it is impossible to apply a net torque to your object with them, in which case your rotational dynamics are uncontrollable. At the very least, I would bet that they are equidistant from the CM in the lateral direction, in which case I think only the pitch will be controllable and not the roll.

Also, I'm assuming here that your CM is at the same height as your turbines. If it isn't (say it's higher), then your system is controllable, and your problem basically reduces to balancing a broomstick on your hand (this is the classic rocket stabilization problem). But if it is higher, then from your picture it must be so by only a tiny amount. If this is the case, then your open-loop system will have a very fast unstable pole which will be hard to stabilize. Intuitively, it's harder to balance a shorter broomstick on your hand (and impossible to balance a zero-length broomstick).

About this word "controllable" I keep using... it's actually a technical term, but it means what it sounds like. In essence, if some part of your system's dynamics is uncontrollable, it means that you do not have enough independent degrees of actuation to "push" your state in that direction.
I'm not acquainted with many terms that you guys have spoken, I know nothing of control theory and engineering terms, nothing that I can't look into of course (as I said, if it's worth it, due my lack of time...)

Anyway, the center of mass is the same height as the turbines, and they're equidistant from the center of mass but not from each other (as you can see from the picture, disregarding the shape of the body object), making it higher or lower would make any difference? I can't see the picture even with the broomstick example...

Anyway... I still have to look into everyone's thoughts before posting any new questions.

Thanks

This topic is closed to new replies.

Advertisement