Newton + Irrlicht crash problem

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Newton + Irrlicht crash problem

Postby telmopereira » Thu Apr 15, 2010 1:28 pm

Hi everybody ! This is my first post, I'm starting with Newton (and also Irrlicht) now, and i doing a work for my master where i need to put this both engines working together and also with an haptic device interacting with the virtual world created with both engines. So if i made some not so smart question, please sorry for that.

So, right now i start with this tutorial: http://irrlicht.sourceforge.net/tut_newton.html and things are work fine. The problem is that there is one object that i am controlling with a haptic device (but i think we can think in this problem like i was controlling with the keyboard). So, everytime the position of the haptic device change i call a function setPositionHDRep. It's something like this :

void vehi_hdRepresentation::hapticTransformMatrixChanged(const matrix4& mat)
{
vehi_hdRepresentation::setPosition(vector3df(p_pos.X/2,p_pos.Y/2, -p_pos.Z/2));

p_lastHapticPos = p_pos;

}

void vehi_hdRepresentation::setPosition(const vector3df& pos)
{
if(p_irrSceneNode)
p_irrSceneNode->setPosition(pos);

if(p_body)
{
matrix4 mat;
NewtonBodyGetMatrix(p_body, mat.pointer());
mat.setTranslation(pos);
NewtonBodySetMatrix(p_body, mat.pointer());
}
}


The problem is that this seems to work, but after few seconds the program breaks with the message : "Unhandled exception at 0x003a4807 in VEHI.exe: 0xC0000005: Access violation writing location 0xfeef00ba."

If instead of call the function that i made (setPosition) i only updates the irrSceneNode position by doing p_irrSceneNode->setPosition(pos); the program works fine (except that collisions are not well made ! )

Can anyone help me please? Any idea?? If needed i can send the entire code. I spent a lot of time trying to solve this but i can't ! If someone have some idea please help me! :S

Thanks in advance,

Telmo
telmopereira
 
Posts: 29
Joined: Thu Apr 15, 2010 12:52 pm

Re: Newton + Irrlicht crash problem

Postby Julio Jerez » Thu Apr 15, 2010 1:57 pm

without looking at why the cause of teh crash, I can tell you that setting the matrix position in real time is a very bad idea.
you should try using a Kinematically controll joint.
that is a unilateral joint the serve as a controller that you can use to position the body in the worl and still abide by the physics laws.
Basically that joint conve the tranlations and rotations steps into the force you need to apply to control the body.
check out the Joint in the wiki tutorials fo 103.

as for the Crash there could be many reason for it, can you post a demo that reproduce it?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton + Irrlicht crash problem

Postby telmopereira » Thu Apr 15, 2010 2:28 pm

There is the demo: http://feupload.fe.up.pt/get/gmDMdm6bGdh6YcT . The object that i'm moving has gravity. The logical thing is to remove the gravity of course, but the problem will remain. I just left the program like that to show that if i move the haptic device he updates the "graphic and physic positions" and do the physics as was suppose.

So, i will wait for your opinion.

Thanks,

Telmo
telmopereira
 
Posts: 29
Joined: Thu Apr 15, 2010 12:52 pm

Re: Newton + Irrlicht crash problem

Postby Julio Jerez » Thu Apr 15, 2010 2:30 pm

It is difficult to debug from a video.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton + Irrlicht crash problem

Postby telmopereira » Fri Apr 16, 2010 10:29 am

I don't know if you could debug the program because you will need the haptic device to control the object that is causing problems, install OpenHaptics toolkit and have all the libraries.

Still, i will let here a link ( http://feupload.fe.up.pt/get/DAMhDwwuFUsJ9yM ) my source code and haptic libraries.

Thanks,
Telmo
telmopereira
 
Posts: 29
Joined: Thu Apr 15, 2010 12:52 pm

Re: Newton + Irrlicht crash problem

Postby telmopereira » Fri Apr 16, 2010 10:34 am

The last link was wrong, the correct is this one : http://feupload.fe.up.pt/get/HNnErbIK3pY6XdR

Thanks,

Telmo
telmopereira
 
Posts: 29
Joined: Thu Apr 15, 2010 12:52 pm

Re: Newton + Irrlicht crash problem

Postby Julio Jerez » Fri Apr 16, 2010 10:54 am

can you just post a executable that I can run?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton + Irrlicht crash problem

Postby telmopereira » Fri Apr 16, 2010 12:35 pm

Like i told you, there is an object that is controlled by an haptic device...and is that object that is creating the problems i think.
But i send the exe as you ask me.

http://feupload.fe.up.pt/get/KNoeMORxVSCkJEa

Thanks
telmopereira
 
Posts: 29
Joined: Thu Apr 15, 2010 12:52 pm

Re: Newton + Irrlicht crash problem

Postby Julio Jerez » Fri Apr 16, 2010 1:20 pm

What I say is that you know the pattern that cause the crash,
Can you just replace the input to the matrix form teh device with somes procedurally values more or lest like the stuff I see if the video
essencially you just change position of a matrix at random or from some algorithmically generate curve.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton + Irrlicht crash problem

Postby telmopereira » Mon Apr 26, 2010 2:29 pm

Hi again,

Well, i try out many things, and changing the place where i update the physics, it seems that stops to crash the program.

The problem now is that the collisions are not well made. I try out to control a box with the keyboard and another one with the haptic device. With the keyboard everything is fine, but not with the box that i control with haptic device. The only difference between the code is that with a box controlled by the keyboard i do in the update function something like:

Code: Select all
  vector3df actualPos = p_irrSceneNode->getAbsolutePosition();
      matrix4 mat;

      if(p_moveObjFB != 0)
      {
         p_irrSceneNode->setPosition(vector3df(actualPos.X, actualPos.Y, actualPos.Z + (p_moveObjFB * 0.05)) );
   
         mat.setRotationDegrees(  p_irrSceneNode->getRotation() );
         mat.setTranslation( p_irrSceneNode->getPosition() );
         NewtonBodySetMatrix(p_body, mat.pointer())


and with the haptic i do something like:

Code: Select all
   p_irrSceneNode->setPosition(HapticPos);
      matrix4 mat;
      mat.setTranslation( getPosition() );
//      mat.setRotationDegrees( getRotation() );
      NewtonBodySetMatrix(p_body, mat.pointer());


So is pretty much the same. Do you have any idea we the behavior of the object controlled by the haptic device is different ?

I sent a link to a video (http://feupload.fe.up.pt/get/DmjJvwD2uECm02y) where i show the different behaviors. The blue box is controlled by the haptic device and the red one is controlled by the keyboard. Many thanks,

Telmo
telmopereira
 
Posts: 29
Joined: Thu Apr 15, 2010 12:52 pm

Re: Newton + Irrlicht crash problem

Postby Sash » Mon Apr 26, 2010 3:41 pm

Personally I have no idea what you are trying to do.
It is supposed (typically) to use NewtonBodySetMatrix only once, for a body' startup initialization, but not for every step update, and instead "control" them by forces.
Otherwise, you're just loosing benefits of Newton as physical environment.
Sash
 
Posts: 34
Joined: Wed Sep 30, 2009 3:38 am
Location: Novosibirsk

Re: Newton + Irrlicht crash problem

Postby Julio Jerez » Mon Apr 26, 2010 3:58 pm

telmopereira wrote:Well, i try out many things, and changing the place where i update the physics, it seems that stops to crash the program.
The problem now is that the collisions are not well made. I try out to control a box with the keyboard and another one with the haptic device. With the keyboard everything is fine, but not with the box that i control with haptic device. The only difference between the code is that with a box controlled by the keyboard i do in the update function something like:


I have not seen the videos, but if the keyboard control world then it does not really matter what is wrong, because both methods of controlling the object are wrong.
what you need to do is, you need to set a CustomKinematicController
check out wiki tutorial, it has an exact example of what you want to do.
http://newtondynamics.com/wiki/index.php5?title=Tutorial_103:_-_Adding_Joints

basically the it is a unilateral joint that convert change in position into Forces and Torques applied to the bodies.
Then those move are passed to the physics solver to be considered for calculation of contacts with other bodies,
and the bodies in contact with the one in contact, and so on.
In the wiki demo, there is a Box that follows a circular path, but you can modifies to take input form you Haptic device..
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton + Irrlicht crash problem

Postby telmopereira » Tue Apr 27, 2010 10:39 am

Hi,

I am using Newton 1.53. There is something similar in version 1.53 ?

Thanks
telmopereira
 
Posts: 29
Joined: Thu Apr 15, 2010 12:52 pm

Re: Newton + Irrlicht crash problem

Postby Julio Jerez » Tue Apr 27, 2010 1:20 pm

Why are you using 1.53 when 2.00 is on its 2.20 update?
you need to use latest version of 2.00 for everything.

I do not undestand why people insist in using newton 1.53 a library that is already 5 years old.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Newton + Irrlicht crash problem

Postby telmopereira » Tue Apr 27, 2010 5:43 pm

I start with 1.53, because i find out more information about integration of Irrlicht with Newton 1.53, so i start with that version and never change.

To change now i will need to change many things i think. There is really no way with 1.53 ?

Thanks,
Telmo
telmopereira
 
Posts: 29
Joined: Thu Apr 15, 2010 12:52 pm

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron