Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] Joystick programming & inline script writing

edited April 2015 in OpenSesame

Hi

I am hoping to use Open Sesame for an upcoming experiment, but I nor anyone else in my team has even the slightest knowledge of coding/script writing.

I want Open Sesame to show a video and record a joystick movement response (the direction, speed and extent of the towards/away movement) simultaneously. There will then be a keyboard yes/no response time task before the next video is shown.
I have used the GUI to present the video and record the keyboard yes/no response times but I believe in order to make the joystick work, it requires an inline script item to be included after the joystick item (this is what I have read on previous forums).

As you can probably tell, I have no experience whatsoever in the area of computer programming so don't even know where to begin with this... I get to the stage of inserting an inline script item using the GUI and then get stuck. Consequently I have no script to show you!

I realise this is a big ask but any help would be fantastic!

Thank you!

Comments

  • edited 7:24AM

    Hey Helen,

    Unfortunately, I have myself not much experience which joysticks. So, I can give you only some very general advice. First of all, in case you haven't seen it yet, here you can find some information how to deal with joysticks in an inline_script.

    A way you could start is inserting the joystick plug-in in the beginning of your experiment, followed by placing an inline_script right after your video. There you can refer to the joystick by calling exp.joystick. The best way to learn using it, is playing around with it. So, have a look on the functions that are described in the documentation and check out what they are doing (you can print their return values to the debug window). For example, I could imagine that based on this function, you can compute direction and speed rather easily.

    I hope this was of any help.

    Good luck,

    Eduard

    Buy Me A Coffee

  • edited 7:24AM

    Hi Helena,

    This sounds like an approach-avoidance task, am I right?

    I want Open Sesame to show a video and record a joystick movement response (the direction, speed and extent of the towards/away movement) simultaneously.

    You can use the media_player_vlc plug-in for video playback, and use its inline-script field to interact with the joystick. For example, this piece of script, when entered into the media_player_vlc will check whether a joystick button is pressed, and stop playback when this is the case:

    b, t = self.experiment.joystick.get_joybutton(timeout=0)
    if b is not None:
        continue_playback = False
    

    For a full list of joystick functions, see:

    To make this script work, you need to add a joystick plug-in somewhere in your experiment to initialize the joystick. And you need to set 'Call custom code' to 'on every frame' in the media_player_vlc plug-in.

    So, in general, this is how you interact with the joystick. To get a more specific answer, you need to specify in detail what kind of information you want to have. The direction of which movement? Because the joystick can be moved multiple times. Which speed? The average speed, the top speed, the speed of the first movements, etc.? So first you need to be very specific about what information you want to log, and from there you (with some help perhaps) can build a simple script like the one above.

    Cheers and good luck!
    Sebastiaan

Sign In or Register to comment.