Note: This tutorial assumes that you have completed the previous tutorials: ApplicationsPlatform/Clients/Android/LaunchingExistingApplicationsFromAndroid. |
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. |
Tuck Arms Launch Example
Description: Example of how to run an application with a single .launch file from Android device.Tutorial Level: BEGINNER
Contents
Launch File
The launch file needs to launch one node. It will launch a node of the type "tuck_arms.py", which is just a script that calls tuck_arms_main.py. We will call the package pr2_tuck_arms2_app. Use that as the name of the node. The executable that will run takes some arguments. You should also include those and name the file tuck_arms.launch.
<launch> <node pkg="pr2_tuck_arms4_app" type="tuck_arms.py" name="tuck_arms4_app" output="screen" args="-l t -r t -q"> </node> </launch>
Create Package
Create a new package for our application in the ROS install directory, wherever apps for testing usually go. On the PR2 this would be the ~/ros directory.
cd ros roscreate-pkg pr2_tuck_arms2_app rospy trajectory_msgs pr2_mechanism_msgs pr2_tuck_arms_action cd pr2_tuck_arms2_app
Now make a directory called launch in your package and put the launch file inside. We can also make the 'scripts' directory and put our executable inside. The executable, tuck_arms.py, can be about 4 lines:
import roslib roslib.load_manifest('pr2_tuckarm') from pr2_tuck_arms_action import tuck_arms_main tuck_arms_main.main()
We'll make pr2_tuck_arms2_app its own stack.
roscreate-stack .
Now would be the time to edit the CMakeLists.txt and Makefile. However, no changes are necessary.
Generate Android-Related Files
Now we can run the app_files_create script that's attached to this page. If we put that script in the ~/ros directory then we can run:
../app_files_create --create pr2_tuck_arms2_app `rospack find pr2_tuck_arms_app`/icon.png "Tuck Arms2" "Tucks robot's arms." tuck_arms.launch pr2
You might notice that we're just copying the icon from the original Tuck Arms app. For your unique applications you should use a unique icon.
Installing the Application
As instructed by the output message of the previous script, you should add the following line to the .rosinstall file in ~/ros:
- other: {local-name: pr2_tuck_arms2_app}
And then (also in ~/ros) type:
rosintall . source ~/ros/setup.bash
The next steps are only necessary if this is the first time that applications have been installed in this ~/ros directory. Add
echo "Sourcing /u/applications/ros/setup.bash" . /u/applications/ros/setup.bash
to your .bashrc. If other applications have already been installed from this location then those lines are probably already added.
Testing App
De-activate your robot by shutting down the app manager (on most robots, connect with an android device and hit the "deactivate" button). Restart your robot (on most robots, connect with your android device).
You should now see your application listed on your device. If you see no applications listed, this means that your application's formatting is invalid, and it has caused errors. If you do not see your application listed at all, this means that you have skipped a step or failed to restart the app manager.