#1
|
|||
|
|||
Working in Haptic device (PHANTOM)
Hello
I am working with "sensable PHANTON Omni" & "Worldviz 5". I have created boundary for the car which will not allow the car to go beyond that walls (cube1 & cube2). I want to implement fillowing effects in the code 1) When car touch/strike with boundary, I want to generate opposite force in haptic device that give the feel of the wall. 2) I want to add spring effect from the point [0,0,0] in all direction Kindly give your suggestions to implement bounding ares for car. The code is: Code:
import viz import vizact import vizshape viz.setMultiSample(4) viz.fov(60) viz.go() viz.phys.enable() viz.collision(viz.ON) car = viz.add( 'mini.osg' ) car.collideBox() ViewCarLink = viz.link(car,viz.MainView) ViewCarLink.preEuler( [0,30,0] ) ViewCarLink.preTrans( [0,0,-10] ) ViewCarLink.preEuler( [0,-20,0] ) ground = viz.addChild('ground.osgb') ground.collidePlane() sensable = viz.add('sensable.dle') device = sensable.addHapticDevice() device.workspace.setScale([20,20,20]) device.addNode(ground) #right boundary for car cube1 = vizshape.addCube(size=1) cube1.setPosition([2,0.5,8]) cube1.setScale(20,1,0.2) cube1.setEuler(90,0,0) RightB=cube1.collideBox([20,1,0.2]) RightB.density=10000 #left boundary for car cube2 = vizshape.addCube(size=1) cube2.setPosition([-2,0.5,8]) cube2.setScale(20,1,0.2) cube2.setEuler(90,0,0) LeftB=cube2.collideBox([20,1,0.2]) LeftB.density=10000 def UpdateMovement(): elapsed = viz.elapsed() x,y,z = device.getPosition() forwardMovementAmount = viz.elapsed() * (z+0.5) car.setPosition( [ 0, 0, forwardMovementAmount], viz.REL_LOCAL ) rotationAmount = viz.elapsed() *(x)*10 car.setEuler( [ rotationAmount, 0 , 0 ],viz.REL_LOCAL) #add spring effect device.addSpringEffect( gain=10,magnitude=10,position=[0,0,0]) vizact.ontimer(0, UpdateMovement) |
#2
|
|||
|
|||
1) Make sure the walls are added to the haptic simulation using the device.addNode(node) command. The front of the car (not center) should be aligned with the haptic device if you want resistance when the front touches the wall.
2) The following code should add a spring effect: Code:
import viz viz.go() sensable = viz.add('sensable.dle') device = sensable.addHapticDevice() spring = device.addSpringEffect(gain=0.2,magnitude=0.5,position=[0,0,0]) |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to get real time position of a object which is connected to a haptic device | Melody | Vizard | 4 | 09-15-2014 02:35 PM |
haptic device problem | guof6570969 | Vizard | 2 | 06-09-2010 02:37 AM |
Haptic Device Shadows | vTony | Vizard | 1 | 05-04-2009 05:58 PM |
Phantom Omni Device Scripts | vSuejung | Vizard | 1 | 09-17-2008 04:42 PM |
Phantom Device Getting Stuck | vjosh | Vizard | 1 | 05-09-2005 11:16 AM |