Forum Replies Created
-
AuthorPosts
-
3 November 2021 at 20:56 in reply to: Problems with ‘CubeTopology’ when using ‘BeamFEMForceField’ #20737AndrijaBlocked
Hi @hugo,
Many thanks for your great help and for the reply (no worries with time of response I know you are busy).
Yes thanks for all the help, information and links! It makes sense, I will try what you proposed.
No we didn’t consider using RigidMapping, but thanks! Sounds like great idea, and actually something that maybe is more easier to implement. We will look into it. When we have the update I will post our solution here.
Thanks again!
Best,
Andrija8 October 2021 at 17:14 in reply to: Problems with ‘CubeTopology’ when using ‘BeamFEMForceField’ #20566AndrijaBlockedHi @hugo,
Thank again for the help.
I am not sure what you meant exactly. To avoid confusion (from my side), here are the images where I marked the frames / beams:
https://drive.google.com/file/d/1hjtRaWu0yc-qZAHnl6HKgTCkboEm_5uj/view?usp=sharing
https://drive.google.com/file/d/1rSxMR0pK3m6SJW34Amzya7D5yKqo2y1c/view?usp=sharing
Following this, yes it seems to me fine for the frame 1 and 2. The problem is when I go from frame 2 to frame 3, as you see there is an unwanted curvature in mesh for the collision model.
If we follow this numeration of frames, like I illustrated on the images, then I didn’t try what you suggested. I am not entirely sure how to do what you propose? In general I think I understand what you want to say, that by taking the derivative it should give the right orientation and then the mesh should be better. But don’t know how exactly to do this? To have a function that represents a line between the frame 2 and 4 (line through 2 points), then to find the derivative of this, which should give me the right orientation of frame 3?
Did I understood right?
Thanks!!!
Best,
Andrija8 October 2021 at 07:49 in reply to: Problems with ‘CubeTopology’ when using ‘BeamFEMForceField’ #20554AndrijaBlockedHi @hugo,
Thank you for your fast reply. Yes sorry I don’t know why the images didn’t loaded.
Here are the images again:
If they don’t work again, here are the links:
https://drive.google.com/file/d/1aDP362Jc1GDRZkGJJMcVF_Bn8ApuA6CX/view?usp=sharing
https://drive.google.com/file/d/18sDEAdAExjIuAsUxlxSc3DTDsTkAWQJ-/view?usp=sharing
The only workourn so far that I manage to find is not to use any mesh for the collision model but rather just lines and point of the beams, i.e. to use this:
Visu = mechanics.addChild('Visu') Visu.addObject("MechanicalObject") Visu.addObject("IdentityMapping") Visu.addObject("LineCollisionModel") Visu.addObject("PointCollisionModel", name="FloorPoint")
But still the problem remains if I want to use a
CubeTopology
.It is great to hear if you will somehow enable this in the next version 🙂 !
Thanks again for the help!!!
Best regards,
Andrija6 October 2021 at 11:32 in reply to: Cannot import SofaRuntime form python interpreter, no module found #20522AndrijaBlockedHi I resolve this.
I didn’t put the right path to my
SOFA_ROOT
. Now everything is working!Thanks!
19 March 2021 at 11:57 in reply to: Simulating deformation of a simple set of beams via BeamFEMForceField #18926AndrijaBlockedHi @hugo,
Many thanks again for the reply.
Yes that is what I would like. To couple or use both
FixedConstraint
andFixedRotationConstraint
but apply them only to desired indices. In my case I would like to fix both translation and rotation of the indices 0. Is seems like there is no option that I useFixedRotationConstraint
but apply only to the desired indices. When I write this in my code/scene:
mechanics.createObject("FixedRotationConstraint", template="Rigid3d", name="fixRotation", indices="0", FixedXRotation="1", FixedYRotation="1", FixedZRotation="1")
I get the warning message meaning that this attribute for selecting incidences was not used.
Unused Attribute: "indices" with value: "0" (/Mechanics/fixRotation)
I really don’t know how to apply thisFixedRotationConstraint
to only for example indices 0? Or if there is some other ways to constrain all degrees of freedom of indices 0 (desired indices in general)?It would be really great to have a chat with you then I can share in more depth what we are trying to do at the end, and what is our project about. Think it would be interested for you and SOFA. Of course we are more then happy to promote SOFA with citations in our future papers, in general as a really great framework to use.
I am free in the next weeks, feel free to write me or reach me out at: Andrija.Milojevic@lut.fi, or use my email address I use and registered here at SOFA forum. Then we can correspond about the meeting. It would be great to share what we are doing in SOFA, or trying to do 🙂 .
I am looking forward hearing from you!
Best regards,
Andrija18 March 2021 at 17:36 in reply to: Simulating deformation of a simple set of beams via BeamFEMForceField #18919AndrijaBlockedHi @hugo,
Many thanks for the reply and great help!!!
Actually that did the trick and solved what I was searching for. This is what I asked. Sorry for some reason the links to figures I provided didn’t work out, and I provided the figures to better illustrate what I was asking. But the line of code you wrote worked quite nicely for me.
Sorry I have another question in relation to this. How it is possible to fix all degrees of freedom in only certain desired indices? I mean how to constrain motion, both translation and rotation degrees of freedom? In the example and code above, how I can fix both translation and rotation of indices 0?
Using the
FixedConstraint
, seems to constraint only translation degrees of freed but not rotation. Then when I try to useFixedRotationConstraint
, there is no option to constrain the rotation of only indices I want (e.g. indices 0), but rather when I use it it constraints rotation of all the indices. Or maybe I don’t know how to apply this constrain in the right way. Can you maybe help you with some suggestions what I can use?If you are free/interested I can share more about my project in SOFA and what we are trying to realize, maybe we can promote SOFA through our project, and vice verse. Feel free to reach me out for possible organizing meeting in the future.
Thanks!
Best,
AndrijaAndrijaBlockedHi @hugo,
My problem now is to effectively connect the Articulations with deformable bodies (my input ports). But do you (others) think that using Rigidify to for example transform some nodes of my inputs to rigid nodes (e.g. middle point node of my input ports), and then create Articulations between rigid DoF would help? It seems to me in theory it would work?
Below is a part of code I managed to find from the Triopd tutorial
https://github.com/SofaDefrost/SoftRobots/blob/master/docs/tutorials/Tripod/details/step4-3.pyscnBut this part is a bit hard to read, or impelement in my case since I used different setup of the scene. Any idea how I could adopt it to my scene in my previous comments?
# Rigidify the deformable part at extremity to attach arms rigidifiedstruct = Rigidify(self.node, deformableObject, groupIndices=groupIndices, frames=frames, name="RigidifiedStructure") rigidifiedstruct.DeformableParts.createObject("UncoupledConstraintCorrection") rigidifiedstruct.RigidParts.createObject("UncoupledConstraintCorrection")
I would appreciate any help!
Thanks!
Best,
AndrijaAndrijaBlockedHi,
Thanks @hugo! Keep up the great work. I believe you are doing a really important work and contribution with SOFA. Hope in the future more interesting plugins and invitations will come in SOFA. Hope also the community will contribute in growing and expanding SOFA, giving more ideas and applications for the future.
Best,
AndrijaAndrijaBlockedHi everyone,
I think moving to github discussions is a good option. Maybe is better for tracking the issues, problems and questions that people ask. Also as someone mentioned, it is a bit better for searching, and maybe later would be easier for you to sort out issues by topics i.e. open new separate sections and topics as you did here for Soft Robotics. Additionally if some novel ideas for future implementation in SOFA poops up I guess it would be more easier to track this and then implement and share via github and link things to direct solutions.
Independent on this. What I would really like to have as an option, just a general suggestion, is to have some options for online chat. Then maybe the people who are already online and working on their projects in SOFA could directly help and chat with others, in order to solve the problems and issues posted. I don’t know if some of these options already exist, but I would consider opening some Slack channel, or maybe using Discord. Think then maybe people could help directly, but guess the downside would be that once you solve the problem, you would need to post the solution back to forum or github discussions. But don’t know if people would do it in general. Overall I think maybe people would be more connected in the community with the online chat, and help out on currently posting issues in short notice and that could not be resolved simply by posting the issue then waiting for reply, then trying out things, then posting, then waiting.
But all this is just a thought 🙂 .
Best,
AndrijaAndrijaBlockedHi @hugo,
Many thanks for your reply. I am still struggling with this one and I literary tried so many things. I think also it is a bit hard to explain like this without showing what is the problem. But let me try.
Yes you are right, the question is now how to define a spring like element that would be attacked to both input ports, so that when I apply for example
LinearForceField
at both ends, the input ports would move only in axial direction i.e. direction of spring element? The system should behave so like the spring has infinity stiffness in all directions except the axial direction. And keeping in mind that my two input ports can globally move within the work space, meaning that usingPartialFixedConstraint
would not work, as it would constrain the spring globally.I tried using the Cable but this will not do for my system as when I use it I get some undesired motion of input ports in other directions, beside the axial motion. But since I last posted this problem I tried many things. @scheikl proposed to use
ArticulatedSystemMapping
and I tired this as well. See the code below. What I did is I made the Articulation between my two input ports, where now when I apply displacement or force at the articulations it moves only in axial direction and the whole articulation system can move globally with the two input ports. Disregard that for the time being one input port is fixed (this is just so that the system don’t fly away as I didn’t yet put floor, not to complicate the scene at this stage), and also disregard that for the left input port, articulation base point is placed at the attached point of the input port. You will see in the code. But the problem here is when I tired to attach the other end of the articulation system to the right input port. This is not working. I tried to attach them by creating a connecting point at my Input port 2 in formMechanicalObject
,Rigid3d
then mapping this withBarycentricMapping
. Then I tired to connect this point with the articulation system, by using:
AttachConstraint
– this does not work properly for some reason, the Input port 2 can freely move in space, like it is connected with very weak spring to the articulation. And I tired usingtwoWay
nothing happens.
StiffSpringForceField
– this does not exactly connect them as there is some undesired motion, feel free to see. The input is attached to articualtion but it can rotate around connecting point.
RestShapeSpringsForceField
– the same like above.I know that
BilateralInteractionConstraint
would in general work for connecting these, but for some reason this does not work in my scene as it is required to useFreeMotionAnimationLoop
which when I use, then theArticulatedSystemMapping
does not work. You can try and see.In general, for me it would work as well if there is a way to somehow constrain the motion for example of my pointCon2, so that it can move only linearly in one direction (axial direction), but in such way that this constrain applies only to this point but you can normally golobaly move my two input ports. I tried applying
PartialFixedConstraint
andLinearMovementConstraint
to this point, but it does not work at all for some reason as pointCon2 is mapped to my Input_port2. When I remove mapping then normally all works. Maybe based on all this you will have more ideas.It would be great if you are open for a chat!!! That would be super helpful! Then I can share a couple of more things about my project what we are tying to do. I am a postdoc from LUT University in Finland. I know that you must be very busy but if you think it is possible to find the time to have a chat, feel free to write me! Don’t know how to reach you out?
Here is the code:
# Simulating contracting actuator import Sofa import os from stlib.scene import MainHeader, ContactHeader # Defining a scene def createScene(rootNode): # Inicilaize disply rootNode.createObject('VisualStyle', displayFlags='showForceFields showBehaviorModels showBehavior') # Required plugins rootNode.createObject('RequiredPlugin', name='soft', pluginName='SoftRobots') rootNode.createObject('RequiredPlugin', name='SofaPython', pluginName='SofaPython') rootNode.createObject('RequiredPlugin', name='OpenVis', pluginName='SofaOpenglVisual') # Animation loops # rootNode.createObject('FreeMotionAnimationLoop') # Constrain solver rootNode.createObject('GenericConstraintSolver', tolerance="1e-12", maxIterations="100000") # Input port 1 Input_port1 = rootNode.createChild('Input_port1') Input_port1.createObject('EulerImplicit', name='odesolver') Input_port1.createObject('SparseLDLSolver', name='directSolver') Input_port1.createObject('MeshGmshLoader', name='loader', filename='mesh\\CubeBlock.msh', rotation = [0, 90, 0], translation = [0, -10, 25]) Input_port1.createObject('Mesh', src='@loader', name='container') Input_port1.createObject('MechanicalObject', name='tetras', template='Vec3d', showObject='true', showObjectScale='1') Input_port1.createObject('TetrahedronFEMForceField', template='Vec3d', name='FEM', method='large', poissonRatio='0.4', youngModulus='8000', drawAsEdges="true") Input_port1.createObject('UniformMass', totalMass='0.1') # Adding supports Input_port1.createObject('BoxROI', name='boxROI', box='-5 0 -1 5 20 3', drawBoxes='true') Input_port1.createObject('RestShapeSpringsForceField', points='@boxROI.indices', stiffness='1e12', angularStiffness='1e12') # Visualization modelVisu1 = Input_port1.createChild('visu1') modelVisu1.createObject('MeshSTLLoader', name="loader", filename="mesh\\CubeBlock.stl", rotation = [0, 90, 0], translation = [0, -10, 25]) modelVisu1.createObject('OglModel', src="@loader", template='ExtVec3f', color='0.7 0.7 0.7 0.6') modelVisu1.createObject('BarycentricMapping') #Input_port1.createObject('LinearSolverConstraintCorrection', solverName='directSolver') Input_port1.createObject('UncoupledConstraintCorrection') # Input port 2 Input_port2 = Input_port1.createChild('Input_port2') Input_port2.createObject('EulerImplicit', name='odesolver') Input_port2.createObject('SparseLDLSolver', name='directSolver') Input_port2.createObject('MeshGmshLoader', name='loader2', filename='mesh\\CubeBlock.msh', rotation = [0, 90, 0], translation = [20, -10, 25]) Input_port2.createObject('Mesh', src='@loader2', name='container2') Input_port2.createObject('MechanicalObject', name='tetras2', template='Vec3d', showObject='true', showObjectScale='1') Input_port2.createObject('TetrahedronFEMForceField', template='Vec3d', name='FEM', method='large', poissonRatio='0.4', youngModulus='8000', drawAsEdges="true") Input_port2.createObject('UniformMass', totalMass='0.1') # # Adding supports # Input_port2.createObject('BoxROI', name='boxROI2', box='20 0 -1 25 20 3', # drawBoxes='true') # Input_port2.createObject('RestShapeSpringsForceField', points='@boxROI2.indices', # stiffness='1e12', angularStiffness='1e12') # Visualization modelVisu2 = Input_port2.createChild('visu2') modelVisu2.createObject('MeshSTLLoader', name="loader", filename="mesh\\CubeBlock.stl", rotation = [0, 90, 0], translation = [20, -10, 25]) modelVisu2.createObject('OglModel', src="@loader", template='ExtVec3f', color='0.7 0.7 0.7 0.6') modelVisu2.createObject('BarycentricMapping') #Input_port1.createObject('LinearSolverConstraintCorrection', solverName='directSolver') Input_port2.createObject('UncoupledConstraintCorrection') # Creating connecting point for Input port 1 - Rigid body pointCon1 = Input_port1.createChild('pointCon1') pointCon1.createObject('MechanicalObject', name="DOFpoint1", template="Rigid3d", position="13 5.5 6 0 0 0 0") pointCon1.createObject('BarycentricMapping') #pointCon1.createObject('BarycentricMapping') #pointCon1.createObject('EulerImplicit', name='odesolver') #pointCon1.createObject('CGLinearSolver', name="linear solver") articulation = rootNode.createChild("articulation") articulation.createObject('EulerImplicit', name='odesolver') articulation.createObject('CGLinearSolver', name="linear solver") articulation.createObject("MechanicalObject", name="Articulations", template="Vec1d", position=[0, 0, 0, 0]) # translation=[19, 16, 5] mechanics = articulation.createChild("Mechanics") mechanics.createObject("MechanicalObject", template="Rigid3d", name="DOFs", position=[ [0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [3, 0, 0, 0, 0, 0, 1], [5, 0, 0, 0, 0, 0, 1], [7, 0, 0, 0, 0, 0, 1] ]) mechanics.createObject("BeamFEMForceField", name="FEM", radius=0.1, youngModulus=10000, poissonRatio=0.45) mechanics.createObject("MeshTopology", name="lines", lines="0 1 1 2 2 3 3 4 ") mechanics.createObject("UniformMass", template="Rigid3d", name="mass", vertexMass="0.1 0.1 [1 0 0,0 1 0,0 0 1]") mechanics.createObject("FixedConstraint", template="Rigid3d", name="fixOrigin", indices=0) mechanics.createObject("ArticulatedSystemMapping", input1=articulation.Articulations.getLinkPath(), input2=pointCon1.DOFpoint1.getLinkPath(), output=mechanics.DOFs.getLinkPath()) # # Defining viusal model Visu = mechanics.createChild('Visu') Visu.createObject('OglModel', name="Visual", position="-1 -0.5 -0.5 -1 0.5 -0.5 -1 0.5 0.5 -1 -0.5 0.5 1 -0.5 -0.5 1 0.5 -0.5 1 0.5 0.5 1 -0.5 0.5 -1 -0.5 -0.5 -1 0.5 -0.5 -1 0.5 0.5 -1 -0.5 0.5 1 -0.5 -0.5 1 0.5 -0.5 1 0.5 0.5 1 -0.5 0.5 -1 -0.5 -0.5 -1 0.5 -0.5 -1 0.5 0.5 -1 -0.5 0.5 1 -0.5 -0.5 1 0.5 -0.5 1 0.5 0.5 1 -0.5 0.5 -1 -0.5 -0.5 -1 0.5 -0.5 -1 0.5 0.5 -1 -0.5 0.5 1 -0.5 -0.5 1 0.5 -0.5 1 0.5 0.5 1 -0.5 0.5", triangles="3 1 0 3 2 1 3 6 2 3 7 6 7 5 6 7 4 5 4 1 5 4 0 1 5 1 2 2 6 5 4 7 3 4 3 0 11 9 8 11 10 9 11 14 10 11 15 14 15 13 14 15 12 13 12 9 13 12 8 9 13 9 10 10 14 13 12 15 11 12 11 8 19 17 16 19 18 17 19 22 18 19 23 22 23 21 22 23 20 21 20 17 21 20 16 17 21 17 18 18 22 21 20 23 19 20 19 16 27 25 24 27 26 25 27 30 26 27 31 30 31 29 30 31 28 29 28 25 29 28 24 25 29 25 26 26 30 29 28 31 27 28 27 24") Visu.createObject('RigidMapping', template="Rigid3d,ExtVec3f", rigidIndexPerPoint="1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4", input="@..", output="@Visual") articulation.createObject("ArticulatedHierarchyContainer") centers = articulation.createChild("articulationCenters") center1 = centers.createChild("center1") center1.createObject("ArticulationCenter", parentIndex=0, childIndex=1, posOnParent=[0, 0, 0], posOnChild=[-1, 0, 0]) rotation1 = center1.createChild("articulations") rotation1.createObject("Articulation", translation=True, rotation=False, translationAxis=[1, 0, 0], articulationIndex=0) center2 = centers.createChild("center2") center2.createObject("ArticulationCenter", parentIndex=1, childIndex=2, posOnParent=[1, 0, 0], posOnChild=[-1, 0, 0], articulationProcess=2) rotation2 = center2.createChild("articulations") rotation2.createObject("Articulation", translation=True, rotation=False, translationAxis=[1, 0, 0], articulationIndex=1) center3 = centers.createChild("center3") center3.createObject("ArticulationCenter", parentIndex=2, childIndex=3, posOnParent=[1, 0, 0], posOnChild=[-1, 0, 0], articulationProcess=0) rotation3 = center3.createChild("articulations") rotation3.createObject("Articulation", translation=True, rotation=False, translationAxis=[1, 0, 0], articulationIndex=2) center4 = centers.createChild("center4") center4.createObject("ArticulationCenter", parentIndex=3, childIndex=4, posOnParent=[1, 0, 0], posOnChild=[-1, 0, 0], articulationProcess=1) rotation4 = center4.createChild("articulations") rotation4.createObject("Articulation", translation=True, rotation=False, translationAxis=[1, 0, 0], articulationIndex=3) # # Creating connecting point for Input port 2 - Rigid body pointCon2 = Input_port2.createChild('pointCon2') pointCon2.createObject('MechanicalObject', name="DOFpoint2", template="Rigid3d", position="20 5.5 6 0 0 0 0") pointCon2.createObject('BarycentricMapping') #articulation.createObject("UncoupledConstraintCorrection") #mechanics.createObject('RestShapeSpringsForceField', stiffness="10000", angularStiffness="1e50", external_rest_shape="@Input_port1/Input_port2/pointCon2", points="4", external_points="0", drawSpring="true", springColor="1 1 1 1") #pointCon2.createObject('RestShapeSpringsForceField', stiffness="500", angularStiffness="1e50", external_rest_shape="@articulation/Mechanics/DOFs", points="0", external_points="4", drawSpring="true", springColor="1 1 1 1") pointCon2.createObject('StiffSpringForceField', object1="@pointCon2/DOFpoint2", object2="@articulation/Mechanics/DOFs", spring="0 4 500 0.0 0.0") #rootNode.createObject('AttachConstraint', object1="@Input_port1/Input_port2", object2="@articulation/Mechanics/DOFs", twoWay="true", radius="0.1", indices1 = "73", indices2 = "4", constraintFactor="1 1")
AndrijaBlockedHey @hugo,
Thanks again for the reply. I know that you must be very busy with all ongoing things, and thanks for still wanting to help out.
To reply to your questions and further clarify things.
In the drawing, the red part along the axis is a spring like element, the two green input ports are deformable bodies, and the blue part (what I call robot body) is actually deformable body as well. So basically read part is a spring like element, all other parts are deformable bodies.
But to provide more in depth explanation. At the moment the bottom blue part is maybe not so important, as I would know how to connect my two green input ports to a blue part. We can pose the issue I am having like this. How to simulate a linear contracting actuator between my two green input ports so when I apply the force in axial direction, the actuator would move my two input ports only in axial direction, thus acting as a linear actuator for my system, where the actuator is in a form of a spring element (for example). Further the two input ports with my linear actuator could move globally in space (for example could freely move on some floor) – meaning that linear actuator/spring element can realize only linear axial motion relative to two input ports (green parts) but can globally move in space.
I posted some other specific questions regarding my issue in another topic, that I closed now as we could not find solution for this. But there @scheikl proposed that maybe using
ArticulatedSystemMapping
could help. But what I don’t know is how to use this between two deformable bodies. Below is a code of my initial scene. And you can download the meshes here:https://drive.google.com/drive/folders/1rCwFsuc9sYQZy3WmxnlZRbrnRGopb3mT?usp=sharing
Code:
# Simulating contracting actuator import Sofa import os from stlib.scene import MainHeader, ContactHeader # Defining a scene def createScene(rootNode): # Inicilaize disply rootNode.createObject('VisualStyle', displayFlags='showForceFields showBehaviorModels showBehavior') # Required plugins rootNode.createObject('RequiredPlugin', name='soft', pluginName='SoftRobots') rootNode.createObject('RequiredPlugin', name='SofaPython', pluginName='SofaPython') rootNode.createObject('RequiredPlugin', name='OpenVis', pluginName='SofaOpenglVisual') # Animation loops # rootNode.createObject('FreeMotionAnimationLoop') # Constrain solver rootNode.createObject('GenericConstraintSolver', tolerance="1e-12", maxIterations="100000") # Input port 1 Input_port1 = rootNode.createChild('Input_port1') Input_port1.createObject('EulerImplicit', name='odesolver') Input_port1.createObject('SparseLDLSolver', name='directSolver') Input_port1.createObject('MeshGmshLoader', name='loader', filename='mesh\CubeBlock.msh') Input_port1.createObject('Mesh', src='@loader', name='container') Input_port1.createObject('MechanicalObject', name='tetras', template='Vec3d', showObject='true', showObjectScale='1') Input_port1.createObject('TetrahedronFEMForceField', template='Vec3d', name='FEM', method='large', poissonRatio='0.4', youngModulus='8000', drawAsEdges="true") Input_port1.createObject('UniformMass', totalMass='0.1') # Adding supports Input_port1.createObject('BoxROI', name='boxROI', box='10 5 4 16 22 -3', drawBoxes='true') Input_port1.createObject('RestShapeSpringsForceField', points='@boxROI.indices', stiffness='1e12', angularStiffness='1e12') # Visualization modelVisu1 = Input_port1.createChild('visu1') modelVisu1.createObject('MeshSTLLoader', name="loader", filename="mesh\CubeBlock.stl") modelVisu1.createObject('OglModel', src="@loader", template='ExtVec3f', color='0.7 0.7 0.7 0.6') modelVisu1.createObject('BarycentricMapping') #Input_port1.createObject('LinearSolverConstraintCorrection', solverName='directSolver') Input_port1.createObject('UncoupledConstraintCorrection') # Input port 2 Input_port2 = Input_port1.createChild('Input_port2') Input_port2.createObject('EulerImplicit', name='odesolver') Input_port2.createObject('SparseLDLSolver', name='directSolver') Input_port2.createObject('MeshGmshLoader', name='loader2', filename='mesh\CubeBlock.msh', translation=[0.0, 0.0, 20.0]) Input_port2.createObject('Mesh', src='@loader2', name='container2') Input_port2.createObject('MechanicalObject', name='tetras2', template='Vec3d', showObject='true', showObjectScale='1') Input_port2.createObject('TetrahedronFEMForceField', template='Vec3d', name='FEM', method='large', poissonRatio='0.4', youngModulus='8000', drawAsEdges="true") Input_port2.createObject('UniformMass', totalMass='0.1') # Adding supports Input_port2.createObject('BoxROI', name='boxROI2', box='10 5 25 16 22 18', drawBoxes='true') Input_port2.createObject('RestShapeSpringsForceField', points='@boxROI2.indices', stiffness='1e12', angularStiffness='1e12') # Visualization modelVisu2 = Input_port2.createChild('visu2') modelVisu2.createObject('MeshSTLLoader', name="loader", filename="mesh\CubeBlock.stl", translation=[0.0, 0.0, 20.0]) modelVisu2.createObject('OglModel', src="@loader", template='ExtVec3f', color='0.7 0.7 0.7 0.6') modelVisu2.createObject('BarycentricMapping') #Input_port1.createObject('LinearSolverConstraintCorrection', solverName='directSolver') Input_port2.createObject('UncoupledConstraintCorrection') # Creating connecting point for Input port 1 - Rigid body pointCon1 = Input_port1.createChild('pointCon1') pointCon1.createObject('MechanicalObject', name="DOFpoint1", template="Rigid3d", position="19 16 5 0 0 0 0") pointCon1.createObject('BarycentricMapping') # Creating connecting point for Input port 2 - Rigid body pointCon2 = Input_port2.createChild('pointCon2') pointCon2.createObject('MechanicalObject', name="DOFpoint2", template="Rigid3d", position="19 16 17 0 0 0 0") pointCon2.createObject('BarycentricMapping')
What I basically setup above are two prismatic deformable objects that represent my two input ports. In general these two input ports will belong to one overall body/system, but this is not important for the current thing I am trying to solve i.e. am asking help. Temporally I fixed the two input ports, but this is just so that they don’t fly away before setting the full scene i.e. placing the blue par (robot body), the floor and adding collisions. I added two points that represent Rigid body –
Rigid3d
and they are connected to my input ports withBarycentricMapping
. If theArticulatedSystemMapping
is the solution to the a problem I wrote above, the question is how I can set theArticulatedSystemMapping
between my two input ports, so that they do what I write above.I would really appreciate for help, as I am struggling with this for a while and could not find a solution.
Many thanks!
Best regards,
AndrijaAndrijaBlockedHi @scheikl,
No need to say sorry. I am grateful that you help me and all the links, thoughts and ideas you suggested.
I think it is more my fault for not explaining in general what I was aiming at. I posted a similar issue or general thing what I was aiming at to simulate at the end in the another topic, but since up till recently there were no replies, I posted a new topic here. Hugo replied to my previous question and is trying to help out, and I will move this issue there with tagging you and mentioning what you were proposing. Maybe based on your ideas Hugo will have some further toughs on this issue.
The link to a topic:
Thanks again and hope we will find solution 🙂 .
Best,
AndrijaAndrijaBlockedHi @scheikl,
Thanks again for trying out to help me. I think this is to much complicated for my understanding and current level of knowledge. I really appreciate your help. I still cannot solve it. But I will try to close this issue and maybe open a new one with question how to simulate linear actuator. Somehow I feel that there is a simple solution, but it could be that I also didn’t know how to explain fully what I am aiming at at the end. If I manage to do it with
ArticulatedSystemMapping
in the mean time I will write it here.Thanks for helping!
Best,
AndrijaAndrijaBlockedHi @scheikl,
Many thanks for your help and suggestions! I will try out the things you proposed and see how it goes.
I know how to map or connected deformable body with a rigid one. There are several ways how it is possible to connect them. One is to use
BilateralInteractionConstraint
. In my case to connect thepointCon1
with a new Rigid3 object. This in generaly would work, but forBilateralInteractionConstraint
to work one need to useFreeMotionAnimationLoop
, which when it comes toArticulatedSystemMapping
simply does not work. In other word theArticulatedSystemMapping
does not work when I useFreeMotionAnimationLoop
, but this I don’t know why. Other way to connect them would be to useRestShapeSpringsForceField
between my deformable body and Rigid3 object that would be articulation. In general I have done this in the past and connect them like this, and it work, but when it comes to usingArticulatedSystemMapping
I don’t know if it will work, I will try this one next and see.In general the other thing I am trying is to model simple linear actuator, that I could then attach and use in my robot system, where robot would carry this linear actuator on its top. But I don’t know how to model such actuator, so that it can realize only linear motion in axial direction relative to the robot body, but it can move globally with the robot in different directions. This is why I started to play around with springs, as I thought maybe it is possible to have a spring that has small stiffness in axial direction but very large ones in all other directions, thus it would produce similar behaviour like I am aming at. I wrote this as maybe you will have some other ideas for doing this, beside using
ArticulatedSystemMapping
. You can have a look at this pdf that illustrates what I want to do:
https://drive.google.com/file/d/1DnT40U2oJecc5ph3IwjWj1-986yFUS-_/view?usp=sharingMany thanks! In the mean time I will update you how my progress goes.
Best,
AndrijaAndrijaBlockedHi @scheikl,
Many thanks for your help and for providing me more information about this. I am trying to figure this out, but still no luck. I think the problem is that I don’t understand in detail the
ArticulatedSystemMapping
, and what different components mean. I am really sorry my knowledge is limited.Below is the code and what i have so far.
# Simulating contracting actuator import Sofa import os from stlib.scene import MainHeader, ContactHeader # Defining a scene def createScene(rootNode): # Inicilaize disply rootNode.createObject('VisualStyle', displayFlags='showForceFields showBehaviorModels showBehavior') # Required plugins rootNode.createObject('RequiredPlugin', name='soft', pluginName='SoftRobots') rootNode.createObject('RequiredPlugin', name='SofaPython', pluginName='SofaPython') rootNode.createObject('RequiredPlugin', name='OpenVis', pluginName='SofaOpenglVisual') # Animation loops # rootNode.createObject('FreeMotionAnimationLoop') # Constrain solver rootNode.createObject('GenericConstraintSolver', tolerance="1e-12", maxIterations="100000") # Input port 1 Input_port1 = rootNode.createChild('Input_port1') Input_port1.createObject('EulerImplicit', name='odesolver') Input_port1.createObject('SparseLDLSolver', name='directSolver') Input_port1.createObject('MeshGmshLoader', name='loader', filename='mesh\CubeBlock.msh') Input_port1.createObject('Mesh', src='@loader', name='container') Input_port1.createObject('MechanicalObject', name='tetras', template='Vec3d', showObject='true', showObjectScale='1') Input_port1.createObject('TetrahedronFEMForceField', template='Vec3d', name='FEM', method='large', poissonRatio='0.4', youngModulus='8000', drawAsEdges="true") Input_port1.createObject('UniformMass', totalMass='0.1') # Adding supports Input_port1.createObject('BoxROI', name='boxROI', box='10 5 4 16 22 -3', drawBoxes='true') Input_port1.createObject('RestShapeSpringsForceField', points='@boxROI.indices', stiffness='1e12', angularStiffness='1e12') # Visualization modelVisu1 = Input_port1.createChild('visu1') modelVisu1.createObject('MeshSTLLoader', name="loader", filename="mesh\CubeBlock.stl") modelVisu1.createObject('OglModel', src="@loader", template='ExtVec3f', color='0.7 0.7 0.7 0.6') modelVisu1.createObject('BarycentricMapping') #Input_port1.createObject('LinearSolverConstraintCorrection', solverName='directSolver') Input_port1.createObject('UncoupledConstraintCorrection') # Input port 2 Input_port2 = Input_port1.createChild('Input_port2') Input_port2.createObject('EulerImplicit', name='odesolver') Input_port2.createObject('SparseLDLSolver', name='directSolver') Input_port2.createObject('MeshGmshLoader', name='loader2', filename='mesh\CubeBlock.msh', translation=[0.0, 0.0, 20.0]) Input_port2.createObject('Mesh', src='@loader2', name='container2') Input_port2.createObject('MechanicalObject', name='tetras2', template='Vec3d', showObject='true', showObjectScale='1') Input_port2.createObject('TetrahedronFEMForceField', template='Vec3d', name='FEM', method='large', poissonRatio='0.4', youngModulus='8000', drawAsEdges="true") Input_port2.createObject('UniformMass', totalMass='0.1') # Adding supports Input_port2.createObject('BoxROI', name='boxROI2', box='10 5 25 16 22 18', drawBoxes='true') Input_port2.createObject('RestShapeSpringsForceField', points='@boxROI2.indices', stiffness='1e12', angularStiffness='1e12') # Visualization modelVisu2 = Input_port2.createChild('visu2') modelVisu2.createObject('MeshSTLLoader', name="loader", filename="mesh\CubeBlock.stl", translation=[0.0, 0.0, 20.0]) modelVisu2.createObject('OglModel', src="@loader", template='ExtVec3f', color='0.7 0.7 0.7 0.6') modelVisu2.createObject('BarycentricMapping') #Input_port1.createObject('LinearSolverConstraintCorrection', solverName='directSolver') Input_port2.createObject('UncoupledConstraintCorrection') # Creating connecting point for Input port 1 - Rigid body pointCon1 = Input_port1.createChild('pointCon1') pointCon1.createObject('MechanicalObject', name="DOFpoint1", template="Rigid3d", position="19 16 5 0 0 0 0") pointCon1.createObject('BarycentricMapping') # Creating connecting point for Input port 2 - Rigid body pointCon2 = Input_port2.createChild('pointCon2') pointCon2.createObject('MechanicalObject', name="DOFpoint2", template="Rigid3d", position="19 16 17 0 0 0 0") pointCon2.createObject('BarycentricMapping')
You can download the meshes at this link:
https://drive.google.com/drive/folders/1rCwFsuc9sYQZy3WmxnlZRbrnRGopb3mT?usp=sharing
What I basically setup above are two prismatic objects that represent my two input ports. I don’t know if I mentioned but they need to be modeled as deformable objects, this is why they are modeled as deformable mechanical objects in the code. In general these two input ports will belong to one overall body/system, but this is not important for the current thing I am trying to solve i.e. am asking help. Temproraly I fix the two input ports, but this is just so that they don’t fly away before setting the
ArticulatedSystemMapping
. I added to points that represent Rigid body and they are connected to my input ports withBarycentricMapping
.How I should now define or add
ArticulatedSystemMapping
between my two input ports (or corresponding points that represent rigid body) so that I have the same behavior like in the SOFA doc example forArticulatedSystemMapping
? Or in general sense how I can realize the thing I asked before, i.e. that there is a spring like element between these two input ports, where the spring can realize only axial motion, and motion in all other directions is constraint?I will continue to try to figure this out but I hope you can help me.
Many thanks!
Best,
AndrijaAndrijaBlockedHi @scheikl,
Thanks again for your help back then. Sorry for not been updating sooner with my progress. I tried many things with using the
ArticulatedSystemMapping
but still I cannot make it work as I wanted. I guess I cannot get my head around it and understand it fully. I don’t know how to create Articulations between two indices of my input ports? In the examples of SOFA documents they are using Beams as an example, but don’t know if I need to use it as well.I will share my code as soon as I make it a bit more neat, then maybe you or others can help a bit.
Many thanks!
Best,
AndrijaAndrijaBlockedHey @hugo!
Many thanks for your reply and please sorry for my slow response, but I was on a holiday the past two weeks.
First I want to say my big congrats for the SOFA! It is really an amazing tool and nothing I had the chance to work with before. Truly impressive simulation tool, and many thanks for making it possible and open source for the community! Really appreciate it.
About my questions. Sorry for not being more clear. I will try to explain better. I am trying to simulate simple linear actuator, where this actuator would be attached to a robot body. Further this robot body would “carry” the actuator on its top, meaning that the actuator would realize linear translation in axial direction, relative to a robot body but would globally move with the whole robot in space, as robot carries it. I would apply
LinearForceField
to the actuator or maybe input displacement to realize motion of the actuator i.e. simulate its input force or input displacement (both would work for my case). Here is link to a pdf where I illustrated what I am trying to do:https://drive.google.com/file/d/1DnT40U2oJecc5ph3IwjWj1-986yFUS-_/view?usp=sharing
To explain further. The linear actuator is attached on both ends to two input ports that are part of the robot mechanism/body (not so important maybe). Maybe I didn’t illustrate it good but hope you will got the point.
In essence I am trying to simulate linear actuator and just attach this linear actuator to my robot system to actuate it, where normally actuator can only realize linear axial translation, as any linear actuator do. But the things get complicated as I actually need actuator to behave like a spring that would be elastic in only its axial direction but have infinite stiffens in other directions or that the motion of the spring is constrained in all other directions except axial direction.
Also the two input ports to which the actuator is attached on its ends are model not as rigid objects but as
MechanicalObject
withtemplate="Vec3d"
.I have been struggling with this over a month, and still I don’t know how to do it. I first tried to place a simple spring between my two input ports by attach it to two indices of the input ports. Then I applied
LinearForceField
to both ends of the spring to actuate the input ports, but normally as the spring is “free” in all directions it realizes not only axial motion but also some motion in other directions, which is not desirable in my case. I also tired to usePartialLinearMovementConstraint
between the two input ports, and this worked. But then as the two input ports are part of the overall robot body, this constrained the motion of the whole robot globally. I also triedOscillatorConstraint
, this worked but again somehow my robot motion globally is constrained due to Oscialltor being applied to one indecies. Further I also tried using Articulations which should work, but as my input ports are modeled with “Vec3d” somehow I am having problems with this one as Aritculations are modeled withtemplate="Rigid3d"
, I can share my code if you believe that Articulations are the way to go.
Currently I am trying to figure our things using theSlidingConstraint
between my two input ports, but I don’t know again if this would work out as again the whole robot motion could be constrained as two input ports are part of a robot.I would really much appreciate for any help!!! I am really struggling with this one to make it work.
Many thanks!
Best,
AndrijaAndrijaBlockedHi @scheikl,
Thanks once again. I am working on it now. When I make it work, I will share a code, maybe it would ne useful to others as well.
Thanks!
Best,
AndrijaAndrijaBlockedHi @scheikl,
Many thanks for your help! The
ArticulatedSystemMapping
will solve it! I just need a bit of time to get a hang on it, but it seems like exactly what I was looking for.I was struggling with this for nearly a month, and tried so many different things.
Many thanks for your support and help! Really applicate it.
Best,
– AndrijaAndrijaBlockedHi @scheikl – Paul
Many thanks for the suggestion and your great help! Really appreciate it.
It is a great suggestion, and believe it will work and solve it. But please sorry I didn’t explained the full scene and what I am trying to do. So actually the two rigid bodies that would be connected with a spring, would be lying on top of other bigger cube where this cube would carry them and I will move the cube in different directions by applying input force. To my experience applying the
LinearMovementConstraint
would then limit the motion of two rigid bodes globally and then they cannot realize motion together with the cube that would carry them. But maybe I am wrong? What do you think? I am writing this as I actually tried usingPartialLinearMovementConstraint
and then the motion of the two rigid bodies was globally constrained.I don’t know if there is some way to maybe constrain motion but just relatively to cube where my system would be attached to?
It is a funny thing what I am trying out, but for my project I need somehow to simulate spring like actuator that would attract two rigid bodies i.e. move them in only axical direction of actuator, but in the same time this system would be attach to a larger rigid body that would carry them.
Any thoughts on these?
Many thanks for your help!
By the way, SOFA is really just amazing tool!
Best,
Andrija -
AuthorPosts