question

Clara avatar image
0 Likes"
Clara asked Clara commented

VR with Oculus Quest 2

Hello,

I have a model of a manufacturing line in which I want to implement the use of VR with Oculus Quest.

I want to do something simple like put a joystick that, when moved, varies "run speed" in the model. I don't know how to do it, I'm using the example of the model with VR but even so, I still don't know.


I hope you can help me

oculustouchdemo-6.fsm

FlexSim 24.0.2
virtual realityoculus quest 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered Clara commented

The interaction with the model is handled entirely in the "OnModelPreDraw" user command in the demo model (which calls some of the other user commands). It is run each time before a new frame is generated (through the custom "HandleDraw" object that was added to the tree).

1719217025843.png

I suggest you have a look at that code. There are some comments to show what each code section is roughly responsible for and the variable names are generally chosen so that the code should be understandable to anyone who has some coding experience.

Inputs from the controllers are read with the stick command, so having a look at its documentation might help to understand the code better.


1719217025843.png (35.9 KiB)
· 3
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Clara avatar image Clara commented ·

Please could you help me a little more? I just want a joystick that varies the run speed, but I don't understand anything about the example model

It's very important and urgent for me

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Clara commented ·

I can try, but this is an advanced topic. I don't have a VR setup currently up and running, so I can't test this. It should work, but no promises.

Lines 275-346 handle gripping and moving the handle bar and its impact on the crane z-movement (since run speed is a 1-dimensional value it makes sense to use this object to control it, at least in my mind).

1719221718875.png

Of those lines, only 339-345 deal with the actual crane movement. If you replace them with something like this

double exponent = -handle.rotation.x / 16;
runspeed(Math.pow(2, exponent));

the handle bar should then control the speed (between 1/32 to 32).

Removing all the other control code for the other interactive objects will leave you with the user command code as in the attached model.

You'd need to copy all user commands, the "Handle" object (the thing you will grip in VR) and the "HandleDraw" object (the custom object I highlighted in the answer, copy the treenode from the tree, add a new treenode to the tree of the other model and paste this in there) to the other model. Add the "Handle" global variable and make it be a tree node variable that points to the "Handle" object.

runspeed-control.fsm

1 Like 1 ·
1719221718875.png (7.5 KiB)
Clara avatar image Clara Felix Möhlmann commented ·

it works perfectly. Thank you very much, you have helped me a lot

0 Likes 0 ·