Code walkthrough
Let's check out the Android-ROS application code for the basic publisher-subscriber app. You can get it from ~/android_core/android_tutorial_pubsub/src
. You'll see a file called MainActiviy.java
, and now I'll explain the code.
In the beginning of the code, you can see the package name and required Android modules for this application. The important modules are RosActivity
and NodeConfiguration
. These will help us create a new ROS node in an Android activity (https://developer.android.com/guide/components/activities.html).
package org.ros.android.android_tutorial_pubsub; import android.os.Bundle; import org.ros.android.MessageCallable; import org.ros.android.RosActivity; import org.ros.android.view.RosTextView; import org.ros.node.NodeConfiguration; import org.ros.node.NodeMainExecutor; import org.ros.rosjava_tutorial_pubsub.Talker;
Here is where the Android MainActivity
starts, which is...