- This topic has 0 replies, 1 voice, and was last updated 3 years, 2 months ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
Home › Forum › SOFA › Using SOFA › Accessing and mofiying array values with Context Managers in SofaPython3
Tagged: Linux_ubuntu, SOFA_other
I’d like to inquire about the issue for accessing numpy list values with context managers in SofaPython3. I think the nature of the problem is very similar to the question as in the following thread, but I’ll try to explain it more clearly.
The motivation is I’d like to move object with modifying the rest_position in the mechanicalObject and with the help of RestShapeSpringsForceField. This is very stratiforward in the previous SofaPython2 version. However, in the SofaPython3, it seems cannot directly modify the value. I’ve tried
self.rootNode.finger1.mechObj.rest_position.value = ****
But clearly it doens not work. I’ve checked many related topics in the forum, and one very clear explanation is as:
However, although I understand the motivation and common practice in modifying the values, I cannot successfully achieve it. The big issue is, the accessed numpy array is not the correct one after 2-3 time steps, and obviously it does not point to the correct memory address, which will yield segmentation fault if I modify it. Here I attached the sample scene file for your reference. The example is with rigid body, but the same problem occurs for deformable body.
https://www.dropbox.com/s/2exibu9m2vahlhs/simplegripper.zip?dl=0
Environment: Ubuntu 20.04 + compiled latest SOFA commit at github
One interesting thing is, if I remove the RestShapeSpringsForceField, the readout of the array value is correct. However, I do need this for fix my object.
Not sure whether this is because of my wrong usage, or some bugs in the program. Much appreciate if anyone may help to address this issue.
WARNING
The forum has been moved to GitHub Discussions.
Old topics and replies are kept here as an archive.