9 December 2020 at 20 h 14 min #17989
Is there a way to somehow constrain a spring element so that it has very low stiffness in only axical direction, and infinity stiffness in all other directions? For example to set stiffens in axial (X) direction to “free” but stiff in all other directions?
I am try to simulate a spring that would contract only in one direction when I apply force to it i.e. to the rigid body that is attached to it. I have explored StiffSpringForceField and RestShapeSpringsForceField, attached between two rigid bodies but still spring can move in different directions. I also used JointSpringForceField, but again nothing happens even when I used high values of stiffness. Maybe I am making a mistake somewhere?
Hope you can help me out.
– Andrija10 December 2020 at 19 h 44 min #17996
would it be possible for your case to first constrain the motion of the two bodies with a
LinearMovementConstraintand then introduce a spring? That would basically do the same thing that you are describing, right?
There es an example scene you could use as a starting point:
Paul10 December 2020 at 21 h 24 min #18000
Hi @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
LinearMovementConstraintwould 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 using
PartialLinearMovementConstraintand 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!
Andrija11 December 2020 at 7 h 27 min #18002
Many thanks for your help! The
ArticulatedSystemMappingwill 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.
– Andrija11 December 2020 at 10 h 23 min #18004
you are very welcome! 🙂
The topic seems quite fun, let me know how it works out.
Paul11 December 2020 at 11 h 20 min #18007
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.
Andrija5 January 2021 at 13 h 41 min #18108
Thanks again for your help back then. Sorry for not been updating sooner with my progress. I tried many things with using the
ArticulatedSystemMappingbut 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.
Andrija5 January 2021 at 13 h 49 min #18109
no worries. 🙂
The beam part should not be necessary.
As long as you have some
Rigid3objects it should work fine.
I can highly recommend the Tutorials in the SoftRobots Plugin.
ArticulatedSystemMappingthis one should be quite helpful:
Sure! I would be happy to have a look at the code.
Paul5 January 2021 at 19 h 04 min #18110
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:
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 with
How I should now define or add
ArticulatedSystemMappingbetween my two input ports (or corresponding points that represent rigid body) so that I have the same behavior like in the SOFA doc example for
ArticulatedSystemMapping? 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.
Andrija6 January 2021 at 20 h 18 min #18115
I actually don’t know how I would approach that with two deformable bodies…
Maybe you could try to adapt the code in the actuated arm of the SoftRobots Plugin.
Personally I would try to take that code and add the deformable objects under the Rigid3 objects in
ServoBodyand map them to the Rigid3 objects.
So basically for your scene try to make
Input_port1a child of
pointCon1and not the other way around.
But I am not sure how to properly map the “soft” part to the “rigid” part…
Even if that does not work in the way you want it, the scene might give you a good understanding of how the components in the
Exploring a bit in the Scene Tree of the GUI helps a lot.
Let me know if that worked. 🙂
Paul9 January 2021 at 10 h 04 min #18165
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 the
pointCon1with a new Rigid3 object. This in generaly would work, but for
BilateralInteractionConstraintto work one need to use
FreeMotionAnimationLoop, which when it comes to
ArticulatedSystemMappingsimply does not work. In other word the
ArticulatedSystemMappingdoes not work when I use
FreeMotionAnimationLoop, but this I don’t know why. Other way to connect them would be to use
RestShapeSpringsForceFieldbetween 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 using
ArticulatedSystemMappingI 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:
Many thanks! In the mean time I will update you how my progress goes.
Andrija11 January 2021 at 22 h 21 min #18193
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
ArticulatedSystemMappingin the mean time I will write it here.
Thanks for helping!
Andrija13 January 2021 at 11 h 42 min #18198
sorry for the late reply, and that I could not help you solve the problem. 🙁
I am looking forward to the new issue, maybe we can approach that from another angle.
Paul14 January 2021 at 12 h 54 min #18219
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 🙂 .
Andrija18 March 2021 at 8 h 03 min #18001
no worries :).
Ok now I get it!
ArticulatedSystemMappingshould do the trick!
An example can be found here:
And there is also a very nice explanation in the documentation:
So basically what you would do is creating a linear joint, that is attached to your big “carrier” cube.
Hope that helps!
- You must be logged in to reply to this topic.