- This topic has 1 reply, 2 voices, and was last updated 3 years, 9 months ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
Home › Forum › SofaPython3 › Using SofaPython3 › Issue when changing object position via python scene.
Tagged: mechanical object, modification, python3, scene
Hello to everyone. I am using the almost latest versions 20.12 of Sofa
commit 6f691d00f4f3d871a54bace5a1d6d6200fe23ac6
Author: Guillaume Paran <guillaume.paran@sofa-framework.org>
Date: Tue Jan 26 17:10:24 2021 +0100
and Python3
commit 289c3694019637b31ca35ff2981d7316619f1a75
Author: Jean-Nicolas Brunet <jnbrunet2000@gmail.com>
Date: Tue Jan 26 13:43:49 2021 +0100
and I have a problem when I try to modify the position in my mechanical object.
My scene looks like this:
somewhere in init:
...................
self.impactPoint = dotNode.addObject('MechanicalObject', template='Vec3d', name='dot', showObject='true', position=self.options['impact_parameters']['init_position'])
....................
def onAnimateEndEvent(self, deltaTime):
### modify external impact
with self.impactPoint.position.writeableArray() as pos:
print(pos)
pos[0][1] = pos[0][1] - 0.00002
return 0;
However, the result of the print looks like:
[[0.143369 0.156781 0.395153]]
[[0.143369 0.156761 0.395153]]
[[2.58167165e-316 1.73110010e-316 1.58101007e-322]]
########## SIG 11 -
sometimes it is followed by crash, sometimes the weird numbers continue to appear.
Could you tell me whether you know this issue?
It seems your computation is diverging, isn’t it Sergei?
You are printing the position (DOFs) which clearly seems to undergo a problem.
Could you print before and after you access it to check that the script is not the problem source?
Without seeing more of your scene, it is complicated to guess.
Best
Hugo
WARNING
The forum has been moved to GitHub Discussions.
Old topics and replies are kept here as an archive.