Home › Forum › SOFA › Using SOFA › [SOLVED] Issue of error simulating catheter using CatmullRomSplineMapping etc components
Tagged: 64_bits, catheter, CatmullRomSplineMapping, SOFA_1608, Windows_7
- This topic has 10 replies, 2 voices, and was last updated 7 years, 5 months ago by shang.
-
AuthorPosts
-
27 April 2017 at 03:31 #9010shangBlocked
Hi sofa consortium,
I have always been trying to simulate a catheter in my VR-based endovascular interventional surgical system, and I found a component called CatmullRomSplineMapping, this can simulate a spline like the following pic.
but a problem rose when I simulate my scene file which is attached with the email.
the component is always created in a failure just like the pic below
I am looking forward to get some tips from the consortium, I will appreciate .
the scene file is followed below:<?xml version=”1.0″ ?> <Node name=”root” dt=”0.01″> <VisualStyle displayFlags=”showForceFields showCollisionModels” /> <RequiredPlugin name=”Geomagic plugin” pluginName=”Geomagic” /> <CollisionPipeline name=”pipeline” depth=”6″ verbose=”0″/> <BruteForceDetection name=”detection” /> <CollisionResponse name=”response” response=”FrictionContact” /> <LocalMinDistance name=”proximity” alarmDistance=”0.15″ contactDistance=”0.05″ angleCone=”0.0″ /> <FreeMotionAnimationLoop/> <LCPConstraintSolver tolerance=”0.001″ maxIt=”1000″/> <GeomagicDriver name=”GeomagicDevice” deviceName=”Default Device” scale=”1″ drawDeviceFrame=”1″ positionBase=”0 0 0″ orientationBase=”0 0.707 0 -0.707″ /> <Node name=”omni”> <MechanicalObject template=”Rigid” name=”DOFs” position=”@GeomagicDevice.positionDevice”/> <MechanicalStateController template=”Rigid” listening=”true” mainDirection=”-1.0 0.0 0.0″ handleEventTriggersUpdate=”true”/> <Node name=”VisuAvatar” activated=”false” > <OglModel name=”Visual” fileMesh=”mesh/sphere.obj” color=”gray” scale=”0.1″/> <RigidMapping input=”@..” output=”@Visual” index=”0″/> </Node> <Node name=”RefModel”> <Mesh name=”lines” lines=”0 1 1 2 2 3 3 4 4 5 5 6 6 7″ /> <MechanicalObject template=”Vec3d” name=”instrumentCollisionState” translation=”0 0 1″ position=”0 0 0 1 0 0 2 0 0 3 0 0 4 0 0 5 0 0 6 0 0 7 0 0″ /> <RigidMapping /> </Node> </Node> <Node name=”Instrument”> <EulerImplicitSolver rayleighStiffness=”0.01″ rayleighMass=”0.01″ /> <CGLinearSolver template=”GraphScattered” iterations=”20″ threshold=”1e-008″ tolerance=”1e-5″ /> <MechanicalObject name=”instrumentState” position=”@GeomagicDevice.positionDevice” template=”Rigid” /> <UniformMass name=”mass” totalmass=”0.005″ /> <LCPForceFeedback activate=”true” forceCoef=”0.005″/> <!– ADDED : Compute a force-feedback for the device –> <UncoupledConstraintCorrection/> <Mesh name=”lines” lines=”0 1 1 2 2 3 3 4 4 5 5 6 6 7″ /> <MeshSpringForceField name=”Springs” stiffness=”100000″ damping=”0″ /> <LineBendingSprings name=”BS” stiffness=”100″ damping=”0″ /> <EdgeSetTopologyContainer /> <EdgeSetTopologyModifier /> <Node name=”CollisionModel”> <Mesh name=”lines” lines=”0 1 1 2 2 3 3 4 4 5 5 6 6 7″ /> <MechanicalObject name=”instrumentCollisionState” /> <CatmullRomSplineMapping input=”@instrumentState” output=”@instrumentCollisionState” SplittingLevel=”3″ /> <Line /> <Point /> <RigidMapping name=”MM->CM mapping” input=”@instrumentState” output=”@instrumentCollisionState” /> </Node> <VectorSpringForceField template=”Vec3d” object1=”@Omni/RefModel/instrumentCollisionState” object2=”@Instrument/CollisionModel/instrumentCollisionState” stiffness=”10″ viscosity=”0″ /> </Node> </Node>
Thank you!
27 April 2017 at 03:33 #9011shangBlockedsorry, i tried to outlined the code, but it did not work like i edited using indentation when posted it.
27 April 2017 at 10:40 #9012HugoKeymasterHi @xiaojuan,
I fixed the layout for you. You need to set the code marker at the beginning, jump a line and at the end set another code marker.
It looks like a pretty old component. At least, I did not know it!
The scene examples/Components/mapping/CatmullRomSplineMapping.scn is working fine for me. I am using the master branch on Linux. Are you using SOFA v16.08 ?Otherwise, you can look at the BeamFEMForceField example (examples/Components/forcefield/BeamFEMForceField.scn). Hope this helps
Hugo
27 April 2017 at 15:27 #9016shangBlockedhi hugo, actually, the scene file I posted is not the file CatmullRomSplineMapping.scn in examples/Components/mapping/CatmullRomSplineMapping.scn, I changed it and made a certain scene file of myself. I want to simulate the catheter and give it a forcefield and map it with the geomagic device. But it seems that there exists many problems of the communication between geomagic device and the catheter model with a forcefield or other components. Is this really true that no one can solve this problem? @Hugo
2 May 2017 at 18:35 #9036HugoKeymasterHey Xiaojuan,
By comparing your scene with the CatmullRomSplineMapping.scn, I noted that you were using a Rigid template for the MechanicalObject, whereas the CatmullRomSplineMapping does only handle Vec3d/Vec3f types.
Hugo
3 May 2017 at 00:51 #9038shangBlockedwow,that may exactly be the problem, thank you a lot, Hugo! I will try it.
18 May 2017 at 17:33 #912919 May 2017 at 11:09 #9137shangBlockedDear Hugo,
thank you for asking, actually, I followed your advice and adopted the BeamFEMforceField to simulate the catheter that I need, and what i need to do next is to link the geomagic device, Touch X with the virtual catheter. but as we can see in the “catheter” node<Node name="catheter"> <EulerImplicit rayleighStiffness="0" printLog="false" /> <BTDLinearSolver template="BTDMatrix6d" printLog="false" verbose="false" /> <MechanicalObject template="Rigid" name="DOFs" position="0 0 0 0 0 0 1 1 0 0 0 0 0 1 2 0 0 0 0 0 1 3 0 0 0 0 0 1 4 0 0 0 0 0 1 5 0 0 0 0 0 1 6 0 0 0 0 0 1 7 0 0 0 0 0 1" /> <Mesh name="lines" lines="0 1 1 2 2 3 3 4 4 5 5 6 6 7" /> <FixedConstraint name="FixedConstraint" indices="0" /> <UniformMass mass="1 1 0.01 0 0 0 0.1 0 0 0 0.1" printLog="false" /> <BeamFEMForceField name="FEM" radius="0.1" youngModulus="20000000" poissonRatio="0.49"/> <Node name="Collision"> <CubeTopology nx="15" ny="2" nz="2" min="0 -0.1 -0.1" max="7 0.1 0.1" /> <MechanicalObject /> <BeamLinearMapping isMechanical="true" /> <Triangle /> </Node> </Node>
I have no idea how to map position of the first point of the catheter to the Touch X geomagic device, so I tried to write python scripts using PythonScriptController component to realize this goal,and the python script is as follows:
import sofa class geomagic(Sofa.PythonScriptController): def onLoaded(self,node): self.rootNode = node.getRoot() self.MechanicalState = node.getObject('deviceDOFs') return 0 def onBeginAnimationStep(self,dt): data = self.MechanicalState.position self.rootNode.sendScriptEvent('geoPos',data) return 0 class catheter(Sofa.PythonScriptController): def onLoaded(self,node): self.MechanicalState = node.getObject('catheterDOFs') return 0 catheterPos = self.MechanicalState.position def onScriptEvent(self,senderNode,eventName,data): if eventName = 'geoPos' catheterPos[0] = data self.MechanicalState.position = catheterPos return 0
the callback of PythonScriptController component in XML is like
<PythonScriptController name="device" filename="catheterScripts.py" classname="geomagic"/>
but error occured like the image shows
20 May 2017 at 04:19 #9138shangBlockedI have figured out the problems, it is about the python syntax problems, I have accomplished to control the catheter by keyboard, but I still can not successfully map the position value between virtual catheter(the FEM beam) and the geomagic device. And I am trying to revise my python code to have a try. Than you very much! @Hugo
30 May 2017 at 16:03 #9222HugoKeymasterOk xiaojuam, since you opened this new thread for the mapping problem, shall we close this topic ?
Cheers.Hugo
2 June 2017 at 14:50 #9248shangBlockedok, that’s ok, sorry being so late!
-
AuthorPosts
- You must be logged in to reply to this topic.