- This topic has 2 replies, 2 voices, and was last updated 4 years, 6 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
Home › Forum › SOFA › Using SOFA › [SOLVED] Export the state of a specified node
Tagged: 64_bits, Linux_ubuntu, Plugin_SoftRobots, SOFA_1912
Hi,
First of all, I am aware that similar questions have been answered… Unfortunately, I am still struggling ;(
What I am trying to do is to obtain the position values of one single node and plot a graph of displacement vs time. With the WriteState function, I have managed to export the positions of 10450 nodes which is the total number of vertex on my mesh, but it is too difficult to read so I am wondering if there is a convenient way to output the state of one point at every timestep.
#Export info
pneu.createObject('WriteState', filename=path+'/data/pneu.data', writeX='true', writeX0='false',writeV='false', DOFsX='1')
I have read the post which seems like a solution: https://www.sofa-framework.org/community/forum/topic/get-the-position-value-from-a-mechanicalobject-point-in-python/
And added these lines to my controller:
def onEndAnimationStep(self, dt):
#access the 'position' state vector
myMOpositions = self.myMechanicalObjectPointer.findData('position').value
# print the position value of the DOF 5793
print str(t)
print str(myMOpositions[5783][0])+' '+str(myMOpositions[5783][1])+' '+str(myMOpositions[5783][2])
return 0
However, I have no idea of where to find the outputs in the default user interface. Can anyone give some suggestions?
Many thanks,
Owen
Hi @qwe12050
You have many ways of doing it.
In Python as you suggested at last, the print output is done in the console. But instead of printing it, you could plot it, directly from your python script. For this you could use matplot.
You could also use the Monitor component.
This should do the job.
Best,
Hugo
Hi Hugo,
Thank you for your quick reply.
You solved my problems! Everything works perfectly in the console. I just realised that there is so much potential in using python script.
Thank you!
Regards,
Owen
WARNING
The forum has been moved to GitHub Discussions.
Old topics and replies are kept here as an archive.