Logo
September, 07, 2021

What Is Virtual Reality (VR)?

As you may have already heard, Virtual Reality (VR) and Augmented Reality (AR) have been two of the big market trends for the last five to six years. You may even have worked with some of the devices featuring these technologies, like when playing games with those special headsets. VR and AR have changed our perception and interaction with computers and with the environment around us. VR shows us new alternate universes, and AR superimposes data, images, and unique experiences on the world around us.

VR and AR are also very important in robotics. VR and AR found their way into the robotics world, from applications in rehabilitation robots to autonomous vehicles to military robots. Due to their significance in robotics, Mecharithm has decided to provide free tutorials on Virtual Reality (VR) and Augmented Reality (AR) for our readers and viewers. We partnered with the great and talented VR and AR expert Abolfazl Tanha for these lessons.

This lesson is the first lesson in the series of lessons on Virtual Reality (VR) and Augmented Reality (AR), focusing on applications in robotics.

What is virtual reality (VR)?

As you know, in FPS games, we can see the view of the cameras above the character’s head, and we can rotate these cameras by mouse, but it makes our hands busy.

virtual-reality-vr-augmented0reality-photo-1

Then, what is the solution? We need to have a system to detect the rotation of our head and align it with the cameras of the character. The name of this technology is Gyroscope. The base of VR is detecting the rotation by Gyroscope (you can learn about roll-pitch-yaw angles and how they are used to represent orientation in the lesson on this topic).

virtual-reality-vr-augmented0reality-gyroscope


Initially, we have to simulate the human eyes for the game character, so we have to add two cameras above the character as a left camera and right camera.

virtual-reality-vr-augmented0reality-Both eyes

Eventually, we will have a view exactly like humans with the right and the left view.

virtual-reality-vr-augmented-reality-VR View

Because the screen is very close to our eyes so we cannot see the view very clearly, and also it is dangerous for our eyes as well. So we will use two lenses for each eye to fix this problem. These lenses will work as one stereoscope for us and fix the overlapping problem. So, as a result, we will see the normal view for our VR application.

For making a VR project, We need to have a game engine. Here you can see two popular game engines for making VR. However, they are not the same. Unity is much easier than Unreal. Here, we want to focus on how we can implement a VR project in Unity.

virtual-reality-vr-augmented-reality-Both engines

As a first step, you need to install the Unity hub, and you can download it from the Unity website and install it on your PC or Mac.

virtual-reality-vr-augmented-reality-unity to mac pc

After installing the Unity hub on your computer, you need to open it and go to the installs and click on add button. In the list of the Unity versions, you need to click on the newest version of Unity and click on next. On this new page, you can see the list of features that you can install on your computer, and you need to select Android build support and iOS build support.

virtual-reality-vr-augmented-reality-Unity hub


Basically, we can implement our VR project for mobile phone and put the mobile inside the VR headset or implement it all in one headset, such as an Oculus Quest 1 or 2, and the final solution is using the VR project as an exe game for the computer and run it on headsets for computers. For each solution, you need to install a specific VR implementation SDK on your game engine. For example, if you want to make it for a mobile phone, you need to install the Google Cardboard, or if you want to implement it for an Oculus quest, you need to install the OVR on your game engine, or if you want to make it for the computer, you need to install specific SDKs for making a VR game for computers.

virtual-reality-vr-augmented-reality-implementation-ios-android-computer-quest


Now let’s focus on the three solutions for implementing the VR game for mobile phones. As we mentioned before, if we want to implement the viewer project, we have to put the camera above the character’s head. So if you want to use a specific VR SDK, all of these SDKs have a system for implementing the VR head, and you can use it and put it on your head character. The second solution is you need to script a system that has the ability to read the current angles from the gyroscope of a mobile phone and align these angles with the camera above the character’s head. The third solution is to recognize the rotation of the device with image processing. With this technology, you can use the device’s camera and try to detect the ground. Then you can detect the camera’s rotation and align it with the camera above the character’s head. With this technology, you don’t need to use the gyroscope of the mobile phone.

Now you can make an environment for your VR scene and put your VR character into the scene. And finally, you can export an APK or iOS application for your mobile phone and test it in real-time.

virtual-reality-vr-augmented-reality-VR character in sceen

In conclusion, we can say that Virtual reality is a big revolution in technology, and we can make several types of games and simulators with this technology so we can do many actions. But, with the new technologies such as hand tracking, physical work, voice detection, and other solutions, we can make it better and better.

Watch the video version of this lesson below (plus more examples and demos):