Note: This tutorial assumes that you have completed the previous tutorials: Web App Interactions.
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Android Interactions

Description: Defining interactions that can launch android activities.

Keywords: rocon interactions android

Tutorial Level: BEGINNER

Overview

This tutorial will guide you through the process of launching activities on android devices. This has a really strong advantage in that it provides a systematic way of getting parameters and remappings info to the android activity itself.

Skip to the Quick Instructions if you just want to run/test some existing qt interactions.

Interactions

We will create two talker/listener interactions, each going in a different direction (i.e. from pc->android and from android->pc. One we will run on the /babbler topic and the other on the /natter topic.

Yaml

Let's hypothetically create an interactions yaml called android.interactions in a package called foo.

- name: com.github.rosjava.android_remocons.listener.Listener
  role: Android
  compatibility: rocon:/*/*/hydro|indigo/jellybean|ice_cream_sandwich
  display_name: Listener
  description: Tunes into the babble (/babbler topic).
  max: -1
  remappings:
    - remap_from: chatter
      remap_to: /babbler

- name: com.github.rosjava.android_remocons.talker.Talker
  role: Android
  compatibility: rocon:/*/*/hydro|indigo/jellybean|ice_cream_sandwich
  display_name: Talker
  description: Natters away like an old nag (/natter topic).
  max: -1
  remappings:
    - remap_from: chatter
      remap_to: /natter

Note the remapping instructions that we will pass on to the android applications from this specification.

Launcher

Next, we create a launcher that advertises both the master on the local network (via zeroconf) and our interactions that can be run with that master. Also the talker and listener tutorials remapped to the right topics to create the pc endpoinds of the two interactions.

Save the following as android.launch in package foo.

<launch>
  <!-- ****************************** Arguments ****************************** -->
  <arg name="ros_master_name" default="Rocon Android Interactions"/>
  <arg name="ros_master_description" default="A tutorial environment for android interactions and remocons."/>
  <arg name="ros_master_icon" default="rocon_icons/cybernetic_pirate.png"/>

  <!-- ****************************** Zeroconf ******************************* -->
  <node ns="zeroconf" pkg="zeroconf_avahi" type="zeroconf" name="zeroconf">
    <rosparam param="services" subst_value="true">
        [ { name: "$(arg ros_master_name)", type: _ros-master._tcp, port: 11311, domain: local, description: "$(arg ros_master_description)" } ] 
    </rosparam>
  </node>

  <!-- ***************************** Interactions ***************************** -->
  <param name="name" value="$(arg ros_master_name)"/>
  <param name="description" value="$(arg ros_master_description)"/>
  <param name="icon" value="$(arg ros_master_icon)"/>
  <node pkg="rocon_master_info" type="master.py" name="master"/>

  <node pkg="rocon_interactions" type="interactions_manager.py" name="interactions">
    <rosparam param="interactions">[foo/android, rocon_interactions/web]</rosparam>
    <param name="rosbridge_port" value="$(arg rosbridge_port)"/>
    <param name="webserver_address" value="$(arg webserver_address)"/>
  </node>

  <!-- ******************************* Programs ******************************* -->
  <node pkg="roscpp_tutorials" type="talker" name="pc_talker">
    <remap from="chatter" to="babbler"/>
  </node>
  <node pkg="roscpp_tutorials" type="listener" name="pc_listener">
    <remap from="chatter" to="natter"/>
  </node>
</launch>

Android

We need the android remocon, as well as some android talker/listener applications.

  • Compile android_remocons

  • Download rocon_remocon, listener and talker to the phone.

Interacting

PC:

# Dependencies
> sudo apt-get install ros-indigo-roscpp-tutorials ros-indigo-rocon-master-info rocon-interactions ros-indigo-zeroconf-avahi-suite
# set to your IP (need this, it's going to be across the network)
> export ROS_IP=192.168.1.1
> roslaunch foo android.launch --screen

Android Phone:

  • Make sure your phone is on the local network
  • Start the remocon application.
  • Scan the local network for masters.
    • If scanning fails, you may need to edit the zeroconf avahi configuration as described here.

    • Alternatively connect by IP manually.
  • Select the android role.
  • Start either talker or listener.

Quick Instructions

PC:

> roslaunch rocon_interactions android_demo.launch --screen

Android Phone:

  • Compile android_remocons

  • Download rocon_remocon, listener and talker to the phone.
  • Make sure your phone is on the local network
  • Start the remocon application.
  • Scan the local network for masters.
  • Select the android role.
  • Start either talker or listener.

Wiki: rocon_interactions/Tutorials/indigo/Android Interactions (last edited 2015-02-24 01:05:55 by DanielStonier)