Example #1
0
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('----------------------')
Example #2
0
import zmq
from threedworld.clienttools.tdw_client import TDW_Client
from StringIO import StringIO
from PIL import Image
import time

tc = TDW_Client("171.64.40.116",
                username="******",
                description="test script",
                initial_command="request_create_environment")
                #selected_build="TestBuild22.x86_64", get_obj_data=True)
tc.load_config({
	"environment_scene" : "ProceduralGeneration",
	"random_seed": 1, #Omit and it will just choose one at random. Chosen seeds are output into the log(under warning or log level).
	"should_use_standardized_size": False,
	"standardized_size": [1.0, 1.0, 1.0],
	"disabled_items": [], #["SQUIRL", "SNAIL", "STEGOSRS"], // A list of item names to not use, e.g. ["lamp", "bed"] would exclude files with the word "lamp" or "bed" in their file path
	"permitted_items": [], #["bed1", "sofa_blue", "lamp"],
	"complexity": 10,
	"num_ceiling_lights": 4,
	"minimum_stacking_base_objects": 5,
	"minimum_objects_to_stack": 100,
	"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,