WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-10-2014, 03:28 AM
pradeep pradeep is offline
Member
 
Join Date: Jun 2014
Posts: 14
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)
Reply With Quote
 

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


All times are GMT -7. The time now is 08:56 PM.


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