def watch_dis(): path = '/home/pi/files/IoT/voice/' count = 0 while True: try: distance = Watcher.dis_d() # 将最后2000个距离写入文件,方便调试 count += 1 if count < 2000: with open('/home/pi/files/IoT/voice/data.txt','a+') as f: f.write(str(count) + " ") f.close() else: with open('/home/pi/files/IoT/voice/data.txt','w+') as f: f.write('0 ') f.close() count = 0 # 设定为15cm if distance < 15: Led.red() # 录制一段音频 os.system('arecord -D "plughw:1,0" -d 2 -f S16_LE /home/pi/files/IoT/voice/test.wav') words = Listener.use_cloud('/home/pi/files/IoT/voice/test.wav') if '关' in words: Light.off_all() elif '开' in words: Light.on_all() # 当识别不成功时,led闪烁警告 else: Led.blink1() Led.off_red()
def __init__(self): # Storing the engines of this car self.__leftengine = Engine('A') self.__rightengine = Engine('B') self.__leftled = Light.Light('D') self.__rightled = Light.Light('C') self.__distance_sensor = DistanceSensor(17, 4) # Storing the distance between the centers of the cars # TODO measure width and gearratio self.__widthcar = 20. self.__gearratio = 1. / 3. # Storing the perimeter of the wheels (2*pi*r) self.__perimeter = 2 * math.pi * 2.579 print 'initing Controller' ControllerCommands.init(self.__leftengine, self.__rightengine, self.__distance_sensor, self.__perimeter, self.__gearratio, self.__widthcar, self.__leftled, self.__rightled) print 'Controller inited' # Storing a reference to a brickpi thread self.__io = IO_Thread([self.__leftengine, self.__rightengine], [self.__distance_sensor], [self.__leftled, self.__rightled]) self.__command_going = False self.__command_thread = None self.__parcours = None
def __init__(self, FPGAReader): DemoEngine.SceneBase.__init__(self, 800, 480) #Lock colors: lockScreen = pygame.Surface(self.LockSize) self.lock = Lock.Lock(lockScreen, self) #Random bits: rand = pygame.Surface(self.RandomBitsSize) self.randScreen = RandScreen.RandScreen(rand, FPGAReader, self) randT = pygame.Surface(self.RandomTitleSize) self.randTitle = RandScreenButtons.RandScreenButtons( randT, self.randScreen, self, self.RandomTitlePos) #Live data: liveScreen = pygame.Surface(self.LiveSize) self.liveData = LiveData.LiveData(liveScreen, FPGAReader, self) #Graph: graphScreen = pygame.Surface(self.GraphSize) self.graph = Graph.Graph(graphScreen, FPGAReader, self, self.GraphPos) #Bounds button: boundScreen = pygame.Surface(self.BoundButSize) self.boundButton = BoundButton.BoundButton(boundScreen, FPGAReader, self) #ROSel: RSScreen = pygame.Surface(self.RSSize) self.RS = RS.RS(RSScreen, FPGAReader, self) #Lock light: lockLightScreen = pygame.Surface(self.LockLightSize) self.lockLight = Light.Light(lockLightScreen, 'Lock', FPGAReader.getLock, self) #Not found light: nfLightScreen = pygame.Surface(self.NFLightSize) f = lambda: not (FPGAReader.getFound()) self.nfLight = Light.Light(nfLightScreen, 'Found', f, self) #FPGA reader: self.FPGAReader = FPGAReader
def init(): global height, width handleViewParameters() glClearColor(0.2, 0.2, 0.2, 1.0) mouse.setWindowSize(height, width) Light.setupLighting() texture()
def addLight(pos=P(0, 0, 0, 1), ambient=L(1, 1, 1, 1), diffuse=L(1, 1, 1, 1), specular=L(1, 1, 1, 1), on=True): lightsPos.append(pos) lightsColor.append(Color(diffuse.r, diffuse.g, diffuse.b)) Light.createLight(pos, ambient, diffuse, specular, on)
def handleKeyboard(key, x, y): if key == ESC_KEY: exit() if key == b' ': mouse.reset() # limpa o desenho do mouse tipo = Util.SPHERE # função do augusto retorna o tipo xyz = camera.returnDist(100) objects.append(Util.OBJ(tipo, xyz[0], xyz[1], xyz[2], SIZE[tipo], SIZE[tipo], SIZE[tipo], texId)) if key == b'z': mouse.undo() # desfaz a ultima curva desenhada if key == b'w' or key == b'a' or key == b's' or key == b'd': # se w|a|s|d manda movimento para a camera camera.handleLook(key) if b'1' <= key <= b'8': # numeros de 1 a 8 Light.toggleLight(int(key)-1) glutPostRedisplay()
def run(): # Entity.SetTarget( "light0" ) # Entity.SetPosition( -10.0, 10.5, 20.0 ) # configure light0 Light.SetTargetLight("light0") # Light.SetPosition( -10.0, 14.5, 20.0 ) # Light.SetColor( 0, 1.0, 0.2, 0.2 ) # Light.SetColor( 2, 0.2, 0.0, 0.0 ) Light.SetColor(0, 0.92, 0.92, 0.95) Light.SetColor(2, 0.10, 0.10, 0.10) Light.SetAttenuationFactors(0.001, 0.003, 0.0006) # shadow settings enable_shadow = True if enable_shadow: # VisualEffect.EnableShadowMap() VisualEffect.EnableSoftShadow() else: VisualEffect.DisableShadowMap() # VisualEffect.SetBlur( 0.5, 0.5 ) VisualEffect.ClearBlur() # VisualEffect.SetGlare( 0.085 ) VisualEffect.ClearGlare() # VisualEffect.SetMonochrome( 0.25, 0.20, 0.20 ) VisualEffect.ClearMonochrome() # VisualEffect.SetMotionBlur( 6.5 ) VisualEffect.ClearMotionBlur() VisualEffect.EnableEnvMap() VisualEffect.AddEnvMapTarget("floor") # VisualEffect.DisableEnvMap() # VisualEffect.RemoveEnvMapTarget( "floor" ) # VisualEffect.SaveEnvMapTextureToFile( "", "debug/envmap.dds" ) return 1
def __init__(self, arrivalRates, travelMatrix, capacity, flow, signalTimings, timeLimit, synchronous, seed): random.seed(seed) rng = RandomNumberGenerator.RandomNumberGenerator(seed) self.output = [] self.carsInSystem = 0 self.id = 0 self.finished = False self.timeLimit = timeLimit self.arrivalRates = arrivalRates self.signalTimings = signalTimings self.flow = flow self.capacity = capacity self.time = 0 self.eventList = PQ.PriorQ() self.travelMatrix = travelMatrix self.lights = [Light.Light(self.signalTimings[i]) for i in range(19)] self.randomNumbers = [] self.arrivalIndex = { 0: 0, 1: 1, 2: 2, 5: 3, 6: 4, 9: 5, 10: 6, 13: 7, 16: 8, 17: 9, 18: 10 } self.rngCounter = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] for i in range(20000): self.randomNumbers.append(rng.GetRandList()) if synchronous: for i in [0, 3, 4, 7, 8, 11, 12, 13, 14, 18]: self.lights[i].setState(1) else: for i in [1, 2, 4, 7, 9, 10, 12, 13, 14, 18]: self.lights[i].setState(1) self.lanes = [ Lane.Lane(self.capacity[i], self.lights[i]) for i in range(19) ] for lane in self.arrivalRates: self.scheduler( self.time - math.log(self.randomNumbers[self.rngCounter[ self.arrivalIndex[lane]]][self.arrivalIndex[lane]]) / self.arrivalRates[lane], "System Arrival", lane) self.rngCounter[self.arrivalIndex[lane]] += 1 for i in range(19): self.scheduler(self.lights[i].getNextChange(), "Light Change", i) self.intersections = { 0: (0, 1, 2, 3), 1: (4, 5, 6, 7), 2: (8, 9, 10, 11), 3: (12, 99, 13, 14), 4: (15, 16, 17, 18) }
def run(): # Stage.LoadSkybox( "skybox", "./Stage/Texture/sky10b.dds" ) Light.LoadHSDirectionalLight("Sunlight_Weak") Stage.CreateBox(1, 1, 1, "", "", 0, 1, 0) return 1 # done - release the script
def getLight(self, n): returnValue = libpanda._inPkJyoxj1p(self.this, n) import Light returnObject = Light.Light(None) returnObject.this = returnValue if returnObject.this == 0: return None returnObject.userManagesMemory = 1 return returnObject
def handleKeyboard(key, x, y): global num if key == ESC_KEY: exit() if key == b' ': tipo = readResults(Exporta.func(mouse.xy, num)) num += 1 mouse.reset() # limpa o desenho do mouse xyz = camera.returnDist(100) objects.append( Util.OBJ(tipo, xyz[0], xyz[1], xyz[2], SIZE[tipo], SIZE[tipo], SIZE[tipo], texId)) if key == b'z': mouse.undo() # desfaz a ultima curva desenhada if key == b'w' or key == b'a' or key == b's' or key == b'd': # se w|a|s|d manda movimento para a camera camera.handleLook(key) if b'1' <= key <= b'8': # numeros de 1 a 8 Light.toggleLight(int(key) - 1) glutPostRedisplay()
def getSample(): """ No args. Get a sample of Temp+Humidity & Light. Discard it. Wait half a second """ Temp.Temp() Light.Light() time.sleep(0.5) # Get 5 samples delayed 0,1 sec each to get the average t, h, l = 0, 0, 0 for i in range(5): x, y = Temp.Temp() z = Light.Light() t = t + x h = h + y l = l + z time.sleep(0.1) t = t / 5 h = h / 5 l = l / 5 l = abs(l - 1023) # print "Temperature: ", t, " Humidity:", h,"%", "Light:", l return [t, h, l]
def __init__(self, *args): self.objects = {None: []} self.textures = {} self.gl_textures = {} self.materials = {} self.lights = [] self.options = SceneOptions() # apply default options self.materials[None] = Material() # setup default material self.Add(args) if len(self.lights) == 0: # add default light self.Add( Light(type=POINT).Move(*(self.options.size, ) * 3).Name('DefaultLight')) if not self.ambient_light: self.Add( Light(type=AMBIENT, intensity=self.options.ambient_intensity).Name( 'DefaultAmbientLight'))
def __init__(self): self.PWM = Motor() self.servo = Servo() self.led = Led() self.ultrasonic = Ultrasonic() self.buzzer = Buzzer() self.adc = Adc() self.light = Light() self.infrared = Line_Tracking() self.tcp_Flag = True self.sonic = False self.Light = False self.Mode = 'one' self.endChar = '\n' self.intervalChar = '#'
def watch_dis(): result_dic = {} count = 0 path = '/home/pi/files/IoT/face/storage/test.jpg' while True: try: distance = Watcher.dis_d() count += 1 if count < 2000: with open('/home/pi/files/IoT/face/data.txt', 'a+') as f: f.write(str(count) + " ") f.close() else: with open('/home/pi/files/IoT/face/data.txt', 'w+') as f: f.write('0 ') f.close() if distance < 60: time.sleep(0.5) if Watcher.dis_d() < 60: Led.red() command = 'raspistill -t 2000 -o ' + path + ' -q 5' os.system(command) Led.blink2() result_dic = iden_myface(path) try: if int(float(result_dic['score'])) > 85: print(result_dic['uid'] + ',please come in!') Light.on(Light.pin1) except: print('Nothing.') time.sleep(3) Led.off_red() except: continue
def DefaultWorld(): w = World() w.lights.append( Light.PointLight(Tuple4.Point(-10, 10, -10), Tuple4.Colour(1, 1, 1))) s1 = Sphere.Sphere() s1.material.colour = Tuple4.Colour(0.8, 1.0, 0.6) s1.material.diffuse = 0.7 s1.material.specular = 0.2 w.objects.append(s1) s2 = Sphere.Sphere() s2.transform = Transformation.Scaling(0.5, 0.5, 0.5) w.objects.append(s2) return w
def checkLight(self): """Check if lights should be on or off Args: test: flag for testing system Returns: None Raises: None """ # Move import here so can trap if fails # couchdb library does not seem to load when initially starting self._logger.debug("In checkLight") import Light # Get times from env and split into components s = env['lights']['On'] e = env['lights']['Off'] state = self.determineState(s, e) l = Light.Light(self._logger) if state: l.set_on(test) return "On" else: l.set_off(test) return "Off"
def checkLight(test=False): """Check if lights should be on or off Args: test: flag for testing system Returns: None Raises: None """ # Get times from env and split into components s = env['lights']['On'] e = env['lights']['Off'] state = determineState(s, e) l = Light() if state: l.set_on(test) pass else: l.set_off(test) pass
def checkLight(test=False): # Get times from env and split into components s=env['Lights']['On'] s=s.split(':') e=env['Lights']['Off'] e=e.split(':') # Munge date into times t=datetime.now() st=t.replace(hour=int(s[0]), minute=int(s[1]), second=int(s[2])) et=t.replace(hour=int(e[0]), minute=int(e[1]), second=int(e[2])) if test: print "Start Time: ", st print "End Time: ", et l=Light() msg="Lights should be On" if (st < datetime.now()) and (et > datetime.now()): l.setLightOn() else: msg="Lights should be Off" l.setLightOff(test) if test: print msg
def load(scenarioFilename): scenarioFile = file(scenarioFilename, "rU") scenarioText = scenarioFile.read() scenarioFile.close() globalVars = {} localVars = {} module = compile("from engine.Unit import MALE, FEMALE, NEUTER", "Unit.py", "exec") eval(module, globalVars) module = compile("from engine.Faction import Faction", "Faction.py", "exec") eval(module, globalVars) for m in ["Light", "Battle"]: module = compile("import engine.%s as %s" % (m, m), m, "exec") eval(module, globalVars) compiled = compile(scenarioText, scenarioFilename, 'exec') eval(compiled, globalVars, localVars) scenarioData = localVars if scenarioData['VERSION'] != 1: raise Exception("Scenario version %d not supported" % scenarioData["VERSION"]) # Required fields: map m = Resources.map(scenarioData['MAP']) # Load ending conditions endingConditions = [Battle.NEVER_ENDING] if scenarioData.has_key('ENDING_CONDITIONS'): endingConditions = scenarioData['ENDING_CONDITIONS'] # Load lights if scenarioData.has_key('LIGHTING'): lightEnv = scenarioData['LIGHTING'] else: lightEnv = Light.defaultEnvironment() # Load units units = [] if scenarioData.has_key('FACTIONS'): for f in scenarioData['FACTIONS']: faction = f.faction() for u in f.units(): (unitFile, (x, y)) = u u = Resources.unit(unitFile) m.squares[x][y].setUnit(u) u.setFaction(faction) units.append(u) # Music music = 'barbieri-battle' if scenarioData.has_key('MUSIC'): music = scenarioData['MUSIC'] # Create battle battle = Battle.Battle(endingConditions, units, m) return Scenario(m, units, lightEnv, battle, None, music)
def generate(self): self.shader = ShaderProgram("./shaders/vs.glsl", "./shaders/fs.glsl") self.shader.addUniform("screen_dim") self.shader.addUniform("mat_transform") self.shader.addUniform("mat_projection") self.shader.addUniform("mat_view") self.cubeShader = ShaderProgram("./shaders/cube_vs.glsl", "./shaders/cube_fs.glsl") self.cubeShader.addUniform("mat_transform") self.cubeShader.addUniform("mat_projection") self.cubeShader.addUniform("mat_view") self.lightShader = ShaderProgram("./shaders/light_vs.glsl", "./shaders/light_fs.glsl") self.lightShader.addUniform("mat_transform") self.lightShader.addUniform("mat_projection") self.lightShader.addUniform("mat_view") # ** every shader must be added list of shader called shaders self.shaders = [self.shader, self.cubeShader, self.lightShader] self.meshes = [] self.renderer = Renderer(self.shaders) self.pos = glm.vec2(0, 0) self.angle = 0 self.transform = glm.identity(glm.mat3x3) self.model = Mesh((-1.0, -0.0), (.3, .3), "./res/image.png") self.cube_model = Cube() self.light_model = Light() # self.light_model = Light(0.5) self.e = Entity(self.model, Vector3(0, 0, 0), Vector3(0.0, 0.0, 0.0), Vector3(1, 1, 1)) self.cube_entity = Entity(self.cube_model, Vector3(-1, -1, -1), Vector3(0.0, 0.0, 0.0), Vector3(1, 1, 1)) self.light_entity = Entity(self.light_model, Vector3(-0.5, -0.5, -0.5), Vector3(0.0, 0.0, 0.0), Vector3(0.2, 0.2, 0.2)) self.shadersDict = { self.e: [self.shader, False], self.cube_entity: [self.cubeShader, True], self.light_entity: [self.lightShader, True] } precision = 3 self.cube_entities = [] r = 3 for i in range(10): x = round(uniform(-r, r), precision) y = round(uniform(-r, r), precision) z = round(uniform(-r, r), precision) self.cube_entities.append( Entity(self.cube_model, Vector3(x, y, z), Vector3(0.0, 0.0, 0.0), Vector3(0.5, 0.5, 0.5))) self.shadersDict[self.cube_entities[i]] = [self.cubeShader, True] # self.cube_entities = Entity(self.cube_model, Vector3(0,0,0), Vector3(0.0,0.0,0.0), Vector3(1,1,1)) self.camera = Camera()
import Flame import Light import schedule '''关闭释放资源''' def destroy(): GPIO.cleanup() # 释放资源 if __name__ == "__main__": try: LED_1.init() LED_2.init() LED_3.init() Alarm.init() Fan.init() Fan_2.init() DHT11.init() Flame.init() Light.init() schedule.every(120).seconds.do(DHT11.get_data) schedule.every(2).seconds.do(Flame.get_data) schedule.every(20).seconds.do(Light.get_data) while True: schedule.run_pending() except Exception: print(Exception) finally: destroy()
def initPanels(self): for i in range(NUM_PANEL_LIGHTS): self.cave_panel_lights[i] = Light(i + 1)
from Tkinter import * from Point import * from Ornament import * from Star import * from Light import * from BlinkingLight import * import random window = Tk() window.title("Merry Christmas") Background = PhotoImage(file="tree.gif") width = Background.width() height = Background.height() canvas = Canvas(window, width = width, height = height) canvas.grid(row=0, column=0) canvas.create_image(width/2, height/2, image=Background) Ornament = Ornament(canvas, width, height) Star = Star(canvas, width, height) Light = Light(canvas, width, height) BlinkingLight = BlinkingLight(canvas, width, height) Star.addStar("star.gif") for i in range(7): Ornament.addOrnament("smallOrnament.gif") Light.addLight() BlinkingLight.addBlinkingLight() BlinkingLight.blink() window.mainloop()
import time from LED import * from Light import * from Ir import * from Rest import * from TextLocal import * import datetime rest = Rest() GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) GPIO.setup(31, GPIO.IN) GPIO.setup(33, GPIO.IN) GPIO.setup(35, GPIO.IN) GPIO.setup(37, GPIO.IN) lcd = LED() light = Light() ir = Ir() mode = 'auto' count = 0 textLocal = TextLocal() while True: mymode = rest.get('SmartStreet/Mode') mode = mymode[1]['mode'] print(mode) time.sleep(1) try: if mode == 'auto': if light.getLightStatus() == 'Night': d = 0 if ir.getIrStatus() == 'Yes':
def generateRandom(additionalAIUnits): def generateUnit(faction): unitTemplates = ['archer1', 'fighter1', 'defender1', 'rogue1', 'healer1', 'mage1'] unitTemplate = random.choice(unitTemplates) u = Resources.unit(unitTemplate) u.setFaction(faction) #u.setFaction(0) return u def generateMapAndUnits(): map_ = Resources.map('random') units = [] nUnits = random.randint(4, 8) startColumn = random.randint(0, map_.width - (nUnits + 1) / 2) for i in xrange(0, nUnits): u = generateUnit(PLAYER_FACTION) if i < nUnits / 2: row = map_.height-1 column = startColumn + i else: row = map_.height-2 column = startColumn + (i - nUnits/2) map_.squares[column][row].setUnit(u) units.append(u) nUnits += additionalAIUnits startColumn = random.randint(0, map_.width - (nUnits + 1) / 2) for i in xrange(0, nUnits): u = generateUnit(NPC_HOSTILE_FACTION) if i < nUnits / 2: row = 0 column = startColumn + i else: row = 1 column = startColumn + (i - nUnits/2) map_.squares[column][row].setUnit(u) units.append(u) return (map_, units) def verifyMap(map_, units): for unit in units: map_.fillDistances(unit, unit.posn()) for other in units: (x, y) = other.posn() if map_.squares[x][y].search == None: return False return True validMap = False while not validMap: (map_, units) = generateMapAndUnits() validMap = verifyMap(map_, units) endingConditions = [Battle.PLAYER_DEFEATED, Battle.DEFEAT_ALL_ENEMIES] battle = Battle.Battle(endingConditions, units, map_) lighting = Light.randomEnvironment(map_.width, map_.height) music = random.choice(['barbieri-lyta', 'barbieri-battle', 'barbieri-army-march']) return Scenario(map_, units, lighting, battle, None, music)
def blankMap(map): return Scenario(map, [], Light.defaultEnvironment(), Battle.Battle([Battle.NEVER_ENDING], [], map), None, '')
def load(scenarioFilename): scenarioFile = file(scenarioFilename, "rU") scenarioText = scenarioFile.read() scenarioFile.close() globalVars = {} localVars = {} module = compile("from engine.Unit import numpy.oldnumeric.ma as MALE, FEMALE, NEUTER", "Unit.py", "exec") eval(module, globalVars) module = compile("from engine.Faction import Faction", "Faction.py", "exec") eval(module, globalVars) for m in ["Light", "Battle"]: module = compile("import engine.%s as %s" % (m, m), m, "exec") eval(module, globalVars) compiled = compile(scenarioText, scenarioFilename, 'exec') eval(compiled, globalVars, localVars) scenarioData = localVars if scenarioData['VERSION'] != 1: raise Exception("Scenario version %d not supported" % scenarioData["VERSION"]) # Required fields: map m = Resources.map(scenarioData['MAP']) # Load ending conditions endingConditions = [Battle.NEVER_ENDING] if scenarioData.has_key('ENDING_CONDITIONS'): endingConditions = scenarioData['ENDING_CONDITIONS'] # Load lights if scenarioData.has_key('LIGHTING'): lightEnv = scenarioData['LIGHTING'] else: lightEnv = Light.defaultEnvironment() # Load units units = [] if scenarioData.has_key('FACTIONS'): for f in scenarioData['FACTIONS']: faction = f.faction() for u in f.units(): (unitFile, (x, y)) = u u = Resources.unit(unitFile) m.squares[x][y].setUnit(u) u.setFaction(faction) units.append(u) # Music music = 'barbieri-battle' if scenarioData.has_key('MUSIC'): music = scenarioData['MUSIC'] # Create battle battle = Battle.Battle(endingConditions, units, m) return Scenario(m, units, lightEnv, battle, None, music)
from Car import * import Controller import Light import random import numpy as np import envstate as env NORTH = 0 EAST = 1 SOUTH = 2 WEST = 3 car_list = [] traffic_light_list = [] light_north = Light.TrafficLight("RED", NORTH) light_east = Light.TrafficLight("GREEN", EAST) light_south = Light.TrafficLight("RED", SOUTH) light_west = Light.TrafficLight("GREEN", WEST) class Intersection: center_x = 600 center_y = 450 WIDTH = 110 def __init__(self): traffic_light_list.append(light_north) traffic_light_list.append(light_east) traffic_light_list.append(light_south)
tLights = [] edges = [] allTLIds = [] isAmbulancePresent = False delayTime = 0 while step < 455: if isAmbulancePresent: if last != traci.vehicle.getRoadID(ambulanceID): last = traci.vehicle.getRoadID(ambulanceID) if last[0] != ":": edges.append(last) elif last[1:len(last) - 2] in allTLIds: tLights.append( Light.Light(edges[len(edges) - 1], last[1:len(last) - 2])) elif last[1:len(last) - 3] in allTLIds: tLights.append( Light.Light(edges[len(edges) - 1], last[1:len(last) - 3])) if traci.vehicle.getRoadID(ambulanceID) == endEdge: initialTime = step print(f'Initial Completion Time = {step}') delayTime = 0 isAmbulancePresent = False if step == 100: isAmbulancePresent = True tm.addAmbulance(ambulanceID, routeID, viewID, startEdge, endEdge) allTLIds = traci.trafficlight.getIDList() edges.append(startEdge)
def _addLight(self): l = Light(self._canvas, self._lx.get(), self._ly.get()) self._world.addLight(l)
def add_light(self): light = Light(self.display, color=(0, 0, 0)) obj = Object_Instance(light=light, id=self.id_counter) self.scene.add_instance(obj) self.id_counter += 1