def __init__(self, step_size: float = 3e-3, render_step_size: float = 2e-2, end_time: float = 120, contact_method: str = "NSC", args: 'argparse.Namespace' = None): super().__init__(step_size, render_step_size, end_time, args) if not isinstance(contact_method, str): raise TypeError("Contact method must be of type str") if contact_method == "NSC": system = chrono.ChSystemNSC() elif contact_method == "SMC": system = chrono.ChSystemSMC() system.Set_G_acc(chrono.ChVectorD(0, 0, -9.81)) system.SetSolverType(chrono.ChSolver.Type_BARZILAIBORWEIN) system.SetSolverMaxIterations(150) system.SetMaxPenetrationRecoverySpeed(4.0) self._system = system
# Global -- Optimisation algorithm NEIGHBOURS = 2 INFERRED_RADIUS = 60. # in mm INFERRED_LENGTH = (N_RINGS - 1) * RING_GAP # Constraint of the textile # Global -- Dont touch UNIT_FACTOR = 0.01 metrics = ['mm', 'cm', 'dm', 'm'] metric = metrics[int(math.fabs(round(math.log(UNIT_FACTOR, 10))))] filename = SHAPE_PATH.split('/')[-1].split('.')[0] # --------------------------------------------------------------------------- # Chrono setup chrono.SetChronoDataPath("../data/") mysystem = chrono.ChSystemSMC() mysystem.Set_G_acc(chrono.ChVectorD(0., 0., 0.)) # Remove gravity contact_method = chrono.ChMaterialSurface.SMC # Shape filepath = tool.obj_from_millimeter(chrono.GetChronoDataPath() + SHAPE_PATH, UNIT_FACTOR, f"_{metric}") shape = tool.load_shape(filepath, contact_method, 'textures/skin.jpg') # Get shape bounding box dimensions bbmin, bbmax = chrono.ChVectorD(), chrono.ChVectorD() shape.GetTotalAABB(bbmin, bbmax) bbmin, bbmax = eval(str(bbmin)), eval(str(bbmax)) print(bbmin, bbmax) print(shape.GetPos()) bb_dx = bbmax[0] - bbmin[0]
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
time_create_terrain = duration_pose # create terrain after robot assumes initial pose time_start = time_create_terrain + duration_settle_robot # start actual simulation after robot settling time_end = time_start + duration_sim # end simulation after specified duration # ------------- # Create system # ------------- if contact_method == chrono.ChContactMethod_NSC: my_sys = chrono.ChSystemNSC() chrono.ChCollisionModel.SetDefaultSuggestedEnvelope(0.001) chrono.ChCollisionModel.SetDefaultSuggestedMargin(0.001) if contact_method == chrono.ChContactMethod_SMC: my_sys = chrono.ChSystemSMC() my_sys.SetSolverMaxIterations(200) my_sys.SetSolverType(chrono.ChSolver.Type_BARZILAIBORWEIN) my_sys.Set_G_acc(chrono.ChVectorD(0, 0, -9.8)) # ----------------------- # Create RoboSimian robot # ----------------------- robot = robosimian.RoboSimian(my_sys, True, True) # Set output directory robot.SetOutputDirectory(out_dir)