1 May 2020 at 02:00 #15992
I know there are several threads about using WriteState, but I am still trying to get it right…
I use Python to create my scene, and I am trying to export the force experienced by a cable that is created by PullingCable:
cable.createObject('WriteState', filename='cableTension', time='0.1', writeF='true', period='0.1', stopAt='1')
This WriteState always pops up an error saying “Error creating file cableTension”, and I tried using cableTension.txt and cableTension.data, but none works. By the way, there is only two points composing the cable.
Thank you very much,
Jerry3 May 2020 at 21:13 #16009
This is a follow-up question. I am now using another monitor component, and it is much more powerful! But I feel it is slow if I have to choose the indices of my object one by one, since my object is made of a mesh with ten thousands of vertices…
Is there any way I can appoint all vertices whose z > 10, or like manually select vertices or something like that?
Jerry4 May 2020 at 09:46 #16010SarahBlocked
I had a similar issue using monitor but found that in using BoxROI as found in the documentation and then referring to those indices in the monitor
'@boxROI.indices'(where ‘boxROI’ is the name of your object ‘BoxROI’) was an easy way for me to solve it. Hope that helps.
Sarah4 May 2020 at 22:18 #160134 May 2020 at 22:34 #16017
Hi Sarah and Hugo,
That is really useful, thank you so much Sarah! But now I’m having a problem of exporting .txt files… Every time I export .txt, sofa always exports the same files: velocity and position of mechanical object of each object, plus one mass-energy.txt, no matter what I put into the monitor component. I actually want force of a few specific vertices, is there anything I did wrong?
Jerry5 May 2020 at 01:22 #16020
another question is that I found that the force it shows is actually net force on the particles, but I want the internal force on each particle (ie. stress of each vertices) Is there a way I can acquire that? Or at least the tension in the cable.
Jerry5 May 2020 at 09:25 #16021SarahBlocked
It seems to me that you’re just using the export tab in SOFA. But using monitor you export files independent of the export tab in SOFA.
You can use montior as such and then you can choose if you want pos, vel, or force for specific vertices.
node.createObject('Monitor', name="filename", indices='@boxROI.indices', template="Vec3d", showPositions=True, PositionsColor="1 0 1 1", ExportPositions=False, showVelocities=False, VelocitiesColor="0.5 0.5 1 1", ExportVelocities=False, showForces=True, ForcesColor="0.8 0.2 0.2 1", ExportForces=True, showTrajectories=False, TrajectoriesPrecision="0.1", TrajectoriesColor="0 1 1 1", sizeFactor="1")
You can find the files under the ‘bin’ in sofa where you can also find runSofa. Hope that helpd.
Sarah5 May 2020 at 09:35 #16022
Thanks for the reply! That is actually what I wrote. I think the monitor component does work because I can see force vectors during simulation.
Is it because I built my sofa wrong so I missed the export feature? Because my writeState component also does not work. I’m running a mac, and I just downloaded runSofa and moved softRobots plugin into the plugins folder.
Qifan5 May 2020 at 15:58 #16028
I am not sure to understand your question.
In SOFA, both Monitor and ExportState come by default. So you should not have missed anything.
Could you share a non-working scenario please?
Hugo5 May 2020 at 20:20 #16031
Sure thing. In my case I am trying to export force data of a beam with monitor as follows:
eobject.createObject('Monitor', name="forces", template="Vec3d", listening="1", indices="@boxROI.indices", showPositions="0", PositionsColor="1 1 0 1", showVelocities="0", VelocitiesColor="1 1 0 1", showForces="1", ForcesColor="1 0 0 0.5", showMinThreshold="0.01", sizeFactor="0.5", ExportForces='true', TrajectoriesPrecision="0.1", TrajectoriesColor="1 1 0 1")
I think this component works because in my simulation there are red arrows representing forces, and no error present in sofa.
However, no file is exported no matter whether I select ExportForces/ExportVelocities/ExportPositions or not.
For writeState, I wrote for the cable that pulls on the beam:
cable.createObject('WriteState', name='export', filename='cableTension.txt', writeX='false', writeV='false', writeF='true', time='0', period='0.01')
In this case, sofa says “Error creating file cableTension.txt”, and nothing is exported.
By the way, I tried the example examples/Components/misc/WriteState.xml, and this WriteState also fail to create file, which makes me think if I missed anything during download.
Jerry10 May 2020 at 21:56 #16141
Regarding the WriteState it works fine for me, when running the example scene examples/Components/misc/WriteState.xml I get the resulting gravity*.data files created in my build repository.
Same for the Monitor. Have you checked in the different possible paths:
– build repository
– src root
– or the location your scene file is located
Hugo12 May 2020 at 01:38 #16164
Thank for the tips and sorry for the late reply. I have built it on Windows and writeState and monitor works fine! However, I am now wondering if there is anyway that sofa can output internal force in the object? eg. the internal stress between mesh vertices. Or is there any way I can calculate that from output force or deformation of the object? My goal is to explore the reacting force my object can provide when I am pulling it using a cable (ie. simply the tension of cable).14 May 2020 at 23:29 #16243
We are working on this currently : easier and cleaner output from matrices (stiffness, mass etc). For now, I would say for your own use case, you can pick the value in the code when it is computed, create a dedicated data which would then be available for export.
Hugo15 May 2020 at 00:52 #16250
Thanks for your help! I got a lot done thanks to you. Hope sofa can export internal stress in the future.
Jerry15 May 2020 at 09:53 #16253
We will make sure about this.
Stay tuned in September 😉20 July 2021 at 16:20 #20043GuillaumeBlocked
We would like to get the internal stress of a beam (from beam adapter). Is it possible now ?
- You must be logged in to reply to this topic.