WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Working in Haptic device (PHANTOM) (https://forum.worldviz.com/showthread.php?t=5224)

pradeep 11-10-2014 03:28 AM

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)


Jeff 11-10-2014 03:13 PM

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])



All times are GMT -7. The time now is 06:49 PM.

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