def AddFixedObstacles(system):
    # Create contact material, of appropriate type. Use default properties
    material = None
    if (NSC_SMC == chrono.ChContactMethod_NSC):
        matNSC = chrono.ChMaterialSurfaceNSC()
        #Change NSC material properties as desired
        material = matNSC
    elif (NSC_SMC == chrono.ChContactMethod_SMC):
        matSMC = chrono.ChMaterialSurfaceSMC()
        # Change SMC material properties as desired
        material = matSMC
    else:
        raise ("Unvalid Contact Method")
    radius = 3
    length = 10
    obstacle = chrono.ChBodyEasyCylinder(radius, length, 2000, True, True,
                                         material)

    obstacle.SetPos(chrono.ChVectorD(-20, 0, -2.7))
    obstacle.SetBodyFixed(True)

    system.AddBody(obstacle)

    for i in range(8):
        stoneslab = chrono.ChBodyEasyBox(0.5, 2.5, 0.25, 2000, True, True,
                                         material)
        stoneslab.SetPos(chrono.ChVectorD(-1.2 * i + 22, -1.5, -0.05))

        stoneslab.SetRot(
            chrono.Q_from_AngAxis(15 * chrono.CH_C_DEG_TO_RAD, chrono.VECT_Y))
        stoneslab.SetBodyFixed(True)
        system.AddBody(stoneslab)
Esempio n. 2
0
    def DrawBarriers(self, points, n=5, height=1, width=1):
        points = points[::n]
        if points[-1] != points[0]:
            points.append(points[-1])
        for i in range(len(points) - 1):
            p1 = points[i]
            p2 = points[i + 1]
            box = chrono.ChBodyEasyBox((p2 - p1).Length(), height, width, 1000,
                                       True, True)
            box.SetPos(p1)

            q = chrono.ChQuaternionD()
            v1 = p2 - p1
            v2 = chrono.ChVectorD(1, 0, 0)
            ang = math.atan2((v1 % v2).Length(), v1 ^ v2)
            if chrono.ChVectorD(0, 0, 1) ^ (v1 % v2) > 0.0:
                ang *= -1
            q.Q_from_AngZ(ang)
            box.SetRot(q)
            box.SetBodyFixed(True)

            color = chrono.ChColorAsset()
            if i % 2 == 0:
                color.SetColor(chrono.ChColor(1, 0, 0))
            else:
                color.SetColor(chrono.ChColor(1, 1, 1))
            box.AddAsset(color)
            self.system.Add(box)
def AddMovingObstacles(system):
    # Create contact material, of appropriate type. Use default properties
    material = None
    if (NSC_SMC == chrono.ChContactMethod_NSC):
        matNSC = chrono.ChMaterialSurfaceNSC()
        #Change NSC material properties as desired
        material = matNSC
    elif (NSC_SMC == chrono.ChContactMethod_SMC):
        matSMC = chrono.ChMaterialSurfaceSMC()
        # Change SMC material properties as desired
        material = matSMC
    else:
        raise ("Unvalid Contact Method")
    sizeX = 300
    sizeY = 300
    height = 0
    numObstacles = 10

    for i in range(numObstacles):
        o_sizeX = 1.0 + 3.0 * chrono.ChRandom()
        o_sizeY = 0.3 + 0.2 * chrono.ChRandom()
        o_sizeZ = 0.05 + 0.1 * chrono.ChRandom()
        obstacle = chrono.ChBodyEasyBox(o_sizeX, o_sizeY, o_sizeZ, 2000.0,
                                        True, True, material)

        o_posX = (chrono.ChRandom() - 0.5) * 0.4 * sizeX
        o_posY = (chrono.ChRandom() - 0.5) * 0.4 * sizeY
        o_posZ = height + 4
        rot = chrono.ChQuaternionD(chrono.ChRandom(), chrono.ChRandom(),
                                   chrono.ChRandom(), chrono.ChRandom())
        rot.Normalize()
        obstacle.SetPos(chrono.ChVectorD(o_posX, o_posY, o_posZ))
        obstacle.SetRot(rot)

        system.AddBody(obstacle)
    def add_asset(self, asset: 'Any'):
        if isinstance(asset, chrono.ChBody):
            self._system._system.AddBody(asset)
            return
        if isinstance(asset, WABody):
            if not hasattr(asset, 'size') or not hasattr(asset, 'position'):
                raise AttributeError(
                    "Body must have 'size', and 'position' fields")

            position = asset.position
            yaw = 0 if not hasattr(asset, 'yaw') else asset.yaw
            size = asset.size

            body_type = 'box'
            if hasattr(asset, 'body_type'):
                body_type = asset.body_type

            if body_type == 'sphere':
                body = chrono.ChBodyEasySphere(size.length, 1000, True, False)
                body.SetBodyFixed(True)
            elif body_type == 'box':
                body = chrono.ChBodyEasyBox(
                    size.x, size.y, size.z, 1000, True, False)
                body.SetBodyFixed(True)
            else:
                raise ValueError(
                    f"'{asset.body_type}' not a supported body type.")

            body.SetPos(WAVector_to_ChVector(position))
            body.SetRot(chrono.Q_from_AngZ(-yaw + WA_PI / 2))

            if hasattr(asset, 'color'):
                color = asset.color
                body.AddAsset(chrono.ChColorAsset(
                    chrono.ChColor(color.x, color.y, color.z)))

                texture = chrono.ChVisualMaterial()
                texture.SetDiffuseColor(
                    chrono.ChVectorF(color.x, color.y, color.z))
                chrono.CastToChVisualization(
                    body.GetAssets()[0]).material_list.append(texture)

            if hasattr(asset, 'texture'):
                texture = chrono.ChVisualMaterial()
                texture.SetKdTexture(get_wa_data_file(asset.texture))
                chrono.CastToChVisualization(
                    body.GetAssets()[0]).material_list.append(texture)

            self._system._system.AddBody(body)

            asset.chrono_body = body

        super().add_asset(asset)
Esempio n. 5
0
    def __init__(self, system, mesh):
        beam_L = 0.1
        beam_diameter = 0.015

        # Create a section, i.e. thickness and material properties
        # for beams. This will be shared among some beams.
        msection_cable = fea.ChBeamSectionCable()
        msection_cable.SetDiameter(beam_diameter)
        msection_cable.SetYoungModulus(0.01e9)
        msection_cable.SetBeamRaleyghDamping(0.000)

        # Create the nodes
        hnodeancf1 = fea.ChNodeFEAxyzD(chrono.ChVectorD(0, 0, -0.2),
                                       chrono.ChVectorD(1, 0, 0))
        hnodeancf2 = fea.ChNodeFEAxyzD(chrono.ChVectorD(beam_L, 0, -0.2),
                                       chrono.ChVectorD(1, 0, 0))

        mesh.AddNode(hnodeancf1)
        mesh.AddNode(hnodeancf2)

        # Create the element

        belementancf1 = fea.ChElementCableANCF()

        belementancf1.SetNodes(hnodeancf1, hnodeancf2)
        belementancf1.SetSection(msection_cable)

        mesh.AddElement(belementancf1)

        # Apply a force or a torque to a node:
        hnodeancf2.SetForce(chrono.ChVectorD(0, 3, 0))

        hnodeancf1.SetFixed(True)

        # Add a rigid body connected to the end of the beam:

        self.body = chrono.ChBodyEasyBox(0.1, 0.02, 0.02, 1000)
        self.body.SetPos(hnodeancf2.GetPos() + chrono.ChVectorD(0.05, 0, 0))
        system.Add(self.body)

        constraint_pos = fea.ChLinkPointFrame()
        constraint_pos.Initialize(hnodeancf2, self.body)
        system.Add(constraint_pos)

        constraint_dir = fea.ChLinkDirFrame()
        constraint_dir.Initialize(hnodeancf2, self.body)
        constraint_dir.SetDirectionInAbsoluteCoords(chrono.ChVectorD(1, 0, 0))
        system.Add(constraint_dir)
Esempio n. 6
0
    def DrawBarriers(self, points, n=5, height=1, width=1):
        points = points[::n]
        if points[-1] != points[0]:
            points.append(points[-1])
        for i in range(len(points) - 1):
            p1 = points[i]
            p2 = points[i + 1]
            box = chrono.ChBodyEasyBox((p2 - p1).Length(), height, width, 1000,
                                       True, True)
            box.SetPos(p1)

            q = chrono.ChQuaternionD()
            v1 = p2 - p1
            v2 = chrono.ChVectorD(1, 0, 0)
            ang = math.atan2((v1 % v2).Length(), v1 ^ v2)
            if chrono.ChVectorD(0, 0, 1) ^ (v1 % v2) > 0.0:
                ang *= -1
            q.Q_from_AngZ(ang)
            box.SetRot(q)
            box.SetBodyFixed(True)

            box_asset = box.GetAssets()[0]
            visual_asset = chrono.CastToChVisualization(box_asset)

            vis_mat = chrono.ChVisualMaterial()
            vis_mat.SetAmbientColor(chrono.ChVectorF(0, 0, 0))

            if i % 2 == 0:
                vis_mat.SetDiffuseColor(chrono.ChVectorF(1.0, 0, 0))
            else:
                vis_mat.SetDiffuseColor(chrono.ChVectorF(1.0, 1.0, 1.0))
            vis_mat.SetSpecularColor(chrono.ChVectorF(0.9, 0.9, 0.9))
            vis_mat.SetFresnelMin(0)
            vis_mat.SetFresnelMax(0.1)

            visual_asset.material_list.append(vis_mat)

            color = chrono.ChColorAsset()
            if i % 2 == 0:
                color.SetColor(chrono.ChColor(1, 0, 0))
            else:
                color.SetColor(chrono.ChColor(1, 1, 1))
            box.AddAsset(color)
            self.system.Add(box)
            self.barriers.append(box)
Esempio n. 7
0
    def DrawObstacles(self, obstacles, z=0.0):
        self.boxes = []
        for i, o in obstacles.items():
            p1 = o.p1
            p2 = o.p2
            box = chrono.ChBodyEasyBox(o.length, o.width, 1, 1000, True, True)
            box.SetPos(p1)

            q = chrono.ChQuaternionD()
            v1 = p2 - p1
            v2 = chrono.ChVectorD(1, 0, 0)
            ang = math.atan2((v1 % v2).Length(), v1 ^ v2)
            if chrono.ChVectorD(0, 0, 1) ^ (v1 % v2) > 0.0:
                ang *= -1
            q.Q_from_AngZ(ang)
            box.SetRot(q)
            box.SetBodyFixed(True)
            box_asset = box.GetAssets()[0]
            visual_asset = chrono.CastToChVisualization(box_asset)

            self.system.Add(box)
            self.boxes.append(box)
Esempio n. 8
0
# Easy shortcuts to add camera, lights, logo, and sky in Irrlicht scene:
application.AddTypicalLogo()
application.AddTypicalSky()
application.AddTypicalLights()
application.AddTypicalCamera(chronoirr.vector3df(12, 15, -20))

# Contact material shared among all bodies
mat = chrono.ChMaterialSurfaceNSC()

# Create all rigid bodies.

radA = 2
radB = 4

# ...the truss
mbody_truss = chrono.ChBodyEasyBox(20, 10, 2, 1000, True, False, mat)
mphysicalSystem.Add(mbody_truss)
mbody_truss.SetBodyFixed(True)
mbody_truss.SetPos(chrono.ChVectorD(0, 0, 3))

# ...a texture asset that will be shared among the four wheels
cylinder_texture = chrono.ChTexture(
    chrono.GetChronoDataFile("textures/pinkwhite.png"))

# ...the rotating bar support for the two epicycloidal wheels
mbody_train = chrono.ChBodyEasyBox(8, 1.5, 1.0, 1000, True, False, mat)
mphysicalSystem.Add(mbody_train)
mbody_train.SetPos(chrono.ChVectorD(3, 0, 0))

# ...which must rotate respect to truss along Z axis, in 0,0,0
link_revoluteTT = chrono.ChLinkLockRevolute()
Esempio n. 9
0
mysurfmaterial.SetRestitution(0.2)
mysurfmaterial.SetAdhesion(0)

# Create the contact surface and add to the mesh, using our SMC contact material
mcontactcloud = fea.ChContactSurfaceNodeCloud(mysurfmaterial)
mesh.AddContactSurface(mcontactcloud)

# Must use this to 'populate' the contact surface use larger point size to match beam section radius
mcontactcloud.AddAllNodes(0.01)

# 8. Create a collision plane, as a huge box

floor = chrono.ChBodyEasyBox(
    4,
    0.2,
    4,  # x,y,z size
    1000,  # density
    True,  # visible
    True,  # collide
    mysurfmaterial)

system.Add(floor)

floor.SetBodyFixed(True)
floor.SetPos(chrono.ChVectorD(0, -0.1, 0))

# 9. Make the finite elements visible in the 3D view

#   - FEA fisualization can be managed via an easy
#     ChVisualizationFEAmesh helper class.
#     (Alternatively you could bypass this and output .dat
#     files at each step, ex. for VTK or Matalb postprocessing)
    def reset(self):
        del self.manager
        material = chrono.ChMaterialSurfaceNSC()
        self.vehicle = veh.HMMWV_Reduced()
        self.vehicle.SetContactMethod(chrono.ChContactMethod_NSC)
        self.vehicle.SetChassisCollisionType(
            veh.ChassisCollisionType_PRIMITIVES)

        self.vehicle.SetChassisFixed(False)
        self.vehicle.SetInitPosition(
            chrono.ChCoordsysD(self.initLoc, self.initRot))
        self.vehicle.SetPowertrainType(veh.PowertrainModelType_SHAFTS)
        self.vehicle.SetDriveType(veh.DrivelineType_AWD)
        #self.vehicle.SetSteeringType(veh.SteeringType_PITMAN_ARM)
        self.vehicle.SetTireType(veh.TireModelType_TMEASY)
        self.vehicle.SetTireStepSize(self.timestep)
        self.vehicle.Initialize()

        #self.vehicle.SetStepsize(self.timestep)
        if self.play_mode == True:
            self.vehicle.SetChassisVisualizationType(
                veh.VisualizationType_MESH)
            self.vehicle.SetWheelVisualizationType(veh.VisualizationType_MESH)
            self.vehicle.SetTireVisualizationType(veh.VisualizationType_MESH)
        else:
            self.vehicle.SetChassisVisualizationType(
                veh.VisualizationType_PRIMITIVES)
            self.vehicle.SetWheelVisualizationType(
                veh.VisualizationType_PRIMITIVES)
        self.vehicle.SetSuspensionVisualizationType(
            veh.VisualizationType_PRIMITIVES)
        self.vehicle.SetSteeringVisualizationType(
            veh.VisualizationType_PRIMITIVES)
        self.chassis_body = self.vehicle.GetChassisBody()
        self.chassis_body.GetCollisionModel().ClearModel()
        size = chrono.ChVectorD(3, 2, 0.2)
        self.chassis_body.GetCollisionModel().AddBox(material, 0.5 * size.x,
                                                     0.5 * size.y,
                                                     0.5 * size.z)
        self.chassis_body.GetCollisionModel().BuildModel()

        # Driver
        self.driver = veh.ChDriver(self.vehicle.GetVehicle())

        # Rigid terrain
        self.system = self.vehicle.GetSystem()
        self.terrain = veh.RigidTerrain(self.system)
        patch = self.terrain.AddPatch(
            material, chrono.ChVectorD(0, 0, self.terrainHeight - .5),
            chrono.VECT_Z, self.terrainLength, self.terrainWidth, 10)
        material.SetFriction(0.9)
        material.SetRestitution(0.01)
        #patch.SetContactMaterialProperties(2e7, 0.3)
        patch.SetTexture(veh.GetDataFile("terrain/textures/tile4.jpg"), 200,
                         200)
        patch.SetColor(chrono.ChColor(0.8, 0.8, 0.5))
        self.terrain.Initialize()

        ground_body = patch.GetGroundBody()
        ground_asset = ground_body.GetAssets()[0]
        visual_asset = chrono.CastToChVisualization(ground_asset)
        vis_mat = chrono.ChVisualMaterial()
        vis_mat.SetKdTexture(chrono.GetChronoDataFile("concrete.jpg"))
        visual_asset.material_list.append(vis_mat)

        # create obstacles
        self.boxes = []
        for i in range(3):
            box = chrono.ChBodyEasyBox(2, 2, 10, 1000, True, True)
            box.SetPos(
                chrono.ChVectorD(25 + 25 * i,
                                 (np.random.rand(1)[0] - 0.5) * 10, .05))
            box.SetBodyFixed(True)
            box_asset = box.GetAssets()[0]
            visual_asset = chrono.CastToChVisualization(box_asset)

            vis_mat = chrono.ChVisualMaterial()
            vis_mat.SetAmbientColor(chrono.ChVectorF(0, 0, 0))
            vis_mat.SetDiffuseColor(chrono.ChVectorF(.2, .2, .9))
            vis_mat.SetSpecularColor(chrono.ChVectorF(.9, .9, .9))

            visual_asset.material_list.append(vis_mat)
            visual_asset.SetStatic(True)
            self.boxes.append(box)
            self.system.Add(box)

        # Set the time response for steering and throttle inputs.
        # NOTE: this is not exact, since we do not render quite at the specified FPS.
        steering_time = 1.0
        # time to go from 0 to +1 (or from 0 to -1)
        throttle_time = .5
        # time to go from 0 to +1
        braking_time = 0.3
        # time to go from 0 to +1
        self.SteeringDelta = (self.timestep / steering_time)
        self.ThrottleDelta = (self.timestep / throttle_time)
        self.BrakingDelta = (self.timestep / braking_time)

        self.manager = sens.ChSensorManager(self.system)
        self.manager.scene.AddPointLight(chrono.ChVectorF(100, 100, 100),
                                         chrono.ChVectorF(1, 1, 1), 4000.0)
        self.manager.scene.AddPointLight(chrono.ChVectorF(-100, -100, 100),
                                         chrono.ChVectorF(1, 1, 1), 4000.0)
        # ------------------------------------------------
        # Create a self.camera and add it to the sensor manager
        # ------------------------------------------------
        self.camera = sens.ChCameraSensor(
            self.chassis_body,  # body camera is attached to
            50,  # scanning rate in Hz
            chrono.ChFrameD(chrono.ChVectorD(1.5, 0, .875)),
            # offset pose
            self.camera_width,  # number of horizontal samples
            self.camera_height,  # number of vertical channels
            chrono.CH_C_PI / 3,  # horizontal field of view
            #(self.camera_height / self.camera_width) * chrono.CH_C_PI / 3.  # vertical field of view
        )
        self.camera.SetName("Camera Sensor")
        self.camera.PushFilter(sens.ChFilterRGBA8Access())
        self.manager.AddSensor(self.camera)
        # -----------------------------------------------------------------
        # Create a filter graph for post-processing the data from the lidar
        # -----------------------------------------------------------------

        self.d_old = np.linalg.norm(self.Xtarg + self.Ytarg)
        self.step_number = 0
        self.c_f = 0
        self.isdone = False
        self.render_setup = False
        if self.play_mode:
            self.render()

        return self.get_ob()
Esempio n. 11
0
mysystem.Add(mbodyL)

R1 = Sr + Dr * 0.5
R2 = Sr - Dr * 0.5
R3 = chrono.ChVectorD(1, R2.y, 0)
R4 = chrono.ChVectorD(1, R1.y, 0)
pointsR = chrono.vector_ChVectorD(
    [R1 + Dz, R2 + Dz, R3 + Dz, R4 + Dz, R1 - Dz, R2 - Dz, R3 - Dz, R4 - Dz])

mbodyR = chrono.ChBodyEasyConvexHullAuxRef(pointsR, 1000, True, True,
                                           brick_material)
mbodyR.SetBodyFixed(True)
mysystem.Add(mbodyR)

if not (fixed_L):
    mbodyG = chrono.ChBodyEasyBox(1, 0.5, thick * 2.2, 1000, True, True,
                                  brick_material)
    mbodyG.SetPos(chrono.ChVectorD(-1, L2.y - 0.5 / 2, 0))
    mbodyG.SetBodyFixed(True)
    mysystem.Add(mbodyG)

# ---------------------------------------------------------------------
#
#  Create an Irrlicht application to visualize the system
#

myapplication = chronoirr.ChIrrApp(mysystem, 'Test',
                                   chronoirr.dimension2du(1024, 768))

myapplication.AddTypicalLogo(
    chrono.GetChronoDataFile('logo_pychrono_alpha.png'))
myapplication.AddTypicalSky()
Esempio n. 12
0
import pychrono as chrono
import pychrono.irrlicht as irr
import math as m

print("Copyright (c) 2017 projectchrono.org")

# The path to the Chrono data directory containing various assets (meshes, textures, data files)
# is automatically set, relative to the default location of this demo.
# If running from a different directory, you must change the path to the data directory with:
#chrono.SetChronoDataPath('path/to/data')

system = chrono.ChSystemNSC()

# Create a floor
mfloor = chrono.ChBodyEasyBox(3, 0.2, 3, 1000, False, False)
mfloor.SetBodyFixed(True)
system.Add(mfloor)

#
# EXAMPLE 1
#
# In this example we impose position and rotation of a body shape respect to absolute reference,
# using the following methods:
#
# position:  use a triplet of X,Y,Z ChFunction objects
# rotation:  use a fixed axis of rotation and an angle(time) function defined via a ChFunction

# Create the object to move
mmoved_1 = chrono.ChBodyEasyMesh(
    chrono.GetChronoDataFile("models/support.obj"), 1000, True, True, False)
Esempio n. 13
0
    def __init__(self, system, mesh, n_chains=6):
        self.bodies = []  #[chrono.ChBodyEasyBox for i in range(n_chains)]
        msection_cable2 = fea.ChBeamSectionCable()
        msection_cable2.SetDiameter(0.015)
        msection_cable2.SetYoungModulus(0.01e9)
        msection_cable2.SetBeamRaleyghDamping(0.000)

        mtruss = chrono.ChBody()
        mtruss.SetBodyFixed(True)

        for j in range(n_chains):
            builder = fea.ChBuilderCableANCF()

            # Now, simply use BuildBeam to create a beam from a poto another:
            builder.BuildBeam(
                mesh,  # the mesh where to put the created nodes and elements
                msection_cable2,  # ChBeamSectionCable to use for the ChElementBeamANCF elements
                1 + j,  # number of ChElementBeamANCF to create
                chrono.ChVectorD(0, 0, -0.1 * j),  # poA (beginning of beam)
                chrono.ChVectorD(0.1 + 0.1 * j, 0,
                                 -0.1 * j)  # poB (end of beam)
            )

            builder.GetLastBeamNodes().back().SetForce(
                chrono.ChVectorD(0, -0.2, 0))

            constraint_hinge = fea.ChLinkPointFrame()
            constraint_hinge.Initialize(builder.GetLastBeamNodes().front(),
                                        mtruss)
            system.Add(constraint_hinge)

            msphere = chrono.ChSphereShape()
            msphere.GetSphereGeometry().rad = 0.02
            constraint_hinge.AddAsset(msphere)

            # make a box and connect it
            mbox = chrono.ChBodyEasyBox(0.2, 0.04, 0.04, 1000)
            mbox.SetPos(builder.GetLastBeamNodes().back().GetPos() +
                        chrono.ChVectorD(0.1, 0, 0))
            system.Add(mbox)

            constraint_pos = fea.ChLinkPointFrame()
            constraint_pos.Initialize(builder.GetLastBeamNodes().back(), mbox)
            system.Add(constraint_pos)

            constraint_dir = fea.ChLinkDirFrame()
            constraint_dir.Initialize(builder.GetLastBeamNodes().back(), mbox)
            constraint_dir.SetDirectionInAbsoluteCoords(
                chrono.ChVectorD(1, 0, 0))
            system.Add(constraint_dir)

            # make another beam
            builder.BuildBeam(
                mesh,  # mesh where to put the created nodes and elements
                msection_cable2,  # ChBeamSectionCable to use for the ChElementBeamANCF elements
                1 + (n_chains - j),  # number of ChElementBeamANCF to create
                chrono.ChVectorD(mbox.GetPos().x + 0.1, 0,
                                 -0.1 * j),  # poA (beginning of beam)
                chrono.ChVectorD(mbox.GetPos().x + 0.1 + 0.1 * (n_chains - j),
                                 0, -0.1 * j)  # poB (end of beam)
            )

            constraint_pos2 = fea.ChLinkPointFrame()
            constraint_pos2.Initialize(builder.GetLastBeamNodes().front(),
                                       mbox)
            system.Add(constraint_pos2)

            constraint_dir2 = fea.ChLinkDirFrame()
            constraint_dir2.Initialize(builder.GetLastBeamNodes().front(),
                                       mbox)
            constraint_dir2.SetDirectionInAbsoluteCoords(
                chrono.ChVectorD(1, 0, 0))
            system.Add(constraint_dir2)

            # make a box and connect it
            self.bodies.append(chrono.ChBodyEasyBox(0.2, 0.04, 0.04, 1000))
            self.bodies[j].SetPos(builder.GetLastBeamNodes().back().GetPos() +
                                  chrono.ChVectorD(0.1, 0, 0))
            system.Add(self.bodies[j])

            constraint_pos3 = fea.ChLinkPointFrame()
            constraint_pos3.Initialize(builder.GetLastBeamNodes().back(),
                                       self.bodies[j])
            system.Add(constraint_pos3)

            constraint_dir3 = fea.ChLinkDirFrame()
            constraint_dir3.Initialize(builder.GetLastBeamNodes().back(),
                                       self.bodies[j])
            constraint_dir3.SetDirectionInAbsoluteCoords(
                chrono.ChVectorD(1, 0, 0))
            system.Add(constraint_dir3)
Esempio n. 14
0
import pychrono as chrono
import pychrono.robot as viper
try:
    from pychrono import irrlicht as chronoirr
except:
    print('Could not import ChronoIrrlicht')

# Chreate Chrono system
system = chrono.ChSystemNSC()
system.Set_G_acc(chrono.ChVectorD(0, -9.81, 0))
chrono.ChCollisionModel.SetDefaultSuggestedEnvelope(0.0025)
chrono.ChCollisionModel.SetDefaultSuggestedMargin(0.0025)

# Create ground body
ground_mat = chrono.ChMaterialSurfaceNSC()
ground = chrono.ChBodyEasyBox(20, 1, 20, 1000, True, True, ground_mat)
ground.SetPos(chrono.ChVectorD(0, -1, 0))
ground.SetBodyFixed(True)
system.Add(ground)

texture = chrono.ChTexture()
texture.SetTextureFilename(chrono.GetChronoDataFile("textures/concrete.jpg"))
ground.AddAsset(texture)

# Create Viper rover
rover = viper.ViperRover(system, chrono.ChVectorD(0, -0.2, 0),
                         chrono.Q_from_AngX(-chrono.CH_C_PI_2))
rover.Initialize()

# Create run-time visualization
application = chronoirr.ChIrrApp(system, "Viper rover - Rigid terrain",
Esempio n. 15
0
m2.setFluidDensityAtNodes(np.array([rho_0 for i in range(m2.nodes_nb)]))
# sets drag coefficients
m2.setDragCoefficients(tangential=1.15, normal=0.213, segment_nb=0)
# sets added mass coefficients
m2.setAddedMassCoefficients(tangential=0.269, normal=0.865, segment_nb=0)
# small Iyy for bending
m2.setIyy(0., 0)
# attach back node of cable to body
m2.attachBackNodeToBody(body)
# attach front node to anchor
m2.attachFrontNodeToBody(body2)

# SEABED

# create a box
seabed = pychrono.ChBodyEasyBox(100., 0.2, 1., 1000, True)
# move box
seabed.SetPos(pychrono.ChVectorD(0., -0.1 - d * 2, 0.))
# fix boxed in space
seabed.SetBodyFixed(True)
# add box to system
system.ChSystem.Add(seabed)

# CONTACT MATERIAL

# define contact material for collision detection
material = pychrono.ChMaterialSurfaceSMC()
material.SetKn(3e6)  # normal stiffness
material.SetGn(1.)  # normal damping coefficient
material.SetFriction(0.3)
material.SetRestitution(0.2)
Esempio n. 16
0
mysystem.Add(mbodyL)

R1 = Sr + Dr * 0.5
R2 = Sr - Dr * 0.5
R3 = chrono.ChVectorD(1, R2.y, 0)
R4 = chrono.ChVectorD(1, R1.y, 0)
pointsR = chrono.vector_ChVectorD(
    [R1 + Dz, R2 + Dz, R3 + Dz, R4 + Dz, R1 - Dz, R2 - Dz, R3 - Dz, R4 - Dz])

mbodyR = chrono.ChBodyEasyConvexHullAuxRef(pointsR, 1000, True, True)
mbodyR.SetBodyFixed(True)
mbodyR.SetMaterialSurface(brick_material)
mysystem.Add(mbodyR)

if not (fixed_L):
    mbodyG = chrono.ChBodyEasyBox(1, 0.5, thick * 2.2, 1000, True, True)
    mbodyG.SetPos(chrono.ChVectorD(-1, L2.y - 0.5 / 2, 0))
    mbodyG.SetBodyFixed(True)
    mbodyG.SetMaterialSurface(brick_material)
    mysystem.Add(mbodyG)

# ---------------------------------------------------------------------
#
#  Create an Irrlicht application to visualize the system
#

myapplication = chronoirr.ChIrrApp(mysystem, 'Test',
                                   chronoirr.dimension2du(1024, 768))

myapplication.AddTypicalLogo(
    chrono.GetChronoDataFile('logo_pychrono_alpha.png'))
Esempio n. 17
0
    mfloor.GetCollisionModel().BuildModel()
    mfloor.SetCollide(True)

    masset_meshbox = chrono.ChTriangleMeshShape()
    masset_meshbox.SetMesh(mmeshbox)
    mfloor.AddAsset(masset_meshbox)

    masset_texture = chrono.ChTexture()
    masset_texture.SetTextureFilename(
        chrono.GetChronoDataFile("textures/concrete.jpg"))
    mfloor.AddAsset(masset_texture)

else:
    # floor as a simple collision primitive:

    mfloor = chrono.ChBodyEasyBox(2, 0.1, 2, 2700, True, True, mysurfmaterial)
    mfloor.SetBodyFixed(True)
    my_system.Add(mfloor)

    masset_texture = chrono.ChTexture()
    masset_texture.SetTextureFilename(
        chrono.GetChronoDataFile("textures/concrete.jpg"))
    mfloor.AddAsset(masset_texture)

# two falling objects:

mcube = chrono.ChBodyEasyBox(0.1, 0.1, 0.1, 2700, True, True, mysurfmaterial)
mcube.SetPos(chrono.ChVectorD(0.6, 0.5, 0.6))
my_system.Add(mcube)

msphere = chrono.ChBodyEasySphere(0.1, 2700, True, True, mysurfmaterial)