Building a ROS-VR Android application

In this section, we will see how to create a virtual reality experience in ROS, especially in robotics simulators such as Gazebo. Luckily, we have an open source Android project called ROS Cardboard (https://github.com/cloudspace/ros_cardboard). This project is exactly what we want we want for this application. This application is based on ROS-Android APIs, which help us visualize compressed images from a ROS PC. It also does the splitting of the view for the left and right eye, and when we put this on a VR headset, it will feel like 3D.

Here is a figure that shows how this application works:

Figure 12: Communication between a ROS PC and Android phone

From the preceding figure, you can see that the image topic from Gazebo can be accessed from a ROS environment, and the compressed version of that image is sent to the ROS-VR app, which will split the view into left and right to provide 3D vision. Setting the ROS_IP variable on PC is important for the proper working of the VR application. The communication between PC and phone happens over Wi-Fi, both on same network.

Building this application is not very tough; first, you can clone this app into some folder. You need to have all of the Android development environment and SDK installed. To do so, you can refer to Chapter 26ROS on MATLAB and Android. Just clone it and you can simply build it using the following instructions:

Plug your Android device into Ubuntu and execute the following command to check whether the device is detected on your PC:

    $ adb devices

The adb command, which stands for Android Debug Bridge, will help you communicate with an Android device and emulator. If this command lists out the devices, then you are done; otherwise, do a Google search to find out how to make it work. It won't be too difficult.

After getting the device list, clone the ROS Cardboard project using the following command. You can clone into home or desktop.

    $ git clone https://github.com/cloudspace/ros_cardboard.git

After cloning, enter the folder and execute the following command to build the entire package and install it on the device:

    $ ./gradlew installDebug

You may get an error saying the required Android platform is not available; what you need is to simply install it using the Android SDK GUI. If everything works fine, you can able install the APK on an Android device. If you are unable to build the APK, you can also find it in chapter_11_codes/ros_cardboard. If installing the APK to the device directly failed, you can find the generated APK from ros_cardboard/ros_cardboard_module/build/outputs/apk. You can copy this APK to the device and try to install it. If you have any difficulty installing it, you can use the APK editor app, mentioned in Chapter 26,  ROS on MATLAB and Android.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.242.157