Debug Assertion Failed - RayCast

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Debug Assertion Failed - RayCast

Postby ToniMachado » Wed Aug 31, 2011 7:09 am

Hello,

I developped a robot simulator in c++.
In this simulator the user can insert either robots or objects as obstacles.
Each robot has 11 distance sensors, emulated by ray casting to a fixed distance and using the closest hit approach ( returning 0.0f in the callback filter, as described in the WIKI - function NewtonWorldRayCast ).
Some days ago I detected a bug when a sensor from one robot detects another robot, which does not happen when the "sensed" body is an obstacle.
My robots are made of three cylinders and two spheres ( one chassis, two motorized wheels, and two casters ).
The error, when in debug mode, is as follows:

---
File: ..\..\..\sdk\physics\dgBody.cpp
Line: 355

Expression: t<=1.0f
---

From my debug attempts, it seems that when this bug happens, this variable "t" takes a value slightly larger than the assertion limit (like 1.05 or something close). I find it strange that this only happens when the projected ray intersects a robot and not an obstacle, as stated before. Another thing to note is that this bug seems to disappear when i suppress my callback filter function, passing a NULL as the argument for the NewtonWorldRayCast function. The callbackfunction impremented only gets the _intersetParam and stores it on a member of an object to which i pass the pointer through the userdata field. The problem doesn't seem to be related to my implementation of the callback filter, because when i leave it empty, just returning 0.0f as stated before, the bug still appears.
I'm using newtonGD v2.30, developing on a windows 32bit platform and using visual studio 2010.

Hope to get an answer,

Thank you,
Toni Machado
ToniMachado
 
Posts: 14
Joined: Thu Jan 29, 2009 11:22 am

Re: Debug Assertion Failed - RayCast

Postby Julio Jerez » Wed Aug 31, 2011 1:15 pm

if you pass a filter callback, the callback must return a value.
return 0 will terminate the scan, returning 1 will continue scanning, returning t will search shorte teh ray alone the path.
if you return t in or zero the ray scan will terminate the search, and no test some potecil hits.
try returnion 1 and see if is if fixes the bug. if ti does then try what followes.

objects are reperted from to back alone teh ray in a loose way,
if in a cell there are mode than one object, it is possible to get a body with a biger t in the callback first.
bassicall for an efficient closets body hit call back, you should return t + some epsilon
like t + 0.1, and collect the body with the smallest t.

this will be efficient and will alway get the closest hit.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Debug Assertion Failed - RayCast

Postby ToniMachado » Thu Sep 01, 2011 6:20 am

Thank you for your answer.

I had tried returning different values (between 0 and 1) in the callback before, with no sucess. As for your suggestion, i'm sorry but i didn't understand what you meant. You're saying for me to try and return the intersectParam( NewtonWorldRayFilterCallback ) plus some small number? But the problem is not getting the first body that the ray intersects, but when the ray seems to start intersecting another robot, or when it stops intersecting it, the bug occurs, as i stated before.

Regards,
Toni Machado
ToniMachado
 
Posts: 14
Joined: Thu Jan 29, 2009 11:22 am

Re: Debug Assertion Failed - RayCast

Postby Julio Jerez » Thu Sep 01, 2011 1:09 pm

What I say is the the ray may hit the other robot, but it will also hit the other objects in teh same mutigrid cell,
if you break at the first hit, then you may end up with the wrong object.

basically the the scan do no scan objects from from to back, it scans cells that contain a list of objects form front to back.
if the robot and the other object happens to be in the same cell, then the ray may call the call back with a wrong object just because
it finds it first on the list of objects of that cell of the Mutiresolution grid.

to test if the ray is hitting the object, return 1.0 in the call back and collect oll the objecst tha the ray hit,
if the object you are looking for is in the set, them doing return t + some expilon in teh callback, fixes the problem and still is very efficient.

Returning t in teh callback is teh trick to make the ray cast very fast, since is shorten the ray, after each hit. which mean it will no scan cell behond the first cell with a hit.
reruntion t make teh raycast asimptotilcally const time, while retirning 1.0 make it linerar tiem wit teh number of bodie in teh path of the ray. so for long ray is very imprtant to return t.
return t + epsilon, guarantee that al least all bodis in the cell will be tested.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 5 guests