Running a roscore in an android smartphone

A little something about roscore: (wiki.ros.org/roscore)
roscore is a collection of nodes and programs that are pre-requisites of a ROS-based system. You must have a roscore running in order for ROS nodes to communicate. It is launched using the roscore command.

NOTE: If you use roslaunch, it will automatically start roscore if it detects that it is not already running.

roscore will start up:

I have taken the example of the camera tutorial in the ROSJava tutorials page. The installation instructions are pretty clear and concise and I didn't face any problems in  installing the camera tutorial in my smartphone using the Android Studio, Here's a link to the page : Importing projects in Android Studio
(NOTE: Only follow the steps till the application is installed in your phone. We don't want to start a roscore service on our laptop.)

After following the steps mentioned in the above link, the applications are installed in the smartphone. Here's a screenshot of some of the applications I have installed following the steps mentioned on the 'Importing projects in Android Studio page'



For this post, I'll be using the example of the camera_tutorial. As soon as the application starts, the following screen appears. This is known as the 'Master Chooser'. If you're running a roscore on your laptop, then the IP Address of the laptop has to be entered in the Robot URI field. However, we're not going to do that.

Now instead of entering the Robot URI, select the 'Show Advanced Options' and select New Public Master.

Once, you've done that, fire up a terminal window and enter :
$ export ROS_MASTER_URI=http://192.168.1.3:11311/

Instead of entering 192.168.1.3 as in the above command, enter the IP address of your smartphone. After this, run :
$ rosnode list
This command will yield  '/ros_camera_preview_view' on your terminal screen. This means that your laptop has successfully connected to the ROS master running on your phone. Type the following command next:

$ rosrun image_view image_view image:=camera/image _image_transport:=compressed

This will open up a window of the image viewer and you can view your live camera feed (And that's me goofing around.)

 

So, as of now, I've established how to run roscore services on smartphones, how to connect to those roscore services from a laptop terminal and access data.