Closed nwood99 closed 2 years ago
Thanks for reporting. It's an interesting case - and my apologise for the cryptic message/variable names. It could be a bug or a particular case that stresses the algorithm beyond the set tolerances.
The warning is triggered inside S3D
: the function that computes the point of a tetrahedron closest to the origin. To speed up the solution, this function uses information from the past GJK-iteration(s). This means that the search is not brute-force, but the problem is simple enough to be compared to the exact solution and debug from there.
You can either:
eps_rel22
or eps_tot22
. Relax these tolerances until the warning disappears. This will terminate GJK earlier and hopefully will give good results. No guarantees tho.S3D
and post here the coordinates of the four vertices (s1
, s2
, s3
and s4
) of the tetrahedron. Or add few lines of code that print to console these coordinates when the warning is triggered. We'll take it from there.Mattia,
My preference is to go with Option 2. I'd like to know if the warning is being displayed for good reason before discounting it. A quick question regarding s1 through s4: Are these the vertices of the tetrahedrons that the GJK algorithm generates internally as it searches the minkowski difference for the origin, or are they the vertices of the source polyhedron being tested? I ask for clarification because the polyhedrons I'm checking for convergence are themselves tetrahedrons. I don't have much experience programming in C (I'm using the MATLAB installation), and converting vectors (3D coords of each vertex) to strings for use in Mexprintf seems nontrivial. My apologies for the inconvenience my inexperience causes.
It's alright, glad the Matlab interface breaks some barrier. Still, it's a great task to start giving into C. If you want to debug, that's the way to go.
s1 to s4 are the coordinates from the Minkowski difference.
From: nwood99 @.***> Sent: Saturday, 5 February 2022, 20:13 To: MattiaMontanari/openGJK Cc: Mattia Montanari; Comment Subject: Re: [MattiaMontanari/openGJK] UNEXPECTED VALUES !!! warning message (Issue #20)
Mattia,
My preference is to go with Option 2. I'd like to know if the warning is being displayed for good reason before discounting it. A quick question regarding s1 through s4: Are these the vertices of the tetrahedrons that the GJK algorithm generates internally as it searches the minkowski difference for the origin, or are they the vertices of the source polyhedron being tested? I ask for clarification because the polyhedrons I'm checking for convergence are themselves tetrahedrons. I don't have much experience programming in C (I'm using the MATLAB installation), and converting vectors (3D coords of each vertex) to strings for use in Mexprintf seems nontrivial. My apologies for the inconvenience my inexperience causes.
— Reply to this email directly, view it on GitHubhttps://github.com/MattiaMontanari/openGJK/issues/20#issuecomment-1030682993, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADJFWWDGHJ5X23O2CVMKD63UZVZFHANCNFSM5NPHOIEQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you commented.Message ID: @.***>
Mattia,
I've checked when the error message arises, and found some interesting results. Here are the vertex coordinates of two tetrahedra that produce this error:
E_target=[3.5074, 3.3263, 0; 2.5000, 5.0000, 0; 1.7122, 2.7488, 2.7488; 3.3789, 2.9915, 2.9915];
E_test=[3.3789, 2.9915, 2.9915; 3.5074, 0, 1.6737; 1.7122, 2.7488, 2.7488; 3.5017, 1.6638, 0];
The UNEXPECTED VALUES message appears when evaluating a Minkowski Difference tetrahedron with vertices located at
s1: 1.666693, 0.242770, 0.242770 s2: -1.666693, -0.242770, -0.242770 s3: -0.122842, 1.327708, 2.991528 s4: 0.128510, 0.334741, -2.991528
"target" in red, "test" in grey, and s1-s4 in green.
However, there's a further complicating factor: the message only appears when evaluating in a while loop. My code checks collision between the "target" tetrahedron and all neighbors of the "test" tetrahedron (the test tetrahedron is an element of a mesh). Collision is checked repeatedly among the neighbors of neighbors until no new collisions are found. As a consequence, the collision check happens several dozen times in a row. The UNEXPECTED VALUES message appears in the context of this repeated checking.
I mention this because the UNEXPECTED VALUES message does NOT appear if I write a separate script that checks nothing but the above-specified "target" and "test" tetrahedrons in isolation. Unfortunately, I believe this to be a memory handling error. I believe this because I tried commenting the message out and running openGJK in the full context of my application. This application iterates the above neighbor-collision check for a mesh of "target" elements. I do this for several pairs of meshes. This means running openGJK several thousand times. On the 14th mesh-to-mesh collision analysis, MATLAB encounters an access violation error and crashes:
The full text of the crash report is included at the end of this comment. If I had to guess, the presence of this warning message in the context of a loop, but not in isolation, is the early warning sign of whatever's going wrong, which progresses until provoking a crash if the program is called enough times in a row.
MATLAB crash file:C:\Users\nwood\AppData\Local\Temp\matlab_crash_dump.2508-1:
Access violation detected at 2022-02-07 09:33:12 -0500
Configuration: Crash Decoding : Disabled - No sandbox or build area path Crash Mode : continue (default) Default Encoding : windows-1252 Deployed : false Graphics Driver : NVIDIA Corporation NVIDIA GeForce GTX 1650/PCIe/SSE2 Version 4.6.0 NVIDIA 496.76 Graphics card 1 : NVIDIA ( 0x10de ) NVIDIA GeForce GTX 1650 Version 30.0.14.9676 (2021-11-9) Graphics card 2 : NVIDIA ( 0x10de ) NVIDIA GeForce GTX 1070 Version 30.0.14.9676 (2021-11-9) Graphics card 3 : Citrix Systems Inc. ( 0x5853 ) Citrix Indirect Display Adapter Version 12.40.44.247 (2019-1-23) Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode MATLAB Architecture : win64 MATLAB Entitlement ID : 1334657 MATLAB Root : C:\Program Files\MATLAB\R2020b MATLAB Version : 9.9.0.1538559 (R2020b) Update 3 OpenGL : hardware Operating System : Microsoft Windows 10 Home Process ID : 2508 Processor ID : x86 Family 143 Model 113 Stepping 0, AuthenticAMD Session Key : 55a00498-7965-4960-b106-490327c7ff92 Window System : Version 10.0 (Build 19042)
Fault Count: 1
Abnormal termination: Access violation
Current Thread: 'MCR 0 interpreter thread' id 11908
Register State (from fault): RAX = 0000000000000030 RBX = 0000000000000000 RCX = 00000016d9ff6d90 RDX = 00000016d9ff6d60 RSP = 00000016d9ff6bc0 RBP = 00000016d9ff6c40 RSI = 0000000000000004 RDI = 0000000000000000
R8 = 00000016d9ff6e20 R9 = 0000000000000040 R10 = 00000000000002c0 R11 = bd00840a12548001 R12 = 000001cdbc37ff20 R13 = 0000000000000000 R14 = 0000000000000000 R15 = 000001cdb683a120
RIP = 00000000002746d5 EFL = 00010206
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x00000000002746d5 F:\mirror\work mirror\work files\adaptive mesh 3D\troubleshoot supermesh\openGJK.mexw64+00018133
[ 1] 0x00000000002755b2 F:\mirror\work mirror\work files\adaptive mesh 3D\troubleshoot supermesh\openGJK.mexw64+00021938 mexFunction+00000466
[ 2] 0x00007ff8e72ea289 C:\Program Files\MATLAB\R2020b\bin\win64\libmex.dll+00565897 mexfile::Inspector::needs_upgrade+00015977
[ 3] 0x00007ff8e72eb67b C:\Program Files\MATLAB\R2020b\bin\win64\libmex.dll+00571003 MexRetrieveVersion+00003579
[ 4] 0x00007ff8e72eb7ec C:\Program Files\MATLAB\R2020b\bin\win64\libmex.dll+00571372 MexRetrieveVersion+00003948
[ 5] 0x00007ff8e72eb9b4 C:\Program Files\MATLAB\R2020b\bin\win64\libmex.dll+00571828 MexRetrieveVersion+00004404
[ 6] 0x00007ff8e72cc209 C:\Program Files\MATLAB\R2020b\bin\win64\libmex.dll+00442889 mexUnlock_800+00023993
[ 7] 0x00007ff8e79226c1 bin\win64\pgo\m_dispatcher.dll+00665281 Mfh_file::dispatch_file_common+00000165
[ 8] 0x00007ff8e7921d62 bin\win64\pgo\m_dispatcher.dll+00662882 Mfh_error::lookup+00006498
[ 9] 0x00007ff8e7922615 bin\win64\pgo\m_dispatcher.dll+00665109 Mfh_file::dispatch+00000045
[ 10] 0x00007ff8e48e8208 bin\win64\pgo\m_lxe.dll+00557576 CGGBuiltinImpl+00181784
[ 11] 0x00007ff8e48cb484 bin\win64\pgo\m_lxe.dll+00439428 CGGBuiltinImpl+00063636
[ 12] 0x00007ff8e49e7861 bin\win64\pgo\m_lxe.dll+01603681 mwboost::serialization::singleton<mwboost::serialization::extended_type_info_typeid
This error was detected while a MEX-file was running. If the MEX-file is not an official MathWorks function, please examine its source code for errors. Please consult the External Interfaces Guide for information on debugging MEX-files.
Sorry for the late reply. I don't have access to a Matlab license anymore and I cannot test the solution.
I did use the C code many times in many for loops and I doubt there is a problem on that front.. perhaps the Matlab wrapper could be a source of memory errors.
The Mex wrapper is far from great, but I cannot see any memory leak there. My understanding is that mxCreateDoubleMatrix
is used correctly because is used against plhs
(see documentation). Therefore we don't need mxDestroyArray
.
From the he picture of your polyhedra it seems that they touch on an edge. Very little however. Perhaps that's where relaxing tolerances can help you get going.
Hello,
I have experienced this warning message when using openGJK in my applications. I'm not sure what it indicates. The variable names in openGJK are very abbreviated and it's hard for me to understand what they denote. Furthermore, even though the warning message displays, the script doesn't seem to halt execution or return bad/nonsensical results. I'd greatly appreciate knowing what this warning message means before doing something as reckless as commenting it out. My thanks in advance for any clarification that can be provided!