-
Hello, I'm playing around with changing out the collision model in the Geomagic haptics plugin, as implemented in the "Geomagic-FEMLiver.scn" example. The purpose is to get custom instrument representations, and to improve collision detection (sometimes the line collision model goes through the deformable object mesh). Code sample below. From the Liver example, I would expect there to be a visual model, and a collision model. However, there are these two reference models in addition - "refModelRight" and "refModelLeft", and I'm having a hard time wrapping my head around what these actually do. Does anybody know why they are needed? Best, #OMNI NODE BEGIN****
omni = rootNode.addChild('Omni')
omni.addObject('MechanicalObject', name='DOFs', template='Rigid3d', position='@GeomagicDevice.positionDevice')
omni.addObject('MechanicalStateController', template="Rigid3d", listening="true", mainDirection="1 0 0", handleEventTriggersUpdate="true")
visuAvatar = omni.addChild('visuAvatar', activated="false")
visuAvatar.addObject('MeshOBJLoader', name="meshLoader_0", filename="mesh/sphere.obj", scale="0.1", handleSeams="1")
visuAvatar.addObject('OglModel', name="Visual", src="@meshLoader_0", color="gray")
visuAvatar.addObject('RigidMapping', input="@..", output="@Visual", index="0")
refModel = omni.addChild('refModel')
refModel.addObject('MeshOBJLoader', name="loader", filename="Demos/Dentistry/data/mesh/dental_instrument_centerline.obj")
refModel.addObject('MeshTopology', src="@loader")
refModel.addObject('MechanicalObject', src="@loader", name="instrumentRefState1", ry="-180", rz="-90", dz="3.5", dx="-0.3")
refModel.addObject('RigidMapping')
refModelRight = omni.addChild('refModelRight')
refModelRight.addObject('MeshOBJLoader', name="loader", filename="Demos/Dentistry/data/mesh/dental_instrument_centerline.obj")
refModelRight.addObject('MeshTopology', src="@loader")
refModelRight.addObject('MechanicalObject', src="@loader", name="instrumentRefState2", ry="-180", rz="-90", dz="3.5", dx="-0.3")
refModelRight.addObject('RigidMapping')
refModelLeft = omni.addChild('refModelLeft')
refModelLeft.addObject('MeshOBJLoader', name="loader", filename="Demos/Dentistry/data/mesh/dental_instrument_centerline.obj")
refModelLeft.addObject('MeshTopology', src="@loader")
refModelLeft.addObject('MechanicalObject', src="@loader", name="instrumentRefState3", ry="-180", rz="-90", dz="3.5", dx="-0.3")
refModelLeft.addObject('RigidMapping')
#OMNI NODE END****
#INSTRUMENT NODE BEGIN****
geomagic = rootNode.addChild('Instrument')
geomagic.addObject('EulerImplicitSolver', name="ODE solver", rayleighStiffness="0.05", rayleighMass="1.0")
geomagic.addObject('CGLinearSolver', name="linear solver", iterations="25", tolerance="1.0e-10", threshold="10.0e-10")
geomagic.addObject('MechanicalObject', name='instrumentState', template='Rigid3d')#, position="-3 -3 -3 0 0 0 1")
geomagic.addObject('UniformMass', name="mass", totalMass="0.5")
geomagic.addObject('LCPForceFeedback', activate="true", forceCoef="0.1")
geomagic.addObject('UncoupledConstraintCorrection')
#Instrument visual model
instrumentVisu = geomagic.addChild('InstrumentVisualModel')
instrumentVisu.addObject('MeshOBJLoader', name="loader", filename="Demos/Dentistry/data/mesh/dental_instrument.obj", handleSeams="1")
instrumentVisu.addObject('OglModel', name="InstrumentVisualmodel", src="@loader", color="1.0 0.2 0.2 1.0", ry="-180", rz="-90", dz="3.5", dx="-0.3")
instrumentVisu.addObject('RigidMapping', name="MM->VM mapping", input="@instrumentState", output="@InstrumentVisualModel")
#Instrument collision model
instrumentCollision = geomagic.addChild('instrumentCollision')
instrumentCollision.addObject('MeshOBJLoader', name="loader", filename="Demos/Dentistry/data/mesh/dental_instrument_centerline.obj")
instrumentCollision.addObject('MeshTopology', src="@loader")
instrumentCollision.addObject('MechanicalObject', name="instrumentCollisionState1", src="@loader", ry="-180", rz="-90", dz="3.5", dx="-0.3")
instrumentCollision.addObject('LineCollisionModel', contactStiffness="10")
instrumentCollision.addObject('PointCollisionModel', contactStiffness="10")
instrumentCollision.addObject('RigidMapping', name="MM->CM mapping", input="@instrumentState", output="@instrumentCollisionState1")
#Instrument RefModelRight
refModelRight = geomagic.addChild('refModelRight')
refModelRight.addObject('MeshOBJLoader', name="loader", filename="Demos/Dentistry/data/mesh/dental_instrument_centerline.obj")
refModelRight.addObject('MeshTopology', src="@loader")
refModelRight.addObject('MechanicalObject', name="instrumentCollisionState2", src="@loader", ry="-180", rz="-90", dz="3.5", dx="-0.3")
refModelRight.addObject('RigidMapping', name="MM->CM mapping", input="@instrumentState", output="@instrumentCollisionState2")
#Instrument RefModelLeft
refModelLeft = geomagic.addChild('refModelLeft')
refModelLeft.addObject('MeshOBJLoader', name="loader", filename="Demos/Dentistry/data/mesh/dental_instrument_centerline.obj")
refModelLeft.addObject('MeshTopology', src="@loader")
refModelLeft.addObject('MechanicalObject', name="instrumentCollisionState3", src="@loader", ry="-180", rz="-90", dz="3.5", dx="-0.3")
refModelLeft.addObject('RigidMapping', name="MM->CM mapping", input="@instrumentState", output="@instrumentCollisionState3")
#Vector spring force field
geomagic.addObject('VectorSpringForceField', template="Vec3d", object1="@Omni/refModel/instrumentRefState1", object2="@Instrument/instrumentCollision/instrumentCollisionState1", stiffness="10", viscosity="0")
geomagic.addObject('VectorSpringForceField',template="Vec3d", object1="@Omni/refModelRight/instrumentRefState2", object2="@Instrument/refModelRight/instrumentCollisionState2", stiffness="10", viscosity="0")
geomagic.addObject('VectorSpringForceField',template="Vec3d", object1="@Omni/refModelLeft/instrumentRefState3", object2="@Instrument/refModelLeft/instrumentCollisionState3", stiffness="10", viscosity="0")
#INSTRUMENT NODE END*** |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
That is strange. What happens when you remove them ? I suppose nothing apart from the fact that the link between the 'Insutrument' and the 'omni' is less stiff ? This may come from old tests done with that ? I am not sure, let's see what the others think of it |
Beta Was this translation helpful? Give feedback.
-
Okay, so I updated the Geomagic scene using the same structure as suggested with the Force Dimensions plugin (see https://gitlab.com/polyakovkrylo/forcedimensions/-/blob/master/scenes/OmegaInstrumentController.scn?ref_type=heads) This seems to give more or less the same result but with less code, and runs very well on my computer. And it's easier to understand. I suppose the "RestShapeSpringsForceField" in the code below does the same job as the "VectorSpringForceField" in the code above.
|
Beta Was this translation helpful? Give feedback.
Okay, so I updated the Geomagic scene using the same structure as suggested with the Force Dimensions plugin (see https://gitlab.com/polyakovkrylo/forcedimensions/-/blob/master/scenes/OmegaInstrumentController.scn?ref_type=heads)
This seems to give more or less the same result but with less code, and runs very well on my computer. And it's easier to understand. I suppose the "RestShapeSpringsForceField" in the code below does the same job as the "VectorSpringForceField" in the code above.