Hello,
I made avaliable the class ChLoadXYZROTnodeXYZROTnodeBushingGeneric in a compiled python interface, but I am getting a type error when trying to instantiate it. The issue seems to come from the namespace difference between the type of the object and the type expected in the method signature in the module. The error is as follows:
_core.ChLoadXYZROTnodeXYZROTnodeBushingGeneric_swiginit(self, _core.new_ChLoadXYZROTnodeXYZROTnodeBushingGeneric(mnodeA, mnodeB, abs_application, mstiffness, mdamping))
TypeError: in method 'new_ChLoadXYZROTnodeXYZROTnodeBushingGeneric', argument 1 of type 'std::shared_ptr< fea::ChNodeFEAxyzrot >'
The flow for the code is as follows:
# Creates system and mesh
system = core.ChSystemSMC()
system.Set_G_acc(m_acc=core.VNULL)
mesh = fea.ChMesh()
# Creates nodes and adds them to mesh
node1 = fea.ChNodeFEAxyzrot(core.ChFrameD(core.ChVectorD(0., 0., 0.)))
node2 = fea.ChNodeFEAxyzrot(core.ChFrameD(core.ChVectorD(0., 0., 0.)))
node2.SetForce(core.ChVectorD(0., 5000., 0.)) # Force at node2 (y-direction)
mesh.AddNode(node1)
mesh.AddNode(node2)
system.Add(mesh)
# Creates fixed body
truss = core.ChBody()
truss.SetBodyFixed(True)
system.Add(truss)
# Links node to truss
linkA = core.ChLinkMateGeneric()
linkA.Initialize(node1, truss, False, node1.Frame(), truss.GetAssetsFrame())
system.Add(linkA)
# Creates load container for bushing load
load_container = core.ChLoadContainer()
system.Add(load_container)
# Stiffness and damping matrices
K_matrix = core.ChMatrixDynamicD(6, 6)
R_matrix = core.ChMatrixDynamicD(6, 6)
for i in range(6):
K_matrix[i, i] = 1e5
for i in range(6):
for j in range(6):
R_matrix[i, j] = 1e-3
ch_bushing = core.ChLoadXYZROTnodeXYZROTnodeBushingGeneric(
mnodeA=node1,
mnodeB=node2,
abs_application=core.ChFrameD(core.ChVectorD(0., 0., 0.)),
mstiffness=K_matrix,
mdamping=R_matrix)
load_container.Add(newload=ch_bushing)
The created nodes have the following value:
node1 = {ChNodeFEAxyzrot} <pychrono.fea.ChNodeFEAxyzrot; proxy of <Swig Object of type 'std::shared_ptr< chrono::fea::ChNodeFEAxyzrot >
Bellow is the method signature taken from core.py module:
def __init__(self, mnodeA, mnodeB, abs_application, mstiffness, mdamping):
r"""__init__(ChLoadXYZROTnodeXYZROTnodeBushingGeneric self, std::shared_ptr< fea::ChNodeFEAxyzrot > mnodeA, std::shared_ptr< fea::ChNodeFEAxyzrot > mnodeB, ChFrameD abs_application, chrono::ChMatrixConstRef mstiffness, chrono::ChMatrixConstRef mdamping) -> ChLoadXYZROTnodeXYZROTnodeBushingGeneric"""
_core.ChLoadXYZROTnodeXYZROTnodeBushingGeneric_swiginit(self, _core.new_ChLoadXYZROTnodeXYZROTnodeBushingGeneric(mnodeA, mnodeB, abs_application, mstiffness, mdamping))
So the error seems to come from the difference in the signature of the Swig Object in the created node (std::shared_ptr< chrono::fea::ChMesh >>) and the one expected in the method (std::shared_ptr< fea::ChMesh >), but I don't know how to solve this namespace problem.
Thank you in advance.
André Marinho