def render(self, mode='human'):
        if not (self.play_mode == True):
            raise Exception('Please set play_mode=True to render')

        if not self.render_setup:
            vis = True
            save = False
            birds_eye = False
            third_person = True
            width = 1280
            height = 720
            if birds_eye:
                body = chrono.ChBodyAuxRef()
                body.SetBodyFixed(True)
                self.system.AddBody(body)
                vis_camera = sens.ChCameraSensor(
                    body,  # body camera is attached to
                    20,  # scanning rate in Hz
                    chrono.ChFrameD(chrono.ChVectorD(0, 0, 200),
                                    chrono.Q_from_AngAxis(chrono.CH_C_PI / 2, chrono.ChVectorD(0, 1, 0))),
                    # offset pose
                    width,  # number of horizontal samples
                    height,  # number of vertical channels
                    chrono.CH_C_PI / 3  # horizontal field of view
                )
                vis_camera.SetName("Birds Eye Camera Sensor")
                if vis:
                    vis_camera.PushFilter(sens.ChFilterVisualize(width, height, "Visualization Camera"))
                if save:
                    vis_camera.PushFilter(sens.ChFilterSave())
                self.manager.AddSensor(vis_camera)

            if third_person:
                vis_camera = sens.ChCameraSensor(
                    self.chassis_body,  # body camera is attached to
                    20,  # scanning rate in Hz
                    chrono.ChFrameD(chrono.ChVectorD(-8, 0, 3),
                                    chrono.Q_from_AngAxis(chrono.CH_C_PI / 20, chrono.ChVectorD(0, 1, 0))),
                    # offset pose
                    width,  # number of horizontal samples
                    height,  # number of vertical channels
                    chrono.CH_C_PI / 3  # horizontal field of view
                )
                vis_camera.SetName("Follow Camera Sensor")
                if vis:
                    vis_camera.PushFilter(sens.ChFilterVisualize(width, height, "Visualization Camera"))
                if save:
                    vis_camera.PushFilter(sens.ChFilterSave())
                self.manager.AddSensor(vis_camera)

            # -----------------------------------------------------------------
            # Create a filter graph for post-processing the data from the lidar
            # -----------------------------------------------------------------

            # self.camera.PushFilter(sens.ChFilterVisualize("RGB Camera"))
            # vis_camera.PushFilter(sens.ChFilterVisualize("Visualization Camera"))
            self.render_setup = True

        if (mode == 'rgb_array'):
            return self.get_ob()
# Chrono::Engine Python script from SolidWorks
# Assembly: C:\tasora\lavori\orologio_audemar\CAD_swiss_escapement\escapement.SLDASM

import pychrono as chrono
import builtins

shapes_dir = 'swiss_escapement_shapes/'

if hasattr(builtins, 'exported_system_relpath'):
    shapes_dir = builtins.exported_system_relpath + shapes_dir

exported_items = []

body_0 = chrono.ChBodyAuxRef()
body_0.SetName('ground')
body_0.SetBodyFixed(True)
exported_items.append(body_0)

# Rigid body part
body_1 = chrono.ChBodyAuxRef()
body_1.SetName('escape_wheel^escapement-1')
body_1.SetPos(chrono.ChVectorD(0, 0.000381819559584939, 0))
body_1.SetRot(chrono.ChQuaternionD(0, 0, 0.707106781186548, 0.707106781186547))
body_1.SetMass(0.385093622816182)
body_1.SetInertiaXX(
    chrono.ChVectorD(0.000614655341550614, 0.00114774663635329,
                     0.000614655341550614))
body_1.SetInertiaXY(
    chrono.ChVectorD(1.04945260437012e-19, -5.29910899706164e-19,
                     5.85921324575995e-19))
body_1.SetFrame_COG_to_REF(
Esempio n. 3
0
# Iterate over added bodies (Python style)
print ('Positions of all bodies in the system:')
for abody in my_system.Get_bodylist():
    print ('  body pos=', abody.GetPos() )


# Move a body, using a ChFrame
my_displacement = chrono.ChFrameMovingD(chrono.ChVectorD(5,1,0));
my_shbodyA %= my_displacement
# ..also as:
#  my_shbody.ConcatenatePreTransformation(my_displacement)

print ('Moved body pos=', my_shbodyA.GetPos() )


# Use a body with an auxiliary reference (REF) that does not correspond
# to the center of gravity (COG)
body_1= chrono.ChBodyAuxRef()
body_1.SetName('Parte1-1')
body_1.SetPos(chrono.ChVectorD(-0.0445347481124079,0.0676266363930238,-0.0230808979433518))
body_1.SetRot(chrono.ChQuaternionD(1,0,0,0))
body_1.SetMass(346.17080777653)
body_1.SetInertiaXX(chrono.ChVectorD(48583.2418823358,526927.118351673,490689.966726565))
body_1.SetInertiaXY(chrono.ChVectorD(1.70380722975012e-11,1.40840344485366e-11,-2.31869065456271e-12))
body_1.SetFrame_COG_to_REF(chrono.ChFrameD(chrono.ChVectorD(68.9923703887577,-60.1266363930238,70.1327223302498),chrono.ChQuaternionD(1,0,0,0)))
myasset = chrono.ChObjShapeFile()
myasset.SetFilename("shapes/test.obj")
body_1.GetAssets().push_back(myasset)

print ('Done...')
Esempio n. 4
0
    my_system.DoStepDynamics(0.01)

    print('time=', my_system.GetChTime(), ' bodyB y=', bodyB.GetPos().y)

    my_system.GetContactContainer().ReportAllContacts(my_rep)

print('----------')

# Iterate over added bodies (Python style)
print('Positions of all bodies in the system:')
for abody in my_system.Get_bodylist():
    print(' ', abody.GetName(), ' pos =', abody.GetPos())

# Use a body with an auxiliary reference (REF) that does not correspond to the center of gravity (COG)
bodyC = chrono.ChBodyAuxRef()
my_system.AddBody(bodyC)
bodyC.SetName('Parte1-1')
bodyC.SetPos(
    chrono.ChVectorD(-0.0445347481124079, 0.0676266363930238,
                     -0.0230808979433518))
bodyC.SetRot(chrono.ChQuaternionD(1, 0, 0, 0))
bodyC.SetMass(346.17080777653)
bodyC.SetInertiaXX(
    chrono.ChVectorD(48583.2418823358, 526927.118351673, 490689.966726565))
bodyC.SetInertiaXY(
    chrono.ChVectorD(1.70380722975012e-11, 1.40840344485366e-11,
                     -2.31869065456271e-12))
bodyC.SetFrame_COG_to_REF(
    chrono.ChFrameD(
        chrono.ChVectorD(68.9923703887577, -60.1266363930238,
Esempio n. 5
0
# PyChrono script generated from SolidWorks using Chrono::SolidWorks add-in
# Assembly: C:\Users\SB\Documents\CAD\Comau-R3\Racer3 (3D-SOLIDWORKS)\Racer3_HandE.SLDASM

import pychrono as chrono
import builtins

shapes_dir = 'ComauR3_shapes/'
mymat = chrono.ChMaterialSurfaceNSC()
if hasattr(builtins, 'exported_system_relpath'):
    shapes_dir = builtins.exported_system_relpath + shapes_dir

exported_items = []

body_0 = chrono.ChBodyAuxRef()
body_0.SetName('ground')
body_0.SetBodyFixed(True)
exported_items.append(body_0)

# Rigid body part
body_1 = chrono.ChBodyAuxRef()
body_1.SetName('HAND_e_finger-1')
body_1.SetPos(
    chrono.ChVectorD(-0.52964000188, 0.684998394063328, 1.11022302462516e-16))
body_1.SetRot(
    chrono.ChQuaternionD(0.707106781186546, 1.43973102426035e-15,
                         -1.03316459816659e-15, 0.707106781186549))
body_1.SetMass(0.0938874355859725)
body_1.SetInertiaXX(
    chrono.ChVectorD(1.89819866463215e-05, 4.06468272765221e-05,
                     3.48488688224795e-05))
body_1.SetInertiaXY(