A SERIOUS SURGICAL simulation!

Share with us how are you using the powerrrr of the force

Moderator: Alain

Re: A SERIOUS SURGICAL simulation!

Postby Julio Jerez » Sun Feb 16, 2020 3:37 pm

Charles wrote:But i have an question here: How can i rotate the handle around the axis of itself, say the z axis of the handle? Each time i try to do that, the handle always rotate about the world axis not axis of itself. And i tried many ways but the result are all the same.


I said I have not done that yet, I will add a test later today.

but the way to go about is that you use a joint to fix the root body in place.
the closer stock joint I can think of would be the corkscrew.
this joint has one degree of longitudinal translation and one degree of axial rotation.
but most likely this will not be enough so the best is to make a custom joint the allow three degrees of translation and one or two degrees or rotation.

this free dof are a dry friction, by the I mean you apply a motion and when the motion is stronger than the dry friction the root body moves, but as soon as you let go is stops because of the high dry friction.

then is just a matter of applying the desire linear an angular impulse to the root body you move anyway you want.

I will make the joint in the demo, and will add some kind of control so that you see how I do it and you can go from there.

one of the feature of newton is that is easy to make these kind of custom functionality,
plus the plugin design let the end user extended and expose the functionality they want.
it is not a one fix all solution.

In that regard, if you look at the demo, to get a quick result I used a stock ball and socket joint and
relaxed the cone stiffness. This makes the joint somewhat elastic but is also make it too plastic.

this is because when a link violates the cone limit, zero in this case, it tries to recover at a constant velocity. this is by design in newton.
you probably noticed this when the Cather twist and get entangled that is difficult to get it untangled.
in your case you probably want a link to be more elastic, so that when you twist the root node, it is capable is transmit the angular rotation a easier.

given the difficult of the problem, with any other engine you would probably live with that and did not even noticed the problem, but this is Newton we can do better than that.
for that we can make the cone a legitimate spring damper, with a low coefficient of drag.

if you did not get what I was trying to explain, do not worry, just wait until I add it all together, then you can add it to your plugin.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: A SERIOUS SURGICAL simulation!

Postby Julio Jerez » Sun Feb 16, 2020 5:26 pm

Ok if you sync to Github you will see that now you can manipulate the handle body. and drag around to any position you want.

The control joint is not complete yet as if does no control the angular dof, I will do than later.
but you can see how the final thin will work, even wen only liars dof are controlled.

I am moving with the the mouse, but you should do it by dappling impulses with make order of magnitude more accurate. in fact if you have a Haptic device that how you have to do it.

by in this case using the mouse grab seem to do the job.

you can see now see how the handle mass dominate the motion.
I made 30 time heavier than the link by maybe 50 time is a better value, you can play with the the value and the joint friction and see what is better for you.

remember the the handle mass represent the attachment to the world, which will be the doctor controlling the apparatus which will be 100 of time large that the string by not infinite.


alright I also added the angular control, you can see that you can rotate the root handle by is hard with the mouse.
bu this is a trivial thong to do applying an angular impulse to the root body, the annual impulse should be such that is bigger that the fiction alone the axis of rotation you want. and structure some spins by the fast that the handle has such large inertial.

I will write the function as a member of the joint so that you can use it when you wan to control the joint. the I will have as a option that you can enable by un commenting the code since they is no user interface for it.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: A SERIOUS SURGICAL simulation!

Postby Julio Jerez » Sun Feb 16, 2020 10:52 pm

alright I now added teh ability to move the handle around.
so far only linear motion. angular motion is very similar and I will add later.

to demostrate teh effect and place the keyboard input in the joint call back itself. you nee to make teh call from the appropriate place in the Unity gui.

if you hit teh key 'O' or 'P' it move forward or backward.

since the call is in teh callback itself if the whole structure goes to sleep teh funtion is no called. for that you need to add logic to wake up the body when you wan the body to move.
in this demo you will nee to touch any body with the mouse to case the articulation to wake up.

the motion is quite exaggerate for a medical device, but this is just for demonstration, you can calibrate anyway you want.
you can change direction of the handle with the mouse and it will move along that direction.

anyway try that out and tell me if this is alone what you wanted.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: A SERIOUS SURGICAL simulation!

Postby Julio Jerez » Mon Feb 17, 2020 11:03 am

al right I added the angula rotation control.
you control it with the key 'K' and 'L'
it probably spins too fast, but you can controll it.

nwo you can see the problem I mention before that the viscus drag between each joint is too strong and does not let the string to disentangle quick enough.

of course if this was guide inside a hollow tube the engagement will not happens because the wall of teh tube as constrains preventing the vending.
but I do not know how you are going to use it. but if the entangle is a problem, the solution is to override the default spring damper in the stock joint and assign a custom cone strong spring, with a damper just enough to damp the spring oscillations. you tell me if this is the case.

but form now I think this is close enough to what you asked.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: A SERIOUS SURGICAL simulation!

Postby Charles » Wed Feb 19, 2020 2:50 am

Julio Jerez wrote:al right I added the angula rotation control.
you control it with the key 'K' and 'L'
it probably spins too fast, but you can controll it.


Hi Julio Jerez, Thanks! This is just the way i want to manipulate the rod. And in these days i have been trying to merge dFlexyPipeHandle to Unity but i failed. I checked the arguments and they looked all the same. And i have tried dCustomCorkScrew too because it seems capable to manipulate the rod in my case after given a second thought, but also failed.
They are all failed in the same way when twisting the handle. Vedios below show the way i use the rod and the twist problem:
https://youtu.be/OOjSxCl1A1c
https://youtu.be/aIlJoLwgb1E
But i have tried use a combination of static and slider and hingle as one handle instead of using a custom handle. And it worked well for now so let's put the handle's problem aside for the moment. :D


Julio Jerez wrote:nwo you can see the problem I mention before that the viscus drag between each joint is too strong and does not let the string to disentangle quick enough.

of course if this was guide inside a hollow tube the engagement will not happens because the wall of teh tube as constrains preventing the vending.


I can not tell wheter engagement is a problem for now because there is a big problem stand in my way of testing the rod in a real situation. I think i must solve this problem first before continuing. And for this problem i really need your suggestions first ohterwise I may waste a lot of time in the wrong way.

Here is the problem: I want a rod go along another rod exactly to simulate a guidewire moving in a catheter. And when some part of the guidewire has gone out of the catheter, the part follow physics again. In a word, a node has 2 ways to follow: along another rod or just follows physics, and i want change the way at run time. So what is the best way from your opionion?
Last edited by Charles on Thu Feb 20, 2020 8:05 am, edited 9 times in total.
Charles
 
Posts: 43
Joined: Thu Jan 16, 2020 12:58 am

Re: A SERIOUS SURGICAL simulation!

Postby Dave Gravel » Wed Feb 19, 2020 9:06 pm

Hi Charles,
Just a suggestion if you try to use a static body with joint and if you try to move the static body.
In the old newton version it don't cause problem to use static body in that way.

In the current newton version it cause problem.
If i'm not wrong in release mode it can work, But it can cause internal newton problem and it is a bad idea.
In debug mode newton is supposed to report the problem.

I used this way in old newton version for control the first part of the rod links.
I used this way too before for control robot with 6 axes.

Now you can use the kinematic joint for control a object similar to the static body wrong method.
If i'm wrong and if you don't try to move the static body connected by joint forget my suggestion.

Again maybe i'm wrong but in your first video the joints pin look incorrect.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: A SERIOUS SURGICAL simulation!

Postby Charles » Thu Feb 20, 2020 1:12 am

Dave Gravel wrote:Hi Charles,
Just a suggestion if you try to use a static body with joint and if you try to move the static body.
In the old newton version it don't cause problem to use static body in that way.

In the current newton version it cause problem.
If i'm not wrong in release mode it can work, But it can cause internal newton problem and it is a bad idea.
In debug mode newton is supposed to report the problem.

I used this way in old newton version for control the first part of the rod links.
I used this way too before for control robot with 6 axes.

Now you can use the kinematic joint for control a object similar to the static body wrong method.
If i'm wrong and if you don't try to move the static body connected by joint forget my suggestion.

Again maybe i'm wrong but in your first video the joints pin look incorrect.


Hi Gravel, thanks for your kindful suggestion first! I already know the that it is forbidden to move a static body directly. What i move is the target body of the slider joint linked to the static body. Thanks for your reminder all the same!
Charles
 
Posts: 43
Joined: Thu Jan 16, 2020 12:58 am

Re: A SERIOUS SURGICAL simulation!

Postby Julio Jerez » Thu Feb 20, 2020 11:35 am

few things:
do you want the catheter to get entangled or you do not?

regard using that static body. You can do anyway you feel it works best for you.
I simply gave you my experiences on how to set up the way I best understood the problem.

I already told you why I believe using a static body is the wrong thing to do, even if by tweaking the setting to have have something that look more or less ok.

I will try again one more time. but I will not repeat it any more.
Basically you have a chain of small bodies that when they all combined offer a strong resistance to the motion of just one body.
if you connect the to first body to a another static body, all methods of motion will be in violation of some laws conservation of momentum, and in Newton conservation of momentum is the foundation of the technology, It is not not an impulse based engine.
moving the static body is wrong because this adds an infinite amount of momentum to the system since static bodies have infinite mass.
and linking a body to a static is also wrong because physics is all about conservation of momentum, so when you move one link, since the link is equal mass and inertia to the other links, then if can not transferred enough angular momentum to the other links and any small friction generated by the joints or collision is enough to act as strong noise on the input.

In a nutshell what you want is that the momentum vector of the body that is controlling the motion remain unchanged or change very little when adding the external impulse from the person controlling the thing.

since momemtum is L = mass * veloc;

there are only three ways to do this, you change the velocity, you change the mass or you change
both.

the effect is that when you add a delta impulse to the root body, the root body transmit some of that to the chain. but here the velocity can not be too large so you need to make the mass large, so that small velocity add amount to a large momentum.

if you do not change the mass then any small velocity will add a small delta impulse to the momentum of the body making the current vector change a lot, even worse the reaction forces will also act as reaction changing the momentum of the root body making the vector practically random.

if the body was very massive compared to the rest of the links, any small velocity and angular velocity acting as input does not change the current momentum vector too much. so the system is stable because is can recover from a small perturbation of the momentum vector.

I can go on a technical explanation of this, it comes right out of the equations of conservation of momentum, but I hope an intuitive explanation is sufficient to explain why fiddling with a static body is not the physically plausible way to do it.

The other point is that I am now baffled, your first post asked for a physically plausible simulation, and you even mentioned the many papers about.
I told you all those paper amount to less than pseudo academic garbage babble since they try to circumvent the equations of classical physics with brand new laws to get a make believe facade simulation.
I, gave a high level explanation and wrote the demo as a template for you to use as reference.
but 3/4 of the way of the development you are the first one who say, I do not want to be physically plausible, I want to be fake using the same methods that other physics libraries are using.
and all this apparently because you could not integrated the demo to the engine?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: A SERIOUS SURGICAL simulation!

Postby Charles » Thu Feb 20, 2020 10:54 pm

Julio Jerez wrote:few things:
do you want the catheter to get entangled or you do not?


No, i don't want the catheter to get entangled, that's for sure.

Julio Jerez wrote:The other point is that I am now baffled, you first post asked for a physically plausible simulation, and you even mention the many papers about.
I told you all those paper amount to less than pseudo academic garbage babble since they try to circumvent the equations of classical physics with brand new laws to get a make believe facade simulation.
I, gave a high level explanation and wrote the demo as a template for you to use as reference.
but 3/4 of the way of the development you are the first one who say, I do not want to be physically plausible, I want to be fake using the same methods that other physics libraries are using.
and all this apparently because you could not integrated the demo to the engine?


Sorry to let you feel that way :( . For this part i need to explain cause i really don't want to be misunderstood. First of all, I'm indeed asking for a physically plausible simulation and it never changed. I think the result of using a fake physics system has no guarantee of the results and it's hard to make it work properly by physical intuition.

And yes i had tried a wrong way because i could not integrated the demo to Unity at the first place. But the thing is that i did not reallize linking to a static body will finally leads to violation of physics laws until your newest explaination. If i've known this, i would have never tried that!

Julio Jerez wrote:I will try again one more time. but I will not repeat it any more.
Basically you have a chain of small bodies that when they all combined offer a strong resistance to the motion of just one body.
if you connect the to first body to a another static body, all methods of motion will be in violation of some laws conservation of momentum, and in Newton conservation of momentum is the foundation of the technology, It is not not an impulse based engine.
moving the static body is wrong because this adds an infinite amount of momentum to the system since static bodies have infinite mass.
linking a body to another static body is also wrong because physics is all about conservation of momentum, so when you move one link, since the link is equal mass and inertia to the other links, then if can not transferred enough angular momentum to the other links and any small friction generated by the joints or collision is enough to act as strong noise on the input.

In a nutshell what you want is that the momentum vector of the body that is controlling the motion remain unchanged or change very little when adding the external impulse for the person controlling the thing.

since momemtum is L = mass * veloc;

there are only three ways to do this, you change the velocity, you change the mass or you change
both.

the desired effect is that when you add a delta impulse to the control body, that body transmit some of momentum the to the chain.
In this problem the velocity can not be too large so you need to change the mass.

if you do not change the mass then any small velocity will add a small delta impulse to the momentum of the body making the current vector change a lot, even worse the reaction forces will also add reaction momentum to the control body making the net momentum vector practically random.

if the body was very massive compared to the rest of the links, any small velocity and angular velocity acting as input is does not change the current momentum vector by a lot so the system is stable because it can recover for small perturbation of the momentum vector. How much small perturbation can be added, should be the parameter to tune, and it is the reason for the chain to get entangled.

I can go on a technical explanation of this, it comes right out of the equations of conservation of momentum, but I hope an intuitive explanation is sufficient to explain why fiddling with a static body is not the physically plausible way to do it.


Thanks for your detailed explanation. And i must admit that i even feel normal about some fake physics for the past half year. Now i will use Newton in the real physics way avoiding including any infinite mass body in the momentum system. And use a relative massive body to get the handle as stable as possible as you do in the demo. I am turning back to intergrate the demo now. To get real physics! :D
Charles
 
Posts: 43
Joined: Thu Jan 16, 2020 12:58 am

Re: A SERIOUS SURGICAL simulation!

Postby Charles » Fri Feb 21, 2020 3:10 am

I have just finished the integration of the rod demo into Unity, and change the angular friction bigger to 2000 to make the handle stable. It seems the same as the c++ demo now.
https://youtu.be/jpEX_k_An-Q
It turns out to be that the matrix of the socket joint is not properly set before. The position of the joint is not at the middle of the 2 bodies connected by each other as in the c++ demo.

I will try to override the default spring method of the BallAndSocket joint next! :D
Charles
 
Posts: 43
Joined: Thu Jan 16, 2020 12:58 am

Re: A SERIOUS SURGICAL simulation!

Postby Julio Jerez » Fri Feb 21, 2020 7:47 am

Ah very good.

Now the next problem to solve is the entanglement.

The reason for this is the viscuos drag among consecutive links, this should be the objective parameter to tune.

What happens is that between two consecutive links, each time they flex, they go into a state that violates the constrain angle be some amount.

Note that these violation are inevitable even in reality.
In reality this violations manifest in the form of vibration or plasticity, because all material has some degree of elasticity or plasticity, therefore they deform under stress.
In a rigid body numerical simulation, ideally body should not deform, but unfortunately they have to be numerically integrated and all numerical integration are an approximations of a close form numerical equation.

In Newton the way numerical integration errors in joint is dealt with, is adding a small regularization factor to the diagonal of the mass matrix of the system and the on right side of the equation adding a super critically damped strong spring damper factor.

It is the super critically damped part that makes the error to be corrected gradually at a constant speed, while the spring add the needed acceleration to reduce the violation error.

The problem on this case is that the recovering speed is too slow, so what happens between any two adjacents links when their constrain angle is violated, is that they are not obey conservation of momentum, in fact they are trying to burn some momentum proportional to the angle violation.
The result is that the momentum is not transferred properly as desired by the kinematic relation stablished by the joint.

The solution is to override the spring damper of the cone part of the joint and make the damper sufficiently small to make the joint critically damper.

This will allows some amount of twist without entangle as long as the transfer of momemtum is small enough that can be deal with by the joint.

Notice that the final system will be such that will behave as desire under some angular velocity limits, but if you appply too much rotation then it will overwelme the joint and the link will not transfer the axial angular momentum.

What this will gives you is a window of rotarion in which the system will act as desire and outside that window will entangled again.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: A SERIOUS SURGICAL simulation!

Postby Dave Gravel » Fri Feb 21, 2020 8:58 am

It turns out to be that the matrix of the socket joint is not properly set before. The position of the joint is not at the middle of the 2 bodies connected by each other as in the c++ demo.

It is what I have see when I have say:
Again maybe i'm wrong but in your first video the joints pin look incorrect.

Cool it look to work a lot better now :D
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: A SERIOUS SURGICAL simulation!

Postby Charles » Mon Feb 24, 2020 9:51 pm

Julio Jerez wrote:This will allows some amount of twist without entangle as long as the transfer of momemtum is small enough that can be deal with by the joint.

Notice that the final system will be such that will behave as desire under some angular velocity limits, but if you appply too much rotation then it will overwelme the joint and the link will not transfer the axial angular momentum.

What this will gives you is a window of rotarion in which the system will act as desire and outside that window will entangled again.


Hi Jerez, it sounds great! :D How is it going? Can't wait to have a try! There are some very details that I really can't handle now when trying to do it myself.
Charles
 
Posts: 43
Joined: Thu Jan 16, 2020 12:58 am

Re: A SERIOUS SURGICAL simulation!

Postby Julio Jerez » Tue Feb 25, 2020 6:36 pm

ok, I was hoping you could figured it out yourself.
It's ok, I try to set it up tonight them.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: A SERIOUS SURGICAL simulation!

Postby Charles » Tue Feb 25, 2020 8:52 pm

Julio Jerez wrote:ok, I was hoping you could figured it out yourself.
It's ok, I try to set it up tonight them.


Thanks, I will learn by comparing yours with mine! :D
Charles
 
Posts: 43
Joined: Thu Jan 16, 2020 12:58 am

PreviousNext

Return to User Gallery

Who is online

Users browsing this forum: No registered users and 5 guests