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
mvisualizemeshD.SetColorscaleMinMax(-0.5, 5) mvisualizemeshD.SetZbufferHide(False) my_mesh.AddAsset(mvisualizemeshD) application.AssetBindAll() application.AssetUpdateAll() # Perform a dynamic time integration: solver = chrono.ChSolverMINRES() my_system.SetSolver(solver) solver.SetMaxIterations(1000) solver.SetTolerance(1e-10) solver.EnableDiagonalPreconditioner(True) solver.SetVerbose(False) mystepper = chrono.ChTimestepperHHT(my_system) my_system.SetTimestepper(mystepper) mystepper.SetAlpha(-0.2) mystepper.SetMaxiters(100) mystepper.SetAbsTolerances(1e-5) mystepper.SetMode(chrono.ChTimestepperHHT.POSITION) mystepper.SetScaling(True) application.SetTimestep(0.004) while application.GetDevice().run(): application.BeginScene() application.DrawAll() application.DoStep() application.EndScene()