Forum Replies Created
-
AuthorPosts
-
Diogo
BlockedHi @hugo
I had to put the work on hold because of exams, but I’ve now returned and I’m still trying to figure things. I think me and @aryakarani have different implementations of the CableConstraint, since I think I used an old one that came with an older version of the SoftRobots plugin that is not the same as newer documentation shows, so I’m working around that, but thank you for checking in! I will update the thread if I am sucessful in order to help other people with the same problem
Best wishes,
Diogo
Diogo
BlockedHello @froy
I’m sorry I took so long to reply, exams forced me to pause work on my thesis and on Sofa, and I deeply appreciate your answer!
I’ve tried both the 1st and 3rd methods, and I don’t think that’s the problem, since the exact same error happened.
For some reason the video record function uses a forward slash after the SOFA folder name instead of the backslash in the rest of the Windows directory. I tried changing the SofaGuiQt.ini file to …\bin\ instead of …/bin/ and that did not work, nor did it work to add …\\bin\. I can’t find any sort of path option to fix that forward slash
Just to add to the original post, the error shows after [VideoRecorderFFMPEG] in the Sofa Information Window
Thank you once again,
Diogo
Diogo
BlockedHello @aryakarani
Thank you so much for your answer!! This is my current code:
# -*- coding: utf-8 -*- from stlib.physics.deformable import ElasticMaterialObject from stlib.physics.constraints import FixedBox from stlib.scene import Node from softrobots.actuators import PullingCable from splib.loaders import loadPointListFromFile import Sofa import os #Opening the file file1 = open("myfile.txt","w") #Defining the python controller class CilinderController(Sofa.PythonScriptController): def __init__(self, node, cable1, cable2, cable3): self.node=node self.cableconstraintvalue1 = cable1.getObject("CableConstraint").findData('value') self.cableconstraintvalue2 = cable2.getObject("CableConstraint").findData('value') self.cableconstraintvalue3 = cable3.getObject("CableConstraint").findData('value') self.cableconstraintdisp1 = cable1.getObject("CableConstraint").findData('displacement') self.cableconstraintdisp2 = cable2.getObject("CableConstraint").findData('displacement') self.cableconstraintdisp3 = cable3.getObject("CableConstraint").findData('displacement') self.name = "CilinderController" self.n=1 self.deformableObject = self.node.ElasticMaterialObject #Control actions for each cable (extend and retract) def onKeyPressed(self,c): if (c == "4"): self.cableconstraintvalue1.value = self.cableconstraintvalue1.value[0][0] + 1. if (c == "1"): self.cableconstraintvalue1.value = self.cableconstraintvalue1.value[0][0] - 1. if (c == "5"): self.cableconstraintvalue2.value = self.cableconstraintvalue2.value[0][0] + 1. if (c == "2"): self.cableconstraintvalue2.value = self.cableconstraintvalue2.value[0][0] - 1. if (c == "6"): self.cableconstraintvalue3.value = self.cableconstraintvalue3.value[0][0] + 1. if (c == "3"): self.cableconstraintvalue3.value = self.cableconstraintvalue3.value[0][0] - 1. if (c == "9"): #file1.write(str(Output1)) self.node.getRootContext().animate = False file1.close() #Writing the displacements and point position to a file def onEndAnimationStep(self,dt): # displacement1 = self.cableconstraintdisp1.value # displacement2 = self.cableconstraintdisp2.value # displacement3 = self.cableconstraintdisp3.value displacement1 = self.cableconstraintvalue1.value displacement2 = self.cableconstraintvalue2.value displacement3 = self.cableconstraintvalue3.value # dispform1 = "{:.2f}".format(displacement1) # dispform2 = "{:.2f}".format(displacement2) # dispform3 = "{:.2f}".format(displacement3) dispform1 = displacement1 dispform2 = displacement2 dispform3 = displacement3 position=self.deformableObject.dofs.getData("position").value positionform1="{:.2f}".format(float(position[493][0])) positionform2="{:.2f}".format(float(position[493][1])) positionform3="{:.2f}".format(float(position[493][2])) file1.write(str(self.n) + ',' + str(dispform1) + ","+ str(dispform2) + "," + str(dispform3) + ", ["+ str(positionform1) + ";" + str(positionform2) + ";" + str(positionform3)+"]"+'\n') self.n +=1 def Cilinder(parentNode=None, name="Cilinder", rotation=[0.0, 0.0, 0.0], translation=[0.0, 0.0, 0.0], fixingBox=[0.0,0.0,0.0], pullPointLocation=[0.0,0.0,0.0]): #Defining the elastic material cilinder = Node(parentNode, "Cilinder") eobject = ElasticMaterialObject(cilinder, volumeMeshFileName="data/mesh/Elo3D.vtk", poissonRatio=0.49, youngModulus=48000000, totalMass=1.5, surfaceColor=[0.0, 0.8, 0.7], surfaceMeshFileName="data/mesh/EloSurface.stl") FixedBox(eobject, doVisualization=True, atPositions=[-30, 0 ,-30 ,30 ,5,30]) #Creating the cables cable1 = PullingCable(eobject, cableGeometry=loadPointListFromFile("data/mesh/cable1S.json")) cable2 = PullingCable(eobject, cableGeometry=loadPointListFromFile("data/mesh/cable2S.json")) cable3 = PullingCable(eobject, cableGeometry=loadPointListFromFile("data/mesh/cable3S.json")) #Calling the controller CilinderController(cilinder,cable1,cable2,cable3)
This is the relevant part, the rest is just defining the scene. As you can see, my goal is to get the cable lengths and the position of a point to a file. What happens right now is that the displacements show up as zero when the robot is at rest (the cable length at rest is meant to be 84.63 cm) and when I give inputs, it changes to “1” or “-1” etc, according to the given input.
There are other ways to define the cables, maybe that’s the issue? The cable geometry files are just a list of points through where the cables pass in the channels inside the robot
-
AuthorPosts