Esempio n. 1
0
   def __init__(self, render):

      self.animate = render
      self.observation_space = np.empty([30,])
      self.action_space = np.zeros([8,])
      self.info =  {}
    # ---------------------------------------------------------------------
    #
    #  Create the simulation system and add items
    #
      self.Xtarg = 1000.0
      self.Ytarg = 0.0
      self.d_old = np.linalg.norm(self.Xtarg + self.Ytarg)
      self.ant_sys = chrono.ChSystemNSC()

    # Set the default outward/inward shape margins for collision detection,
    # this is epecially important for very large or very small objects.
      chrono.ChCollisionModel.SetDefaultSuggestedEnvelope(0.001)
      chrono.ChCollisionModel.SetDefaultSuggestedMargin(0.001)

    #ant_sys.SetSolverType(chrono.ChSolver.Type_BARZILAIBORWEIN) # precise, more slow
      self.ant_sys.SetSolverMaxIterations(70)
      

      self.ant_material = chrono.ChMaterialSurfaceNSC()
      self.ant_material.SetFriction(0.5)
      self.ant_material.SetDampingF(0.2)
      self.ant_material.SetCompliance (0.0005)
      self.ant_material.SetComplianceT(0.0005)

      self.timestep = 0.01
      self.abdomen_x = 0.25
      self.abdomen_y = 0.25
      self.abdomen_z = 0.25

      self.leg_density = 250    # kg/m^3
      self.abdomen_density = 100
      self.abdomen_y0 = 0.4
      self.leg_length = 0.3
      self.leg_radius = 0.04
      self.ankle_angle = 60*(math.pi/180)
      self.ankle_length = 0.4
      self.ankle_radius = 0.04
      self.gain = 30

      self.abdomen_mass = self.abdomen_density * ((4/3)*chrono.CH_C_PI*self.abdomen_x*self.abdomen_y*self.abdomen_z)
      self.abdomen_inertia = chrono.ChVectorD((1/5)*self.abdomen_mass*(pow(self.abdomen_y,2)+pow(self.abdomen_z,2)),(1/5)*self.abdomen_mass*(pow(self.abdomen_x,2)+pow(self.abdomen_z,2)),(1/5)*self.abdomen_mass*(pow(self.abdomen_y,2)+pow(self.abdomen_x,2)))
      self.leg_mass = self.leg_density * self.leg_length * math.pi* pow (self.leg_radius,2)
      self.leg_inertia = chrono.ChVectorD(0.5*self.leg_mass*pow(self.leg_radius,2), (self.leg_mass/12)*(3*pow(self.leg_radius,2)+pow(self.leg_length,2)),(self.leg_mass/12)*(3*pow(self.leg_radius,2)+pow(self.leg_length,2)))
      self.ankle_mass = self.leg_density * self.ankle_length * math.pi* pow (self.ankle_radius,2)
      self.ankle_inertia = chrono.ChVectorD(0.5*self.ankle_mass*pow(self.ankle_radius,2), (self.ankle_mass/12)*(3*pow(self.ankle_radius,2)+pow(self.ankle_length,2)),(self.ankle_mass/12)*(3*pow(self.ankle_radius,2)+pow(self.ankle_length,2)))
      
      self.leg_limit = chrono.ChLinkLimit()
      self.ankle_limit = chrono.ChLinkLimit()
      self.leg_limit.SetRmax(math.pi/9)
      self.leg_limit.SetRmin(-math.pi/9)
      self.ankle_limit.SetRmax(math.pi/9)
      self.ankle_limit.SetRmin(-math.pi/9)
      
      if (self.animate) :
             self.myapplication = chronoirr.ChIrrApp(self.ant_sys)
             self.myapplication.AddShadowAll()
             self.myapplication.SetStepManage(True)
             self.myapplication.SetTimestep(self.timestep)
             self. myapplication.SetTryRealtime(True)  
             self.myapplication.AddTypicalSky()
             self.myapplication.AddTypicalLogo(chrono.GetChronoDataFile('logo_pychrono_alpha.png'))
             self.myapplication.AddTypicalCamera(chronoirr.vector3df(0,1.5,0))
             self.myapplication.AddLightWithShadow(chronoirr.vector3df(4,4,0),    # point
                                            chronoirr.vector3df(0,0,0),    # aimpoint
                                            20,                 # radius (power)
                                            1,9,               # near, far
                                            90)                # angle of FOV
Esempio n. 2
0
   def __init__(self):
      ChronoBaseEnv.__init__(self)
      
      low = np.full(30, -1000)
      high = np.full(30, 1000)
      self.observation_space = spaces.Box(low, high, dtype=np.float32)
      self.action_space = spaces.Box(low=-1.0, high=1.0, shape=(8,), dtype=np.float32)
      
      self.info =  {"timeout": 10000.0}
    # ---------------------------------------------------------------------
    #
    #  Create the simulation system and add items
    #
      self.Xtarg = 1000.0
      self.Ytarg = 0.0
      self.d_old = np.linalg.norm(self.Xtarg + self.Ytarg)
      self.ant_sys = chrono.ChSystemNSC()

    # Set the default outward/inward shape margins for collision detection,
    # this is epecially important for very large or very small objects.
      chrono.ChCollisionModel.SetDefaultSuggestedEnvelope(0.001)
      chrono.ChCollisionModel.SetDefaultSuggestedMargin(0.001)

    #ant_sys.SetSolverType(chrono.ChSolver.Type_BARZILAIBORWEIN) # precise, more slow
      self.ant_sys.SetSolverMaxIterations(70)
      

      self.ant_material = chrono.ChMaterialSurfaceNSC()
      self.ant_material.SetFriction(0.5)
      self.ant_material.SetDampingF(0.2)
      self.ant_material.SetCompliance (0.0005)
      self.ant_material.SetComplianceT(0.0005)

      self.timestep = 0.01
      self.abdomen_x = 0.25
      self.abdomen_y = 0.25
      self.abdomen_z = 0.25

      self.leg_density = 250    # kg/m^3
      self.abdomen_density = 100
      self.abdomen_y0 = 0.4
      self.leg_length = 0.3
      self.leg_radius = 0.04
      self.ankle_angle = 60*(math.pi/180)
      self.ankle_length = 0.4
      self.ankle_radius = 0.04
      self.gain = 30

      self.abdomen_mass = self.abdomen_density * ((4/3)*chrono.CH_C_PI*self.abdomen_x*self.abdomen_y*self.abdomen_z)
      self.abdomen_inertia = chrono.ChVectorD((1/5)*self.abdomen_mass*(pow(self.abdomen_y,2)+pow(self.abdomen_z,2)),(1/5)*self.abdomen_mass*(pow(self.abdomen_x,2)+pow(self.abdomen_z,2)),(1/5)*self.abdomen_mass*(pow(self.abdomen_y,2)+pow(self.abdomen_x,2)))
      self.leg_mass = self.leg_density * self.leg_length * math.pi* pow (self.leg_radius,2)
      self.leg_inertia = chrono.ChVectorD(0.5*self.leg_mass*pow(self.leg_radius,2), (self.leg_mass/12)*(3*pow(self.leg_radius,2)+pow(self.leg_length,2)),(self.leg_mass/12)*(3*pow(self.leg_radius,2)+pow(self.leg_length,2)))
      self.ankle_mass = self.leg_density * self.ankle_length * math.pi* pow (self.ankle_radius,2)
      self.ankle_inertia = chrono.ChVectorD(0.5*self.ankle_mass*pow(self.ankle_radius,2), (self.ankle_mass/12)*(3*pow(self.ankle_radius,2)+pow(self.ankle_length,2)),(self.ankle_mass/12)*(3*pow(self.ankle_radius,2)+pow(self.ankle_length,2)))
      
      self.leg_limit = chrono.ChLinkLimit()
      self.ankle_limit = chrono.ChLinkLimit()
      self.leg_limit.SetRmax(math.pi/9)
      self.leg_limit.SetRmin(-math.pi/9)
      self.ankle_limit.SetRmax(math.pi/9)
      self.ankle_limit.SetRmin(-math.pi/9)