Forum Replies Created
-
AuthorPosts
-
SenBlocked
hi,
I want to know the of principle sofacarving pluin. How it removes the vertices and edges, and how to generate new surfaces? Do you have a related article or flowchart ?SenBlockedHi Max,
Thank you. In bruteforcedetection, I want to know that how to detect the collision in detail in Narrow phases. I need you give me specific process or literature or formulas to explain it.
And in SOFA ,the force is f=k*x ? How to calculate the force? I also need formulas.
And in SOFA, How the friction contact is produced? I also need literature or formulas.
I have a lot of questions and I really like SOFA. I want to understand it theoretically and then improve it.
Thank you.SenBlockedHi,
When the collision happened, if it is friction contact,I do not know how to calculate the force .SenBlockedhi,
I can not see the inside of the content in your ‘Like this’.Can you resend once again?In SOFA, can it simulate grasping ?SenBlockedHi,
When the collision happened, if it is friction contact,I do not know how to calculate the force .SenBlockedHi Hugo,
Thank you. I would like to know more details about broadphase , Narrow phases and friction contact.
broadPhaseDetection->addCollisionModels(vectBoundingVolume); // detection is done there
I do not know how it detects the collision. I found it in the “BruteForceDetection::addCollisionModel(core::CollisionModel *cm)”,But I can not understand the code.And in the Narrow phases , “BruteForceDetection::addCollisionPair”
is to find the collision point.But I do not know what method it is using to detect the collision point.Are there formulas or documents or Flow chart or algorithms to explain it ?11 May 2017 at 15:30 in reply to: [SOLVED] Collision detection algorithm and the algorithm to calculate the feedback force. #9108SenBlockedHi,
There are formulas or documents to how to explain or calculate it ?SenBlockedhi,
In actual surgery, the doctor will often involve the use of tweezers to clip the object movement, we want to simulate the operation of this operation. We use tweezers to clip things and then move it18 April 2017 at 14:51 in reply to: [SOLVED] How to read XML file in SOFA? Where to read it in c++ code? #8955SenBlockedHi,
I know XML file can read by c++.But I don not konw where to read the XML information in c++code .Such as how visual model and gravity information is passed to the c++ code by XML.8 April 2017 at 15:50 in reply to: [SOLVED] How to look at the example of the source code(c++) ? #8895SenBlockedHi,
/****************************************************************************** * SOFA, Simulation Open-Framework Architecture, version 1.0 RC 1 * * (c) 2006-2011 INRIA, USTL, UJF, CNRS, MGH * * * * This program is free software; you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by the Free * * Software Foundation; either version 2 of the License, or (at your option) * * any later version. * * * * This program is distributed in the hope that it will be useful, but WITHOUT * * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * * more details. * * * * You should have received a copy of the GNU General Public License along * * with this program; if not, write to the Free Software Foundation, Inc., 51 * * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ******************************************************************************* * SOFA :: Applications * * * * Authors: The SOFA Team and external contributors (see Authors.txt) * * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ #include <iostream> #include <sstream> #include <fstream> #include <sofa/helper/ArgumentParser.h> #include <sofa/simulation/common/common.h> #include <sofa/simulation/common/Node.h> #include <sofa/helper/system/PluginManager.h> #ifdef SOFA_HAVE_DAG #include <sofa/simulation/graph/init.h> #include <sofa/simulation/graph/DAGSimulation.h> #endif #ifdef SOFA_SMP #include <sofa/simulation/tree/SMPSimulation.h> #endif #include <sofa/simulation/tree/init.h> #include <sofa/simulation/tree/TreeSimulation.h> #include <SofaComponentMain/init.h> #include <SofaLoader/ReadState.h> #include <SofaValidation/CompareState.h> #include <sofa/helper/Factory.h> #include <sofa/helper/BackTrace.h> #include <sofa/helper/system/FileRepository.h> #include <sofa/helper/system/SetDirectory.h> #include <sofa/helper/Utils.h> #include <sofa/gui/GUIManager.h> #include <sofa/gui/Main.h> #include <sofa/gui/BatchGUI.h> // For the default number of iterations #include <sofa/helper/Logger.h> #include <sofa/helper/system/gl.h> #include <sofa/helper/system/glut.h> #include <sofa/helper/system/atomic.h> #ifdef SOFA_SMP #include <athapascan-1> #endif /* SOFA_SMP */ #ifdef WIN32 #include <windows.h> #endif using std::cerr; using std::endl; using sofa::helper::Utils; using sofa::helper::Console; void loadVerificationData(std::string& directory, std::string& filename, sofa::simulation::Node* node) { std::cout << "loadVerificationData from " << directory << " and file " << filename << std::endl; std::string refFile; refFile += directory; refFile += '/'; refFile += sofa::helper::system::SetDirectory::GetFileName(filename.c_str()); std::cout << "loadVerificationData " << refFile << std::endl; sofa::component::misc::CompareStateCreator compareVisitor(sofa::core::ExecParams::defaultInstance()); compareVisitor.setCreateInMapping(true); compareVisitor.setSceneName(refFile); compareVisitor.execute(node); sofa::component::misc::ReadStateActivator v_read(sofa::core::ExecParams::defaultInstance(), true); v_read.execute(node); } // --------------------------------------------------------------------- // --- // --------------------------------------------------------------------- int main(int argc, char** argv) { sofa::simulation::tree::init(); #ifdef SOFA_HAVE_DAG sofa::simulation::graph::init(); #endif sofa::component::init(); //std::cout << "Using " << sofa::helper::system::atomic<int>::getImplName()<<" atomics." << std::endl; sofa::helper::BackTrace::autodump(); sofa::core::ExecParams::defaultInstance()->setAspectID(0); #ifdef WIN32 { HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE); COORD s; s.X = 160; s.Y = 10000; SetConsoleScreenBufferSize(hStdout, s); CONSOLE_SCREEN_BUFFER_INFO csbi; if (GetConsoleScreenBufferInfo(hStdout, &csbi)) { SMALL_RECT winfo; winfo = csbi.srWindow; //winfo.Top = 0; winfo.Left = 0; //winfo.Bottom = csbi.dwSize.Y-1; winfo.Right = csbi.dwMaximumWindowSize.X-1; SetConsoleWindowInfo(hStdout, TRUE, &winfo); } } #endif sofa::gui::initMain(); std::string fileName ; bool startAnim = false; bool printFactory = false; bool loadRecent = false; bool temporaryFile = false; bool testMode = false; int nbIterations = sofa::gui::BatchGUI::DEFAULT_NUMBER_OF_ITERATIONS; unsigned int nbMSSASamples = 1; unsigned computationTimeSampling=0; ///< Frequency of display of the computation time statistics, in number of animation steps. 0 means never. std::string gui = ""; std::string verif = ""; #ifdef SOFA_SMP std::string simulationType = "smp"; #else std::string simulationType = "tree"; #endif std::vector<std::string> plugins; std::vector<std::string> files; #ifdef SOFA_SMP std::string nProcs=""; bool disableStealing = false; bool affinity = false; #endif std::string colorsStatus = "auto"; std::string gui_help = "choose the UI ("; gui_help += sofa::gui::GUIManager::ListSupportedGUI('|'); gui_help += ")"; sofa::helper::parse(&files, "This is a SOFA application. Here are the command line arguments") // alphabetical order on short name .option(&startAnim,'a',"start","start the animation loop") .option(&computationTimeSampling,'c',"computationTimeSampling","Frequency of display of the computation time statistics, in number of animation steps. 0 means never.") .option(&gui,'g',"gui",gui_help.c_str()) .option(&plugins,'l',"load","load given plugins") .option(&nbMSSASamples, 'm', "msaa", "number of samples for MSAA (Multi Sampling Anti Aliasing ; value < 2 means disabled") .option(&nbIterations,'n',"nb_iterations","(only batch) Number of iterations of the simulation") .option(&printFactory,'p',"factory","print factory logs") .option(&loadRecent,'r',"recent","load most recently opened file") .option(&simulationType,'s',"simu","select the type of simulation (bgl, dag, tree, smp)") .option(&temporaryFile,'t',"temporary","the loaded scene won't appear in history of opened files") .option(&testMode,'x',"test","select test mode with xml output after N iteration") .option(&verif,'v',"verification","load verification data for the scene") .option(&colorsStatus,'z',"colors","use colors on stdout and stderr (yes, no, auto)") #ifdef SOFA_SMP .option(&disableStealing,'w',"disableStealing","Disable Work Stealing") .option(&nProcs,'c',"nprocs","Number of processor") .option(&affinity,'f',"affinity","Enable aFfinity base Work Stealing") #endif (argc,argv); #ifdef SOFA_SMP int ac = 0; char **av = NULL; Util::KaapiComponentManager::prop["util.globalid"]="0"; Util::KaapiComponentManager::prop["sched.strategy"]="I"; if(!disableStealing) Util::KaapiComponentManager::prop["sched.stealing"]="true"; if(nProcs!="") Util::KaapiComponentManager::prop["community.thread.poolsize"]=nProcs; if(affinity) { Util::KaapiComponentManager::prop["sched.stealing"]="true"; Util::KaapiComponentManager::prop["sched.affinity"]="true"; } a1::Community com = a1::System::join_community( ac, av); #endif /* SOFA_SMP */ #ifndef SOFA_NO_OPENGL if(gui!="batch") glutInit(&argc,argv); #endif #ifdef SOFA_SMP if (simulationType == "smp") sofa::simulation::setSimulation(new sofa::simulation::tree::SMPSimulation()); else #endif #ifdef SOFA_HAVE_DAG if (simulationType == "tree") sofa::simulation::setSimulation(new sofa::simulation::tree::TreeSimulation()); else sofa::simulation::setSimulation(new sofa::simulation::graph::DAGSimulation()); #else //SOFA_HAVE_DAG sofa::simulation::setSimulation(new sofa::simulation::tree::TreeSimulation()); #endif if (colorsStatus == "auto") Console::setColorsStatus(Console::ColorsAuto); else if (colorsStatus == "yes") Console::setColorsStatus(Console::ColorsEnabled); else if (colorsStatus == "no") Console::setColorsStatus(Console::ColorsDisabled); else { Console::setColorsStatus(Console::ColorsAuto); sofa::helper::Logger::getMainLogger().log( sofa::helper::Logger::Warning, std::string( "Invalid argument '") + colorsStatus + std::string(" 'for '--colors '" ) ); } // Add the plugin directory to PluginRepository #ifdef WIN32 const std::string pluginDir = Utils::getExecutableDirectory(); #else const std::string pluginDir = Utils::getSofaPathPrefix() + "/lib"; #endif sofa::helper::system::PluginRepository.addFirstPath(pluginDir); // Initialise paths sofa::gui::BaseGUI::setConfigDirectoryPath(Utils::getSofaPathPrefix() + "/config"); sofa::gui::BaseGUI::setScreenshotDirectoryPath(Utils::getSofaPathPrefix() + "/screenshots"); if (!files.empty()) fileName = files[0]; for (unsigned int i=0; i<plugins.size(); i++) sofa::helper::system::PluginManager::getInstance().loadPlugin(plugins[i]); sofa::helper::system::PluginManager::getInstance().init(); if(gui.compare("batch") == 0 && nbIterations >= 0) { std::ostringstream oss ; oss << "nbIterations="; oss << nbIterations; sofa::gui::GUIManager::AddGUIOption(oss.str().c_str()); } if(nbMSSASamples > 1) { std::ostringstream oss ; oss << "msaa="; oss << nbMSSASamples; sofa::gui::GUIManager::AddGUIOption(oss.str().c_str()); } if (int err = sofa::gui::GUIManager::Init(argv[0],gui.c_str())) return err; if (fileName.empty()) { if (loadRecent) // try to reload the latest scene { std::string scenes = sofa::gui::BaseGUI::getConfigDirectoryPath() + "/runSofa.ini"; std::ifstream mrulist(scenes.c_str()); std::getline(mrulist,fileName); mrulist.close(); } else fileName = "Demos/caduceus.scn"; fileName = sofa::helper::system::DataRepository.getFile(fileName); } if (int err=sofa::gui::GUIManager::createGUI(NULL)) return err; //To set a specific resolution for the viewer, use the component ViewerSetting in you scene graph sofa::gui::GUIManager::SetDimension(800,600); sofa::simulation::Node::SPtr groot = sofa::core::objectmodel::SPtr_dynamic_cast<sofa::simulation::Node>( sofa::simulation::getSimulation()->load(fileName.c_str())); if (groot==NULL) { groot = sofa::simulation::getSimulation()->createNewGraph(""); } if (!verif.empty()) { loadVerificationData(verif, fileName, groot.get()); } sofa::simulation::getSimulation()->init(groot.get()); sofa::gui::GUIManager::SetScene(groot,fileName.c_str(), temporaryFile); //======================================= //Apply Options if (startAnim) groot->setAnimate(true); if (printFactory) { std::cout << "////////// FACTORY //////////" << std::endl; sofa::helper::printFactoryLog(); std::cout << "//////// END FACTORY ////////" << std::endl; } if( computationTimeSampling>0 ) { sofa::helper::AdvancedTimer::setEnabled("Animate", true); sofa::helper::AdvancedTimer::setInterval("Animate", computationTimeSampling); } //======================================= // Run the main loop if (int err = sofa::gui::GUIManager::MainLoop(groot,fileName.c_str())) return err; groot = dynamic_cast<sofa::simulation::Node*>( sofa::gui::GUIManager::CurrentSimulation() ); if (testMode) { std::string xmlname = fileName.substr(0,fileName.length()-4)+"-scene.scn"; std::cout << "Exporting to XML " << xmlname << std::endl; sofa::simulation::getSimulation()->exportXML(groot.get(), xmlname.c_str()); } if (groot!=NULL) sofa::simulation::getSimulation()->unload(groot); sofa::gui::GUIManager::closeGUI(); sofa::simulation::tree::cleanup(); #ifdef SOFA_HAVE_DAG sofa::simulation::graph::cleanup(); #endif return 0; }
my mian.cpp has 350 line . I do not konw where is the 392 line.
6 April 2017 at 15:46 in reply to: [SOLVED] How to look at the example of the source code(c++) ? #8862SenBlockedHi Hugo,
I want to create simulation by using c++. And I find that .scn file is to simulate.I wan to know that xml or scn can be converted to c++ ? Or How the xml or scn file is called c++ C++ programs or functions? And In the future, I can develop their own algorithm by using c++.1 March 2017 at 14:37 in reply to: the moving of Instrument is not perfectly follow the phantom device #8741SenBlockedHi,
I write the .scn file running in the modeler. Dose not write .scn file running in the modeler. And I find that (dentalSurgery_08.scn) the instrument of example(dentalSurgery_08.scn) will spinning slowing.When the collision occurs, the instrument will rotate violently. .That’s what I use. I want the instrument to stop spinning. You can see here
Thank youSenBlockedWhy I can use the mouse to carve,Not by by phantom device
SenBlocked<?xml version=”1.0″?> <Node name=”root” gravity=”10 0 0″ dt=”0.005″ > <RequiredPlugin name=”Sensable Plugin” printLog=”1″ pluginName=”Sensable” /> <RequiredPlugin name=”Carving” printLog=”1″ pluginName=”SofaCarving” /> <VisualStyle name=”visualStyle1″ displayFlags=”hideBehaviorModels hideForceFields hideCollisionModels hideMappings” /> <DefaultPipeline name=”pipeline” verbose=”0″ depth=”6″ /> <BruteForceDetection name=”detection” /> <DefaultContactManager name=”response” response=”FrictionContact” /> <LocalMinDistance name=”proximity” alarmDistance=”0.15″ contactDistance=”0.05″ angleCone=”0″ /> <FreeMotionAnimationLoop name=”freeMotionAnimationLoop1″ /> <CarvingManager name=”carvingManager1″ listening=”1″ active=”1″ /> <LCPConstraintSolver name=”lCPConstraintSolver1″ tolerance=”0.001″ maxIt=”1000″ group=”0″ /> <Node name=”Tooth” > <EulerImplicitSolver name=”cg_odesolver” printLog=”0″ /> <CGLinearSolver template=”GraphScattered” name=”linear solver” iterations=”25″ tolerance=”1e-009″ threshold=”1e-009″ /> <MeshGmshLoader name=”GmshLoader” filename=”d:/src/installables/sofa/git/sofafromgit/sofa/share/mesh/cylinder.msh” tetrahedraGroups=” -1 0 2430″ createSubelements=”1″ /> <MechanicalObject template=”Vec3d” name=”dofs” position=”@GmshLoader.position” velocity=”0 0 0″ force=”0 0 0″ externalForce=”0 0 0″ restScale=”1″ scale3d=”1 1 1″ /> <TriangleSetTopologyContainer name=”topo” position=”@GmshLoader.position” edges=”@GmshLoader.edges” triangles=”@GmshLoader.triangles” /> <TriangleSetTopologyModifier name=”modif” /> <TriangleSetTopologyAlgorithms template=”Vec3d” name=”algo” /> <TriangleSetGeometryAlgorithms template=”Vec3d” name=”triGeo” showPointIndices=”0″ showEdgeIndices=”0″ drawEdges=”0″ /> <DiagonalMass template=”Vec3d” name=”diagonalMass1″ massDensity=”0.15″ /> <FixedConstraint template=”Vec3d” name=”fixedConstraint1″ indices=”0 1″ /> <TriangularFEMForceField template=”Vec3d” name=”FEM” method=”large” poissonRatio=”0.3″ youngModulus=”100″ /> <TriangularBendingSprings template=”Vec3d” name=”FEM-Bend” stiffness=”300″ damping=”1″ /> <TTriangleModel template=”Vec3d” name=”tTriangleModel1″ /> <Node name=”VisualModel” > <OglModel template=”ExtVec3f” name=”VisualModel” material=”Default Diffuse 1 0.74902 0.74902 0.74902 1 Ambient 1 0.2 0.2 0.2 1 Specular 0 1 1 1 1 Emissive 0 0 0 0 0 Shininess 0 45 ” primitiveType=”DEFAULT” blendEquation=”GL_FUNC_ADD” sfactor=”GL_SRC_ALPHA” dfactor=”GL_ONE_MINUS_SRC_ALPHA” /> <IdentityMapping template=”Vec3d,ExtVec3f” name=”mapping” input=”@..” output=”@VisualModel” /> </Node> </Node> <Node name=”Omni” > <MechanicalObject template=”Rigid3d” name=”DOFs” position=”0 0 0 0 0 0 1″ velocity=”0 0 0 0 0 0″ force=”0 0 0 0 0 0″ externalForce=”0 0 0 0 0 0″ restScale=”1″ /> <MechanicalStateController template=”Rigid3d” name=”mechanicalStateController1″ listening=”1″ handleEventTriggersUpdate=”1″ mainDirection=”-1 0 0″ /> <OmniDriver name=”omniDriver0″ listening=”1″ scale=”100″ omniVisu=”0″ /> <Node name=”RefModel” > <MeshObjLoader name=”loader” filename=”d:/wqf/dental_instrument_centerline.obj” /> <MeshTopology name=”meshTopology1″ position=”@loader.position” edges=”@loader.edges” triangles=”@loader.triangles” quads=”@loader.quads” tetrahedra=”@loader.tetras” hexahedra=”@loader.hexas” /> <MechanicalObject template=”Vec3d” name=”instrumentCollisionState” position=”@loader.position” velocity=”0 0 0″ force=”0 0 0″ externalForce=”0 0 0″ restScale=”1″ translation=”-0.3 0 3.5″ rotation=”0 -180 -90″ /> <RigidMapping template=”Rigid3d,Vec3d” name=”rigidMap2″ input=”@../” output=”@./” /> </Node> </Node> <Node name=”Instrument” > <EulerImplicitSolver name=”cg_odesolver” printLog=”0″ /> <CGLinearSolver template=”GraphScattered” name=”linear solver” iterations=”25″ tolerance=”1e-009″ threshold=”1e-009″ /> <MechanicalObject template=”Rigid3d” name=”instrumentState” tags=”Omni” position=”0 0 0 0 0 0 1″ velocity=”0 0 0 0 0 0″ force=”0 0 0 0 0 0″ externalForce=”0 0 0 0 0 0″ restScale=”1″ /> <UniformMass template=”Rigid3d” name=”mass” totalmass=”0.05″ /> <LCPForceFeedback template=”Rigid3d” name=”lCPForceFeedback1″ listening=”1″ activate=”1″ forceCoef=”0.005″ /> <UncoupledConstraintCorrection template=”Rigid3d” name=”uncoupledConstraintCorrection1″ /> <Node name=”VisualModel” > <OglModel template=”ExtVec3f” name=”InstrumentVisualModel” fileMesh=”d:/wqf/dental_instrument.obj” translation=”-0.412256 -0.067639 3.35″ rotation=”180 0 150″ scale3d=”1 1 1″ material=”Default Diffuse 1 1 0.2 0.2 1 Ambient 1 0.2 0.0392157 0.0392157 1 Specular 0 1 0.2 0.2 1 Emissive 0 1 0.2 0.2 1 Shininess 0 45 ” primitiveType=”DEFAULT” blendEquation=”GL_FUNC_ADD” sfactor=”GL_SRC_ALPHA” dfactor=”GL_ONE_MINUS_SRC_ALPHA” /> <RigidMapping template=”Rigid3d,ExtVec3f” name=”MM->VM mapping” input=”@../” output=”@./” /> </Node> <Node name=”CollisionModel” > <MechanicalObject template=”Vec3d” name=”Particle” position=”-0.2 -0.2 -0.2″ velocity=”0 0 0″ force=”0 0 0″ externalForce=”0 0 0″ restScale=”1″ /> <TPointModel template=”Vec3d” name=”ParticleModel” tags=”CarvingTool” contactStiffness=”2″ /> <RigidMapping template=”Rigid3d,Vec3d” name=”MM->CM mapping” input=”@../” output=”@./” /> </Node> <VectorSpringForceField template=”Vec3d” stiffness=”10″ viscosity=”0″ object1=”@Omni/RefModel/instrumentCollisionState” /> <JointSpringForceField template=”Rigid3d” name=”jointSpringFF4″ spring=”BEGIN_SPRING 0 0 END_SPRING ” object1=”@Omni” object2=”@instrumentState” /> </Node> </Node>
SenBlockedWhat I mean is that I’m going to touch it, it comes in contact with the boundary of the collision model, without touching the boundary of the mesh, which leads to not carve, and I’m in contact with the mesh boundary, so he can carve.Can I give you my SCN file, can you help me to look at it?
SenBlockedHi Hugo,
I may know the reasons. I may know why, when I phantom device to touch the rigid body , it is actually in the collision model, is exposed to a boundary, and no contact with the object, and I use the mouse event contact to the surface of the hard object, so it can be carve. So, how to modify the boundaries of the collision model, so that the boundary on the surface or on the surface of the inside.@HugoSenBlockedHi Hugo,
where is Geomagic plugin?I can not find it. what is the difference Geomagic plugin between Sensable plugin ?
Thanks,
SenSenBlockedHi Hugo,
Now I can carve using mouse, but i want to use sensible device.However, the carving.scn in application/plugins/sensable/examples doesn’t work.Can this example carve with sensible? And could you please give me some other examples about it?
Thanks,
Sen
-
AuthorPosts