Flywheel attitude control system.

Official forum for the Chipmunk2D Physics Library.
Post Reply
speeder
Posts: 14
Joined: Thu Aug 14, 2008 2:04 pm
Contact:

Flywheel attitude control system.

Post by speeder »

Hello! I am making a game where the player must control a ship that uses a flywheel attitude control system (yes, there are rotational intertia on the ship, to make things easier, the player can not move)

But I've got the following problem: How much impulse or force I apply to the flywheel and to the ship? (that rotates in the opposite direction obviously)

The ship is a "tube" (ie: if viewed from top a circle with a round hole on it), and also the same applied to the flywheel, also the flywheel is inside the ship (the external radius of the flywheel is a tad smaller than the internal radius of the ship), and I know how much power I have avaible per frame (ie: how much power I can draw from the ship powerplant)

But I found not way to know how I accelerate the flywheel correctly, but that I need to apply a force or a impulse on two opposite sides (or the flywheel moves around), and the same applies to the ship.
User avatar
tartley
Posts: 37
Joined: Thu Jun 12, 2008 5:01 pm
Location: London, England
Contact:

Re: Flywheel attitude control system.

Post by tartley »

The cpBody structure has a member 't', for torque. Instead of applying to forces on opposite sides, I'd experiment with setting this. A torque is the twisting provided by two equal and opposite forces with an offset between them.
[color=#808080]Tartley - Jonathan Hartley, [url]http://tartley.com[/url]
Using Pymunk (Chipmunk's Python bindings) for a game project:
[url]http://code.google.com/p/sole-scion[/url][/color]
speeder
Posts: 14
Joined: Thu Aug 14, 2008 2:04 pm
Contact:

Re: Flywheel attitude control system.

Post by speeder »

Huh... And how I apply that to my problem?
User avatar
tartley
Posts: 37
Joined: Thu Jun 12, 2008 5:01 pm
Location: London, England
Contact:

Re: Flywheel attitude control system.

Post by tartley »

Hey. I was trying to answer the first problem you asked about, 'knowing how to accelerate the flywheel correctly' Once you have created the flywheel body, try setting its 't' member, see if that makes it rotate in the way you want. It might not, I may have misunderstood how Chipmunk works. If it doesn't work, then you should probably try applying two opposing impulses on opposite sides of the flywheel.

The other problem you asked about is how much force or impulse to apply. I don't know that - I'd suggest experimenting is the way to go : creating a program with the body and shapes first and then try out different sizes of forces (or impulses or torques) and see which one produces the results you want.

Am I misunderstanding your question?

Good luck! Let us know how it works out!
[color=#808080]Tartley - Jonathan Hartley, [url]http://tartley.com[/url]
Using Pymunk (Chipmunk's Python bindings) for a game project:
[url]http://code.google.com/p/sole-scion[/url][/color]
speeder
Posts: 14
Joined: Thu Aug 14, 2008 2:04 pm
Contact:

Re: Flywheel attitude control system.

Post by speeder »

Yes, indeed you misunderstood the question :P

I want to know how much force or impulse I apply to make the thing physically correct, not how to use chipmunk actually :)
maximile
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK
Contact:

Re: Flywheel attitude control system.

Post by maximile »

Apply the same torque in opposite directions (+ve and -ve) to the ship and the wheel. That's enough to make it physically correct. How much you apply is up to you, and depends on the power of the motor or brakes or whatever is applying it.

And again, you don't want to apply "force or impulse", you'll definitely want to set the torque like tartley said.
speeder
Posts: 14
Joined: Thu Aug 14, 2008 2:04 pm
Contact:

Re: Flywheel attitude control system.

Post by speeder »

I want to know how much torque I need to apply (and indeed, I made some tests, and torque works, but it needs reseting, that is annoying :( impulse is easier)

I know how much power I can draw from the powerplant, how I convert energy into torque?
User avatar
tartley
Posts: 37
Joined: Thu Jun 12, 2008 5:01 pm
Location: London, England
Contact:

Re: Flywheel attitude control system.

Post by tartley »

Thanks for the clarification.

If you have E Joules of energy, you can apply a torque of E/theta Newton-metres, where theta is the angle turned by the object being twisted:

T = energy / theta

or, equivalently

T = power / angular velocity

(where all angles are measured in radians)

It sounds like you are keen to calculate an accurate simulation, in which case you should bear in mind that in order for formulae like these to be useful, everything you do must be in S.I. units: distances in metres, masses in kilograms, angles in radians, and everything else in units directly derived from these (eg. velocity in metres per second.)

If the flywheel is being used to turn the ship, then the torque on the wheel should be equal and opposite to the torque on the ship.
[color=#808080]Tartley - Jonathan Hartley, [url]http://tartley.com[/url]
Using Pymunk (Chipmunk's Python bindings) for a game project:
[url]http://code.google.com/p/sole-scion[/url][/color]
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests