Home › Forum › SOFA › Using SOFA › [SOLVED] Creating attractive forces
Tagged: 32_bits, SOFA_1912, Windows_10
- This topic has 4 replies, 2 voices, and was last updated 4 years, 3 months ago by mikelitu.
-
AuthorPosts
-
20 July 2020 at 12:06 #16906mikelituBlocked
Hello everyone,
I am trying to build an attractive path over a mesh surface to travel with my haptic device. For this purpose I want to generate a line connecting different control points from the surface and create an attractive force over it. I am new to SOFA and I do not know how to extract all the needed information for this purpose. How can I extract some indices from a mesh surface and generate a line over them? How can I generate an attractive force (similar to gravity), over this line? Thank you for your attention.
Mikel
21 July 2020 at 17:41 #16923HugoKeymasterHey @mikelitu
For this, you can use the component RepulsiveSpringForceField. It is an old and dirty class but working. It will create an attractive (if stiffness<0) or repulsive (if stiffness>0) force between points of two different MechanicalObjects.
Here is an example :
<?xml version="1.0"?> <Node name="root" dt="0.001" gravity="0 0 0"> <VisualStyle displayFlags="showBehaviorModels showForceFields" /> <DefaultPipeline verbose="0" draw="0" /> <BruteForceDetection name="N2" /> <MinProximityIntersection name="Proximity" alarmDistance="0.8" contactDistance="0.5" /> <DefaultContactManager name="Response" response="default" /> <Node name="Floor"> <RegularGridTopology nx="30" ny="1" nz="30" xmin="7" xmax="-7" ymin="-4" ymax="-4" zmin="-7" zmax="7"/> <MechanicalObject template="Vec3d" name="FloorMO" showObject="1"/> </Node> <Node name="cubeFEM"> <EulerImplicitSolver name="cg_odesolver" printLog="false" /> <CGLinearSolver iterations="25" name="linear solver" tolerance="1.0e-9" threshold="1.0e-9" /> <MechanicalObject template="Vec3d" name="cubeMO"/> <UniformMass vertexMass="0.25" /> <RegularGridTopology nx="5" ny="5" nz="5" xmin="-3.5" xmax="3.5" ymin="-3.5" ymax="3.5" zmin="-3.5" zmax="3.5" /> <TetrahedronFEMForceField name="FEM" youngModulus="25" poissonRatio="0.3" computeGlobalMatrix="false" updateStiffnessMatrix="false" method="large" /> <RepulsiveSpringForceField template="Vec3d" name="RSFF" stiffness="-200" damping="100" length="1" object1="@cubeMO" object2="@../Floor" indices1="0 4 100 104 52" indices2="232 217 682 667 435"/> <Node name="Visu"> <MeshObjLoader name='myLoader' filename='mesh/smCube125.obj'/> <OglModel name="Visual" src="@myLoader" color="red" /> <SubsetMapping input="@.." output="@Visual" /> </Node> </Node> </Node>
you can use it to adapt it to your case.
BestHugo
21 July 2020 at 17:55 #16924mikelituBlockedHello Hugo,
Thank you for your answer I will try this fuction and will adapt it to my case.
Best,
Mikel30 July 2020 at 15:14 #16994HugoKeymaster31 July 2020 at 09:13 #16995 -
AuthorPosts
- You must be logged in to reply to this topic.