Home › Forum › SOFA › Programming with SOFA › Control actuators and receive sensor variables of scene .scn
- This topic has 5 replies, 2 voices, and was last updated 3 years ago by eaparra.
-
AuthorPosts
-
2 September 2021 at 17:54 #20299eaparraBlocked
Hello every one.
I hope you are having a good week.I have a question, and it would be very good If someone could resolve it.
I have a scene made in xml, .scn, and I would like to control the actuators and receive the parameters, for example position.
But I don’t know if I could communicate with the xml file using python or c++?
And if possible, someone could help me by sending me some example.Thanks sou much and I’m waiting your answer.
7 October 2021 at 10:28 #20541HugoKeymasterOla @eaparra
To have interactions with your simulation:
– in xml, the only solution is to use Controller (C++ class) in your scene that would do what you are looking for, but you will have to implement them for your specific purpose
– python is actually replacing these controllers with simple scripts. In python, you will have the possibility to access all data from your scene, process them and even input new data in the simulation while it’s runningI hope this answers your point.
Best wishes,Hugo
19 October 2021 at 09:00 #20651eaparraBlockedHi @Hugo.
Following the solution I used in https://www.sofa-framework.org/community/forum/topic/beamfemforcefield-setting/, that using multiple BilateralInteractionConstraint avoid vibration a little bit, but the vibration continuous. I continued working with the Communication plugin that you and your fellow suggest me https://www.sofa-framework.org/community/forum/topic/input-and-output-in-sofa-scn-file/.
Taking into account the code that I shared with you https://github.com/eaparra01/Femur_Movement, I modified both codes, .scn and c ++, which help me to control and take the values of the positions of the masses with a refresh rate of 1000, 1ms.
But you mention the Controller (C ++ class) that can help me, it would be great if you could send me the link that explains how to work with this class.
Although, continuing with the Communication plugin, which is working well so far, I would like to know if SOFA has an actuation function that allows me to give it an angle and that it goes to that angle without using the ConstantForceField function.
Thank you for you help I’m looking forward to hearing from you.
20 October 2021 at 15:25 #20669eaparraBlockedHi @hugo.
I’ve been looking for some functions that could help me control the rotation of the joint.
I saw that LinearMovementConstraint function could help but I can’t find good information of how to use it.
The examples that you have shows some features but not explain some characteristics like keyTime, keyMovements, prevM, and so on.
I would like to know if the keyTime is the number of key frame it uses to do a movement or it is the number of frame does the movement? and could it make a movement without speficy the keyTimes?Thank you for you help I’m looking forward to hearing from you.
2 November 2021 at 19:00 #20723HugoKeymasterOla @eaparra
Apologies for the delay.
The LinearMovementConstraint and its associated (missing) doc are hard to get indeed. The keyTimes are times between which the movement will be interpolated: between keyTimes[0] and keyTimes[1], a linear interpolation is computed between the movements[0] and movements[1] (keyTimes and movements being input vector data). This motion can be applied on specific indices.You therefore cannot make a movement without specifying the keyTimes.
Let me know if this helps.
Best,Hugo
3 November 2021 at 15:26 #20734 -
AuthorPosts
- You must be logged in to reply to this topic.