The Android operating system is an open source mobile platform that is widely used on smartphones and tablets. Its design is based on the Linux kernel, and its primary user control interface is via a touchscreen. This user interface consists of touch actions, such as swiping, tapping, or pinching elements on the screen. Tapping a virtual keyboard is one of the methods of entering text input. Various types of game control screens allow user interaction similar to joysticks and pushbuttons. The screen interface typically adjusts from portrait display to landscape based on the orientation in which the device is held. Sensors such as accelerometers, gyroscopes, and proximity sensors are usually available on the mobile device platform and are used by the application software.
To provide this type of interface for the user of a robot, the ROS Android metapackage has been developed and made available for use and further development.
The next sections will setup and describe the ROS Android development environment through the use of Android Studio and a Java Development Kit (JDK). We start by downloading this software to become an Android developer using ROS.
There is one non-ROS software package to download in order to become a ROS–Android developer. You will need Android Studio, which is the official Integrated Development Environment (IDE) for Android. Android Studio provides all the tools you need to build apps for every type of Android device. Download the Android Studio package as a ZIP file from http://developer.android.com/sdk/index.html.
Be sure to load the Linux platform distribution.
It is recommended that you install this package in the /opt
directory (as /opt/android-studio
). Next, run the setup script using the following command:
$ /opt/android-studio/bin/studio.sh
A setup wizard will guide you through the setup process. When prompted to import previous Android Studio settings, you may select I do not have a previous version of Studio and click on OK. Next you will be prompted for installation instructions, select the Standard installation type.
/opt/android-sdk
or /home/<username>/Android/SDK
. We have chosen our location as the second path.Next, execute the following two commands to add Android Studio to your environment variables. If you installed your Android SDK at /opt/android-sdk
, modify the first command appropriately:
$ echo export ANDROID_HOME=/home/<username>/Android/Sdk >> ~/.bashrc $ echo export PATH=${PATH}:${ANDROID_HOME}/tools${ANDROID_HOME}/platform-tools:/opt/android-studio/bin >> ~/.bashrc
For systems that run a 64-bit version of Ubuntu, the following 32-bit libraries will need to be installed using the command in a terminal window:
$ sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
With Android Studio installed, the ROS metapackages for rosjava
and android
are now needed. The installation of these metapackages is described in the upcoming section.
The first step in our instructions for creating a ROS–Android development environment is to install the Debian packages rosjava-build-tools
and genjava
. The rosjava-build-tools
package contains simple tools and catkin modules for rosjava
development. The genjava
package is useful for generating Java Maven artifacts for message definitions that are in your source workspace. To install the rosjava-build-tools
and genjava
packages, type this command:
$ sudo apt-get install ros-kinetic-rosjava-build-tools ros-kinetic-genjava
Next, create a workspace for the core Android libraries:
$ mkdir –p ~/android_core $ wstool init -j4 ~/android_core/src https://raw.github.com/rosjava/rosjava/kinetic/android_core.rosinstall $ cd ~/android_core $ catkin_make
Add a source command to this workspace in your .bashrc
:
$ echo "source ~/android_core/devel/setup.bash" >>.bashrc
We continue by overlaying these ready-made android_core
libraries onto new workspaces that we will use for Android development. Open a new terminal window and create an empty catkin workspace overlay on top of these files for your Java workspace. Use the following commands:
$ mkdir -p ~/myjava $ wstool init ~/myjava/src $ cd ~/myjava $ catkin_make
If you have your own Java source code and you wish to use it in this workspace, refer to the instructions at http://wiki.ros.org/rosjava/Tutorials/kinetic/Deb%20Installation.
You can also start from here and create your own rosjava
packages. Follow the tutorials at http://wiki.ros.org/rosjava_build_tools/Tutorials/indigo/Creating%20Rosjava%20Packages.
Use the following commands to create an Android workspace, which overlays the rosjava
workspace created previously:
$ mkdir -p ~/myandroid $ wstool init ~/myandroid/src $ source ~/myjava/devel/setup.bash $ cd ~/myandroid $ catkin_make
Other options for installing the source code for ROS–Android core libraries can be found at http://wiki.ros.org/android/Tutorials/kinetic/Installation%20-%20ROS%20Development%20Environment.
To test your ROS–Android Development Environment, proceed to the instructions for accessing the camera on your Android device, found under the Testing section of http://wiki.ros.org/android/Tutorials/kinetic/Installation%20-%20ROS%20Development%20Environment.
Knowing the following terms should help as you learn more about the rosjava
and android
development environments:
antlibs
that contain Ant tasks and types, or they have access to numerous ready-made antlibs
. Apache Ant is a term trademarked by the Apache Software Foundation, which provides support for open source projects.The division between the /myjava
and /myandroid
workspaces is important to the development. In the /myjava
workspace, you can create and build custom rosjava
message JARs and artifacts. You can also use this space to build and test rosjava
algorithms for use in your Android applications. To dive into rosjava
development, refer to the list of tutorials (for ROS Kinetic) at http://wiki.ros.org/rosjava?distro=kinetic.
The /android_core
workspace contains the official ROS android
stacks, a collection of components and examples that are useful for developing ROS applications on Android.
The following diagram highlights the dependencies between the rosjava
and android
libraries:
From this point, you are ready to begin with the creation of Android packages using rosjava
scripts. To begin with, tutorials on creating Android packages and applications are available at http://wiki.ros.org/rosjava_build_tools/Tutorials/indigo/Creating%20Android%20Packages.
For a complete list of ROS–Android tutorials, refer to the list of tutorials (for ROS Kinetic) at http://wiki.ros.org/android?distro=kinetic.
You can also refer to the book ROS Robotics Projects by Lentin Joseph (Packt Publishing, https://www.packtpub.com/hardware-and-creative/ros-robotics-projects). Chapter 8, ROS on MATLAB and Android in this book provides examples of developing ROS–Android applications.