Forum Replies Created
-
AuthorPosts
-
Hugo
KeymasterHi @jieying
I am sorry, I never used MT in Python.
Maybe some others did : @damien-marchaluniv-lille1-fr @jnbrunet @bmarques ?Best,
Hugo
Hugo
KeymasterHi Gaetan
I think I better understood, the question is how to correctly access the fields of a MechanicalObject in C++. Your approach using
this->getContext()->get(mecaState);
will work.Just a remark: this means that your exporter will implicitely browse its node and look for a MechanicalObject. In SOFA, we are now advising to rather use explicit Links (see and example in NearestPointROI). In your case, feel free to use the getContext() approach.
Let me know you struggle to access the ‘position’ field of your MechanicalObject.
Best wishes,Hugo
Hugo
KeymasterHi @gaetan
Before anything, I apologize I am no expert from the Flexible plugin.
If I understand correctly you are using Flexible, in a scene written in python. Is that correct?
Is the gradient matrix directly computed from a Flexible component? or do you want to compute it yourself from the position, rest_position and topology information?Hugo
Hugo
KeymasterOk, you then have a problem of dependency. Let me explain.
You are including classes contained in the SofaBaseTopology library. As shown in the CheatSheet (not perfectly up to date FYI), the SofaBaseTopology belongs the SofaBase package.
Here is the CMakeLists.txt you need to use:
cmake_minimum_required(VERSION 3.1) project(CardiacReduction VERSION 0.1) find_package(SofaFramework REQUIRED) find_package(SofaBase REQUIRED) set(HEADER_FILES initCardiacReduction.h config.h # main.h ) set(SOURCE_FILES initCardiacReduction.cpp # main.cpp ) add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} SofaCore SofaBaseTopology) set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-DSOFA_BUILD_CARDIACREDUCTION") install(TARGETS CardiacReduction RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
Let me know if it helps.
BestHugo
Hugo
KeymasterGreat to hear! Congratulations @taro
I close the topic. The forum and the community stays at your disposal. Good luck in your next steps.Hugo
Hugo
KeymasterHi @gaetan
thanks for the detailed explanation, it helps. Can you finally post your plugin CMakeLists.txt please?
Hugo
Hugo
KeymasterHi @amit
I forgot to mention, but do not hesitate to pull-request this improvement of BoxROI in SOFA! To do so, the documentation is here.
Right now I am struggling with collision detection in sofa. When I set my models for collision(triangle/sphere or any model) the frame rate drops and the simulation becomes unusable.
Performances will depend on your mesh refinement for the collision model, as well as on the numerical properties. I would advise to first try using a slightly coarser mesh for the collision detection. Do not hesitate to share your scene with me (in private if necessary).
However, once everything is optimized, if the simulation is still not efficient enough there is (always!) solutions. We have independent developers in the community working on a multithreaded and GPU collision detection. I could put you in contact with these guys if you need it.
Best
Hugo
Hugo
KeymasterNice !
I will mark the topic as solved, congrats!Hugo
Hugo
KeymasterHey @bence
Your first idea of looking in the ‘keyboardControl’ example of the SofaPython plugin was very good!
Are you sure to have SofaPython compiled on your machine?
Can you tell me what happens (console output) when you run this example?
Nothing happens when using ctrl+keys (from directional keyboard)?Hugo
Hugo
KeymasterHey @amit,
What you can do in the
draw()
function of BoxROI is to use the function:vparams->drawTool()->draw3DText(pv, size, color, indice);
I tried it on my side, it worked. Here is a diff file:
diff --git a/SofaKernel/modules/SofaEngine/BoxROI.h b/SofaKernel/modules/SofaEngine/BoxROI.h index c1896c2..4bad42e 100644 --- a/SofaKernel/modules/SofaEngine/BoxROI.h +++ b/SofaKernel/modules/SofaEngine/BoxROI.h @@ -166,6 +166,7 @@ public: //Parameter Data<bool> d_drawBoxes; ///< Draw Boxes. (default = false) Data<bool> d_drawPoints; ///< Draw Points. (default = false) + Data<bool> d_drawPointIndices; ///< Draw Points indices. (default = false) Data<bool> d_drawEdges; ///< Draw Edges. (default = false) Data<bool> d_drawTriangles; ///< Draw Triangles. (default = false) Data<bool> d_drawTetrahedra; ///< Draw Tetrahedra. (default = false) diff --git a/SofaKernel/modules/SofaEngine/BoxROI.inl b/SofaKernel/modules/SofaEngine/BoxROI.inl index 776307e..43bd206 100644 --- a/SofaKernel/modules/SofaEngine/BoxROI.inl +++ b/SofaKernel/modules/SofaEngine/BoxROI.inl @@ -91,6 +91,7 @@ BoxROI<DataTypes>::BoxROI() , d_nbIndices( initData(&d_nbIndices,"nbIndices", "Number of selected indices") ) , d_drawBoxes( initData(&d_drawBoxes,false,"drawBoxes","Draw Boxes. (default = false)") ) , d_drawPoints( initData(&d_drawPoints,false,"drawPoints","Draw Points. (default = false)") ) + , d_drawPointIndices( initData(&d_drawPointIndices,false,"drawPointIndices","Draw Points indices in ROI. (default = false)") ) , d_drawEdges( initData(&d_drawEdges,false,"drawEdges","Draw Edges. (default = false)") ) , d_drawTriangles( initData(&d_drawTriangles,false,"drawTriangles","Draw Triangles. (default = false)") ) , d_drawTetrahedra( initData(&d_drawTetrahedra,false,"drawTetrahedra","Draw Tetrahedra. (default = false)") ) @@ -810,6 +811,29 @@ void BoxROI<DataTypes>::draw(const core::visual::VisualParams* vparams) vparams->drawTool()->drawLines(vertices, linesWidth, color); } + ///draw points indices in ROI + if( d_drawPointIndices.getValue()) + { + float size = d_drawSize.getValue() ? (float)d_drawSize.getValue() : 1; + vparams->drawTool()->setLightingEnabled(false); + std::vector<Vector3> vertices; + ReadAccessor< Data<VecCoord > > pointsInROI = d_pointsInROI; + ReadAccessor< Data<SetIndex > > indices = d_indices; + + for (unsigned int i=0; i<pointsInROI.size() ; ++i) + { + CPos p = DataTypes::getCPos(pointsInROI[i]); + Vector3 pv; + for( unsigned int j=0 ; j<max_spatial_dimensions ; ++j ) + pv[j] = p[j]; + + std::ostringstream oss; + oss << indices[i]; + const char* indice = oss.str().c_str(); + vparams->drawTool()->draw3DText(pv, size, color, indice); + } + } + ///draw triangles in ROI if( d_drawTriangles.getValue()) {
Events are described here. Using the listening option, you will activate the c++ function handleEvent() handling all SOFA events.
Best,
Hugo
Hugo
KeymasterAt the configuration phase (Cmake), what was the output?
What were the info about boost at this cmake stage?Best
Hugo
Hugo
KeymasterHi Gaetan
If I understood correctly, you downloaded the binary version of SOFA v18.12.01. And now you are willing to compile your own plugin separately. Is that it?
Could you describe the way your repositories are arranged? (where are the binaries of SOFA, where is you main.cpp etc)Hugo
Hugo
KeymasterHi @atefe
And welcome to the SOFA forum! Physics simulation is advanced modeling. I advise you to read papers focusing on this (see our Publication page) and to read this habilitation thesis which is really complete.
You can also find sources of information to start with SOFA:
– follow the online documentation
– watch our first Tutorials on YouTube
– start using SOFA, running the examples/TutorialsNote that we are also provided training sessions for an efficient introduction to SOFA.
I hope this helps.Best
Hugo
Hugo
KeymasterHi @lakehanne
1. I am not familiar with ROS and not sure of what you need. As I understand it, something would solve your question: either use python in which you can have global variable in your script or in xml, you can use *.pscn files (e.g. see /data/Softwares/sofa/src/master/examples/Benchmark/Performance/Bar16-fem-implicit-Vec3f.pscn or any other pscn scene.
2. your warning comes from the fact that the component MeshTopology has no data named “dx”. This input is therefore just not taken into account.
Does this answer your questions?
BestHugo
Hugo
KeymasterRegarding the blue ball not following, here is the explanation. You are controlling the blue ball, which has no collision model. The red ball has a collision model therefore, when a collision occurs, the ball is stuck due to collision. Since both objects are only related by springs, even if the blue ball pulls on the red one, collision forces the red ball to remain in collision on the floor.
Does it answer your question?
bestHugo
Hugo
KeymasterHi @ma1991,
I poke again @damien-marchaluniv-lille1-fr since I am not sure he saw your reply on STLIB and SoftRobot.
Best,
Hugo
Hugo
KeymasterHi @taro and welcome on the SOFA forum !
I am no big Windows user, but boost can be installed anywhere. Then, to solve Boost detection errors, click on Add Entry and add
BOOST_ROOT
with type PATH and valueC:/boost/boost_1_XX_X
matching your Boost lib folder. Example:BOOST_ROOT=C:/boost/boost_1_61_0
and Configure again.This is detailed in the Win documentation.
Let me know if it helps.
Hugo
Hugo
KeymasterHi @secretdevil
Thank you so much for this very interesting feedback.
Work at Simedix is impressive, carry on the good work!Hugo
Hugo
KeymasterJust to close this topic, all contribution information can be found in the source of SOFA: CONTRIBUTING.md
Hugo
Hugo
KeymasterHi all,
Just some updates about SOFA within Unity3D or UnrealEngine. The company InfinyTech3D performed the coupling of SOFA within these two softwares:
- video for SOFA in Unity3D
- video of the POC for for SOFA in UnrealEngine
Any interest? you can contact the SOFA staff here.
Best wishes,
Hugo
Hugo
KeymasterThe little change you had to do might come from the difference of SOFA version.
Just a short question, is your gist scene file up-to-date?
Hugo
Hugo
KeymasterHey @amit,
There is no such option in the BoxROI. However, this could be added in the
draw()
function of the BoxROI class by getting inspired of the draw() in the MechanicalObject.
Let us know if you struggle with this part.Best
Hugo
Hugo
KeymasterHi @lakehanne
In the SOFA GUI, you have a button “Save View” allowing you to save the current camera position. This actually generates a file (*.scn.view) storing these information (position and orientation).
If you are in python, an alternative is to use an
<InteractiveCamera />
. You can find the API of InteractiveCamera here.Let me know if it helps.
Hugo
Hugo
KeymasterThanks @amit for redirecting to InfinyTech3D.
For any such technology question, never hesitate to contact directly the SOFA staff through the contact form.Best
Hugo
Hugo
KeymasterHey @amit,
To know which are the indices, you can see these point indices in SOFA by setting in the MechanicalObject:
showIndices="1"
andshowIndicesScale="3.0"
(set the scale you want).If you want to automatically select points in a region of interest (ROI), you can still use Box/Sphere/NearestPointROI.
This could help. If this is not what you are looking for, please let me know.
BestHugo
-
AuthorPosts