[ODE] Collision detection of rapidly moving objects
Keshav
kbc at dhruva.com
Mon Aug 26 02:42:02 2002
This is a multi-part message in MIME format.
------=_NextPart_000_0001_01C24D13.060407C0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Hello,
How can I retrieve or find out, where my dynamic object will be, i.e
it's position and orientation after a time step, without calling
"dWorldStep"?
Why I'm asking the above question is, the documentation of ODE says, the
typical simulation code will look like this:
Loop:
1. Apply forces to the bodies as necessary.
2. Adjust the joint parameters as necessary.
3. Call collision detection.
4. Create a contact joint for every collision point, and put it in
the contact joint group.
5. Take a simulation step.
6. Remove all joints in the contact joint group.
I'm doing the collision detection on my own. I'm not using ODE's
collision detection.
Now, if 'm taking small time steps, and the objects really don't attain
high speeds, then, this is okay.
Consider an example.
Say, a sphere with a radius (in 3D graphics units) of 1.0 is being
simulated.
Say there is a plane having a equation of (0, 1, 0, 0). i.e it is at the
origin, and facing upwards.
Assume that the sphere is dropped from a certain height and is soon
approaching the ground plane.
Say, it's current position is (0, 2.2f, 0).
If we match the proceedings to the simulation loop, we would get:
Step 3: Because the position is (0, 2.2f, 0), the collision detection
routine would return that there was no collision.
Step 4: No contact joints, because, there was no collision.
Step 5: Take a simulation step. Now, say, the time step was pretty large
due to some reason, and the sphere really accelerated fast.
Say, it moved to position (0, -2.2f, 0), i.e it has moved
below the ground plane.
Step 3: Because the position is (0, -2.2f, 0), the collision detection
routine would return that there was no collision.
Step 4: No contact joints, because, there was no collision.
Step 5: Take a simulation step. Now, the sphere has already gone through
the floor. There's no way to recover.
One solution for the above problem is to check collision of the movement
vector.
This is the reason, I need the "next position" and "next orientation" of
the moving object, w.r.t to time step.
Does ODE support it, or do I have to work around??
How does ODE do it's collision detection for a moving object? Is it
w.r.t movement vectors or only with the objects position?
----------
I thought of one more method. Just let me know if it's correct.
Say, the previous position was (0, 3.5f, 0), and after "dWorldStep", the
sphere had moved to (0, 2.2f, 0)
Step 3: Now, check the collision of the movement vector from (0, 3.5f,
0) to (0, 2.2f, 0).
The collision detection routine would return that there
was no collision.
Step 4: No contact joints, because, there was no collision.
Step 5: Take a simulation step. Now, say, the time step was pretty large
due to some reason, and the sphere really accelerated fast.
Say, it moved to position (0, -2.2f, 0), i.e it has moved
below the ground plane.
Step 3: Now, check the collision of the movement vector from (0, 2.2f,
0) to (0, -2.2f, 0). Obviously, there will be a collision.
Step 4: Generate contact joints.
Step 5: Take a simulation step.
Now, the collision will be resolved, and the sphere will
be above the plane, rather that going right through it.
Is the above method feasible? Is it okay to do this?
- Keshav.
------=_NextPart_000_0001_01C24D13.060407C0
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<TITLE>Message</TITLE>
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR></HEAD>
<BODY>
<DIV><SPAN class=3D960482107-13082002><FONT face=3DArial=20
size=3D2>Hello,</FONT></SPAN></DIV>
<DIV><SPAN class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT></SPAN> </DIV>
<DIV><SPAN class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002>How can I retrieve or find out, where my =
dynamic object=20
will be, i.e it's position and orientation after a time step, without =
calling=20
<FONT=20
face=3D"Courier =
New"><STRONG>"dWorldStep"?</STRONG></FONT></SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT></SPAN> </DIV>
<DIV><SPAN class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002>Why I'm asking the above question is, the =
documentation=20
of ODE says, the typical simulation code will look like=20
this:</SPAN></FONT></SPAN></DIV>
<DIV><SPAN class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT></SPAN> </DIV><SPAN=20
class=3D960482107-13082002><SPAN class=3D111145714-14082002>
<DIV><FONT face=3DArial><FONT size=3D2><STRONG><SPAN =
class=3D111145714-14082002><FONT=20
face=3DVerdana=20
color=3D#0000ff><STRONG>Loop:</STRONG></FONT></SPAN></STRONG></FONT></FON=
T></DIV>
<OL>
<LI><FONT face=3DArial color=3D#0000ff size=3D2>Apply forces to the =
bodies as=20
necessary. </FONT>
<LI><FONT face=3DArial color=3D#0000ff size=3D2>Adjust the joint =
parameters as=20
necessary. </FONT>
<LI><FONT face=3DArial color=3D#0000ff size=3D2>Call collision =
detection. </FONT>
<LI><FONT face=3DArial color=3D#0000ff size=3D2>Create a contact joint =
for every=20
collision point, and put it in the contact joint group. </FONT>
<LI><FONT face=3DArial color=3D#0000ff size=3D2>Take a simulation =
step. </FONT>
<LI><FONT face=3DArial color=3D#0000ff size=3D2>Remove all joints in =
the contact=20
joint group. </FONT></LI></OL>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial color=3D#0000ff size=3D2><SPAN =
class=3D111145714-14082002>
<DIV><SPAN class=3D960482107-13082002><FONT face=3DArial color=3D#000000 =
size=3D2><SPAN=20
class=3D111145714-14082002><STRONG>I'm doing the collision detection on =
my own.=20
I'm not using ODE's collision=20
detection.</STRONG></SPAN></FONT></SPAN></DIV></SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002>Now, =
if 'm taking=20
small time steps, and the objects really don't attain high speeds, then, =
this is=20
okay.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D111145714-14082002>Consider an=20
example.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002>Say, a =
sphere with a=20
radius (in 3D graphics units) of 1.0 is being=20
simulated.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002>Say =
there is a plane=20
having a equation of (0, 1, 0, 0). i.e it is at the origin, and facing=20
upwards.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002>Assume =
that the=20
sphere is dropped from a certain height and is soon approaching the =
ground=20
plane. </SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002>Say, =
it's current=20
position is (0, 2.2f, 0).</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002>If we =
match the=20
proceedings to the simulation loop, we would get:</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><FONT =
face=3DVerdana=20
color=3D#800000><STRONG>Step 3:</STRONG></FONT> Because the position is =
(0, 2.2f,=20
0), the collision detection routine would return that there was no=20
collision.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D111145714-14082002><FONT face=3DVerdana =
color=3D#800000><STRONG>Step=20
4:</STRONG></FONT></SPAN> No contact joints, because, there was no=20
collision.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D111145714-14082002><FONT face=3DVerdana =
color=3D#800000><STRONG>Step=20
5:</STRONG></FONT></SPAN> Take a simulation step. </SPAN></FONT><FONT =
face=3DArial=20
size=3D2><SPAN class=3D111145714-14082002>Now, say, the time step =
was pretty=20
large due to some reason, and the sphere really accelerated=20
fast.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002> &nbs=
p; =20
Say, it moved to position (0, -2.2f, 0), i.e it has moved below the =
ground=20
plane.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D111145714-14082002><FONT face=3DVerdana =
color=3D#800000><STRONG>Step=20
3:</STRONG></FONT></SPAN> Because the position is (0, -2.2f, 0), =
the=20
collision detection routine would return that there was no=20
collision.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D111145714-14082002><FONT face=3DVerdana =
color=3D#800000><STRONG>Step=20
4:</STRONG></FONT></SPAN> No contact joints, because, there was no=20
collision.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D111145714-14082002><FONT face=3DVerdana =
color=3D#800000><STRONG>Step=20
5:</STRONG></FONT></SPAN> Take a simulation step. Now, the sphere has =
already=20
gone through the floor. There's no way to recover.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D111145714-14082002>One solution=20
for the above problem is to check collision of the movement=20
vector.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002>This =
is the reason,=20
I need the "next position" and "next orientation" of the moving object, =
w.r.t to=20
time step.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002>Does =
ODE support it,=20
or do I have to work around??</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002>How does ODE do it's collision detection for =
a moving=20
object? Is it w.r.t movement vectors or only with the objects=20
position?</SPAN></FONT></SPAN></SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT></SPAN></SPAN></FONT> </DIV=
>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002>----------</SPAN></FONT></SPAN></SPAN></FONT><=
/DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT></SPAN></SPAN></FONT> </DIV=
>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002>I thought of one more method. Just let me =
know if it's=20
correct.</SPAN></FONT></SPAN></SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002>Say, the previous position was (0, 3.5f, 0), =
and after=20
"dWorldStep", the sphere had moved to (0, 2.2f,=20
0)</SPAN></FONT></SPAN></SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT></SPAN></SPAN></FONT> </DIV=
>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN =
class=3D111145714-14082002>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D111145714-14082002><FONT face=3DVerdana =
color=3D#800000><STRONG>Step=20
3:</STRONG></FONT></SPAN> Now, check the collision of the movement =
vector=20
from (0, 3.5f, 0) to (0, 2.2f, 0).</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002> &nbs=
p; The=20
collision detection routine would return that there was no=20
collision.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D111145714-14082002><FONT face=3DVerdana =
color=3D#800000><STRONG>Step=20
4:</STRONG></FONT></SPAN> No contact joints, because, there was no=20
collision.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D111145714-14082002><FONT face=3DVerdana =
color=3D#800000><STRONG>Step=20
5:</STRONG></FONT></SPAN> Take a simulation step. </SPAN></FONT><FONT =
face=3DArial=20
size=3D2><SPAN class=3D111145714-14082002>Now, say, the time step =
was pretty=20
large due to some reason, and the sphere really accelerated=20
fast.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002> &nbs=
p; =20
Say, it moved to position (0, -2.2f, 0), i.e it has moved below the =
ground=20
plane.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D111145714-14082002><FONT face=3DVerdana =
color=3D#800000><STRONG>Step=20
3:</STRONG></FONT></SPAN> Now, check the collision of the movement =
vector=20
from (0, 2.2f, 0) to (0, -2.2f, 0). Obviously, there will be a=20
collision.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D111145714-14082002></SPAN></FONT><FONT=20
face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D111145714-14082002><FONT face=3DVerdana =
color=3D#800000><STRONG>Step=20
4:</STRONG></FONT></SPAN> Generate contact =
joints.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN =
class=3D111145714-14082002></SPAN></FONT><FONT=20
face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D111145714-14082002><FONT face=3DVerdana =
color=3D#800000><STRONG>Step=20
5:</STRONG></FONT></SPAN> Take a simulation step. </SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002> &nbs=
p; =20
Now, the collision will be resolved, and the sphere will be above the =
plane,=20
rather that going right through it.</SPAN></FONT></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002>Is the =
above method=20
feasible? Is it okay to do=20
this?</SPAN></FONT></SPAN></FONT></SPAN></SPAN></FONT></DIV></DIV>
<DIV><FONT face=3DArial size=3D2><SPAN class=3D111145714-14082002><SPAN=20
class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT></SPAN></SPAN></FONT> </DIV=
>
<DIV><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT></SPAN></SPAN><SPAN=20
class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT></SPAN><SPAN=20
class=3D960482107-13082002><FONT face=3DArial size=3D2><SPAN=20
class=3D111145714-14082002></SPAN></FONT></SPAN> </DIV>
<DIV><SPAN class=3D960482107-13082002><FONT face=3DArial size=3D2>-=20
Keshav.</FONT></SPAN></DIV></BODY></HTML>
------=_NextPart_000_0001_01C24D13.060407C0--