Home › Forum › SOFA › Using SOFA › [SOLVED] Using a Novint Falcon with SOFA on a 64 bits architecture
Tagged: 64_bits, Haptics, SOFA_other, Windows_7
- This topic has 14 replies, 3 voices, and was last updated 7 years, 9 months ago by Hugo.
-
AuthorPosts
-
6 September 2016 at 17:00 #7449Le GouisBlocked
Hello,
I need to use a Novint Falcon for a project.
The only plugin I found that included the Falcon is the SofaHAPI plugin.
Yet when i follow the instructions for the setup of this plugin, i either have an old 32bits version of HAPI, not compatible with my 64 bits version of Sofa, or a newer 64 bits version of H3D, containing HAPI, but that does not find the drivers for the Falcon (32 bits).
Has anyone managed to have the Falcon working on a 64 bits version of Sofa?I’m currently working on an old version of Sofa, but the plugin seems rather similar in the current version of Sofa compared to mine.
Thanks,
Benoît Le Gouis
11 October 2016 at 09:49 #7567HugoKeymasterDear Benoit,
I am very sorry you did not get an answer yet.
We are not big users of Novint Falcon in Strasbourg.Hopefully, some other SOFA developers may give some feedback about it!
Anyone ?Best,
Hugo
11 October 2016 at 18:54 #7568ErdemirBlockedUnfortunately, I will not be answering this question. I am simply responding to show my interest in a solution and may be start a community around this topic.
I am interested in hearing about experiences of SOFA users trying to compile and run SofaHAPI and Novint Falcon together. I must admit we have not even successfully compiled SOFA with SofaHAPI yet. I have been working on Ubuntu Linux and had issues with broken CMAKE files among others. Is there anyone who were able compile SOFA and SofaHAPI on linux systems following the instructions provided in the documentation.
Best,
Ahmet
2 February 2017 at 20:26 #8503ErdemirBlockedRecently, I was able to get Novit Falcon working using the SofaHAPI plugin on Ubuntu. Except, there was a catch. When I use the following scene, simulation immediately crashed causing a segmentation fault.
<?xml version="1.0"?> <Node name="Root" gravity="0 0 0" time="0" animate="0" > <RequiredPlugin pluginName="SofaHAPI" /> <Node name="Haptics"> <MechanicalObject name="State" template="Rigid" position="0 0 0 0 0 0 1" /> <HAPIHapticsDevice name="NovintFalcon1" printLog="1" drawDevice="1" scale="100"/> </Node> <OglModel filename="mesh/floorFlat.obj" /> </Node>
If I comment the line related to the MechanicalObject, as seen below, the simulation works and I can control the object with Novint Falcon.
<?xml version="1.0"?> <Node name="Root" gravity="0 0 0" time="0" animate="0" > <RequiredPlugin pluginName="SofaHAPI" /> <Node name="Haptics"> <!-- <MechanicalObject name="State" template="Rigid" position="0 0 0 0 0 0 1" /> --> <HAPIHapticsDevice name="NovintFalcon1" printLog="1" drawDevice="1" scale="100"/> </Node> <OglModel filename="mesh/floorFlat.obj" /> </Node>
Any insight on resolving this issue is much appreciated.
Best,
Ahmet
9 February 2017 at 09:30 #8532HugoKeymasterHi @benoitlegouis, @aerdemir,
Sorry for not replying on this, but we do not have an Novint haptic interface here.
So impossible for us to test.
Benoit any news ? Did you notice the same issue ?By looking into the code of SofaHAPIHapticsDevice, we can read at line 186:
mState = dynamic_cast<MechanicalState<sofa::defaulttype::Rigid3dTypes> *> (this->getContext()->getMechanicalState());
mState is a pointer to a MechanicalState templated on Rigid type.
This should work.
What message do you get when it crashes?
“SofaHAPIHapticsDevice has no binding MechanicalState” or “[Device] init” (cf lines 187-188)Best,
Hugo
9 February 2017 at 15:30 #8538ErdemirBlockedDear Hugo,
Thanks for the feedback. I tried to put the whole trail of segmentation fault in this message but the forum did not allow me to submit as it suspected that the message was spam. It seems like the fault starts at (the first four lines of segfault)
../lib/libSofaHelper.so.16.12.0(sofa::helper::BackTrace::dump()+0x23) [0x7f9505edf1d3] ../lib/libSofaHelper.so.16.12.0(sofa::helper::BackTrace::sig(int)+0x19c) [0x7f9505edf51c] /lib/x86_64-linux-gnu/libc.so.6(+0x354a0) [0x7f95052fb4a0] /home/aerdemir/Apps/sofa/v16.12/build/install/lib/libSofaHAPI.so(sofa::component::SofaHAPIHapticsDevice::onBeginAnimationStep(double)+0x84e) [0x7f94c84b3b0e]
Ahmet
9 February 2017 at 15:46 #8539HugoKeymasterOk,
To debug it, we should look at SofaHAPIHapticsDevice (line 368):
sofa::helper::ReadAccessor<Data<sofa::helper::vector<sofa::defaulttype::RigidCoord<3,double> > > > x = *this->mState->read(sofa::core::VecCoordId::position()); Transform world_H_virtualTool(x[newToolIndex].getCenter(), x[newToolIndex].getOrientation());
- either, the casting between mState and the accessor (Rigid3d) is not working, i.e. both are not from the same DataTypes.
- or the second line, where the indice newToolIndex would exceed the mState size.
Let me know if you find something.
Best,Hugo
9 February 2017 at 17:16 #8542ErdemirBlockedThanks Hugo,
I tried to dig in a bit deeper. The problem does not seem to be at the lines that you noted as the running of the code does not enter to that if block. The code enters the block for if (isToolControlled) and subsequently the block for if (mstate). It causes the segfault at the line
sofa::helper::AdvancedTimer::stepBegin("SetState");
I appreciate your insight.
9 February 2017 at 17:22 #8544HugoKeymasterHi Erdermir,
I doubt the problem is caused by the timer, it would be weird.
Don’t you think it comes from the the lines just below the Timer ?9 February 2017 at 18:21 #8545ErdemirBlockedThanks Hugo,
You are right, I did not copy the correct line it causes the issue at the line
xfree[currentToolIndex].getCenter() = world_H_virtualTool.getOrigin();
I suspect this is related to the casting not working as a few lines above there is the assignment for xfree as
sofa::helper::WriteAccessor<Data<sofa::helper::vector<sofa::defaulttype::RigidCoord<3,double> > > > xfree = *this->mState->write(sofa::core::VecCoordId::freePosition());
Ahmet
9 February 2017 at 23:29 #8547ErdemirBlockedDear Hugo,
I think I found the problem. I commented the following lines related to xfree:
sofa::helper::WriteAccessor<Data<sofa::helper::vector<sofa::defaulttype::RigidCoord<3,double> > > > xfree = *this->mState->write(sofa::core::VecCoordId::freePosition());
xfree[currentToolIndex].getCenter() = world_H_virtualTool.getOrigin();
xfree[currentToolIndex].getOrientation() = world_H_virtualTool.getOrientation();
The simulations stopped crashin and I get haptic feedback when I run an example scene. I am not sure if removing the lines related to xfree will break anything else.
Any insights? Thank you again for your help.
Ahmet
10 February 2017 at 10:38 #8553HugoKeymasterHi Ahmet,
Nice to hear that it fixes your issue!
But, strange indeed. I will see if freePosition makes sense for rigid bodies and let you know if I find anything about it.Cheers,
Hugo
10 February 2017 at 11:04 #8555HugoKeymasterHi Ahmet,
After discussions the freePosition vector is initialized by the FreeMotionAnimationLoop (used for simulation involving collisions). So if you’re not using this, this explains the crash (accessor on a non-existing vector). However, this shows the problem of vector initialization depending on the animation loop.
We will discuss this at the dev meeting. It this appears to be a real problem, we will create an issue on Github.
Shall I close the forum topic ?
Hugo
10 February 2017 at 15:10 #8559ErdemirBlockedThanks Hugo for the insight. I was also able to solve the problem in another way, based on the code in SensableEmulation/OmniDriverEmu.cpp. I needed to replace the following lines
sofa::helper::WriteAccessor<Data<sofa::helper::vector<sofa::defaulttype::RigidCoord<3,dobble> > > > x = *this->mState->write(sofa::core::VecCoordId::position()); sofa::helper::WriteAccessor<Data<sofa::helper::vector<sofa::defaulttype::RigidCoord<3,double> > > > xfree = *this->mState->write(sofa::core::VecCoordId::freePosition());
with
sofa::helper::WriteAccessor<Data<sofa::helper::vector<sofa::defaulttype::RigidCoord<3,dobble> > > > x = *this->mState->write(sofa::core::VecCoordId::position()); this->getContext()->getMechanicalState()->vRealloc( sofa::core::MechanicalParams::defaultInstance(), core::VecCoordId::freePosition() ); // freePosition is not allocated by default sofa::helper::WriteAccessor<Data<sofa::helper::vector<sofa::defaulttype::RigidCoord<3,double> > > > xfree = *this->mState->write(sofa::core::VecCoordId::freePosition()); /// FIX : check if the mechanical state is empty, if true, resize it /// otherwise: crash when accessing xfree[] and x[] if(xfree.size() == 0) xfree.resize(1); if(x.size() == 0) x.resize(1);
At this moment, I can load the example SofaHAPI problem SofaHAPI1.scn and run a simulation with haptics where I can control the object with Novint Falcon and it seems like I get some force feedback as well. Of course, I need to test further if I am getting desirable control and feedback. This is a great start. I appreciate your help.
About closing the forum, as far as I am concerned, the problem is solved. My experience may also help Benoit to solve his problem as well. I got everything running on Ubuntu 64bit using libnifalcon. I. should note that I had to edit the cmake file for SofaHAPI as it had some rogue lines.
Cheers,
Ahmet
10 February 2017 at 15:53 #8560HugoKeymasterIf you bring new fixes, do not hesitate to pull-request them on GitHub, right?
We are warmly welcoming external contributions!Check out the contribution guidelines.
Best,
Hugo
-
AuthorPosts
- You must be logged in to reply to this topic.