![]() |
|
#1
|
|||
|
|||
Omni Velocity information
Hi, do you know if there is the chance to get the velocity information from the Omni.
The problem is that i have attacched a ball to the omni, and i am able to control the pose of the ball with it. What i want to do is to use velocity like trigger to send forces from the device to the operator. This is my code: Code:
import viz import hd import vizinfo import time import math import cmath from datetime import datetime viz.go() ball=viz.add('white_ball.wrl') viz.MainView.setPosition([0,-0.5,-5]) hd.marker(ball) start_box=viz.add('box.wrl') start_box.setPosition([2.5,-0.7,3]) start_box.color([0,256,0]) start_box.setScale([0.5,0.5,0.5]) start_box.collideBox() finish_box=viz.add('box.wrl') finish_box.setPosition([-2.5,-0.7,3]) finish_box.setScale([0.5,0.5,0.5]) finish_box.collideBox() pos_goal=[2.35,-0.4,0] #print pos_new[0],pos_new[1],pos_new[2] vizinfo.add('To start reach the green zone and then reach the red one') error=[0,0,0] vel=[0,0,0] Kp=([0.05,0,0],[0,0.05,0],[0,0,0.05]) pos_hidden=[0,0,0] def print_pos(): t1 = current_milli_time() delay=t1-t0 print delay if (delay>3000): for i in range(0,3): pos=hd.get(hd.POSITION) error[i]=-pos_goal[i]+pos_hidden[i] vel[i]=-Kp[i][i]*error[i] pos_hidden[i]=pos_hidden[i]+vel[i] ce = hd.ConstantEffect(dir=[pos_hidden[0]-pos[0],pos_hidden[1]-pos[1],0],mag=0.2) ce.trigger(0.2) # print pos_goal[0],pos_goal[1],pos_goal[2] # print error[0],error[1],error[2] # print vel[0],vel[1],vel[2] # print pos_hidden[0],pos_hidden[1],pos_hidden[2] current_milli_time = lambda: int(round(time.time() * 1000)) def start(): global t0 t0 = current_milli_time() vizact.ontimer(0.1,print_pos) vizact.onkeydown(' ',start) |
#2
|
|||
|
|||
Do you mean the velocity of the stylus as the operator moves it or something else?
|
#3
|
|||
|
|||
I would like to have information about the phantom's velocity during the motion!
I want to use it as a trigger,like: Before sending forces check if in the last 3 seconds the velocity(x,y,z) was zero->in that case send forces otherwise wait! I would like to now if there is already something like the hd.POSITION but for the velocity! |
#4
|
|||
|
|||
It does not look like there is a velocity command. The available commands can be found in the Sensable and standard sensor pages in the Vizard help. You could calculate the velocity between frames or some other time interval. For example:
Code:
import viz import vizact import vizmat viz.go() viz.addChild('piazza.osgb') device = sensable.addHapticDevice() lastPos = [0,0,0] def calculateVelocity(): global lastPos pos = device.getPosition() distance = vizmat.Distance(lastPos,pos) velocity = distance/viz.elapsed() lastPos = pos vizact.ontimer(0.1,calculateVelocity) |
#5
|
|||
|
|||
First of all thanks for your interest.
I thougth about this solution and in this case it could work. The problem is:what happens when i need velocity information in real time during a task? What I am trying to say is that velocity computed in this way could be affected by rumors,it means that i have to filter the information obtained. What do you think? |
#6
|
|||
|
|||
You could calculate the velocity from one frame to the next using the following:
Code:
lastPos = [0,0,0] def calculateVelocity(): global lastPos pos = device.getPosition() distance = vizmat.Distance(lastPos,pos) velocity = distance/viz.getFrameElapsed() lastPos = pos vizact.onupdate(0,calculateVelocity) |
#7
|
|||
|
|||
getVelocity Function
Hello @Jeff & @Marcello,
since this thread is a little bit older, I wanted to know, if there is a update regarding the velocity issue. I'm am working on a Virtual Track in WorldViz with STOP-signs, where the user is instructed to stop. Whether he does so, I wanted to controll with the help of a proximity sensor. The requirements for a successful "stop" should be "reached sensor" and "velocity = 0". Within the vizard help I found the command getVelocity(), which only works with <node3D>. Is it somehow possible to get the velocity of the user (or rather the MainView)? Best regards Robin |
#8
|
|||
|
|||
Here's an example that prints out the viewpoint velocity each frame:
Code:
import viz viz.go() viz.addChild('piazza.osgb') lastPos = [0,0,0] def calculateVelocity(): global lastPos pos = viz.MainView.getPosition() distance = vizmat.Distance(lastPos,pos) velocity = distance/viz.getFrameElapsed() print velocity lastPos = pos vizact.onupdate(0,calculateVelocity) |
![]() |
Tags |
omni, velocity |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Information associated with a model | roobert | Vizard | 7 | 08-01-2014 09:34 AM |
MainView velocity depending on joystick deflection | 4711 | Vizard | 3 | 01-17-2014 12:50 PM |
velocity shader | subbu | Vizard | 0 | 11-24-2013 06:56 AM |
how to remove velocity when mouse is disabled? | jvacare1 | Vizard | 2 | 02-18-2010 10:25 AM |
How Can I use two SensAble Omni at the same time | junghungchien | Vizard | 0 | 09-03-2009 07:04 AM |