コード例 #1
0
    def add_dice(self, use_set_params=False):
        dice = list()

        # Create falling rigid bodies (dice)
        for i in range(self.dice_num):
            die_body = chrono.ChBodyEasyMesh(
                self.die_file,  # obj filename
                10000,  # density
                True,  # compute mass?
                True,  # visualization?
                True,  # collision?
                self.dice_mat)  # material
            self.system.Add(die_body)
            self.set_start_parameters(die_body, use_set_params)
            dice.append(die_body)
        return dice
コード例 #2
0
def LoadFromObj(filename, density=1000, color=[1,0.1,0.1]):
    body = chrono.ChBodyEasyMesh(filename, density, True, True)
    body.AddAsset(chrono.ChColorAsset(chrono.ChColor(color[0], color[1], color[2])))
    return body
コード例 #3
0
#
# NOTE: for collision purposes, the .obj mesh must be "watertight", i.e. having
# no gaps in edges, no repeated vertexes, etc.
#
# NOTE: for visualization purposes only, i.e. if you do not use the mesh also for
# collision, the mesh does not need to be watertight.

# Method A:
# - use the ChBodyEasyMesh
# This will automatically create the visualization mesh, the collision mesh,
# and will automatically compute the mass property (COG position respect to REF,
# mass and inertia tensor) given an uniform density.

body_A = chrono.ChBodyEasyMesh(
    chrono.GetChronoDataFile('shoe_view.obj'),  # mesh filename
    7000,  # density kg/m^3
    True,  # use mesh for visualization?
    True)  # use mesh for collision?
body_A.SetPos(chrono.ChVectorD(0.5, 0.5, 0))
mysystem.Add(body_A)

# Method B:
# - create a ChBodyAuxRef,
# - set mass and inertia tensor as you like
# - set COG center of mass position respect to REF reference as you like
# - attach a visualization shape based on a .obj triangle mesh
# - add contact shape based on a .obj triangle mesh
# This is more complicate than method A, yet this can be still preferred if you
# need deeper control, ex. you want to provide two different meshes, one
# with high level of detail just for the visualization and a coarse one for
# collision, or if you want to set custom COG and inertia values, etc.
コード例 #4
0
ファイル: demo_mesh.py プロジェクト: ttide/chrono
#
# NOTE: for collision purposes, the .obj mesh must be "watertight", i.e. having
# no gaps in edges, no repeated vertexes, etc.
#
# NOTE: for visualization purposes only, i.e. if you do not use the mesh also for
# collision, the mesh does not need to be watertight.

# Method A:
# - use the ChBodyEasyMesh
# This will automatically create the visualization mesh, the collision mesh,
# and will automatically compute the mass property (COG position respect to REF,
# mass and inertia tensor) given an uniform density.

body_A = chrono.ChBodyEasyMesh(
    chrono.GetChronoDataPath() + 'body_1_1.obj',  # mesh filename
    7000,  # density kg/m^3
    True,  # use mesh for visualization?
    True)  # use mesh for collision?
body_A.SetPos(chrono.ChVectorD(0.5, 1, 0))
mysystem.Add(body_A)

# Method B:
# - create a ChBodyAuxRef,
# - set mass and inertia tensor as you like
# - set COG center of mass position respect to REF reference as you like
# - attach a visualization shape based on a .obj triangle mesh
# - add contact shape based on a .obj triangle mesh
# This is more complicate than method A, yet this can be still preferred if you
# need deeper control, ex. you want to provide two different meshes, one
# with high level of detail just for the visualization and a coarse one for
# collision, or if you want to set custom COG and inertia values, etc.
コード例 #5
0
# Shared contact materials for falling objects
dice_mat = chrono.ChMaterialSurfaceNSC()
dice_mat.SetFriction(0.5)

# Create the five walls of the rectangular container, using fixed rigid bodies of 'box' type
floor_body = chrono.ChBodyEasyBox(210, 1, 210, 1000, True, True, ground_mat)
floor_body.SetPos(chrono.ChVectorD(0, 0, 0))
floor_body.SetBodyFixed(True)
system.Add(floor_body)

die_file = dodeca.get_chrono_mesh()
die = chrono.ChBodyEasyMesh(
    die_file,  # obj filename
    10000,  # density
    True,  # compute mass?
    True,  # visualization?
    True,  # collision?
    dice_mat)  # material
system.Add(die)

dice_position = [0, 5, 0]
dice_speed = [0, 0, 0]
dice_rotation = chrono.Q_from_AngAxis(
    -0 * chrono.CH_C_DEG_TO_RAD, chrono.VECT_Y) * chrono.Q_from_AngAxis(
        -91 * chrono.CH_C_DEG_TO_RAD, chrono.VECT_Z)
print(dice_rotation,
      chrono.Q_to_Euler123(dice_rotation) * chrono.CH_C_RAD_TO_DEG)
normals = dodeca.face_normals
for normal in normals:
    ch_normal = chrono.ChVectorD(*normal)
コード例 #6
0
# no gaps in edges, no repeated vertexes, etc. 
#
# NOTE: for visualization purposes only, i.e. if you do not use the mesh also for 
# collision, the mesh does not need to be watertight. 


# Method A: 
# - use the ChBodyEasyMesh
# This will automatically create the visualization mesh, the collision mesh,
# and will automatically compute the mass property (COG position respect to REF, 
# mass and inertia tensor) given an uniform density.

body_A= chrono.ChBodyEasyMesh(chrono.GetChronoDataFile('models/bulldozer/shoe_view.obj'), # mesh filename
                              7000,             # density kg/m^3
                              True,             # automatically compute mass and inertia
                              True,             # visualize?>
                              True,             # collide?
                              contact_material, # contact material
                              )
body_A.SetPos(chrono.ChVectorD(0.5,0.5,0))
mysystem.Add(body_A)



# Method B: 
# - create a ChBodyAuxRef, 
# - set mass and inertia tensor as you like
# - set COG center of mass position respect to REF reference as you like
# - attach a visualization shape based on a .obj triangle mesh
# - add contact shape based on a .obj triangle mesh
# This is more complicate than method A, yet this can be still preferred if you
コード例 #7
0
q = chrono.ChQuaternionD()
q.Q_from_AngAxis(math.pi / 8, chrono.ChVectorD(0, 1, 0))
mbody1.SetRot(q)
mbody1.SetMass(1)
mbody1.SetMaterialSurface(brick_material)
mbody1.GetCollisionModel().ClearModel()
mbody1.GetCollisionModel().AddBox(1, 1, 1)  # must set half sizes
mbody1.GetCollisionModel().BuildModel()
mbody1.SetCollide(True)
ChronoPandaInterface.PandaCube(cpi, mbody1, 2, WHITE)

mysystem.Add(mbody1)

# Create the falling rigid body

mbody2 = chrono.ChBodyEasyMesh("fancy_models\pallet.obj", 500, True, True,
                               0.001, True)
mysystem.Add(mbody2)
mbody2.SetBodyFixed(False)
mbody2.SetPos(chrono.ChVectorD(0, 6.5, 0))

mbody2.SetMass(1)
mbody2.SetMaterialSurface(brick_material)
q = chrono.ChQuaternionD()
q.Q_from_AngAxis(math.pi / 2, chrono.ChVectorD(1, 0, 0))
mbody2.SetRot(q)

mbody2.SetCollide(True)

ChronoPandaInterface.PandaGenericBody(cpi, mbody2, 'fancy_models\pallet.obj')

timestep = 0.002