Rigid body dynamics : simulating steering

Started by
9 comments, last by johnstanp 15 years, 11 months ago
Hi everybody... I was trying to simulate steering and I've noticed some unwanted effects. They obviously must stem from the fact I'm updating my state variables with the explicit Euler method. I want to use another scheme(RK4): the forces and torques I compute should therefore vary between each update.I could simulate a linear,quadratic,exponential,etc variation of my forces and torques...The problem is the variable to update are vectors and matrices.While it is easy to imaginate a linear variation of vectors , it's a bit hard to imagine the same thing for matrices. Well,my "physics engine" is based on Baraff's paper(a great one) and I define the same state variables.For people who want a link: [link]http://www.cs.cmu.edu/~baraff/sigcourse/notesd1.pdf[/link] Could you tell me what function F(t)(see definition on Baraff's paper,page 16) I could use for a steering problem? Edit:it seems that forces and torques variations are only required...the others variables being "derived" from them.However,I prefer not removing the question to see if someone could come up with an interesting idea. [Edited by - johnstanp on May 6, 2008 12:19:52 PM]
Advertisement
Well to be more precise , here are the equations of the rigid body dynamics:


Photobucket - Video and Image Hosting


Photobucket - Video and Image Hosting





Photobucket - Video and Image Hosting




[Edited by - johnstanp on May 6, 2008 3:42:20 PM]

Photobucket - Video and Image Hosting


I'm on my own,it seems.
Well,simply,I just want to know how to use RK4 to integrate the equations of motion of a rigid body.
Well, it's actually a lot easier than what I thought : I'm just implementing the solution.Thank you all for your precious help and your disponibility.It means so much for me.
I think you didn't get any replies because you didn't make it clear exactly what problem you're trying to solve. I still don't know what you mean by "simulate steering" or "a steering problem". You could be dealing with cars, spaceships, boats, humans or anything... and the approaches are completely different in each case.
Quote:Original post by MrRowl
I think you didn't get any replies because you didn't make it clear exactly what problem you're trying to solve. I still don't know what you mean by "simulate steering" or "a steering problem". You could be dealing with cars, spaceships, boats, humans or anything... and the approaches are completely different in each case.


I was kidding in my last post.The steering problem is a very general one : I simply defined an object(rectangular),computed its inertia tensor and defined some actions corresponding to presses of specific buttons.It's not a car,not a plane or something more complex than a rectangular shape moving on a plane.I just wanted to play with a very basic model to test my "Physics Engine".
The "thing" was supposed to move to the left with a constant angular velocity until I release the left arrow key, to move to the right with the same constant angular velocity(with the appropriate sign) , accelerate and decelerate...
I first used the Explicit Euler method(since the forces and hence the torques generated are constant between two successive update) and I didn't see the need to implement a more robust method.However I noticed that when my object decelerates and turns(or accelerates and turns) , the velocity tends to make an angle with the local x axis(aligned with the velocity).
The problem could arise from the way I update the state of the mobile or the integration scheme I use.So I wanted to use the Runge-Kutta method to see how in the problematic situations , the mobile will behave.
I simply didn't understand how to use it since "Mister" Baraff never provided a method in his paper and the notations of the wiki site I checked,while strictly correct,doesn't help to actually understand that one doesn't need to have the derivative function(right in English?because it's not my mother tongue) explicitly depending on the time and the state variables...

I understood it only once I started to write down the parameters(slopes at specific times of the function integrated):it then seemed obvious,so obvious I got mad at me...
I've noticed that the Runge-Kutta algorithm for rigid body dynamics is never explicitly given on forums so when I get time,I'll post the algorithm applied to the system of equations as expressed by Baraff.

But I could post my code if some of you want to take a look at it and provide an insight.But I've solved my Runge-Kutta problem.
www.gaffer.org

I'm having trouble viewing the site but there is a good Runge-Kutta implementation there.
Quote:Original post by bzroom
www.gaffer.org

I'm having trouble viewing the site but there is a good Runge-Kutta implementation there.


Me too...But thank you.I've actually implemented Runge-Kutta for my update function:I simply wrote the state derivative in terms of the state variables and then everything was very simple(even if it is lengthy to write all the equations on a paper).
But I didn't notice any apparent improvement from the Explicit Euler Method.
Well,it would rather be more useful to give a link to the actual code and give a precise description of my "problem".

For the code:
www.esnips.com/web/johnstanpsStuff

Well,what is the real problem?
In the function "void steering()" in "main.cpp" I implement a very simple steering scheme.I simply compute the force needed to make the velocity angle with the world frame x axis(for example) increase or decrease by(good grammar?) "dangle" and I set the angular momentum corresponding to the wanted angular velocity( which as a norm equal to dangle divided by the time step of the simulation ).
Everything works fine as long as I don't accelerate or decelerate at low speed while making the body continuously steering until it almost stops.If you play a little with the SDL-OpenGL little program you'll notice that the velocity(or the momentum) starts deverging from the x local axis when cornering and decelerating(or accelerating) at low speed...(the body axis?good grammar? are displayed as well as the momentum).To actually view the velocity,just make a simple substitution in the function "template<typename T> void RigidBody<T>::showAxis( const float& scale )const":replace all P by v.
My question is:how can I keep the velocity and the heading(x axis of the body) aligned?
Thanks for all your replies.

P.S:in the header.hpp file remove the Car.hpp and the Runge-Kutta.hpp includes since they're not present in the zip file...You'll need SDL_ttf for the compilation.

[Edited by - johnstanp on May 10, 2008 3:58:59 PM]
Or to rephrase things differently, is there a method to solve the rigid body motion equations under general constraints?( here the constraint would be , linear momentum and local x axis must be parallel )
I could try to figure it out but I just want to know if specific methods do exist...

This topic is closed to new replies.

Advertisement