Combining static and motion positions in condition file?

Hi all,

This community has really helped me out quite a bit and I have just one more teency question:

I have a square that I want to be presented in either a variable x location (-.5,-.3,0,0,.3,.5), with a static y position (0), or a changing position.

The changing position is defined by a variation of .48*sin(n*pi*.9*t) where n changes to effect the speed of the square.

I currently have a .csv setup as such:

sq_posx sq_posy
-.5 0
-.3 0
0 0
.3 0
.5 0
.48sin(0pi*.9*t) 0
.48sin(1.5pi*.9*t) 0
.48sin(3pi*.9*t) 0
.48sin(4.5pi*.9*t) 0

In builder I have the position set to [sq_posx,sq_posy] but the experiment crashes as soon as it runs. I have tried to put a code component above the shape that consists of print(sq_posx), to no avail as nothing prints. I have also tried to put an eval() in front of sq_posx with no luck either.

Any help would be appreciated, thank you!

That’s strange, eval is never advisable (it’s a bit of a fast & dirty solution) but I would have expected it to at least do something. What might be safer is to randomise the value of n and then calculate sq_posx each time using a code component, rather than specifying the calculation in Excel.

I think I was struggling to get what I wanted to work so I was just reaching out for any attempt, but I am glad that eval did not work! I want the project to be done as ‘correctly’ as possible.

What I’ve done instead is have the position of the square be a constant:

move*.48*sin(sq_pos*pi*.9*t)+loc

Where:

move - a 0 or 1 to indicate stasis or motion
sq_pos - variable ‘speeds’ at which the square will move
loc - the values I want the square to be in when it is meant to be static

This is the gitlab where the experiment is hosted. My university does not have a license so it can only be piloted on my end, but this appears to be working!

1 Like