def loop(): global tstart global config global sock global tc print "connecting..." #sock = ctx.socket(zmq.REQ) #sock.connect("tcp://" + host_address + ":5556") print "... connected @" + host_address + ":" + "5556" tc = TDW_Client(host_address, initial_command='request_create_environment', description="test script", #selected_build='test_none.x86_64', # or skip to select from UI #queue_port_num="23402", get_obj_data=True, send_scene_info=True ) tc.load_config(config) tc.load_profile({'screen_width': 256, 'screen_height': 256}) sock = tc.run() #Receive answer #print "receiving initial answer..." #sock.recv() #for i in range(3): # msg = sock.recv() # print i #print "...received\n" #print "sending scene switch..." #handle_message(sock, write=True, outdir=path, prefix=str(0) + '_' + str(0)) #sock.send_json({"msg_type" : "CLIENT_JOIN", "get_obj_data" : True, "send_scene_info" : True}) #sock.send_json({"msg_type" : "CLIENT_JOIN_WITH_CONFIG", "config" : config, "get_obj_data" : True, "send_scene_info" : True}) #sock.send_json({'n': 4, 'msg': {"msg_type": "SCENE_SWITCH", "config": config, 'send_scene_info': True}}) #msg = {'n': 4, 'msg': {"msg_type": "CLIENT_INPUT", "get_obj_data": True, "actions": []}} #sock.send_json(msg) #print "...switch sent" ''' while True: print "waiting on messages..." msg1 = sock.recv() msg2 = sock.recv() msg3 = sock.recv() msg4 = sock.recv() print "...messages received\n\nsending input..." print msg1 img1 = Image.open(StringIO(msg2)).convert('RGB') img2 = Image.open(StringIO(msg3)).convert('RGB') img3 = Image.open(StringIO(msg4)).convert('RGB') img1.show() img2.show() img3.show() time.sleep(10) sock.send_json({"msg_type" : "CLIENT_INPUT", "vel": [0.0, 0.0, 0.0], "ang_vel" : [0.0, 0.0, 0.0], "teleport_random" : True, "get_obj_data" : True, "send_scene_info" : True}) print "...input sent" ''' #teleport=0 bn = 0 while True: print "waiting on messages" #msg = [sock.recv() for _ in range(4)] print "messages received" make_new_batch(bn) bn = bn + 1 end = time.time() FPS = number_of_frames / (end - tstart) print('--------TIME----------') print(end - tstart) print(number_of_frames) print('--------FPS-----------') print(FPS) print('----------------------')
"room_width": 45.0, "room_height": 20.0, "room_length": 45.0, "wall_width": 1.0, "door_width": 1.5, "door_height": 3.0, "window_size_width": 5.0, "window_size_height": 5.0, "window_placement_height": 5.0, "window_spacing": 10.0, #Average spacing between windows on walls "wall_trim_height": 0.5, "wall_trim_thickness": 0.01, "min_hallway_width": 5.0, "number_rooms": 1, "max_wall_twists": 3, "max_placement_attempts": 300, #Maximum number of failed placements before we consider a room fully fil "grid_size": 0.4 #Determines how fine tuned a grid the objects are placed on during Proc. Gen. Smaller the number, the }) sock = tc.run() while True: print "\nnext batch:\n" print sock.recv() for _ in range(3): msg = sock.recv() Image.open(StringIO(msg)).convert('RGB').show() time.sleep(5) sock.send_json({'n' : 4, 'msg' : {"msg_type" : "CLIENT_INPUT", "teleport_random": True, "vel" : [0.0, 0.0, 0.0], "ang_vel" : [0.0, 0.0, 0.0]}})