Joystick using for Approach - Avoidance Task
Hi,
I have some experience with Opensesame, but I have hardly any coding knowledge or experience. Currently, I'm trying to prepare an approach-avoidance task using the joystick (I've never used joystick before). Although I understand some of the basics of using the joystick while looking at the forum, I still need your support.
In the task, some photos will be presented, and when the participant wants to approach the photo, he/she has to pull the joystick and push forward if he/she wants to avoid it. When the participant pushes or pulls the joystick, the size of the photo should increase or decrease by 20% for every 7% of the joystick movement. When the joystick movement is greater than 30%, the stimulus screen should disappear and the fixation screen should appear.
So far I have done the following; I added a joystick plug in before a sketchpad(0 ms duration) for stimulus presentation. And after the sketchpad, in an inline_script, I added some code from the forum discussions. These codes are as follows;
# Loop until a response is given while True: # Get a joystick movement movement,timestamp = exp.joystick.get_joyaxes() # `movement` is a tuple indicating the horizontal and vertical movement. dy = movement[1] # If there is vertical movement, set the variable `move_joystick` to up or # down, and break the loop. if dy < 0: exp.set('move_joystick', 'up') var.derece = dy break elif dy > 0: exp.set('move_joystick', 'down') var.derece = dy break
When I looked at previous discussions on this, there were some similar questions, but I did not solve some basic problems. Here my questions;
1- What can I do to increase or decrease stimulus size according to joystick movement?
2- How do I set the stimulus presentation time, based on the participant's joystick response? (Fixation screen should come when joystick movement is greater than 30% angle).
- I guess, the solution of this is about 'while loop', but unfortunately, I have no idea how to do that.
3- I want the other buttons on the joystick to be inactive and the only allowed response is to be the joystick movement (Y axis). How can I do that?
- I know all the button numbers except the joystick movement.
I know that the answers to these questions are available under different topics in the forum, but since I don't have coding skills, I have difficulty integrating them into this experiment. Any help would be greatly appreciated!
Kind regards,
Aslan.
Comments
Hi Aslan,
1- What can I do to increase or decrease stimulus size according to joystick movement?
In the same while loop you have to access the stimulus information and show it. For example, an image has a scale keyword that you can use, other stimuli you might have to first compute the new dimensions, and then draw it. For example:
See https://osdoc.cogsci.nl/3.2/manual/python/canvas/ for more info
How do I set the stimulus presentation time, based on the participant's joystick response? (Fixation screen should come when joystick movement is greater than 30% angle).
Same way as changing the scale factor, but instead of adjusting the canvas that you are currently seeing, show another canvas that only has a fixation dot
3- I want the other buttons on the joystick to be inactive and the only allowed response is to be the joystick movement (Y axis). How can I do that?
I don't know whether you can actively deactive them, but if you don't access its values and they don't, per default, with your experiment, why not just ignore them?
Hope this helps.
Eduard
Hi Eduard,
Thank you for your interest! And I apologize for the late reply, I was working on your suggestions during this time. And in line with your suggestions, I solved my 2nd and 3rd questions. Thank you so much!
However, I did not figure out how to adjust the stimulus size according to the joystick movement (question 1). I'm actually using the sketchpad but these codes are about canvas. So, i couldn't adapt these codes to sketchpad. I think I need access to the sketchpad items.
I've tried something like the following;
But it doesn't work:(.
I receive the error message "The picture file '[uyaranlar]' does not exist."
I don't understand what to write instead of "image (path_to_image.png)".
Any suggestions would be appreciated!
Thanks in advance.
I've tired to new way as below:
Now, i have a KeyError u problem with the name of image file.
Details
item-stack: experiment[run].practice[run].new_sequence[run].new_inline_script_3[run]
exception type: KeyError
exception message: u'0299.jpg'
item: new_inline_script_3
time: Sun Aug 25 14:43:47 2019
phase: run
Even if there is no Turkish or special characters in the image file name, this error message occurs.
Thanks.
I still haven't solved the problem. I've attached the experiment file (a draft) below.
Any suggestions will make me grateful to you.
HI Aslan,
Sorry for the late reply. I changed a bit of the code. The main problem was that the image in the sketchpad was not found. This should be fixed now. However, I don't have a joystick to test whether the experiment does what it is supposed to. Could you confirm?
Eduard
Hi Eduard,
Thank you so much! It works smoothly.
Best regards.
Aslan
Hello, I tried to use the script but apparently It doesn't run because it can't read the Joystick. Do you have the same problem AslanKaraaslan?
Thank you in advance,
Best,
Dam
Hi Dami23,
I haven't any problem with this script. What kind of problem do you have? Can you add the opensesame error or screenshot?
First of all, you need to put the joystick plugin anywhere in the experiment, did you?