orientation=[math.pi / 4.0], velocity=[0, 0, -1.0], mass=1., inertia=2.0) # the ground object made with the ground shape. As the mass is # not given, it is a static object only involved in contact # detection. io.add_object('ground', [Contactor('Ground')], translation=[0, -.5]) # Run the simulation from the inputs previously defined and add # results to the hdf5 file. The visualisation of the output may be done # with the vview command. bullet_options = SiconosBulletOptions() bullet_options.worldScale = 1.0 bullet_options.contactBreakingThreshold = 0.04 bullet_options.dimension = SICONOS_BULLET_2D bullet_options.perturbationIterations = 0 bullet_options.minimumPointsPerturbationThreshold = 0 options = sk.solver_options_create(sn.SICONOS_FRICTION_2D_NSGS) options.iparam[sn.SICONOS_IPARAM_MAX_ITER] = 100000 options.dparam[sn.SICONOS_DPARAM_TOL] = 1e-8 T = 2.0 if restart: T = 2.0 #T=1*0.001 hstep = 0.01 run_options = MechanicsHdf5Runner_run_options()
# # Here we demonstrate the use of two very small cubes simulated with # geometry at 1000x its scale. Without scaling, contact detection is # incorrect for an object of this size. When contact detection is # performed with scaled-up geometries, the contact points are # correctly generated and used by Siconos. # from siconos.mechanics.collision.tools import Contactor from siconos.io.mechanics_run import MechanicsHdf5Runner import siconos.numerics as Numerics # We need to pass some options to the Bullet backend from siconos.mechanics.collision.bullet import SiconosBulletOptions options = SiconosBulletOptions() options.worldScale = 1000.0 # Creation of the hdf5 file for input/output with MechanicsHdf5Runner() as io: # Definition of a cube as a convex shape io.add_convex_shape('CubeCH', [(-0.001, 0.001, -0.001), (-0.001, -0.001, -0.001), (-0.001, -0.001, 0.001), (-0.001, 0.001, 0.001), (0.001, 0.001, 0.001), (0.001, 0.001, -0.001), (0.001, -0.001, -0.001), (0.001, -0.001, 0.001)]) # Definition of a cube as a primitive shape io.add_primitive_shape('CubeP', 'Box', (0.002, 0.002, 0.002)) # Definition of the ground shape
#!/usr/bin/env python # # Example of one object under gravity with one contactor and a ground # using the Siconos proposed mechanics API # from siconos.mechanics.collision.tools import Contactor from siconos.io.mechanics_io import Hdf5 import siconos.numerics as Numerics import siconos.io.mechanics_io from siconos.mechanics.collision.bullet import SiconosBulletOptions options = SiconosBulletOptions() options.worldScale = 1.0 options.contactBreakingThreshold = 0.04 # Creation of the hdf5 file for input/output with Hdf5() as io: # Definition of a sphere io.addPrimitiveShape('Sphere', 'Sphere', (2, ), insideMargin=0.2, outsideMargin=0.3) # Definition of the ground shape io.addPrimitiveShape('Ground', 'Box', (10, 10, 0.1), insideMargin=0.05, outsideMargin=0.1)
mu=0.3, mu_r=1e-03) #io.add_Newton_impact_friction_nsl('contact', e= 0.0, mu=0.3) # Create solver options options = sk.solver_options_create(sn.SICONOS_ROLLING_FRICTION_3D_NSGS) #options = sk.solver_options_create(sn.SICONOS_FRICTION_3D_NSGS) options.iparam[sn.SICONOS_IPARAM_MAX_ITER] = 1000 options.dparam[sn.SICONOS_DPARAM_TOL] = 1e-4 # Run the simulation from the inputs previously defined and add # results to the hdf5 file. The visualisation of the output may be done # with the vview command. from siconos.mechanics.collision.bullet import SiconosBulletOptions bullet_options = SiconosBulletOptions() bullet_options.worldScale = 1000.0 bullet_options.contactBreakingThreshold = 0.04 bullet_options.dimension = 1 with MechanicsHdf5Runner(mode='r+') as io: # By default earth gravity is applied and the units are those # of the International System of Units. # Because of fixed collision margins used in the collision detection, # sizes of small objects may need to be expressed in cm or mm. io.run( with_timer=False, bullet_options=bullet_options, gravity_scale=1, t0=0, T=T,