Scenario Tardis - HU-ICT-LAB/WebVR-Demo GitHub Wiki

We, David and Daan, are Technical Information Engineering Students on the Utrecht University of Applied sciences (HU for short). With this minigame we want to introduce you to the world of TI. TI is a specialization of the ICT Institute. In TI you work close to the hardware, learn how to program hardware without an operating system, solve difficult coding problems, write efficient code and much more. It is a great study and we would love to recruit young and new engineers. This little game addresses a few of the learning points above, we use smart code for the VR world, we interface with hardware without an OS and use a lightweight internet communication protocol often used in IOT devices. Our game is an infinite forest that gives multiple ways to travel around and will soon have he option to control a robot arm in the real world!

Field of View

Description

Tardis-world

TI-Representation

As TI representation, we plan to add a robot arm. This robot arm is specifically the URE3 by universal robots. The robot will be controlled from inside the VR game. We do this by using an ESP8266. This little microcontroller will connect with the MQTT server and receive commands over MQTT. It then interprets those commands and checks if they can be applied to the robot arm without trouble. If the ESP deems the command correct it will send a command to the robot arm over a socket connection. This command is a string that contains the desired movement in the form of code in the language URScript. URScript is a programing language made by Universal Robots specifically designed for their UR robot series.

Environment

Infinite World

To let the player lose sense of space we created a semi infinite world. The user can walk in any direction but wont be able to escape the forest. There are a few components that are needed to create this illusion:

  • Tree generator
  • Tree mover

Tree generator

To create the forest we generate a square of trees. The location of these trees are based on the amount of trees spawned, each tree has the same distance between them on both the x and z axis.

Tree Mover

As loading in too many objects will slow the program we came to a clever solution of getting an infinite forest. The player has a sort of rendering distance around him. If a tree is outside of this rendering distance we add the length of the rendering distance to the x or z position of the tree (depending on which side it is too far away) the tree then moves to the opposite side of the player and will end up inside the rendering field. This way the entire forest will move with the player as the player walks thru the world.

To hide the moving of the trees we added a fog component to the scene. The fog is the same color as the background so when a tree spawns in front of the player the player wont notice. The tree just seems to be in the fog all along.

Movement

  1. Moving with Joysticks
  2. Moving by jogging in place
  3. Moving further than the distance in real life

These movement methods are implemented in tardis-world/scripts/movement.js

Moving with Joysticks

We could have used a pre made component for this but decided to do it ourselves to learn more about A-Frame and JavaScript. As we would have to use similar techniques with other planned movement methods.

Moving by jogging in place

We do this by measuring the distance traveled by the headset on the Y axis in the last 20 ticks. If the total distance exceeds the treshold and the movement of the headset on the X and Z axis stay below the threshold it means the player is jogging in place. We can then calculate the distance the player needs to move forward and add this distance to the players location.

To determine wich direction the player should move we make use of the controllers. We find the point that is directly in the midle the two controllers in the vr space. We then calculate the angle of the line between the headset and the point between the controllers. This is the direction we want the player to move in.

Preventing direction change when rotating your head. The headsets location in vr space is located in the middle of the headset. But the headset does not rotate around this point, it rotates around the middle of your head. To combat this problem we find the direction the headset is looking and move the location of the headset back by 8 centimeters. That new point should be in the middle of your head and can now be used to determine the direction you should move in.

Another problem is looking up and down with the headset, as the y axis also changes when looking up and down you will also move forward. To prevent this we check the rotation of the headset on the X axis. We can use a threshold value to solve this problem. If the rotation on the x axis is lower than the threshold we can conclude the player is not looking up and down and allow the player to move forward. If the rotation value is high we will not allow the player to move forward.

Moving further than the distance in real life

Every tick we calculate the difference of the current player position versus the last player position. This difference is than added onto the position of the camera rig that contains the camera in VR. Without any further calculations the player speed is now doubled.

The difference we calculate can also be multiplied by our multiplier. This multiplier can be negative 0 or positive and signed. When the multiplier is 0 it means the player speed is not affected. If the value is negative the player is slowed down, and if the value is below -1 the player movement is reversed. If the value is above 0 the speed is accelerated where with speed 1 the speed of the player is doubled

This speed can be controlled via a webpage. tardis-world/speed_controll.html. This page has a slider that ranges from -400 to +400. This is way more then -1 and 1 but gives more precise control and the values will be converted to values suitable for movement multiplier before applying them (divide by 100). Tardis-world

Bugs

  • The trees of the world are not collidable, which means you can walk through it.
  • The joystick movement does not allow you to move to the left or right, only forwards and backwards
  • the world is not actually infinite as the sky box stops after a certain distance, this breaks the immersion

Sources