![]() |
|
#4
|
|||
|
|||
|
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()) 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())
|
|
|
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 |