NaN value on NewtonBody Position

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: NaN value on NewtonBody Position

Postby KATO2 » Sat Nov 19, 2011 5:14 pm

hello Julio.

I get the latest svn version of Newton. I had to make some changes to source code for compatibility with linux32. please, check this files and add changes to svn.

coreLibrary_200.zip
(10.66 KiB) Downloaded 153 times
KATO2
 
Posts: 23
Joined: Thu Nov 10, 2011 11:16 pm

Re: NaN value on NewtonBody Position

Postby KATO2 » Sat Nov 19, 2011 5:20 pm

Julio i ran simulation and got following error message:
Code: Select all
physicsdveserver: ../../source/core/dgGoogol.cpp:305: dgGoogol dgGoogol::operator*(const dgGoogol&) const: Assertion `dgInt64 (A.m_mantissa[0]) >= 0' failed.
KATO2
 
Posts: 23
Joined: Thu Nov 10, 2011 11:16 pm

Re: NaN value on NewtonBody Position

Postby Julio Jerez » Sat Nov 19, 2011 5:53 pm

Ok I check iin the changes. I did not applied the changes to file ...\source\core\dgHeap.h
I will be very surpriced if there is a bug on the any funtions in that template, I have being using it extensivallyt for over 20 years, never having an error.
if there is an erro rther it is somewher else.


on this:
KATO2 wrote:Julio i ran simulation and got following error message:
Code: Select all
physicsdveserver: ../../source/core/dgGoogol.cpp:305: dgGoogol dgGoogol::operator*(const dgGoogol&) const: Assertion `dgInt64 (A.m_mantissa[0]) >= 0' failed.


you have to post the trace stack so taht I can see what is casing the bug.
My guess is that you are passing convex hull calculation on a degenerate gemetry and the engine is trying to calculate some distance on a degenedated plane.
The convex hull uses adaptive arithmetic and only in the cases of extreme degenerated cases will call of those arbitrary extended precision floats operations.

please print the trace stack, I am almost sure that it comes from a call to create convex hull with a vertex clould that is almost flat.
In the abcent of any assert it will probably create a convex hull with almost zero volume and that is what is making the contact solver generate Nans.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NaN value on NewtonBody Position

Postby KATO2 » Sat Nov 19, 2011 6:01 pm

Julio, there is not a but in file ...\source\core\dgHeap.h, but when i define assert(x) in linux, i get an error in this lines:
Code: Select all
   dgInt32 i;
   dgInt32 j;
   _ASSERTE (m_curCount < m_maxCount);


class attributes are not reconigzed for compiler. I had to change that code in functions dgDownHeap<OBJECT,KEY>::Push and dgUpHeap<OBJECT,KEY>::Push to:
Code: Select all
   dgInt32 i, cc=dgHeapBase<OBJECT,KEY>::m_curCount;
   dgInt32 j, cm=dgHeapBase<OBJECT,KEY>::m_maxCount;
   _ASSERTE (cc < cm);
KATO2
 
Posts: 23
Joined: Thu Nov 10, 2011 11:16 pm

Re: NaN value on NewtonBody Position

Postby Julio Jerez » Sat Nov 19, 2011 6:14 pm

_ASSERTE (m_curCount < m_maxCount);

That must be something new in GCC because I had compiled the engine with GCC and that never happen before
maybe teh assert in GCC does not handle templates arguments very well.

anyway I made the change and checked it, see if it works now.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NaN value on NewtonBody Position

Postby KATO2 » Sat Nov 19, 2011 7:22 pm

well, i sync to head revision. and build Newton whitout any error. later, i ran the simulation and that gave me next exception:
Code: Select all
physicsdveserver: ../../source/core/dgGoogol.cpp:305: dgGoogol dgGoogol::operator*(const dgGoogol&) const: Assertion `dgInt64 (A.m_mantissa[0]) >= 0' failed.
KATO2
 
Posts: 23
Joined: Thu Nov 10, 2011 11:16 pm

Re: NaN value on NewtonBody Position

Postby Julio Jerez » Sat Nov 19, 2011 7:50 pm

KATO2 wrote:well, i sync to head revision. and build Newton whitout any error. later, i ran the simulation and that gave me next exception:
Code: Select all
physicsdveserver: ../../source/core/dgGoogol.cpp:305: dgGoogol dgGoogol::operator*(const dgGoogol&) const: Assertion `dgInt64 (A.m_mantissa[0]) >= 0' failed.


I said you need to print the trace stack, that does not tell me anything at all.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NaN value on NewtonBody Position

Postby KATO2 » Sat Nov 19, 2011 8:29 pm

Julio Jerez wrote: you have to post the trace stack so taht I can see what is casing the bug.
My guess is that you are passing convex hull calculation on a degenerate gemetry and the engine is trying to calculate some distance on a degenedated plane.
The convex hull uses adaptive arithmetic and only in the cases of extreme degenerated cases will call of those arbitrary extended precision floats operations.

please print the trace stack, I am almost sure that it comes from a call to create convex hull with a vertex clould that is almost flat.
In the abcent of any assert it will probably create a convex hull with almost zero volume and that is what is making the contact solver generate Nans.


Ok, i have a body with box as collision primitive. Size of this is (1000, 0.01, 1000), this box is the ground for my simulation, and all objects collides with this. I will try to print trace stack to give you more information.
KATO2
 
Posts: 23
Joined: Thu Nov 10, 2011 11:16 pm

Re: NaN value on NewtonBody Position

Postby KATO2 » Sat Nov 19, 2011 8:41 pm

here is the stack trace:
Code: Select all
#0  0x0012e416 in __kernel_vsyscall ()
#1  0x00cbbe71 in raise () from /lib/i386-linux-gnu/libc.so.6
#2  0x00cbf34e in abort () from /lib/i386-linux-gnu/libc.so.6
#3  0x00cb4888 in __assert_fail () from /lib/i386-linux-gnu/libc.so.6
#4  0x0078f4d5 in dgGoogol::operator* (this=0xb6fced58, A=...) at ../../source/core/dgGoogol.cpp:305
#5  0x007e3983 in Determinant3x3 (matrix=0xb6fcedfc) at ../../source/core/dgSmallDeterminant.cpp:98
#6  0x007b6a12 in dgConvexHull3DFace::Evalue (this=0x81abca4, pointArray=0xb20851c0, point=...) at ../../source/core/dgConvexHull3d.cpp:98
#7  0x007baa42 in dgConvexHull3d::CalculateConvexHull (this=0x81abb80, vertexTree=0xb2c4cb60, points=0xb2b85080, count=105,
    distTol=<value optimized out>, maxVertexCount=2147483640) at ../../source/core/dgConvexHull3d.cpp:751
#8  0x007bb1e0 in dgConvexHull3d::BuildHull (this=0x81abb80, vertexCloud=0xb2b81b60, strideInBytes=24, count=112, distTol=0.0010000000474974513,
    maxVertexCount=2147483647) at ../../source/core/dgConvexHull3d.cpp:148
#9  0x007bb2ba in dgConvexHull3d::dgConvexHull3d (this=0x81abb80, allocator=0x811c2a0, vertexCloud=0xb2b81b60, strideInBytes=24, count=564,
    distTol=0.0010000000474974513, maxVertexCount=2147483647) at ../../source/core/dgConvexHull3d.cpp:123
#10 0x00904f8b in dgCollisionConvexHull::Create (this=0x81a3b80, count=564, strideInBytes=12, vertexArray=0xb2c01858, tolerance=0.00100000005)
    at ../../source/physics/dgCollisionConvexHull.cpp:428
#11 0x0090699c in dgCollisionConvexHull::dgCollisionConvexHull (this=0x81a3b80, allocator=0x811c2a0, signature=707270999, count=564,
    strideInBytes=12, tolerance=<value optimized out>, vertexArray=0xb2c01858, matrix=...) at ../../source/physics/dgCollisionConvexHull.cpp:53
#12 0x0085f528 in dgWorld::CreateConvexHull (this=0x80fd660, count=564, vertexArray=0xb2c01858, strideInBytes=12, tolerance=<value optimized out>,
    shapeID=0, offsetMatrix=...) at ../../source/physics/dgNarrowPhaseCollision.cpp:322
#13 0x0098924a in NewtonCreateConvexHull (newtonWorld=0x80fd660, count=564, vertexCloud=0xb2c01858, strideInBytes=12,
    tolerance=<value optimized out>, shapeID=0, offsetMatrix=0xb6fd7fe8) at ../../source/newton/Newton.cpp:2781
#14 0x00a40b69 in OgreNewt::CollisionPrimitives::ConvexHull::ConvexHull(OgreNewt::World const*, Ogre::Entity*, int, Ogre::Quaternion const&, Ogre::Vector3 const&, float, Ogre::Vector3 const&) () from /usr/local/lib/libOgreNewt.so.2
#15 0x0808f5a5 in PhysicalObject::createCollisionBody (this=0xb2ce63a8)
    at /home/mbsanchez/Tesis/code/Ogre3D/PhysicsDVEServer/src/PhysicalObject.cpp:64
#16 0x0808ee2d in PhysicalObject::PhysicalObject (this=0xb2ce63a8, mesh=0x811bef8)
    at /home/mbsanchez/Tesis/code/Ogre3D/PhysicsDVEServer/src/PhysicalObject.cpp:15
#17 0x080573c1 in PhysicalControlAgent::createPhysicalEntity (this=0x811c0c8, mesh=0x811bef8)
    at /home/mbsanchez/Tesis/code/Ogre3D/PhysicsDVEServer/src/PhysicalControlAgent.cpp:264
#18 0x08057c2d in PhysicalControlAgent::beginPhysicsWorld (this=0x811c0c8)
    at /home/mbsanchez/Tesis/code/Ogre3D/PhysicsDVEServer/src/PhysicalControlAgent.cpp:396
#19 0x080578f2 in PhysicalControlAgent::run (this=0x811c0c8) at /home/mbsanchez/Tesis/code/Ogre3D/PhysicsDVEServer/src/PhysicalControlAgent.cpp:355
#20 0x080690d2 in _THKERNEL (lpvData=0x811c0c8) at ../../useful_libraries/othread/src/Thread.cpp:39
#21 0x00af6e99 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
#22 0x00d6173e in clone () from /lib/i386-linux-gnu/libc.so.6

KATO2
 
Posts: 23
Joined: Thu Nov 10, 2011 11:16 pm

Re: NaN value on NewtonBody Position

Postby Julio Jerez » Sat Nov 19, 2011 8:53 pm

That is waht I said before you are making a convex hulls for degenerated point cloud.

print the point cloud and let us see what the values are.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NaN value on NewtonBody Position

Postby Julio Jerez » Sat Nov 19, 2011 9:01 pm

Is this function

Code: Select all
dgFloat64 dgConvexHull3DFace::Evalue (const dgBigVector* const pointArray, const dgBigVector& point) const
{
  const dgBigVector& p0 = pointArray[m_index[0]];
  const dgBigVector& p1 = pointArray[m_index[1]];
  const dgBigVector& p2 = pointArray[m_index[2]];

  dgFloat64 matrix[3][3];
  for (dgInt32 i = 0; i < 3; i ++) {
    matrix[0][i] = p2[i] - p0[i];
    matrix[1][i] = p1[i] - p0[i];
    matrix[2][i] = point[i] - p0[i];
  }

  dgFloat64 error;
  dgFloat64 det = Determinant3x3 (matrix, &error);
  dgFloat64 precision  = dgFloat64 (1.0f) / dgFloat64 (1<<24);
  dgFloat64 errbound = error * precision;
  if (fabs(det) > errbound) {
    return det;
  }

  dgGoogol exactMatrix[3][3];
  for (dgInt32 i = 0; i < 3; i ++) {
    exactMatrix[0][i] = dgGoogol(p2[i]) - dgGoogol(p0[i]);
    exactMatrix[1][i] = dgGoogol(p1[i]) - dgGoogol(p0[i]);
    exactMatrix[2][i] = dgGoogol(point[i]) - dgGoogol(p0[i]);
  }

  dgGoogol exactDet (Determinant3x3(exactMatrix));
  det = exactDet.GetAproximateValue();
  return det;
}



basically it try to detremine on what side of the plane form by the points in pointArray is.
but the point are collinear, so it try with double an it failm then it try with extended presition and it also fail because the extend presition class doe not hnadle error checking.

The problem is that the point cloud is degenerated.
Print the values passes to
Code: Select all
0x0098924a in NewtonCreateConvexHull (newtonWorld=0x80fd660, count=564, vertexCloud=0xb2c01858, strideInBytes=12, tolerance=<value optimized out>, shapeID=0, offsetMatrix=0xb6fd7fe8) at ../../source/newton/Newton.cpp:2781

it look like there are 564 point, save then to a file or print them her I can see if it work.


does the program runs on window?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NaN value on NewtonBody Position

Postby KATO2 » Sat Nov 19, 2011 9:15 pm

the program is linux dependents. i have serialized collision data in a file. this files is useful for detect the error?
KATO2
 
Posts: 23
Joined: Thu Nov 10, 2011 11:16 pm

Re: NaN value on NewtonBody Position

Postby Julio Jerez » Sat Nov 19, 2011 9:50 pm

not serialized data is no useful to me. print the values to a text file and post here.

for what I can see, you are abusing the convex hull. a box of 1000 x 0.01 x 1000 is too thin, a shape like that has an aspect ratio of ten tousand to 1, the value can not be hold wih a float32,
but that is not the problem unless that box is the one that has the 500 points.

shapes with aspet ratios like that cause the engine to run slow because converge rate on the contact solve will be very low.
if you nee a shape like that make a collision tree, the collison tree has special code to consider large polygons.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NaN value on NewtonBody Position

Postby KATO2 » Sat Nov 19, 2011 10:13 pm

In file barrel.zip is the vertex data.

barrel.zip
(1.38 KiB) Downloaded 157 times


I will think about using Ellipsoinde, Sphere and Cilinder for the bodys, so that the engine improve his performance.
KATO2
 
Posts: 23
Joined: Thu Nov 10, 2011 11:16 pm

Re: NaN value on NewtonBody Position

Postby Julio Jerez » Sat Nov 19, 2011 10:22 pm

you can use any shape, just do not use shapes with aspec ratio like that box.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests