def __setupVizParams__(self):
		
		#Just playing here#
		#viz.setMultiSample(8)
		#viz.fov(120)
		
		#Check monitor refresh rate and set stereo mode accordingly#
		monitor_RefreshRate = viz.getOption('viz.monitor.refresh_rate', type=int)
		#if(119 <= monitor_RefreshRate):
			#Turn on the physics engine
		viz.phys.enable() 
		viz.window.setFullscreenMonitor(2)
		viz.setMultiSample(8)
		viz.go(viz.FULLSCREEN | viz.QUAD_BUFFER)
		print "here"
Esempio n. 2
0
def on_release(e):
    """
        Callback-Funktion, die bem Loslassen eines Bauteils
        aufgerufen wird.

        Args:
            e: Event, wird nicht verwendet
    """
    global robot, robot_parts, part_index
    # Position des Bauteils mit der des Templates vergleichen
    part = robot_parts[part_index]
    pos_1 = np.array(part.getPosition(viz.ABS_GLOBAL), dtype=np.float32)
    pos_2 = np.array(robot.get_position(part_index), dtype=np.float32)
    dist = np.linalg.norm(pos_1 - pos_2)
    # Falls sich das Bauteil nahe genug an der korrekten Position befindet
    # TODO: Orientierung ueberpruefen
    if dist <= max_dist:
        # Bauteil positionieren und Physik fuer dieses
        # Bauteil ausschalten
        part.disable(viz.DYNAMICS)
        part.collideMesh()
        part.setPosition(robot.get_position(part_index), viz.ABS_GLOBAL)
        part.setAxisAngle(robot.get_orientation(part_index), viz.ABS_GLOBAL)
        # Falls noch Bauteile uebrig geblieben sind, das
        # naechste Bauteil fuer den grabber freischalten
        if part != robot_parts[-1]:
            part_index += 1
            grabber.setItems(robot_parts[part_index:part_index + 1])
            # Ansonsten den Ball fuer den Grabber freischalten und
            # den Roboter dem Ball folgen lassen.
        else:
            # Template sichtbar machen
            robot.visible(True)
            # Neu gebauten Roboter unsichtbar machen
            for p in robot_parts:
                p.visible(False)
            # Ball freischalten
            grabber.setItems([ball])
            # Roboter folgt dem Ball
            vizact.ontimer(1. / float(viz.getOption('viz.max_frame_rate')),
                           robot_follows_marker, robot, ball)
def getPublishedPath(filename):
	publishPath = viz.getOption('viz.publish.path','')
	if publishPath:
		return '/'.join([publishPath,filename])
	return filename
Esempio n. 4
0
def runtrials():

    global trialtype, trialtype_signed, groundplane, radiiPool, out

    #yield viztask.waitTime(5.0) #allow me to get into the seat.

    setStage()  # texture setting. #likely to have to be expanded.
    driver.reset()  # initialization of driver
    [leftbends, rightbends] = BendMaker(radiiPool)
    viz.MainScene.visible(viz.ON, viz.WORLD)

    #add text to denote conditons.
    txtCondt = viz.addText("Condition", parent=viz.SCREEN)
    txtCondt.setPosition(.7, .2)
    txtCondt.fontSize(36)

    out = ""

    def updatePositionLabel():
        global driver, trialtype_signed, trialtype
        ##WHAT DO I NEED TO SAVE?

        # get head position(x, y, z)
        pos = viz.get(viz.HEAD_POS)
        pos[1] = 0.0  # (x, 0, z)
        # get body orientation
        ori = viz.get(viz.BODY_ORI)
        steeringWheel = driver.getPos()

        #what data do we want? RoadVisibility Flag. SWA. Time, TrialType. x,z of that trial These can be reset in processing by subtracting the initial position and reorienting.
        SaveData(pos[0], pos[2], ori, steeringWheel)  ##.

    vizact.ontimer((1.0 / 60.0), updatePositionLabel)

    for j in range(0, TotalN):
        #import vizjoy

        trialtype = abs(TRIALSEQ_signed[j])
        trialtype_signed = TRIALSEQ_signed[j]

        txtDir = ""

        # Define a function that saves data
        def SaveData(pos_x, pos_z, ori, steer):
            global out

            #what data do we want? RoadVisibility Flag. SWA. Time, TrialType. x,z of that trial These can be reset in processing by subtracting the initial position and reorienting.
            if out != '-1':
                # Create the output string
                currTime = viz.tick()
                out = out + str(float(
                    (currTime))) + '\t' + str(trialtype_signed) + '\t' + str(
                        pos_x) + '\t' + str(pos_z) + '\t' + str(
                            ori) + '\t' + str(steer) + '\t' + str(
                                radius) + '\t' + str(occlusion) + '\t' + str(
                                    int(trialbend.getVisible())) + '\n'

        radiipick = 1
        occlpick = 1
        L = len(radiiPool)
        L2 = L * 2
        print trialtype, L, L2
        if trialtype > L and trialtype <= L2:
            print 'here'
            radiipick = trialtype - L  #reset trialtype and occl index
            occlpick = 2
        elif trialtype > L2:
            print 'here too'
            radiipick = trialtype - L2
            occlpick = 3

        print radiipick
        #pick correct object
        if trialtype_signed > 0:  #right bend
            trialbend = rightbends[radiipick - 1]
            txtDir = "R"
        else:
            trialbend = leftbends[radiipick - 1]
            txtDir = "L"

        radius = radiiPool[radiipick - 1]
        occlusion = occlPool[occlpick - 1]
        if radius > 0:
            msg = "Radius: " + str(radius) + txtDir + '_' + str(occlusion)
        else:
            msg = "Radius: Straight" + txtDir + '_' + str(occlusion)
        txtCondt.message(msg)

        #translate bend to driver position.
        driverpos = viz.MainView.getPosition()
        print driverpos
        trialbend.setPosition(driverpos[0], 0, driverpos[2])

        #now need to set orientation
        driverEuler = viz.MainView.getEuler()
        trialbend.setEuler(driverEuler, viz.ABS_GLOBAL)

        #will need to save initial vertex for line origin, and Euler. Is there a nifty way to save the relative position to the road?
        driver.setSWA_invisible()

        yield viztask.waitTime(occlusion)  #wait an occlusion period

        trialbend.visible(1)

        yield viztask.waitTime(
            2.5 - occlusion
        )  #after the occlusion add the road again. 2.5s to avoid ceiling effects.

        trialbend.visible(0)

        #driver.setSWA_visible()

        def checkCentred():

            centred = False
            while not centred:
                x = driver.getPos()
                if abs(x) < .5:
                    centred = True
                    break


#		centred = False
#		while not centred:
#			x = driver.getPos()
#			print x

##wait a while

        print "waiting"
        yield viztask.waitDirector(checkCentred)
        print "waited"

        driver.setSWA_visible()
        yield viztask.waitTime(2)  #wait for input .

    else:
        #print file after looped through all trials.
        fileproper = ('Pilot_CDM.dat')
        # Opens nominated file in write mode
        path = viz.getOption('viz.publish.path/')
        file = open(path + fileproper, 'w')
        file.write(out)
        # Makes sure the file data is really written to the harddrive
        file.flush()
        #print out
        file.close()

        #exit vizard

        viz.quit()  ##otherwise keeps writting data onto last file untill ESC
Esempio n. 5
0
#world_axes = vizshape.addAxes()
#X = viz.addText3D('X',pos=[1.1,0,0],color=viz.RED,scale=[0.3,0.3,0.3],parent=world_axes)
#Y = viz.addText3D('Y',pos=[0,1.1,0],color=viz.GREEN,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
#Z = viz.addText3D('Z',pos=[0,0,1.1],color=viz.BLUE,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)

# add a stencil buffer for the outline highlight
if __name__ == "__main__":
    viz.setOption('viz.display.stencil', 8)
    #vizconnect.go('./vizconnect_config.py')
    vizconnect.go('./xylo_vizconnect_config2017.py')
    for tracker in vizconnect.ConfigurationManager.get().getDict('tracker'):
        print(tracker)
    # get the quality setting of the demo if specified
    DEMO_QUALITY_SETTING = max(
        0, viz.getOption('DEMO_QUALITY_SETTING', default=4, type=int))
    viz.setMultiSample(DEMO_QUALITY_SETTING * 2)
    # disable the head lamps since we're doing lighting ourselves
    for window in viz.getWindowList():
        window.getView().getHeadLight().disable()
else:
    vizconnect.go('./multiscript_vizconnect_config.py')

# Add the local events (events specific to this demo)
#vizconnect.go('vizconnect_config_local_events.py')

# Load the vizconnect configuration. File: base_vizconnect_config2016.py
vizfx.addDirectionalLight(euler=(0, 90, 0))

# Add a viewpoint so the user starts at [0,0,0].
vp = vizconnect.addViewpoint(pos=[0, 0, 0],
Esempio n. 6
0
import os
import viz
import math
import ctypes

# Module is only supported with Vizard 5.1
cv = viz.compareVersion('5.1')
if cv < 0:
	raise EnvironmentError('SMI module is incompatible with Vizard {}. Please contact [email protected] for latest version.'.format(viz.version()))
elif cv > 0:
	raise EnvironmentError('SMI module requires Vizard 5.1')

# Ensure we are not 64-bit
if viz.getOption('platform.bit','32') != '32':
	raise EnvironmentError('SMI module does not support 64-bit versions of Vizard')

# Callback result structure
class _CallbackDataStruct(ctypes.Structure):
	_fields_ = [ ("type", ctypes.c_uint)
				,("result", ctypes.c_void_p)
	]

_CallbackDataStructPointer = ctypes.POINTER(_CallbackDataStruct)

# Callback type
_smiCallback = ctypes.WINFUNCTYPE(None, _CallbackDataStructPointer)

# EyeDataHMDStruct
class _EyeDataHMDStruct(ctypes.Structure):
	_fields_ = [ ("gazePoint_x", ctypes.c_double)
				,("gazePoint_y", ctypes.c_double)
Esempio n. 7
0
import os
import viz
import math
import ctypes

# Module is only supported with Vizard 5.1
#cv = viz.compareVersion('5.1')
#if cv < 0:
#	raise EnvironmentError('SMI module is incompatible with Vizard {}. Please contact [email protected] for latest version.'.format(viz.version()))
#elif cv > 0:
#	raise EnvironmentError('SMI module requires Vizard 5.1')

# Ensure we are not 64-bit
if viz.getOption('platform.bit', '32') != '32':
    raise EnvironmentError(
        'SMI module does not support 64-bit versions of Vizard')


# Callback result structure
class _CallbackDataStruct(ctypes.Structure):
    _fields_ = [("type", ctypes.c_uint), ("result", ctypes.c_void_p)]


_CallbackDataStructPointer = ctypes.POINTER(_CallbackDataStruct)

# Callback type
_smiCallback = ctypes.WINFUNCTYPE(None, _CallbackDataStructPointer)


# EyeDataHMDStruct
class _EyeDataHMDStruct(ctypes.Structure):