WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-06-2012, 02:16 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Quote:
The center, in this example, actually remains at (0,0,0) and does not get assigned to (1,1,1), (2,2,2), or (3,3,3). However, the keyboard rotations all work correctly. Does this make sense?
The center is not changing because there is some incorrect syntax. The line:
Code:
shaft.center = (1,1,1)
should be:
Code:
shaft.center(1,1,1)
If you make that change throughout the function then it will print the center to be (3,3,3) because that's the last center command called before Kinematics_1 returns. Also, it does not appear you are using the task function properly. If the main task function yields to a subtask, the subtask should have a yield command somewhere within it. The following is an example that yields within the subtask for a key event and sets a new rotation point based on that:
Code:
import viztask
import viz
import vizshape
import vizcam
import vizact
viz.go()

viz.clearcolor(0.5,0.7,1)

#Change navigation style to pivot
cam = vizcam.PivotNavigate(center=[0,0,0], distance = 25) 
cam.rotateUp(45)
cam.rotateRight(0)

#Add grid
grid = vizshape.addGrid()
grid.color(viz.GRAY)
grid.collidePlane()   # Make collideable plane

#Add an object.
shaft = vizshape.addCylinder(height = 5, radius = .25, slices = 15)
shaft.runAction(vizact.spin(0,0,1,30))

def Kinematics_1():	
	
	d = yield viztask.waitKeyDown(('a','s','d','f'))
	if d.key == 'a':
		shaft.setCenter(0.5,0,0)
	elif d.key == 's':
		shaft.setCenter(1,0,0)
	elif d.key == 'd':
		shaft.setCenter(2,0,0)
	elif d.key == 'f':
		shaft.setCenter(0,0,0)

def Main_Loop():
	while True:
		print 'shaft center = ', shaft.getCenter()
		yield Kinematics_1()
		print ''
viztask.schedule(Main_Loop())
Quote:
Furthermore, the 'f' key would not rotate with viz.REL_LOCAL for some reason, but does for viz.REL_PARENT (even though there is no parent present).
The shaft object is a child of the world so viz.REL_PARENT in this case refers to world coordinates.
Reply With Quote
  #2  
Old 11-08-2012, 01:26 PM
mhead10 mhead10 is offline
Member
 
Join Date: Mar 2012
Posts: 40
Jeff,

I'm getting closer, but still not quite there. I can get the centers assigned correctly, but my simulation displays my tool in what looks like 3 different places at the same time still (attached).

I think the centers, eulers, and positions are not getting assigned quite quickly enough, therefore, there's a small lag between each.

Is there a better way to do what I'm trying to accomplish (get the shaft to rotate/position with three separate centers in one visual piece)? Altering the subtasks with yields (setCenters) hasn't changed anything.

Thanks again for your help!

Updated Code:
Code:
def Kinematics_1():	
	scale = 40 #degrees (360/9)
	trans_scale = 1 #translation pot (pot #1)
	x = 180
	
	shaft.center(0,0,1.738)
	#POT 0- BASE ROTATIONS#
	yield shaft.setEuler(180+scale*pdata[0],0,0)				

	#POT 1- TRANSLATION#
	yield shaft.setPosition(0,0,pdata[1]*trans_scale-3, viz.ABS_PARENT) 
	
	#pot 2: grasper open/clock
	if pdata[2]*scale > x: 	#graspers are not touching
		#print 'graspers NOT touching'
		babcock_1.setEuler(x-pdata[2]*scale,0,0,viz.ABS_PARENT)
		babcock_2.setEuler(-x+pdata[2]*scale,0,180,viz.ABS_PARENT)
	else: 					#graspers are touching
		#print 'graspers touching'
		babcock_1.setEuler(x/scale,0,0,viz.ABS_PARENT)
		babcock_2.setEuler((x/scale),0,180,viz.ABS_PARENT)	
	
	#POT 3: JOYSTICK TIP ROTATION
	#POT 4: FIRST U-JOINT ROTATION
	yield shaft.setEuler(180+scale*pdata[0],(pdata[4]*scale)+180,-(pdata[3]*scale)+90) 
		
#def Kinematics_2():
	#alter center point of rotation
	shaft.setCenter(0,-1.6125,1.738)
	#POT 5- 1st U-Joint, 2nd Rotation
	#POT 6- 2nd U-Joing, 1st Rotation
	yield shaft.setEuler(0,(-pdata[5]*scale)-180,pdata[6]*scale) 
	
#def Kinematics_3():
	scale = 40
	#alter center point of rotation
	shaft.setCenter(0,-3.227,1.738)
	yield shaft.setEuler(0,0,pdata[7]*scale+40)

def Main_Loop():
	while True:
		yield Kinematics_1()

viztask.schedule(Main_Loop())
Attached Thumbnails
Click image for larger version

Name:	help.png
Views:	6104
Size:	40.5 KB
ID:	545  
Reply With Quote
  #3  
Old 11-25-2012, 03:21 PM
mhead10 mhead10 is offline
Member
 
Join Date: Mar 2012
Posts: 40
I realize this is hard to troubleshoot, but does no response mean you're out of ideas?
Reply With Quote
  #4  
Old 11-26-2012, 12:06 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Sorry for the delay responding. As I mentioned before it's best to post simple example code that shows the problem clearly and that can be run directly.

It sounds like your questions are project specific. You may be interested in our closed support forum where you can get more assistance with that. For more information please contact sales@worldviz.com.
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 03:41 PM.


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