Advertisement

Determine thruster power for arbitrarily-placed thrusters to move in desired direction?

Started by May 25, 2013 03:41 AM
2 comments, last by alvaro 11 years, 9 months ago

This video explains better what I'm trying to do than the subject title can:

This video is of a ship attempting to keep itself level after being hit with balls. Currently it's unstable. But that is not the issue I am currently working on.

Currently,

The ship determines which thrusters to fire based on its current orientation, location, and velocity. But for this ship, I hardcode "if x orientation is negative, activate bottom front thruster", etc to provide torque to attempt to level the ship again.

What I would like to be able to do is, just given a set of arbitrary thruster locations, and arbitrary thruster force vectors (the vector pointing in the direction the thruster applies force and its magnitude), automatically determine which thrusters to fire to achieve a net force on the object of a desired magnitude in a desired location.

I don't know where to start -- any pointer to papers on the subject would be great (I have access to journal articles through school).

Have you tried dividing the problem into (1) making the ship level by changing torque but not velocity (2) now that the ship is no longer rotating, make it move towards the target? I think this would make approaching it simpler, and then you could try combining the two after that. The problem for (2) is straightforward in that you just need to project thrust vectors against your force vector to calculate how much you should fire that thruster to move towards your destination, and maybe iteratively refine the solution until you achieve a sufficient precision. (1) is more complicated, unless you have thrusters that thrust in opposite directions it isn't possible to create torque without creating a translational force, but unless your thrusters are horribly placed the error should be compensated by step (2). Then you fire specific pairs of thrusters in such a way that you apply torque which counteracts your rotational velocity while producing as little translational force as possible.

Also consider that it simply may not be possible for the ship to stabilize itself at all, which would be indicative of bad thruster design, so your algorithm needs to handle that too.

Interesting problem though, I am sure people have dealt with this before though I have no idea what to search for either :)

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

Advertisement

Thanks for the response.

In the video, the thrusters creating torque on the y axis are opposite so there is no translation. There are no thrusters on top of the ship, but there is gravity, so they shouldn't be necesary (as far as I know, quad copters don't need propellers pushing downwards to keep level). It is to be assumed that the ships should always have opposite thrusters -- the idea is that players can customize the locations of thrusters on the ship, so they'll learn soon enough that they can't turn properly without meeting that condition. It is unstable in the video because I'm using a PID system but at the time of recording it had only implemented the P. The controller works separately for each variable (velocity, orientation, location, orientation velocity). I am however having some trouble combining these variables, but have had success correctly controlling just one at a time.

What I meant by (2) in my first post was if there's a way to algorithmicly determine which pairs of thrusters to fire to execute a turn. Right now, turning left is hardcoded to activate the front right thruster and the back left. Instead of specifically setting it to fire the front right and back left, have the AI figure that out for you. Is there a better option than to have the AI try all possible combinations of thrusters until it finds a combination of thrusters that is able to create thrust in the correct direction each time a new target is set (by try, I mean calculate the projection of the thruster's force internally for each combination, and not actually activate any thrusters until it finds the best one).

This is a complex problem, with a whole field behind it called control theory.

Here's one possible plan of attack:

* Come up with an instantaneous function you want to optimize. For instance, if you want your ship to stabilize, you can give a bonus for being in the upright position and penalties for linear speed and angular speed.

* Now consider the problem of maximizing the sum of future values of the objective function, down-weighting the values far away in the future exponentially. Call this function "utility".

* Pick a finite set of situations that covers the range you think you are likely to encounter and make a table that will hold the maximum utility from each situation, assuming optimal future control.

* Use value iteration to refine the table iteratively. As a by-product of value iteration you can get a table that contains the optimal action for each configuration. This step is done once, offline.

* Look up in the optimal-action table to decide what thrusters to activate.

This topic is closed to new replies.

Advertisement