Beispiel #1
0
import Sofa

from Compliant import Rigid, Tools, Frame

mesh_path = Tools.path(__file__)

scale = 1

# parts of the mechanism
parts = [[
    "Corps",
    "Corps.msh",
    "1.36 0 0.0268 0 0 0 1",
    "0 0 0 0 0 0 1",
    "22.8 751 737",
    "2.1e+11",
    "0.28",
    "7.8e+3",
    1291.453 / scale,
    "TetrahedronFEMForceField",
    "Rigid",
    "Vec3d",
    "TLineModel",
    "TPointModel",
    "ExtVec3f",
    "0.obj",
    "Actor_Sensor_NA",
],
         [
             "Roue", "Roue.msh", "0 -0.00604 0.354 0 0 0 1",
             "0 0 -0.148 0 0 0 1", "105 106 205", "2.1e+11", "0.28", "7.8e+3",
Beispiel #2
0
import Sofa

from Compliant import Rigid, Tools

mesh_path = Tools.path( __file__ )

scale = 1

# parts of the mechanism
parts = [ 
    ["Corps","Corps.msh","1.36 0 0.0268 0 0 0 1","0 0 0 0 0 0 1","22.8 751 737", "2.1e+11","0.28","7.8e+3",1291.453/scale,"TetrahedronFEMForceField","Rigid","Vec3d","TLineModel","TPointModel","ExtVec3f","0.obj","Actor_Sensor_NA",],
    ["Roue","Roue.msh","0 -0.00604 0.354 0 0 0 1","0 0 -0.148 0 0 0 1","105 106 205", "2.1e+11","0.28","7.8e+3",780.336/scale,"TetrahedronFEMForceField","Rigid","Vec3d","TLineModel","TPointModel","ExtVec3f","3.obj","Actor_Sensor_NA"],
    ["Came","Came.msh","0 0 -0.00768 0 0 0 1","1.085 -0.072 0.33 0 0 0 1","40.5 40.6 0.331", "2.1e+11","0.28","7.8e+3",161.416/scale,"TetrahedronFEMForceField","Rigid","Vec3d","TLineModel","TPointModel","ExtVec3f","2.obj","Actor_Sensor_NA"],
    ["Piston","Piston.msh","0 0 0.424 0 0 0 1","2.05 0 0.33 0 0 0 1","0.356 14.6 14.7", "2.1e+11","0.28","7.8e+3",132.759/scale,"TetrahedronFEMForceField","Rigid","Vec3d","TLineModel","TPointModel","ExtVec3f","1.obj","Actor_Sensor_NA"]
]


# joint offsets
offset = [
    [0, Rigid.Frame().read('0 0 0 0 0 0 1')],
    [1, Rigid.Frame().read('0 0 0.148 0 0 0 1')],

    [1, Rigid.Frame().read('0.24 -0.145 0.478 0 0 0 1')],
    [2, Rigid.Frame().read('-0.845 -0.073 0 0 0 0 1')],

    [2, Rigid.Frame().read('0.852 0.072 0 0 0 0 1')],
    [3, Rigid.Frame().read('-0.113 0 0 0 0 0 1')],

    [3, Rigid.Frame().read('0.15 0 0 0 0 0 1')],
    [0, Rigid.Frame().read('2.2 0 0.33 0 0 0 1')]    
]
Beispiel #3
0
import Sofa

import math

from Compliant import StructuralAPI, Tools
from Compliant.types import Quaternion, Rigid3
import numpy as np

dir = Tools.path( __file__ )

def createScene(node):
    scene = Tools.scene( node )

    style = node.getObject('style')
    style.findData('displayFlags').showMappings = False
    style.findData('displayFlags').showVisual = False
    style.findData('displayFlags').showCollision = True    

    manager = node.getObject('manager')
    manager.response = 'PenalityCompliantContact'

    manager.responseParams="stiffness=1e5"

    node.dt = 2.5e-3
    # node.createObject('CompliantAttachButton')
                            
    ode = node.getObject('ode')
    node.removeObject(ode)
    ode = node.createObject("EulerImplicitSolver", rayleighStiffness = 0, rayleighMass = 0)
    
    num = node.createObject('CGLinearSolver',
import Sofa

import math

from Compliant import Rigid, Tools

dir = Tools.path(__file__)


def createScene(node):
    scene = Tools.scene(node)

    style = node.getObject('style')
    style.findData('displayFlags').showMappings = True

    manager = node.getObject('manager')
    manager.response = 'FrictionCompliantContact'
    manager.responseParams = 'mu=0'  # per object friction coefficient (the friction coef between 2 objects is approximated as the product of both coefs)

    ode = node.getObject('ode')
    ode.stabilization = True
    ode.debug = False

    num = node.createObject('SequentialSolver',
                            name='num',
                            iterations=100,
                            precision=1e-14)

    proximity = node.getObject('proximity')

    proximity.alarmDistance = 0.5
Beispiel #5
0
## testing Rigid.generate_rigid that computes com, mass and inertia from a mesh

# TODO compute and test principal axes basis by rotating meshes


from SofaTest.Macro import *
from Compliant import Tools
from SofaPython import Quaternion
import SofaPython.mass
import numpy

path = Tools.path( __file__ ) + "/geometric_primitives/"


# cube.obj is unit 1x1x1 cube
# sphere.obj radius=1
# cylinder.obj, height=1 in z, radius=1
# all meshes are centered in (0.5,0.5,0.5)

meshes = ['cube.obj', 'sphere.obj', 'cylinder.obj']
scales = [[1,1,1],[1,1,10],[3.3,3.3,10],[10,5,2]]
densities = [1, 1000, 7.7]
rotations = [[90,0,0],[22.456,0,0],[0,90,0],[0,23.546,0],[0,0,90],[0,0,-63.2],[90,90,0],[90,12.152,0],[25.645,12.36,0],[90,90,90],[-12.356,124.33,-56.1]]

# prepare multi-dimensional structure
masses = []
for x in range(len(meshes)):
    row = []
    for y in xrange(len(scales)):
        col = []
        for z in xrange(len(densities)):
Beispiel #6
0
import Sofa
import os, numpy, sys
from Compliant import StructuralAPI
from Compliant import Tools as CompliantTools
from SofaPython import Quaternion, Tools

currentdir = CompliantTools.path(__file__)

N = 10

bodies = []


def createScene(root):

    root.createObject('PythonScriptController',
                      name="moveController",
                      filename=__file__,
                      classname="MoveController")

    root.createObject('RequiredPlugin', name='Compliant')
    root.createObject('RequiredPlugin', name='ContactMapping')

    root.createObject(
        'VisualStyle',
        name='VisualStyle',
        displayFlags="hideMechanicalMappings showCollisionModels")

    root.createObject('CompliantImplicitSolver')
    #root.createObject('CompliantPseudoStaticSolver',iterations=1,velocityFactor=0)
    #root.createObject('CgSolver',iterations="25", precision="1e-6")
Beispiel #7
0
## testing Rigid.generate_rigid that computes com, mass and inertia from a mesh

# TODO compute and test principal axes basis by rotating meshes

from SofaTest.Macro import *
from Compliant import Tools
from SofaPython import Quaternion
import SofaPython.mass
import numpy

path = Tools.path(__file__) + "/geometric_primitives/"

# cube.obj is unit 1x1x1 cube
# sphere.obj radius=1
# cylinder.obj, height=1 in z, radius=1
# all meshes are centered in (0.5,0.5,0.5)

meshes = ['cube.obj', 'sphere.obj', 'cylinder.obj']
scales = [[1, 1, 1], [1, 1, 10], [3.3, 3.3, 10], [10, 5, 2]]
densities = [1, 1000, 7.7]
rotations = [[90, 0, 0], [22.456, 0, 0], [0, 90, 0], [0, 23.546, 0],
             [0, 0, 90], [0, 0, -63.2], [90, 90, 0], [90, 12.152, 0],
             [25.645, 12.36, 0], [90, 90, 90], [-12.356, 124.33, -56.1]]

# prepare multi-dimensional structure
masses = []
for x in range(len(meshes)):
    row = []
    for y in xrange(len(scales)):
        col = []
        for z in xrange(len(densities)):