Home › Forum › SOFA › Programming with SOFA › Apply translation to mechanical object
Tagged: 64_bits, MacOS, Plugin_SoftRobots, SOFA_1912
- This topic has 11 replies, 3 voices, and was last updated 3 years, 7 months ago by Hugo.
-
AuthorPosts
-
21 October 2020 at 12:28 #17433JonnyBlocked
Hi,
I’m trying to simulate a pneumatic robot with SofaPython (actually using the Soft Robots plugin binaries). In my scene one bellow of the robot(looks like an ellipsoid) inflates using a Python Controller and SurfacePressureConstraint. The inflation is limited by two floors, one above and one below the bellow forcing it to deform when colliding. So far this works reasonably well.
Now I want to translate one of the floors vertically to either compress or expand the bellow and later get the contact area at every time step in order to calculate the contact force. I have tried different methods (move rest_position, free_position, changing translation of mechanical object, LinearMovementConstraint) that I found in the forum to translate the floor but nothing seems to work – at least visually. I checked the properties of my mechanical object via the GUI and the values I tried to change did in fact get updated the way they were supposed to but my scene still looks the same.How do I get the floor the move? I’m guessing there’s only a minor thing I am missing currently, so any help would be great!
Thanks in advance.21 October 2020 at 12:52 #17434ScheiklBlockedHi Jonny,
I had a similar problem and the SoftRobots tutorial on the tripod was incredibly helpful.Have a look at the setupanimation function here:
https://github.com/SofaDefrost/SoftRobots/blob/master/docs/tutorials/Tripod/details/tripodcontroller.pyIf you can use the splib, great! If not, you may want to copy out the relevant snippets of code from there. π
Cheers,
Paul30 October 2020 at 15:06 #17494HugoKeymaster11 November 2020 at 17:32 #17633JonnyBlockedHi,
thank you for your replies and sorry for answering so late but I was working on something different in the meantime.
@scheikl: Thanks for the provided example. So far I haven’t been able to get it working that way but I am sure it will come in handy at a later point and has given me a good idea of how to avoid inflating/deflating manually in the future which I did not think about before.
@hugo I uploaded my files here:
example files
LinearMovementConstraint seems to work now, translating the floor with the controller does not, so maybe you could still have a look.Also I’m struggling to understand how to properly use the different models (especially collision, as my scene gets pretty slow once the bellow hits the floors). The next step would be to have larger floors and two bellows next to each other (as in ‘bellow_rotatory_floors.py’ in the provided folder). Then one of the bellows is inflated causing the floor to rotate around its x-axis and pushing down on the other bellow and so on – both of the bellows should be attached to the floors at their top/bottom center. I found Bilateral Movement Constraint and the corresponding example scene but I don’t understand how to use it properly in my scene. Also I am not sure which component to use regarding the movement of the floor which should be limited to rotation around one axis.
So altogether:
1. How do I get my scene to run smoother during collision?
2. How to best implement the different models and mappings?
3. How to properly attach bellows to floors?
4. How to allow/constraint movements of the floor in case of collision?Thank you so much for your help! If you have any question regarding my code or this long post please do not hesitate to ask π
30 November 2020 at 19:11 #17811JonnyBlockedHi @hugo,
I am still struggling with this. Can you help me with any of my questions or poke someone who can please?
Cheers,
Jonny30 November 2020 at 22:27 #17815ScheiklBlockedHi @jonny,
I just had a look at the files.My intuition would be to create a
MechanicalObject
with theRigid3d
template (so you only have to set one position value to move the floor, and not every position for each node. And then use aRigidMapping
between thisMechanicalObject
and your collision and visual models.###Creating the floor floor = rootNode.addChild(name) floor.addObject( "MechanicalObject", name="mechObject", template="Rigid3", translation="0 0 -30", rotation="90 0 0", ) ###VisualModel floorVisu = floor.addChild("VisualModel") floorVisu.addObject( "MeshObjLoader", name="loader", filename="mesh/floor.obj", scale=1 ) floorVisu.addObject("OglModel", name="model", src="@loader", color=[0.8, 0.8, 0.8]) floorVisu.addObject("RigidMapping") ###CollisionModel floorCollis = floor.addChild("collision") floorCollis.addObject( "MeshObjLoader", name="loader", filename="mesh/floor.obj", triangulate="true", scale=1, ) floorCollis.addObject("MeshTopology", src="@loader") floorCollis.addObject("MechanicalObject") floorCollis.addObject("TriangleCollisionModel",) floorCollis.addObject("LineCollisionModel") floorCollis.addObject("PointCollisionModel") floorCollis.addObject("RigidMapping")
That might speed things up a little. At least for moving the floor.
5 December 2020 at 17:16 #17956JonnyBlockedHi @scheikl,
thanks for your fast response again. Indeed, using Rigid3d template simplified the use of
LinearMovementConstraint
quite a bit.Next thing I am stuck with is the connection between bellow and floor (more important in the other scene with two bellows). From what I have seen
AttachConstraint
andBilateralInteractionConstraint
would be the best options.
From my understanding I would need both the floor and bellow to have the same DOFs (Vec3d in my case). Now when I use AttachConstraint the connection looks pretty realistic and I can easily change the connected “area”/nodes. However the floor is deforming rather than moving once I inflate the bellow whereas I would want the floor to be rigid. Is there a way to fix this?
Furthermore, I want to restrict the movement to just rotation around the x axis – so no translation either.FixedRotationConstraint
seems to work for rotation, and I have triedFixedPlaneConstraint
without any success. I guess I could usePartialFixedConstraint
with Rigid3d as well and then just constraint that one node though the attachment would then not work anymore.I found another topic (topic) with a similar problem where @hugo suggested to create a dedicated subnode to connect the two models. How would I do that?
Thanks again for any help!
Jonny
5 December 2020 at 19:54 #17957ScheiklBlockedHi @jonny,
I’m glad that helped! πFor the deforming floor, you could try setting appropriate flags in the collision model to tell sofa that these models are supposed to move, but not deform.
floorCollis.addObject("MeshTopology", src="@loader") floorCollis.addObject("MechanicalObject") floorCollis.addObject("TriangleCollisionModel", simulated="false", moving="true") floorCollis.addObject("LineCollisionModel", simulated="false", moving="true") floorCollis.addObject("PointCollisionModel", simulated="false", moving="true") floorCollis.addObject("RigidMapping")
Sadly I do not have any (successful) experience with any of the
Constraints
. π
But introducing a ForceField was pretty sufficient for my use cases. As @hugo said in the post, it does not ensure, that the points will be at the exact same location. But that really depends on the use-case, right?Maybe try using BoxStiffSpringForceField. This one will take the indices of both objects from their respective boxes and create springs between them.
8 December 2020 at 18:09 #17977JonnyBlockedHi @scheikl,
I’m currently trying all the different options/components that could be useful in the two scenes in order to figure out which work best. I will post an update as soon as I meet another problem or get everything to work π Once again thanks for you help so far!
Cheers
9 December 2020 at 12:51 #17982ScheiklBlocked18 March 2021 at 08:03 #17933JonnyBlockedHi @scheikl,
thanks again for your fast response. Indeed, using Rigid3d template simplified the use of
LinearMovementConstraint
quite a bit (especially for floor rotation).Next thing I am stuck with is the connection between bellow and floor (more important in the other scene with two bellows). From what I have seen
AttachConstraint
andBilateralInteractionConstraint
would be the best options.
From my understanding I would need both the floor and bellow to have the same DOFs (Vec3d in my case). Now when I use AttachConstraint the connection looks pretty realistic and I can easily change the connected “area”. However the floor is deforming rather than moving once I inflate the bellow whereas I would want the floor to be rigid. Is there a way to fix this?
Furthermore, I want to restrict the movement to just rotation around the x axis – so no translation either.FixedRotationConstraint
seems to work for rotation, and I have triedFixedPlaneConstraint
without any success. I guess I could usePartialFixedConstraint
with Rigid3d as well and then just constraint that one node though the attachment would then not work anymore.I found another topic (https://www.sofa-framework.org/community/forum/topic/attach-a-rigid-cube-to-flexible-fem-body/) with a similar problem where @hugo suggested to create a dedicated subnode to connect the two models. How would I do that?
Thanks again for any help!
Jonny
31 March 2021 at 09:52 #19030HugoKeymasterHi @jonny
The topic you pointed out indeed explains the theoretical difference between the two methods: AttachConstraint vs BilateralInteractionConstraint.
With the PartialFixedConstraint, you can indeed choose which vertices and which dofs of theses vertices to fix.
To answer your last point, I would need a global understanding of what you want to achieve when you say “connect the two models”.
I think what was meant in my comment is that : if you want to connect both objects they have to have the same DOFs types (template). Which is not your case I guess: one object is rigid while the other one is deformable. An alterantive is to simply create a sub-node for the rigid object (connected using a RigidMapping) containing one deformable DOF, e.g. Vec3d.I hope I am clear enough. If not, please let me know.
Best wishes,Hugo
-
AuthorPosts
- You must be logged in to reply to this topic.