WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-25-2015, 01:12 PM
itruginski itruginski is offline
Member
 
Join Date: Mar 2015
Posts: 2
Printing Joystick Positions to a Datafile for Multiple Joysticks

Hi all,

I am an experimental psychologist who uses Vizard (big fan) for testing of perception action coupling. I am interesting in making a joint action paradigm, where two users are able to control a brake while speeding towards three stop signs. Thankfully, I figured out how to add a second joystick to our paradigm, so that two users can simultaneously control execution of the same action, using joy1 and joy2.

My main question concerns the printing of joystick position to the datafile. Can this be simultaneously done for two joysticks, say, in two separate columns? Right now we will have the cumulative velocity/positional/visual angle info, but that will be for the camera position (combined input of the two joysticks) and not the actual action taken with each joystick. Wondering if it was possible, and if so how to code and print out, the x position of each joystick at given time intervals.

My code (in a .txt) is attached if that would be helpful to look at. If you would like to use it or are curious about the associated experiment, please email me at Ian.Ruginski@psych.utah.edu.

Any help that you can provide would be much appreciated!
-Ian
Attached Files
File Type: txt stopCrashJointAction_Ruginski.txt (6.8 KB, 1024 views)
Reply With Quote
  #2  
Old 03-27-2015, 02:54 AM
mape2k mape2k is offline
Member
 
Join Date: Mar 2013
Posts: 60
Hi,

you can do that by defining a function and calling that function repeatedly at a give rate with the vizard <ontimer> function. See my quick example below.

Code:
import viz
import vizact

def writeJoystickPosition():

	joyData1 = joy1.getPosition()
        joyData2 = joy2.getPositio()

        here some lines to write it to a file....

logJoystick = vizact.ontimer(0,writeJoystickPosition)	# start the function

viz.go()
If you start ontimer with a 0, it will call the function each frame. You can also put in other values, e.g. 1 would mean every second.
Reply With Quote
  #3  
Old 04-06-2015, 10:34 AM
itruginski itruginski is offline
Member
 
Join Date: Mar 2015
Posts: 2
Quote:
Originally Posted by mape2k View Post
Hi,

you can do that by defining a function and calling that function repeatedly at a give rate with the vizard <ontimer> function. See my quick example below.

Code:
import viz
import vizact

def writeJoystickPosition():

	joyData1 = joy1.getPosition()
        joyData2 = joy2.getPositio()

        here some lines to write it to a file....

logJoystick = vizact.ontimer(0,writeJoystickPosition)	# start the function

viz.go()
If you start ontimer with a 0, it will call the function each frame. You can also put in other values, e.g. 1 would mean every second.
Thanks a ton! I really appreciate the thoughtful and clear response. I'm going to work on implementing this today.
Reply With Quote
Reply

Tags
datafile, joysticks, programming

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
joystick position nmohandes Vizard 2 01-16-2012 10:03 AM


All times are GMT -7. The time now is 08:59 AM.


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