Forum Replies Created
-
AuthorPosts
-
SergioPM23Blocked
Any advice?
SergioPM23BlockedHi @etagliabue,
Thank you so much for your response.
I have tried to implement the rigid object just as you wrote and no errors appeared, but the attach constraint seems to be not working (the points from the different pairs do not move united between them). The code of the scene is the following one (note that the deformable object is the node called “Cube1” and the rigid object is the node called “RigidObj”. The mesh file is “cube.obj”, which is include in the mesh Sofa’s folder and it is used in both objects):import SofaRuntime SofaRuntime.importPlugin("SofaComponentAll") # to create elements like Node or objects import Sofa.Core def createScene(rootNode): rootNode.findData('dt').value = 0.01 rootNode.findData('gravity').value = [0., 0., 0.] rootNode.addObject('RequiredPlugin', name="SofaPython3") rootNode.addObject('RequiredPlugin', name="SofaBoundaryCondition") rootNode.addObject('RequiredPlugin', name="SofaImplicitOdeSolver") rootNode.addObject('RequiredPlugin', name="SofaMiscForceField") rootNode.addObject('RequiredPlugin', name="SofaOpenglVisual") rootNode.addObject('RequiredPlugin', name="SofaMeshCollision") rootNode.addObject('RequiredPlugin', name="SofaDeformable") rootNode.addObject('RequiredPlugin', name="SofaGeneralObjectInteraction") rootNode.addObject('RequiredPlugin', name="SofaSimpleFem") rootNode.addObject('RequiredPlugin', name="SofaBoundaryCondition") rootNode.addObject('RequiredPlugin', name="SofaGeneralLoader") rootNode.addObject('RequiredPlugin', name="SofaImplicitOdeSolver") rootNode.addObject('RequiredPlugin', name="SofaLoader") rootNode.addObject('RequiredPlugin', name="SofaSimpleFem") rootNode.addObject('CollisionPipeline', name="PipeLine", verbose=0, draw=0) rootNode.addObject('BruteForceDetection', name="N2") rootNode.addObject('NewProximityIntersection', name="Proximity", alarmDistance=0.5, contactDistance=0.25) rootNode.addObject('CollisionResponse', name="Response", response="default") rootNode.addObject('MeshObjLoader', name="meshLoadercube", filename="mesh/cube.obj") #CUBE1 Cube1 = rootNode.addChild("Cube1") Cube1.addObject('EulerImplicitSolver') Cube1.addObject('CGLinearSolver', iterations=200, tolerance="1e-09", threshold="1e-09") Cube1.addObject('PointSetTopologyContainer', name="topoCube1", src="@../meshLoadercube") Cube1.addObject('PointSetGeometryAlgorithms', template="Vec3d", name="GeomAlgo") Cube1.addObject('MechanicalObject', template="Vec3d", name="MechanicalModel", showObject=1, showObjectScale=3, src="@../meshLoadercube") #Cube1.addObject('MeshSpringForceField', name="Springs", stiffness=20000, damping=1) Cube1.addObject('UniformMass', totalMass=100) Cube1.addObject('ConstantForceField', totalForce=[0., 0., 2.]) Cube1.addObject('BoxROI', name="box_roi1", box=[-1.5, -1.5, 1, 1.5, 1.5, 1]) Cube1.addObject('PartialFixedConstraint', fixAll=True, fixedDirections=[1, 0, 0]) Cube1.addObject('PartialFixedConstraint', fixAll=True, fixedDirections=[0, 1, 0]) VisualCube1 = Cube1.addChild("VisualCube1") VisualCube1.addObject('OglModel', name="VisualModelCube1", src="@../../meshLoadercube", color=[0, 0, 1]) VisualCube1.addObject('IdentityMapping', name="MappingCube1", input="@../MechanicalModel", output="@VisualModelCube1") ColisionCube1 = Cube1.addChild("CollisionCube1") ColisionCube1.addObject('MeshTopology', src="@../../meshLoadercube") ColisionCube1.addObject('MechanicalObject', name="CollisionCube1MO", scale=1.0) ColisionCube1.addObject('PointCollisionModel', name="CollisionModelCube11", contactStiffness=10) ColisionCube1.addObject('LineCollisionModel', name="CollisionModelCube12", contactStiffness=10) ColisionCube1.addObject('CubeCollisionModel', name="CollisionModelCube13", contactStiffness=10) ColisionCube1.addObject('IdentityMapping', name="CollisionMappingCube1", input="@../MechanicalModel", output="@CollisionCube1MO") #RigidObj RigidObj = rootNode.addChild("RigidObj") RigidObj.addObject('EulerImplicitSolver') RigidObj.addObject('CGLinearSolver', iterations=200, tolerance="1e-09", threshold="1e-09") RigidObj.addObject('PointSetTopologyContainer', name="topoRigidObj", src="@../meshLoadercube") RigidObj.addObject('MechanicalObject', template="Rigid3d", name="MechanicalModel2", showObject=0, translation=[-1., 1., 3.], showObjectScale=3, src="@../meshLoadercube") RigidObj.addObject('UniformMass', totalMass=100) RigidObjVec = RigidObj.addChild("RigidObjVec") RigidObjVec.addObject('MechanicalObject', template="Vec3d", name="MechanicalModel3", showObject=1, showObjectScale=3, src="@../../meshLoadercube") RigidObjVec.addObject('RigidMapping', template="Rigid3d,Vec3d", input="@../MechanicalModel2", output="@MechanicalModel3") RigidObjVec.addObject('AttachConstraint', object1="@../../Cube1/MechanicalModel", object2="@MechanicalModel3", indices1="1 2 5 6", indices2="0 3 4 7", twoWay=True, constraintFactor="1 1 1 1") VisualRigidObj = RigidObj.addChild("VisualRigidObj") VisualRigidObj.addObject('OglModel', name="VisualModelRigidObj", src="@../../meshLoadercube", color=[1, 0, 0]) VisualRigidObj.addObject('RigidMapping', name="MappingRigidObj", input="@../MechanicalModel2", output="@VisualModelRigidObj") ColisionRigidObj = RigidObj.addChild("CollisionCube1") ColisionRigidObj.addObject('MeshTopology', src="@../../meshLoadercube") ColisionRigidObj.addObject('MechanicalObject', name="CollisionRigidObjMO", scale=1.0) ColisionRigidObj.addObject('PointCollisionModel', name="CollisionModelRigidObj1", contactStiffness=10) ColisionRigidObj.addObject('LineCollisionModel', name="CollisionModelRigidObj2", contactStiffness=10) ColisionRigidObj.addObject('CubeCollisionModel', name="CollisionModelRigidObj3", contactStiffness=10) ColisionRigidObj.addObject('RigidMapping', name="CollisionMappingRigidObj", input="@../MechanicalModel2", output="@CollisionRigidObjMO")
I would like to know what should I change in order to make the scene work propperly. I would appreciate any help. Thanks in advance.
Cheers,
Sergio.SergioPM23BlockedHi @etagliabue,
Thank you so much for your response.
I have tried to implement the rigid object just as you wrote and no errors appeared, but the attach constraint seems to be not working (the points from the different pairs do not move united between them). The code of the scene is the following one (note that the deformable object is the node called “Cube1” and the rigid object is the node called “RigidObj”. The mesh file is “cube.obj”, which is include in the mesh Sofa’s folder and it is used in both objects):import SofaRuntime SofaRuntime.importPlugin("SofaComponentAll") # to create elements like Node or objects import Sofa.Core def createScene(rootNode): rootNode.findData('dt').value = 0.01 rootNode.findData('gravity').value = [0., 0., 0.] rootNode.addObject('RequiredPlugin', name="SofaPython3") rootNode.addObject('RequiredPlugin', name="SofaBoundaryCondition") rootNode.addObject('RequiredPlugin', name="SofaImplicitOdeSolver") rootNode.addObject('RequiredPlugin', name="SofaMiscForceField") rootNode.addObject('RequiredPlugin', name="SofaOpenglVisual") rootNode.addObject('RequiredPlugin', name="SofaMeshCollision") rootNode.addObject('RequiredPlugin', name="SofaDeformable") rootNode.addObject('RequiredPlugin', name="SofaGeneralObjectInteraction") rootNode.addObject('RequiredPlugin', name="SofaSimpleFem") rootNode.addObject('RequiredPlugin', name="SofaBoundaryCondition") rootNode.addObject('RequiredPlugin', name="SofaGeneralLoader") rootNode.addObject('RequiredPlugin', name="SofaImplicitOdeSolver") rootNode.addObject('RequiredPlugin', name="SofaLoader") rootNode.addObject('RequiredPlugin', name="SofaSimpleFem") rootNode.addObject('CollisionPipeline', name="PipeLine", verbose=0, draw=0) rootNode.addObject('BruteForceDetection', name="N2") rootNode.addObject('NewProximityIntersection', name="Proximity", alarmDistance=0.5, contactDistance=0.25) rootNode.addObject('CollisionResponse', name="Response", response="default") rootNode.addObject('MeshObjLoader', name="meshLoadercube", filename="mesh/cube.obj") #CUBE1 Cube1 = rootNode.addChild("Cube1") Cube1.addObject('EulerImplicitSolver') Cube1.addObject('CGLinearSolver', iterations=200, tolerance="1e-09", threshold="1e-09") Cube1.addObject('PointSetTopologyContainer', name="topoCube1", src="@../meshLoadercube") Cube1.addObject('PointSetGeometryAlgorithms', template="Vec3d", name="GeomAlgo") Cube1.addObject('MechanicalObject', template="Vec3d", name="MechanicalModel", showObject=1, showObjectScale=3, src="@../meshLoadercube") #Cube1.addObject('MeshSpringForceField', name="Springs", stiffness=20000, damping=1) Cube1.addObject('UniformMass', totalMass=100) Cube1.addObject('ConstantForceField', totalForce=[0., 0., 2.]) Cube1.addObject('BoxROI', name="box_roi1", box=[-1.5, -1.5, 1, 1.5, 1.5, 1]) Cube1.addObject('PartialFixedConstraint', fixAll=True, fixedDirections=[1, 0, 0]) Cube1.addObject('PartialFixedConstraint', fixAll=True, fixedDirections=[0, 1, 0]) VisualCube1 = Cube1.addChild("VisualCube1") VisualCube1.addObject('OglModel', name="VisualModelCube1", src="@../../meshLoadercube", color=[0, 0, 1]) VisualCube1.addObject('IdentityMapping', name="MappingCube1", input="@../MechanicalModel", output="@VisualModelCube1") ColisionCube1 = Cube1.addChild("CollisionCube1") ColisionCube1.addObject('MeshTopology', src="@../../meshLoadercube") ColisionCube1.addObject('MechanicalObject', name="CollisionCube1MO", scale=1.0) ColisionCube1.addObject('PointCollisionModel', name="CollisionModelCube11", contactStiffness=10) ColisionCube1.addObject('LineCollisionModel', name="CollisionModelCube12", contactStiffness=10) ColisionCube1.addObject('CubeCollisionModel', name="CollisionModelCube13", contactStiffness=10) ColisionCube1.addObject('IdentityMapping', name="CollisionMappingCube1", input="@../MechanicalModel", output="@CollisionCube1MO") #RigidObj RigidObj = rootNode.addChild("RigidObj") RigidObj.addObject('EulerImplicitSolver') RigidObj.addObject('CGLinearSolver', iterations=200, tolerance="1e-09", threshold="1e-09") RigidObj.addObject('PointSetTopologyContainer', name="topoRigidObj", src="@../meshLoadercube") RigidObj.addObject('MechanicalObject', template="Rigid3d", name="MechanicalModel2", showObject=0, translation=[-1., 1., 3.], showObjectScale=3, src="@../meshLoadercube") RigidObj.addObject('UniformMass', totalMass=100) RigidObjVec = RigidObj.addChild("RigidObjVec") RigidObjVec.addObject('MechanicalObject', template="Vec3d", name="MechanicalModel3", showObject=1, showObjectScale=3, src="@../../meshLoadercube") RigidObjVec.addObject('RigidMapping', template="Rigid3d,Vec3d", input="@../MechanicalModel2", output="@MechanicalModel3") RigidObjVec.addObject('AttachConstraint', object1="@../../Cube1/MechanicalModel", object2="@MechanicalModel3", indices1="1 2 5 6", indices2="0 3 4 7", twoWay=True, constraintFactor="1 1 1 1") VisualRigidObj = RigidObj.addChild("VisualRigidObj") VisualRigidObj.addObject('OglModel', name="VisualModelRigidObj", src="@../../meshLoadercube", color=[1, 0, 0]) VisualRigidObj.addObject('RigidMapping', name="MappingRigidObj", input="@../MechanicalModel2", output="@VisualModelRigidObj") ColisionRigidObj = RigidObj.addChild("CollisionCube1") ColisionRigidObj.addObject('MeshTopology', src="@../../meshLoadercube") ColisionRigidObj.addObject('MechanicalObject', name="CollisionRigidObjMO", scale=1.0) ColisionRigidObj.addObject('PointCollisionModel', name="CollisionModelRigidObj1", contactStiffness=10) ColisionRigidObj.addObject('LineCollisionModel', name="CollisionModelRigidObj2", contactStiffness=10) ColisionRigidObj.addObject('CubeCollisionModel', name="CollisionModelRigidObj3", contactStiffness=10) ColisionRigidObj.addObject('RigidMapping', name="CollisionMappingRigidObj", input="@.../MechanicalModel2", output="@CollisionRigidObjMO")
I would like to know what should I change in order to make the scene work propperly. I would appreciate any help. Thanks in advance.
Cheers,
Sergio.22 June 2021 at 21:00 in reply to: [SOLVED] Attach constraint between a rigid and a deformable object. #19794SergioPM23BlockedAny solution?
SergioPM23Blocked@nhnhan The error says the following (I think the error is due to the fact that I am using different templates for the objects on which I want to apply the AttachConstraint):
[ERROR] [SofaPython3::SceneLoader] ValueError: Object type AttachConstraint<> was not created The object is in the factory but cannot be created. Requested template : None Used template : None Also tried to create the object with the template 'Rigid2d' but failed for the following reason(s): 1. Data attribute 'object1' does not point to a valid mechanical state of datatype 'Rigid2d'. Also tried to create the object with the template 'Rigid3d' but failed for the following reason(s): 1. Data attribute 'object1' does not point to a valid mechanical state of datatype 'Rigid3d'. Also tried to create the object with the template 'Vec1d' but failed for the following reason(s): 1. Data attribute 'object1' does not point to a valid mechanical state of datatype 'Vec1d'. Also tried to create the object with the template 'Vec2d' but failed for the following reason(s): 1. Data attribute 'object1' does not point to a valid mechanical state of datatype 'Vec2d'. Also tried to create the object with the template 'Vec3d' but failed for the following reason(s): 1. Data attribute 'object2' does not point to a valid mechanical state of datatype 'Vec3d'.
SergioPM23Blocked@nhnhan Yes, I had tried that (to change the value of the template field to Rigid3d), but when I do that, appears an error that says that AttachConstraints can not be created.
SergioPM23BlockedAny advice?
SergioPM23Blocked@Hugo Okay, thanks for your response. I have already seen this two examples, but I would like to know more about how to controll time events (basically how to do actions on objects in a specific instant of the animation and during a specific period of time).
I have also seen another example (advanced_timer.py) which seems to controll time events, but I do not understand it clearly. Is not there any further documentation which explains more about time Python controllers?
I would appreciate any help. Thanks in advance.Cheers,
Sergio.SergioPM23BlockedIsn’t there any documentation about SofaPython3 controllers? I need to learn about them in order to do my final degree project succesfully.
SergioPM23Blocked@Hugo Thanks for your response, Hugo. I followed the steps in that documentation page and I have finally been able to activate the plugin, thanks.
I would also like to know where could I find more examples and documentation about controllers in python, cause I do not fully understand the example you posted in a previous message.
Thanks in advance.Cheers,
Sergio.SergioPM23Blocked@Hugo Hi Hugo. I decided to install the latest Sofa version from the binaries, because I was having a lot of problems with the version I had. I installed it from the binaries because it includes SofaPython3. My question now is: how I activate the plugin? I tried from the plugin mánager, but it didn’t work.
Thanks in advance.Cheers,
Sergio.SergioPM23Blocked@amazier Thank you again for your help and thank you also for the tip to see the properties in the Graph Scene.
Cheers,
SergioSergioPM23Blocked@amazier Thank you so much for your response, it helped me a lot.
Just one more question: can I use the fixAll option in PartialFixedConstraint, or is it exclusively for FixedConstraint?Thanks in advance.
Cheers,
Sergio.SergioPM23Blocked@akTheTimes Yes, it seemed to be okay. I didn’t know what was the problem, so I installed the new Sofa version from the binaries, because I read that it includes SofaPython3. My question now is how I activate the plug-in? I have tried from the plugin manager but it doesn’t work.
Cheers,
Sergio.SergioPM23Blocked@akTheTimes I have added it and now it configurate and generate well, but when I build from the terminal (make -j12) appear the following errors:
SergioPM23Blocked@akTheTimes in-tree build
SergioPM23BlockedThanks for your response, Hugo. I have the following errors during the cmake-gui configuration step for the SofaPython3 installation:
CMake Error at /home/master/ext_plugin_repo/SofaPython3/Plugin/CMakeLists.txt:27 (find_package): By not providing "FindSofa.Testing.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Sofa.Testing", but CMake did not find one. Could not find a package configuration file provided by "Sofa.Testing" with any of the following names: Sofa.TestingConfig.cmake sofa.testing-config.cmake Add the installation prefix of "Sofa.Testing" to CMAKE_PREFIX_PATH or set "Sofa.Testing_DIR" to a directory containing one of the above files. If "Sofa.Testing" provides a separate development package or SDK, be sure it has been installed.
Do you know how to solve this error?
Cheers,
Sergio26 April 2021 at 22:58 in reply to: [SOLVED] Movement restriction at some points of an object #19319SergioPM23BlockedThank you so much for your response, Scheikl. Yes, that was exactly what I was looking for.
Sincerely,
SergioSergioPM23BlockedThank you for your response Hugo. I am going to read the paper and try to implement the model in SOFA. I will write in this post if I have any doubt.
Sergio.
SergioPM23BlockedHi Hugo.
Thanks for your response. Could you give an example of a field that induce contraction?. I am trying to contract the object using two additional objects that push (ConstantForceField) the object I want to contract from opposite faces, but what I can see so far does not look like a contraction at all.
Thanks in advance.
Sergio.13 April 2021 at 07:13 in reply to: Error while building Sofa for SoftRobots plugin installation #19149SergioPM23BlockedHi Hugo.
I am not sure. I just followed the steps indicated in this documentation for the Sofa installation: https://www.sofa-framework.org/community/doc/getting-started/build/linux/6 April 2021 at 21:09 in reply to: Error while building Sofa for SoftRobots plugin installation #19078SergioPM23BlockedHi Hugo. Thank you for your answer. I am using Sofa v20.12.01.
I have another question: for the SoftRobots plugin installation, is it necessary to download the plugin, or could I just re-build Sofa from cmake-gui activating the softRobots plugin entry?. The last time that I tried to install it I downloaded the last version of the plugin.
I look forward to your response. Thanks in advance.Sergio.
26 March 2021 at 18:28 in reply to: Error while building Sofa for SoftRobots plugin installation #18989SergioPM23Blocked11 March 2021 at 00:27 in reply to: Error while building Sofa for SoftRobots plugin installation #18838SergioPM23Blocked -
AuthorPosts