question

Paulino SMH avatar image
0 Likes"
Paulino SMH asked Paulino SMH edited

Control model status through VR

Hello,

I would like to know if its possible to control the model status (reset, run, stop) through virtual reality with the headset on.

So far I have been able to control model logic following the VR Models that you provide without any problem, but when I try to control the model state I get some errors.

1670576544135.png

I think "OnPreDraw" is not the best place to insert this kind of code, is there any place I can move it to get what I am looking for?

Attached is a demo model showing the problem I am facing (VR Mode must be enabled).

TestVRControl.fsm

Thanks in advance.

FlexSim 22.1.1
virtual realitymodel control
1670576544135.png (96.4 KiB)
testvrcontrol.fsm (27.2 KiB)
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

·
Jonah K avatar image
0 Likes"
Jonah K answered Paulino SMH edited

The simplest way I've found to control the model through the Oculus Quest is to set up a desktop view. Or you could make buttons/levers in the model environment that run/stop/reset the model when interacted with.


Set Up Desktop View:

When you're in the FlexSim model in your VR, press the Oculus home button on your right-hand controller. On the bottom toolbar, select Add Desktop Panel, then chose FlexSim. This should pull up the desktop view of FlexSim with all the model features available (Run, Stop, Skip, etc.). You can then quickly toggle back and forth between your desktop view and the VR view by clicking the Oculus home button on your right-hand controller.

oculusscreenshot1670611027.pngoculusscreenshot1670611317.png


Creating A VR Button to Run/Stop:

If you look at the Zombie game in the VR Demo Models, there are buttons and levers on a control panel. 1670617236028.pngIn the tree for this model, under MODEL:/Controls, you can see each of the buttons and lever objects. You could use these as templates to create your own button or lever to start/stop/reset the model.

I found that inserting this line of code;

onButtonPress(applicationcommand("run"));

in /RunSpeed/One>labels/pressCallback, allows you to run the model by pressing the "1x" button. Use these buttons as templates for creating your own button with the desired functionality.


· 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.

Joerg Vogel avatar image Joerg Vogel commented ·
Because you loose the ability to perform an action in a model 3D View workspace once a model has been stopped in model run dashboard or by command, I suggest to do actions that comes near a reset. You can reset statistics in a model, you can update label and parameter values. BUT you won’t be able to benefit upon actions hitting a reset button like updating coupling data needed for some added new objects.

There doesn’t exists a running environment from which you control a model like you can do it from model run dashboard in a 3D model workspace. For this you are restricted to “setup up desktop view” of @Jonah Ks answer.

0 Likes 0 ·
Paulino SMH avatar image Paulino SMH commented ·

Thanks to both of you for the quick response.

The desktop view is a good alternative but in this case I would lose a bit of the inmersive experience I am looking for. I have also tried using applicationcommand("run") and applicationcommand("stop") but I get the same error with those commands (I was able to perform one action with the error, but if you try to chain start-stop commands the application stops working).

I was able to come up with a solution that works for me, if I use the refreshview() command after go() and stop() I get rid of the error, that command stops VR mode so I had to add the following commands to reenable it:

applicationcommand("switchviewvrmode", view, 1);
setvarnum(view, "vrmode", 1);

Attached is the demo model with the changes applied. To allow start, stop and reset I had to add the global variable ModelState, in the ModelOnPreDraw code I refresh the model state and link one action per button, in this case left trigger for run, right trigger for stop and B button (left controller) for reset (for some reason you have to manually restart the model after opening it for this code to work properly, in addition the model can hang if you don't wait a little between calls).

testvrcontrol_v2.fsm

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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