Exemplo n.º 1
0
patch = terrain.AddPatch(patch_mat, 
                         chrono.ChVectorD(0, 0, 0), chrono.ChVectorD(0, 0, 1), 
                         600, 600)
patch.SetColor(chrono.ChColor(0.8, 0.8, 1.0))
patch.SetTexture(veh.GetDataFile("terrain/textures/tile4.jpg"), 1200, 1200)
terrain.Initialize()

# -------------------------------------
# Create the vehicle Irrlicht interface
# Create the driver system
# -------------------------------------

app = veh.ChWheeledVehicleIrrApp(gator.GetVehicle(), 'Gator', irr.dimension2du(1000,800))
app.SetSkyBox()
app.AddTypicalLights(irr.vector3df(+130, +130, 150), irr.vector3df(-130, +130, 150), 120,
                     120, irr.SColorf(0.7, 0.7, 0.7, 1.0), irr.SColorf(0.7, 0.7, 0.7, 1.0))
app.AddTypicalLights(irr.vector3df(+130, -130, 150), irr.vector3df(-130, -130, 150), 120,
                     120, irr.SColorf(0.7, 0.7, 0.7, 1.0), irr.SColorf(0.7, 0.7, 0.7, 1.0))

app.SetChaseCamera(trackPoint, 6.0, 0.5)
app.SetTimestep(step_size)
app.AssetBindAll()
app.AssetUpdateAll()

# Create the interactive driver system
driver = veh.ChIrrGuiDriver(app)

# Set the time response for steering and throttle keyboard inputs.
steering_time = 1.0  # time to go from 0 to +1 (or from 0 to -1)
throttle_time = 1.0  # time to go from 0 to +1
braking_time = 0.3   # time to go from 0 to +1
    def __init__(self,
                 configuration,
                 visualization: bool = False,
                 output: Optional = None) -> None:
        # TODO a copy of the configuration is better
        self._conf = configuration
        self._visualization = visualization
        self._output = output
        self._app = None

        # TODO not sure about the meaning of theese two parameters, take them from the configuation
        chrono.ChCollisionInfo.SetDefaultEffectiveCurvatureRadius(1)
        chrono.ChCollisionModel.SetDefaultSuggestedMargin(0.006)

        # TODO look into the parameters of the system
        # e.g. MinBounceSpeed, Gravity
        self._system = chrono.ChSystemSMC()

        if self._visualization:
            # TODO take the data path, the title, the dimension and do_[something] from the configuration
            chrono.SetChronoDataPath(
                "/home/gianluca/anaconda3/envs/chrono/share/chrono/data/")
            self._app = irr.ChIrrApp(
                self._system,
                "Artificial Skin",
                irr.dimension2du(1024, 768),
                do_fullscreen=False,
                do_shadows=True,
                do_antialias=True,
            )
            self._app.AddTypicalSky()
            self._app.AddTypicalLights()
            # TODO take the info for the came and lighs from the configuation
            self._app.AddTypicalCamera(irr.vector3df(-1, -1, 0),
                                       irr.vector3df(0, 0, 0))
            # TODO this has too many parameters and it is not that important
            self._app.AddLightWithShadow(
                irr.vector3df(1.5, 5.5, -2.5),
                irr.vector3df(0, 0, 0),
                3,
                2.2,
                7.2,
                40,
                512,
                irr.SColorf(1, 1, 1),
            )
            self._app.AddShadowAll()
            self._app.SetTimestep(0.004)

        self._make_sheets()
        self._make_sensors()
        # TODO make the load class -> it takes a node / pair of indexes and time and return the force
        self._add_forces()

        # TODO look at all the parameters of the solver and the stepper
        # TODO consider also mkl.ChSolverMKL
        # TODO take the parameters from the configuration
        self._solver = chrono.ChSolverMINRES()
        self._system.SetSolver(self._solver)
        self._solver.SetMaxIterations(1000)
        self._solver.SetTolerance(1e-12)
        self._solver.EnableDiagonalPreconditioner(True)
        self._solver.SetVerbose(
            False)  # don't take this from the configuration

        # HHT implicit integrator for II order systems, adaptive
        # TODO take the parameters from the configuaration
        self._stepper = chrono.ChTimestepperHHT(self._system)
        self._system.SetTimestepper(self._stepper)
        self._stepper.SetAlpha(-0.2)
        self._stepper.SetMaxiters(100)
        self._stepper.SetAbsTolerances(1e-5)
        self._stepper.SetMode(chrono.ChTimestepperHHT.POSITION)
        self._stepper.SetScaling(True)

        # TODO from configuarion
        # length of the simulation
        self._life = 5  # seconds
Exemplo n.º 3
0
                                   True)
myapplication.AddTypicalSky()
myapplication.AddTypicalLogo(
    chrono.GetChronoDataFile('logo_pychrono_alpha.png'))
myapplication.AddTypicalCamera(chronoirr.vector3df(2.0, 1.4, 0.0),
                               chronoirr.vector3df(0, tire_rad, 0))
myapplication.AddTypicalLights()
myapplication.AddLightWithShadow(
    chronoirr.vector3df(1.5, 5.5, -2.5),  # point
    chronoirr.vector3df(0, 0, 0),  # aim point
    3,  # radius (power)
    2.2,
    7.2,  # near, far
    40,  # angle of FOV
    512,  # resoluition
    chronoirr.SColorf(0.8, 0.8, 1))  # light color
myapplication.AssetBindAll()
myapplication.AssetUpdateAll()
myapplication.AddShadowAll()

# ------------------
# Run the simulation
# ------------------

myapplication.SetTimestep(0.002)

while (myapplication.GetDevice().run()):
    myapplication.BeginScene()
    myapplication.GetSceneManager().getActiveCamera().setTarget(
        chronoirr.vector3dfCH(body.GetPos()))
    myapplication.DrawAll()
Exemplo n.º 4
0
                         chrono.ChVectorD(0, 0, 1), 600, 600)
patch.SetColor(chrono.ChColor(0.8, 0.8, 1.0))
patch.SetTexture(veh.GetDataFile("terrain/textures/tile4.jpg"), 1200, 1200)
terrain.Initialize()

# -------------------------------------
# Create the vehicle Irrlicht interface
# Create the driver system
# -------------------------------------

app = veh.ChWheeledVehicleIrrApp(uaz.GetVehicle(), 'UAZBUS',
                                 irr.dimension2du(1000, 800))
app.SetSkyBox()
app.AddTypicalLights(irr.vector3df(+130, +130, 150),
                     irr.vector3df(-130, +130, 150), 120, 120,
                     irr.SColorf(0.7, 0.7, 0.7, 1.0),
                     irr.SColorf(0.7, 0.7, 0.7, 1.0))
app.AddTypicalLights(irr.vector3df(+130, -130, 150),
                     irr.vector3df(-130, -130, 150), 120, 120,
                     irr.SColorf(0.7, 0.7, 0.7, 1.0),
                     irr.SColorf(0.7, 0.7, 0.7, 1.0))

app.SetChaseCamera(trackPoint, 6.0, 0.5)
app.SetTimestep(step_size)
app.AssetBindAll()
app.AssetUpdateAll()

# Create the interactive driver system
driver = veh.ChIrrGuiDriver(app)

# Set the time response for steering and throttle keyboard inputs.
Exemplo n.º 5
0
patch.SetContactRestitutionCoefficient(0.01)
patch.SetContactMaterialProperties(2e7, 0.3)
patch.SetColor(chrono.ChColor(0.8, 0.8, 1.0))
patch.SetTexture(veh.GetDataFile("terrain/textures/tile4.jpg"), 1200, 1200)
terrain.Initialize()

# -------------------------------------
# Create the vehicle Irrlicht interface
# Create the driver system
# -------------------------------------

app = veh.ChWheeledVehicleIrrApp(uaz.GetVehicle())  #, "UAZBUS demo")
app.SetSkyBox()
app.AddTypicalLights(chronoirr.vector3df(+130, +130, 150),
                     chronoirr.vector3df(-130, +130, 150), 120, 120,
                     chronoirr.SColorf(0.7, 0.7, 0.7, 1.0),
                     chronoirr.SColorf(0.7, 0.7, 0.7, 1.0))
app.AddTypicalLights(chronoirr.vector3df(+130, -130, 150),
                     chronoirr.vector3df(-130, -130, 150), 120, 120,
                     chronoirr.SColorf(0.7, 0.7, 0.7, 1.0),
                     chronoirr.SColorf(0.7, 0.7, 0.7, 1.0))

app.SetChaseCamera(trackPoint, 6.0, 0.5)
app.SetTimestep(step_size)
app.AssetBindAll()
app.AssetUpdateAll()

# Create the interactive driver system
driver = veh.ChIrrGuiDriver(app)

# Set the time response for steering and throttle keyboard inputs.
Exemplo n.º 6
0
# THE VISUALIZATION SYSTEM
#

# Create the Irrlicht visualization (open the Irrlicht device,
# bind a simple user interface, etc. etc.)
application = chronoirr.ChIrrApp(mphysicalSystem, "Motors",
                                 chronoirr.dimension2du(800, 600), False)

# Easy shortcuts to add camera, lights, logo and sky in Irrlicht scene:
application.AddTypicalLogo()
application.AddTypicalSky()
application.AddTypicalLights()
application.AddTypicalCamera(chronoirr.vector3df(1, 3, -7))
application.AddLightWithShadow(chronoirr.vector3df(20.0, 35.0, -25.0),
                               chronoirr.vector3df(0, 0, 0), 55, 20, 55, 35,
                               512, chronoirr.SColorf(0.6, 0.8, 1.0))

# Use this function for adding a ChIrrNodeAsset to all items
# Otherwise use application.AssetBind(myitem) on a per-item basis.
application.AssetBindAll()

# Use this function for 'converting' assets into Irrlicht meshes
application.AssetUpdateAll()

# This is to enable shadow maps (shadow casting with soft shadows) in Irrlicht
# for all objects (or use application.AddShadow(..) for enable shadow on a per-item basis)
application.AddShadowAll()

#
# THE SOFT-REAL-TIME CYCLE
#
Exemplo n.º 7
0
my_system = chrono.ChSystemSMC()

# Create the Irrlicht visualization (open the Irrlicht device,
# bind a simple user interface, etc. etc.)
application = chronoirr.ChIrrApp(my_system, "FEA contacts",
                                 chronoirr.dimension2du(1024, 768), False,
                                 True)

# Easy shortcuts to add camera, lights, logo and sky in Irrlicht scene:
application.AddTypicalLogo(chrono.GetChronoDataFile('logo_pychrono_alpha.png'))
application.AddTypicalSky()
application.AddTypicalLights()
application.AddTypicalCamera(chronoirr.vector3df(0, 0.6, -1))
application.AddLightWithShadow(chronoirr.vector3df(1.5, 5.5, -2.5),
                               chronoirr.vector3df(0, 0, 0), 3, 2.2, 7.2, 40,
                               512, chronoirr.SColorf(1, 1, 1))

application.SetContactsDrawMode(chronoirr.ChIrrTools.CONTACT_DISTANCES)

#
# CREATE THE PHYSICAL SYSTEM
#

# Set default effective radius of curvature for all SCM contacts.
chrono.ChCollisionInfo.SetDefaultEffectiveCurvatureRadius(1)

# collision::ChCollisionModel::SetDefaultSuggestedEnvelope(0.0) # not needed, already 0 when using ChSystemSMC
chrono.ChCollisionModel.SetDefaultSuggestedMargin(
    0.006
)  # max inside penetration - if not enough stiffness in material: troubles