View Single Post
Old 10-12-2012, 09:00 AM
mhead10 mhead10 is offline
Join Date: Mar 2012
Posts: 40
Custom Joystick Rotation


I'm trying to find the best way to simulate my grasper (like a tweezer- referred to as "babcock" in my code), which is driven by a custom joystick (I'm including an example picture (attachment # 1) of my joystick (left) and grasper (like a tweezer, on the right) for clarity).

I'm trying to rotate my grasper around three different axes (Rx1, Rx2, Rx3). Therefore, I'm currently thinking the best way to accomplish this is by:
  1. read in data[],
  2. assign new center to Rx1, complete euler rotation # 1,
  3. assign new center to Rx2, complete euler rotation # 2,
  4. assign new center to Rx3, complete euler rotation # 3.

However, when I assign a new center from the original grasper origin, 1 unit in the z-direction away (to obtain Rx1), the center remains at the original origin (as seen in attachment # 3).

	# move babcock up and forward a bit (1.25, 2) from World Coordinate System
	babcock.setPosition([0,1.25, 2+ data[2]],viz.ABS_GLOBAL)	 # data[2] = TRANSLATION potentiometer
	babcock_axes = vizshape.addAxes(parent = babcock, pos=[0,0,0],scale=[.05,.05,.05])
	X2 = viz.addText3D('X2',pos=[0.1,0,0],color=viz.RED,scale=[0.05,0.05,0.05],parent=babcock)
	Y2 = viz.addText3D('Y2',pos=[0,0.1,0],color=viz.GREEN,scale=[0.05,0.05,0.05],align=viz.ALIGN_CENTER_BASE,parent=babcock)
	Z2 = viz.addText3D('Z2',pos=[0,0,0.1],color=viz.BLUE,scale=[0.05,0.05,0.05],align=viz.ALIGN_CENTER_BASE,parent=babcock)
	# center of rotation is 3.5 from original (LCS), 0, 1) #change center of rotation to Z0 + 1 (DOESN'T WORK?)
	babcock_axes2 = vizshape.addAxes(parent = babcock, pos=[0,0,0], scale = [.05,.05,.05]) #CHANGE local axis to babcock (0,0,1) for Rx1 Rotation
	X3 = viz.addText3D('X3',pos=[0.1,0,0],color=viz.RED,scale=[0.1,0.1,0.1],parent=babcock)
	Y3 = viz.addText3D('Y3',pos=[0,0.1,0],color=viz.GREEN,scale=[0.1,0.1,0.1],align=viz.ALIGN_CENTER_BASE,parent=babcock)
	Z3 = viz.addText3D('Z3',pos=[0,0,0.1],color=viz.BLUE,scale=[0.1,0.1,0.1],align=viz.ALIGN_CENTER_BASE,parent=babcock)
	# why is the new over the previous still? attached pic # 3
Furthermore, when I use the spin feature, the new center seems to work correctly.
	babcock.addAction( vizact.spin(1,0,0,90)) #for testing purposes only
Any suggestions if there is a better method using transformation matrices to accomplish this task? I would use linking, but my virtual grasper is only comprised of the tweezer (babcock) (it does not have the other links as does the joystick in the picture).

Lastly, (a less important problem currently) it seems like my scaling functions are in meters, but the numbers chosen for position are in units of inches for some reason. Is this correct? For example, if I enter a unit of 1 for the new center position distance, it definitely doesn't look like 1m, rather it's more like 1 inch. (as a frame of reference, I put a 1 inch cube (second attachment) in my VR environment, and all the sizes seem correct)

Thanks in advance!
Attached Thumbnails
Click image for larger version

Name:	transformation.JPG
Views:	682
Size:	46.1 KB
ID:	536   Click image for larger version

Name:	paint.png
Views:	684
Size:	25.7 KB
ID:	537   Click image for larger version

Name:	lcs.png
Views:	689
Size:	105.6 KB
ID:	538  
Reply With Quote