Forum Replies Created
-
AuthorPosts
-
HugoKeymaster
Nice to see you guys connecting!
Do not hesitate to keep us updated on this thread, once you’ve made steps forward! Or even to share your work on the Gallery and Marketplace!
Good luck!Hugo
1 August 2017 at 12:38 in reply to: [SOLVED] Reading indices of FixedConstraint from an ascii file #9893HugoKeymasterHi Noura,
A very simple way of doing what you want is to :
– create an obj file (let’s call it “file.obj”) with your ids like:v id_1 v id_2 .. v id_n
– then, load the above-created obj files with a MeshObjLoader and give it to the FixedConstraint as follows:
<MeshObjLoader name="IDLoader" filename="file.obj" /> ... <FixedConstraint name="myConstraint" indices="@IDLoader.position" />
HTH
Cheers,Hugo
HugoKeymasterHey Kliment,
If a CMake variable is not present, just add it yourself in cmake-gui using “Add Entry”
Cheers
Hugo
HugoKeymasterHey Noura,
You’re right, the folder hierarchy can be somehow confusing. But a new refactoring will be proposed soon. Stay tuned 😉
The idea of SofaKernel was to gather most-used components:
– it includes the base/abstract classes of classes (usually in SofaKernel/framework)
– and it also includes implementations of these classes (usually in SofaKernel/modules)But the future refactoring (by the end of 2017) should ease the understanding of the folder architecture.
Best,
Hugo
HugoKeymasterHi ruilang !
Which version of SOFA are you using?
Are you really (cf tags) using SOFA v1608 ?Cheers,
H
24 July 2017 at 09:07 in reply to: [SOLVED] TetrahedralCorotationalFEMForcefeild used with SurfaceRegistration #9835HugoKeymasterHey Lujain
Have you tried to replace:
<include href="Objects/TetrahedronSetTopology.xml" src="@loader" />
by :
<TetrahedronSetTopologyContainer name="Container" src="@loader"/> <TetrahedronSetTopologyModifier name="Modifier" /> <TetrahedronSetGeometryAlgorithms name="GeomAlgo" template="Vec3d" />
Cheers
Hugo
21 July 2017 at 15:12 in reply to: [SOLVED] TetrahedralCorotationalFEMForcefeild used with SurfaceRegistration #9821HugoKeymasterDear Lujain,
If I got you right, you want to register a 3D object. But to do it, you are registering its surface against the surface of the target. Is that correct ?
If so, then I would advise to have a scene looking as follows (just an example based on Registration/examples/ICPRegistration_ShapeMatching_Engine.scn):
<?xml version="1.0"?> <Node name="Scene" gravity="0 0 0" dt="1" > <RequiredPlugin name="Registration" pluginName="Registration" /> <VisualStyle displayFlags="showForceFields showVisual" /> <EulerImplicitSolver rayleighStiffness="0.5" rayleighMass="0.5" /> <CGLinearSolver template="GraphScattered" iterations="25" threshold="1e-008" /> <Node name="target"> <OglModel name="Bone" fileMesh="data/femur_f.obj" color="0.5 .4 1 1" /> </Node> <Node name="PassiveVolumetricMesh"> <MeshVTKLoader name="meshLoader" filename="yourVTKfile.vtk"/> <Mesh src="@loader" /> <MechanicalObject src="@loader" dx="2.5" /> <include href="Objects/TetrahedronSetTopology.xml" src="@loader" /> <UniformMass totalmass="5" /> <TetrahedronFEMForceField name="FEM" youngModulus="1000" poissonRatio="0.4" computeGlobalMatrix="false" method="large" /> <Node name="RegisteredTriangleSurface"> <include href="Objects/TriangleSetTopology.xml" src="@" tags=" " /> <Tetra2TriangleTopologicalMapping input="@../Container" output="@Container" /> <MechanicalObject name="PointSet" /> <UniformMass mass="10"/> <ClusteringEngine template="Vec3d" name="clustering" radius='0.4' number='100' position="@meshLoader.position"/> <ShapeMatching template="Vec3d" name="shapeMatching" iterations='1' position="@PointSet.position" cluster="@clustering.cluster"/> <PositionBasedDynamicsConstraint template="Vec3d" stiffness = '1' position="@shapeMatching.targetPosition"/> <NormalsFromPoints name="NormalsFromPoints" template="Vec3d" position="@PointSet.position" triangles="@meshLoader.triangles" quads="@meshLoader.quads"/> <ClosestPointRegistrationForceField template="Vec3d" sourceTriangles="@../meshLoader.triangles" sourceNormals="@NormalsFromPoints.normals" position="@../../target/Bone.position" triangles="@../../target/Bone.triangles" normals="@../../target/Bone.normal" cacheSize="4" stiffness="1" damping="0" /> <Node name="Visu"> <OglModel name="Visual" fileMesh="data/femur_m.obj" normals="0" color="1 .4 0.5 1" /> <BarycentricMapping input="@.." output="@Visual" /> </Node> </Node> </Node> </Node>
HTH
Hugo
HugoKeymasterHey @beejay !
Thank you for joining the SOFA force!
Model reduction looks pretty appealing to me, even more when you want to do it in SOFA. I actually think that SOFA is really well suited (thanks to the mapping mechanism among others) for this.Your approach looks good to me: using one MechanicalObject for your real DOFs and one MechanicalObject corresponding to reduced space DOFs. Both should be linked with a specific mapping.
Since I am no expert in model reduction, I will point out your thread to two senior developers that might help you. Hopefully they will reply shortly. If not, I’ll make sure you find answers!
Cheers,
Hugo
HugoKeymasterDear Yannie,
Your question has been discussed at the weekly dev meeting (you can follow the agenda and report by subscribing to the sofa-dev mailing list).
Here is the answer I got:- a question on the forum about SofaPython in a C++ scene: the best is to initialize the python environment using the PluginManager (sofa::helper::system::PluginManager). Thus, you are able to directly load the python environment
- about the initialization of free_position (in the MultiVector of the MechanicalState), it is created when a FreeAnimationLoop is created if I remember properly. Otherwise, it won’t be allocated.
HTH
Best,Hugo
HugoKeymasterClearer, shorter : discover our new Get Involved page!
Ask us for any additional question or information.Best regards,
The SOFA Consortium
13 July 2017 at 17:55 in reply to: [SOLVED] Mapping between BeamFEMForceField behavioral model and oglmodel #978913 July 2017 at 17:54 in reply to: [SOLVED] TetrahedralCorotationalFEMForcefeild used with SurfaceRegistration #9788HugoKeymasterHi Lujain,
Sorry but I really don’t get what you intend to do. Could you explain it more in details (why applying a force on your surface object)
For registration between datasets have a look at the examples in registration plugin.
Did you already build your own simulation ?If you want to create forces, all you need to use is a forcefield (look at the ConstantForcefield which is very basic to have an idea).
HTH
Hugo
HugoKeymasterHi logo,
Thank you for your interest in SOFA!
Unfortunately I am no expert of these collision responses. From what I know, the friction is based on Signorini’s and Coulomb’s laws. But I don’t know well stick contacts.What is sure is that using springs to models contacts, is a strong approximation since you will apply forces mimicking a contact..
Maybe somebody else would have more input about contacts in SOFA.
Best,
Hugo
HugoKeymasterHi Bam !
Thank you for your first post and welcome to the SOFA community!
Sorry for the delay we have been quite busy these days!I am no expert of musculo-skelettal simulation I think @noura might be able to help, looking at her last post: https://www.sofa-framework.org/community/forum/topic/mapping-between-rigid-and-deformable-objects/
Best,
Hugo
HugoKeymasterHi Yannie,
You tried PythonScriptController_Placeholders.py in your C++ scene and it did not work ?
In your C++ scene, you instantiated a PythonScripController with the data filename set toPythonScriptController_Placeholders.py
and the data classname set to the stringExampleController
?Have you tried to specify in you C++ scene, a RequiredPlugin with the data pluginName set to
SofaPython
?HTH
Hugo
HugoKeymasterHi Lujain,
femur_m is maybe used to show that the number of nodes between the origin and target mesh can be different.
Hugo
HugoKeymasterHi wendyarch,
If you want to add a LeapMotion to your initial SOFA scene, here is what you need:
<RequiredPlugin name="LeapMotion Driver" pluginName="LeapMotion" />
to load the LeapMotion plugin (that needs to be compiled before obviously).
Then, you need :<LeapMotionDriver name="leapMotionDriver" displayHand="true"/>
which is the interface component providing all informations from the Leap.
Finally, you can use it in your scene as detailed in applications/plugins/LeapMotion/examples:<Node name="TrackedHand" activated="true" > <Gravity name="Gravity" gravity="0 0 0" /> <Node name="TrackedPalm" > <MechanicalObject name="movingDOFs" template="Rigid" position="@../../leapMotionDriver.handPalmCoordinate" showObject="false" showObjectScale="0.02" /> </Node> <Node name="TrackedFingers" > <MechanicalObject name="movingDOFs" template="Rigid" position="@../../leapMotionDriver.fingersCoordinates" showObject="false" showObjectScale="0.02" /> </Node> </Node> <Node name="SimulatedHand" activated="true" > <VisualStyle displayFlags="showVisualModels hideBehaviorModels hideCollisionModels hideMappings hideForceFields" /> <Node name="Palm"> <Gravity name="Gravity" gravity="0 0 0" /> <MechanicalObject name="palmState" template="Rigid" rest_position="@../../leapMotionDriver.handPalmCoordinate" showObject="false" showObjectScale="0.02" /> <RestShapeSpringsForceField name="RSFF" stiffness="1e6" angularStiffness="1e3" external_rest_shape="../../TrackedHand/TrackedPalm/movingDOFs" recompute_indices="false" /> <UniformMass name="uniformMass" template="Rigid" totalmass="0.1" /> <Node name="Collision_Model" > <MechanicalObject name="collisDOFs" template="Vec3d" position="@../../../leapMotionDriver.handPalmCoordinate" /> <Sphere name="colliSphere" contactStiffness="100" group="1" radius="0.07"/> <IdentityMapping/> </Node> </Node> <Node name="Fingers" > <Gravity name="Gravity" gravity="0 0 0" /> <MechanicalObject name="handDOFs" template="Rigid" rest_position="@../../leapMotionDriver.fingersCoordinates" showObject="false" showObjectScale="0.02" /> <RestShapeSpringsForceField name="RSFF" stiffness="1e3" angularStiffness="1e3" external_rest_shape="../../TrackedHand/TrackedFingers/movingDOFs" recompute_indices="false" /> <UniformMass name="uniformMass" template="Rigid" totalmass="0.5" /> <Node name="Collision_Model" > <MechanicalObject name="lineCollisDOFs" template="Vec3d" position="@../../../leapMotionDriver.fingersCoordinates" /> <EdgeSetTopologyContainer name="EdgeContainer" nbPoints="15" edges="0 2 2 1 3 5 5 4 6 8 8 7 9 11 11 10 12 14 14 13 " position="@../../../leapMotionDriver.fingersCoordinates" /> <Node name="Sphere_Collision_Model"> <PointSetTopologyContainer name="PointContainer" /> <Mesh2PointTopologicalMapping input="@../EdgeContainer" output="@PointContainer" pointBaryCoords="0 0 0" edgeBaryCoords="0.33 0.0 0.0 0.66 0.0 0.0 " /> <MechanicalObject name="sphereCollisDOFs"/> <Mesh2PointMechanicalMapping /> <Sphere name="colliSphere" group="1" contactStiffness="1e7" contactFriction="0.05" contactRestitution="0" radius="0.0175" /> </Node> </Node> </Node> </Node>
Hope this helps,
Hugo
10 July 2017 at 13:33 in reply to: [SOLVED] A Problem About How to Move A Fixed Rigid Object in C++ Project? #9777HugoKeymasterHi wq57fan,
the C++ code you share does not include any MechanicalObject. Is that normal ?
To make your object fall under gravity, I see two issues: the MechanicalObject is missing and the gravity needs to be specified (you can set the gravity in the rootNode as a parameter).For collision detection, you need to specify the collision topology. You can have a look at the scene examples/Components/collisionTriangleModel.scn which illustrate this well.
Let me know if this helps.
Hugo
HugoKeymasterHi Yannie
Could you please post the complete Python script ? Python scripts are sensitive to tabulations. Seeing the entire script would help,
Thank you !
29 June 2017 at 11:13 in reply to: [SOLVED] TetrahedralCorotationalFEMForcefeild used with SurfaceRegistration #9378HugoKeymasterHi Lujain,
What do you mean with SurfaceRegistration ? Is this a scene ? a component ?
I am not aware of it.With a surface mesh, you cannot use the TetrahedralCorotationalFEMForcefield since tetrahedra are needed. Importing volumetric meshes is possible using VTKExporter for instance (or others like GmshLoader).
Hugo
HugoKeymasterHi Cristóbal,
Good to hear!
Setting n = “3 3 3” means that you will have 3x3x3 vertices in x, y and z. In other words, 2x2x2 sub-cubes. So this is normal.But the RegularGrid should be working this way:
<Node name="root" dt="0.02"> <VisualStyle displayFlags="showBehaviorModels showForceFields showVisual" /> <CollisionPipeline verbose="0" /> <BruteForceDetection name="N2" /> <CollisionResponse response="default" /> <DiscreteIntersection/> <Node name="LiverFFD-lowres"> <EulerImplicit /> <CGLinearSolver iterations="25" tolerance="1e-5" threshold="1e-5"/> <MechanicalObject /> <UniformMass totalmass="100.0" /> <RegularGrid nx="5" ny="3" nz="3" xmin="-1" xmax="2" ymin="-1" ymax="2" zmin="-1" zmax="2" /> <BoxConstraint box="-1 -1 -1 2 2 -1" /> <RegularGridSpringForceField name="Springs" stiffness="400" damping="4" /> <Node name="Collision Surface"> <SphereLoader filename="mesh/liver.sph" /> <MechanicalObject position="@[-1].position" translation="-5 0 0" /> <Sphere name="Surf" listRadius="@[-2].listRadius" /> <BarycentricMapping input="@.." output="@." /> </Node> </Node> </Node>
Moreover, avoid the Modeler 😉 it’s considered as deprecated.
HTHHugo
HugoKeymasterHey Cristóbal,
This isn’t normal indeed and I get the same issue. I reported this behaviour in an issue on GitHub, you can further discuss it on GitHub.
I think it is somehow related to the computation of the bounding box of the object (in SparseGrid) influencing the min and max data.
Anyway, if you just want to create a grid, you can bypass the problem by using a RegularGrid instead of a sparse one:
RegularGridTopology name="sparseGridTopology3" min="-1 -1 -1" max="1 1 1" n="2 2 2" />
Thank you again for the notice
Hugo
HugoKeymasterThe mesh is just another configuration, the naming shouldn’t bother you. Do you need any further info? would you like to close the topic?
HugoKeymasterHey Yannie,
the error shows that you are using an un-initialized data. But your code looks ok. I would have written :
#include "PythonScriptController.h" ... int main(int argc, char** argv) { ... sofa::simulation::Node::SPtr groot = sofa::simulation::getSimulation()->createNewGraph("root"); groot->setGravity( Coord3(0,-10,0) ); ... std::string filename = "keyboardControl.py"; std::string classname = "yourclassname"; sofa::component::controller::PythonScriptController::SPtr pyContr = sofa::core::objectmodel::New<sofa::component::controller::PythonScriptController>(); pyContr->m_filename.setValue(filename); pyContr->m_classname.setValue(classname); groot->addObject(pyContr); }
and your CMakeLists.txt should look like:
cmake_minimum_required(VERSION 3.1) project(mytest) find_package(SofaSimulation) find_package(SofaPython) add_executable(${PROJECT_NAME} test.cpp) target_link_libraries(${PROJECT_NAME} SofaPython SofaSimulation)
HTH,
Hugo
-
AuthorPosts