WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-02-2012, 08:49 AM
mhead10 mhead10 is offline
Member
 
Join Date: Mar 2012
Posts: 40
Defining & Using Multiple Centers (of Rotation)

HELLO!

I'm still trying to find out how to set multiple centers (three) for my custom joystick.

Separately, my three joystick centers (and rotations/translations) work perfectly. However, when I try and put all three of the centers (and rotations/translation) into one main function, I get three separate joysticks or the last of the centers overwrites the first two.

Can someone please tell me how I can have three successive centers (and rotation/translation functions) for my joystick?

The pseudo code would look something like:
Code:
def Kinematics_1():
	setCenter_1
	setEuler_1
	setPosition_1

def Kinematics_2():
	setCenter_2
	setEuler_2
	setPosition_2
	
def Kinematics_3():
	setCenter_3
	setEuler_3
	setPosition_3
	
def read_DAQ(): #read in data from DAQ
	data = pdata
	
def director_loop():
	read_DAQ()
	Kinematics_1()
	Kinematics_2()
	Kinematics_3()

viztask.schedule(director_loop())
My actual current code (summarized):
Code:
shaft = viz.add('shaft.dae', pos = (0,5,-5))
babcock_1 = viz.addChild('origin.dae', parent = shaft)
babcock_2 = viz.addChild('origin.dae', parent = shaft)

scale = 40 #degrees (360/9)
trans_scale = 5 #translation pot (pot #1)

def read_DAQ(): # used obtain DAQ values
	CHK(nidaq.DAQmxReadAnalogF64(taskHandle,1,
		float64(-1),
		DAQmx_Val_GroupByChannel,pdata.ctypes.data,max_num_samples,ctypes.byref(read),None))
	return(pdata)
	
def Kinematics_1():	
	shaft.center(0,0,1.738)
	#POT 0- BASE ROTATIONS
	shaft.setEuler(180+scale*pdata[0],0,0)				
	
	#POT 1- TRANSLATION#
	shaft.setPosition(0,0,pdata[1]*trans_scale-3) 
	
	#pot 2: grasper open/clock
	
	babcock_1.setEuler(160-pdata[2]*scale,0,0)			
	babcock_2.setEuler(-160+pdata[2]*scale,0,180)	
	
	#POT 3: JOYSTICK TIP ROTATION
	#POT 4: FIRST U-JOINT ROTATION
	shaft.setEuler(180+scale*pdata[0],(pdata[4]*scale)+180,-(pdata[3]*scale)+90) #CORRECT(3), CORRECT(4)
	
def Kinematics_2():
	shaft.setCenter(0,-1.6125,1.738) 
	#POT 5- 1st U-Joint, 2nd Rotation
	#POT 6- 2nd U-Joing, 1st Rotation
	shaft.setEuler(0,(-pdata[5]*scale)-180,pdata[6]*scale) #reversed pot glue position 180 deg 
	
def Kinematics_3():
	shaft.setCenter(0,-3.227/2,1.738)
	shaft.setEuler(0,0,pdata[7]*scale+40)
	
def read_DAQ(): # used obtain DAQ values
	CHK(nidaq.DAQmxReadAnalogF64(taskHandle,1,
		float64(-1),
		DAQmx_Val_GroupByChannel,pdata.ctypes.pdata,max_num_samples,ctypes.byref(read),None))
	return(pdata)

def director_function_loop():
	while True:
		value0 = yield viztask.waitDirector(read_DAQ) 
		value1 = yield viztask.waitDirector(Kinematics_1)
		value2 = yield viztask.waitDirector(Kinematics_2)
		value3 = yield viztask.waitDirector(Kinematics_3)
viztask.schedule(director_function_loop())
Thanks!
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
joystick position nmohandes Vizard 2 01-16-2012 10:03 AM
writing joystick position to a data file Saz Vizard 3 12-17-2008 05:18 AM
Joystick Navigation Vinicius Lima Vizard 7 10-23-2007 10:42 AM
Facetracking and Immersion Joystick Vygreif Vizard 1 01-25-2006 10:56 AM
animating custom faces: in search of "open_mouth" morphs vr_boyko Vizard 1 09-16-2004 10:30 AM


All times are GMT -7. The time now is 08:24 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC