Forum Replies Created
-
AuthorPosts
-
8 February 2022 at 11:45 in reply to: [SOLVED] โm_ContactsVectorBuffer” not valid sometimes #21475
Scheikl
BlockedHi Hugo,
a happy new year to you too! ๐For some reason the issue was solved by the universal solution: reboot
I still have no idea why the error occurred in the first place or why it did not persist.
I did not rerun cmake.Cheers,
PaulScheikl
BlockedHi @newbie,
you might want to check out SofaPython3.There is a binding for the ContactListener, so you can create a ContactListener object with
`
listener = contactlistener.addObject(
“ContactListener”,
collisionModel1=”@/finger/collisionFinger/triangle”,
collisionModel2=”@/skin/SkinCollision/point”,
)
`
Now you can add any functions from the c++ code to create bindings for it.
Sadly I really do not know how to do that with SofaPython2.
Cheers,
PaulScheikl
BlockedYou’re very welcome! ๐
Thanks, you too!
Scheikl
BlockedHi @chiarasapo,
glad I could help!I would suggest using a
Sofa.Core.Controller
to call the function on a specified event, such as AnimateEndEvent.
There is a nice example in the SofaPython3 repo.Just delete all the functions that you do not need. ๐
For exampleclass PrintContactController(Sofa.Core.Controller): def __init__(self, *args, **kwargs): Sofa.Core.Controller.__init__(self, *args, **kwargs) def init(self, contact_listener): self.contact_listener = contact_listener def onAnimateBeginEvent(self, event): # called at each begin of animation step print(self.contact_listener.getNumberOfContacts())
Cheers,
PaulScheikl
BlockedHi @chiarasapo,
are you using SofaPython3 out-of-tree?Also try removing the build folder to start clean.
What may also help is doing a separate install step after building.
cmake --install <sofa target folder>/external_directories/sofapython3/bindings
Cheers,
PaulScheikl
BlockedHi @chiarasapo,
as you can see in the bindings for ContactListener, the method getNumberOfContacts is commented out. Could you try uncommenting and recompile it?Cheers,
PaulScheikl
BlockedHi @newbie,
you might want to check out SofaPython3.There is a binding for the ContactListener, so you can create a ContactListener object with
listener = contactlistener.addObject( โContactListenerโ, collisionModel1=โ@/finger/collisionFinger/triangleโ, collisionModel2=โ@/skin/SkinCollision/pointโ, )
Now you can add any functions from the c++ code to create bindings for it.
Sadly I really do not know how to do that with SofaPython2.
Cheers,
PaulScheikl
BlockedHi @newbie,
I just tested the scene, and the following works fine for me:contactlistener.addObject( "ContactListener", collisionModel1="@/finger/collisionFinger/triangle", collisionModel2="@/skin/SkinCollision/point", )
Cheers,
PaulScheikl
BlockedHi @newbie,
I totally missed the fact, that you gave the models a specific name, sorry. ๐
Try replacing the type of Object (TriangleCollisionModel) with the name you gave it (triangle). Same for the PointCollisionModel.Cheers,
PaulScheikl
BlockedHi @newbie,
ah theContactListener
is not in the root node, so your path misses going up one step in the tree.
You could trycontactlistener.createObject('ContactListener', collisionModel1 = '@../skin.SkinCollision.TriangleCollisionModel', collisionModel2 = '@../finger.collisionFinger.PointCollisionModel')
Cheers,
PaulScheikl
BlockedHi @newbie,
by specifyingcollisionModel1 = '@skin.SkinCollision'
you are not pointing to an actual collision model, but to a SofaNode that contains multiple collision models.Try changing that to
contactlistener.createObject('ContactListener', collisionModel1 = '@skin.SkinCollision.TriangleCollisionModel', collisionModel2 = '@finger.collisionFinger.PointCollisionModel')
The object should now listen for collisions between the
TriangleCollisionModel
of the skin and thePointCollisionModel
of finger.Cheers,
PaulScheikl
BlockedHi @newbie,
sadly I started using Sofa with SofaPython3 directly so I’ve never really used SofaPython2.Is there an error message you could post?
Is the relative path to
SkinCollision
andcollisionFinger
correct?Cheers,
PaulScheikl
BlockedHi @newbie,
please note, that there is a difference between SofaPython and the Plugin SofaPython3.If you are using SofaPython3, you can add a ContactListener with
listener = scene_node.addObject( "ContactListener", name="TestContactListener", collisionModel1=body1.collision.PointCollisionModel.getLinkPath(), collisionModel2=body2.collision.TriangleCollisionModel.getLinkPath(), )
This one will listen for contacts between PointCollisionModels on body1 and TriangleCollisionModels on body2.
Cheers,
Paul27 April 2021 at 10:01 in reply to: [SOLVED] Movement restriction at some points of an object #19322Scheikl
BlockedHi Sergio,
you’re welcome!
Glad that I could help. ๐Cheers,
Paul22 April 2021 at 09:45 in reply to: [SOLVED] Movement restriction at some points of an object #19271Scheikl
BlockedHi Sergio,
I thinkPartialFixedConstraint
is what you are looking for.There is an example at https://github.com/sofa-framework/sofa/blob/master/examples/Components/constraint/PartialFixedConstraint.scn
<PartialFixedConstraint name="partialFixedConstraint" indices="3 39 64" fixedDirections="0 1 1" />
Cheers,
PaulScheikl
BlockedHi Simit,
you can pass additional arguments to the runSofa binary.
runSofa --help
gives you a detailed list of possible options.Directly running a simulation can be done with
./runSofa -a 1 /path/to/scene/file
Cheers,
PaulScheikl
BlockedHi @andrija987,
no worries :).Ok now I get it!
I thinkArticulatedSystemMapping
should do the trick!
An example can be found here:
https://github.com/sofa-framework/sofa/blob/master/examples/Components/mapping/ArticulatedSystemMapping.scnAnd there is also a very nice explanation in the documentation:
https://www.sofa-framework.org/community/doc/components/mapping/articulatedsystemmapping/So basically what you would do is creating a linear joint, that is attached to your big “carrier” cube.
Hope that helps!
Cheers,
PaulScheikl
BlockedI’d give the reply above a thumbs up, if I could. ;D
Scheikl
BlockedScheikl
BlockedHi!
I have a related problem.
I am able to control the internal data of aninteractiveCamera
, but it does nothing to the view itself, even though I made sure I am using the OpenGL view.You can find a video of the behavior here: https://cloud.ipr.kit.edu/s/y2tjFW2Za4CX5p2
The code to set the pose is
def move_cam(camera, pose: Tuple[float, float, float, float]): camera.position.value = pose[:3] camera.orientation.value = pose[3:]
SOFA: v2012_beta
SP3: masterCheers,
PaulScheikl
BlockedHi @andrija987,
sorry for the late reply, and that I could not help you solve the problem. ๐I am looking forward to the new issue, maybe we can approach that from another angle.
Cheers,
PaulScheikl
BlockedHi @hugo ,
thanks for the follow-up! ๐Yes and no.
I would like tho get a measure of how much overlap is between two volumetric meshes.
I guess that should happen outside of the collision pipeline.
For example a small ball inside (at the center) of a large ball would not stand in collision with the larger ball.
So I am looking for something like>>> std::cout << getOverlap(collisionModelSmallBall, collisionModelLargeBall) << "\n"; 1.0
Cheers,
PaulScheikl
BlockedHi @twxu ,
sadly I am not familiar with the underlying code, but I guess there is some Matrix inversion involved which would make the computation scale roughly cubic.I did not have the chance to work with cavity inside meshes yet.
Maybe someone from the SoftRobots Plugin (for example @@sescaida) could give you more info on that?You are very welcome. ๐
-
AuthorPosts