CableGripper tutorial code failed to load #5091
Unanswered
JiangkunY
asked this question in
Write / Run a simulation
Replies: 1 comment 4 replies
-
|
Hi @JiangkunY Is |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I used SOFA_v24.06.00_Win64.exe to install SOFA on Win10, and I think I have all the plugins for the CableGripper tutorial:
When I open the finger.py from location "...\SofaInstallation\v24.06.00\plugins\SoftRobots\share\sofa\examples\SoftRobots\tutorials\CableGripper\details\finger.py", it only shows a red box, without any finger there:

and it gives warnings as shown below:
Then I add these suggested code from the warning to a copy of finger.py, named finger2.py at same location:
import Sofa.Core import Sofa.constants.Key as Key from stlib3.physics.deformable import ElasticMaterialObject from stlib3.physics.constraints import FixedBox from softrobots.actuators import PullingCable from stlib3.physics.collision import CollisionMesh from splib3.loaders import loadPointListFromFile class FingerController(Sofa.Core.Controller): def __init__(self, *args, **kwargs): Sofa.Core.Controller.__init__(self, args, kwargs) self.cable = args[0] self.name = "FingerController" def onKeypressedEvent(self, e): displacement = self.cable.CableConstraint.value[0] if e["key"] == Key.plus: displacement += 1. elif e["key"] == Key.minus: displacement -= 1. if displacement < 0: displacement = 0 self.cable.CableConstraint.value = [displacement] def Finger(parentNode=None, name="Finger", rotation=[0.0, 0.0, 0.0], translation=[0.0, 0.0, 0.0], fixingBox=[-5.0, 0.0, 0.0, 10.0, 15.0, 20.0], pullPointLocation=[0.0, 0.0, 0.0]): finger = parentNode.addChild(name) eobject = ElasticMaterialObject(finger, volumeMeshFileName="data/mesh/finger.vtk", poissonRatio=0.3, youngModulus=18000, totalMass=0.5, surfaceColor=[0.0, 0.8, 0.7, 1.0], surfaceMeshFileName="data/mesh/finger.stl", rotation=rotation, translation=translation) finger.addChild(eobject) FixedBox(eobject, atPositions=fixingBox, doVisualization=True) cable = PullingCable(eobject, "PullingCable", pullPointLocation=pullPointLocation, rotation=rotation, translation=translation, cableGeometry=loadPointListFromFile("data/mesh/cable.json")); eobject.addObject(FingerController(cable)) CollisionMesh(eobject, name="CollisionMesh", surfaceMeshFileName="data/mesh/finger.stl", rotation=rotation, translation=translation, collisionGroup=[1, 2]) CollisionMesh(eobject, name="CollisionMeshAuto1", surfaceMeshFileName="data/mesh/fingerCollision_part1.stl", rotation=rotation, translation=translation, collisionGroup=[1]) CollisionMesh(eobject, name="CollisionMeshAuto2", surfaceMeshFileName="data/mesh/fingerCollision_part2.stl", rotation=rotation, translation=translation, collisionGroup=[2]) return finger def createScene(rootNode): from stlib3.scene import MainHeader, ContactHeader rootNode.addObject('RequiredPlugin', name='Sofa.Component.AnimationLoop') # Needed to use components [FreeMotionAnimationLoop] rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Detection.Algorithm') # Needed to use components [BVHNarrowPhase,BruteForceBroadPhase,CollisionPipeline] rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Detection.Intersection') # Needed to use components [LocalMinDistance] rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Geometry') # Needed to use components [LineCollisionModel,PointCollisionModel,TriangleCollisionModel] rootNode.addObject('RequiredPlugin', name='Sofa.Component.Collision.Response.Contact') # Needed to use components [RuleBasedContactManager] rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Correction') # Needed to use components [LinearSolverConstraintCorrection] rootNode.addObject('RequiredPlugin', name='Sofa.Component.Constraint.Lagrangian.Solver') # Needed to use components [GenericConstraintSolver] rootNode.addObject('RequiredPlugin', name='Sofa.Component.Engine.Select') # Needed to use components [BoxROI] rootNode.addObject('RequiredPlugin', name='Sofa.Component.LinearSolver.Direct') # Needed to use components [SparseLDLSolver] rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mapping.Linear') # Needed to use components [BarycentricMapping] rootNode.addObject('RequiredPlugin', name='Sofa.Component.Mass') # Needed to use components [UniformMass] rootNode.addObject('RequiredPlugin', name='Sofa.Component.ODESolver.Backward') # Needed to use components [EulerImplicitSolver] rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.FEM.Elastic') # Needed to use components [TetrahedronFEMForceField] rootNode.addObject('RequiredPlugin', name='Sofa.Component.SolidMechanics.Spring') # Needed to use components [RestShapeSpringsForceField] rootNode.addObject('RequiredPlugin', name='Sofa.Component.StateContainer') # Needed to use components [MechanicalObject] rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Constant') # Needed to use components [MeshTopology] rootNode.addObject('RequiredPlugin', name='Sofa.Component.Topology.Container.Dynamic') # Needed to use components [TetrahedronSetTopologyContainer] rootNode.addObject('RequiredPlugin', name='Sofa.Component.Visual') # Needed to use components [VisualStyle] MainHeader(rootNode, gravity=[0.0, -981.0, 0.0], plugins=["SoftRobots"]) ContactHeader(rootNode, alarmDistance=4, contactDistance=3, frictionCoef=0.08) rootNode.VisualStyle.displayFlags = "showBehavior showCollisionModels" Finger(rootNode, translation=[1.0, 0.0, 0.0]) return rootNodewhere Bold codes are added by me. But it still showed the same scene in the window (only red box without any finger) and gave warnings:
And for sure the "gripper.py" also can not display any finger.
I'm new in SOFA, and everything modeled in the SoftRobots/FirstSteps tutorial runs fine.
Can you kindly help me to find the problem?
Beta Was this translation helpful? Give feedback.
All reactions