rosjava / android_apps

Applications built on top of the rosjava android libraries.
132 stars 112 forks source link

Android app to control a Robot that runs kinetic #73

Open shakthi-prashanth-m opened 6 years ago

shakthi-prashanth-m commented 6 years ago

Hi I am new to rosjava android. I am curious to know is it possible to develop Android apps that control Robots (Ubuntu 16.04) running ros-kinetic?

If yes, I would highly appreciate recommended tutorial that I have to go through to develop one. Appreciate your help. Thanks.

jubeira commented 6 years ago

Hi @shakthi-prashanth-m, What type of robot are you trying to control?

If it is an autonomous robot, you can check map_nav inside this repo. It will allow you to send 2D goals to a robot within a map.

http://wiki.ros.org/android This is a good point to get started, and you can also take a look at the source code to see what's happening under the hood.

Does that sound good?

shakthi-prashanth-m commented 6 years ago

Thanks @jubeira . I wanted to develop android application for a Drone. My goal is to control my Drone using Android app. As per my understanding, I can do either of them to start with. Please guide me how to get started in either of the steps.

  1. Develop an Android app and run it on emulator that does Takeoff, Land on Simulator on Gazebo.

  2. Write an Android app on Mobile to issue Takeoff, Land commands to a drone running in simulator. I am using MAVROS node to talk to drone on simulator. Did I sound too technical ? I installed rosjava and android_core but I am unable to create a New Project that can link to these workspaces. Is it possible to simply create an android app using Android studio IDE like we do for other apps ?

Thanks

jubeira commented 6 years ago

Sounds interesting! I don't know the internals of MAVROS. Can you control those actions by using services and/ or sending messages to a node contained in MAVROS? If that's the case, you should be able to do it.

To develop with Android Studio, I personally prefer using it together with the standard ros/catkin way of creating packages. Follow these tutorials:

Once you finish creating the package, you will get a Gradle project that you can import with Android Studio. The autogenerated project will have the dependencies set to start developing with ROS Android. You can compile the package using catkin, Gradle or Android Studio.

shakthi-prashanth-m commented 6 years ago

I don't know the internals of MAVROS. Can you control those actions by using services and/ or sending messages to a node contained in MAVROS? If that's the case, you should be able to do it.

Yes. MAVROS exposes ROS Services to control drone. It supports kinetic version.

Thanks for the pointer to tutorials. I will follow them.

http://wiki.ros.org/rosjava_build_tools/Tutorials/indigo/Creating%20Android%20Packages (creating new ROS Android packages using the command line).

Why indigo ? I wanted to build for kinetic.

jubeira commented 6 years ago

Why indigo ? I wanted to build for kinetic.

That's the way the tutorials are linked; always go to the entry point if you have a doubt: https://wiki.ros.org/android. It's the same for Kinetic/ Indigo; the only thing that matters is the version that you specify in your buildscript. The range [0.3, 0.4) should work well for android_core dependencies at Kinetic version.

If you only need an app that triggers services exposed by MAVROS, it should be relatively easy to do. You will probably need to generate the Java artifacts for those services. You can check here for more info: http://wiki.ros.org/rosjava; in particular, this tutorial provides an example about how how to create custom message artifacts.

shakthi-prashanth-m commented 6 years ago

@jubeira thank you so much for the detailed help. I will post my result.

shakthi-prashanth-m commented 6 years ago

Hi @jubeira warm greetings!

I followed the tutorials you recommended. I was able to connect my Android phone successfully to remote roscore as shown Testing Android ROS installation. Then I proceeded to create Android packages, but its throwing below error.

$ catkin_create_android_project -t 10 -p com.github.ros_java.android_foo.bar bar

Creating android project 
  Name      : bar
  Target Ver: 10
  Java Name : com.github.ros_java.android_foo.bar
  Activity  : Bar

Command: ['android', 'create', 'project', '-n', 'bar', '-p', '/home/intel/android_foo/bar', '-k', 'com.github.ros_java.android_foo.bar', '-t', 'android-10', '-a', 'Bar']
*************************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
*************************************************************************
Invalid or unsupported command "create project -n bar -p /home/intel/android_foo/bar -k com.github.ros_java.android_foo.bar -t android-10 -a Bar"

Error
[error] __init__() takes at least 3 arguments (2 given) : <type 'exceptions.TypeError'>

android command is deprecated and sdkmanager is recommended. My sdkmanager version is 26.1.1.

$  sdkmanager --version
26.1.1

But, we can't create packages using sdkmanager. What is the alternative ? Can't I create these packages using Android Studio GUI ? Appreciate your help. Thanks.

jubeira commented 6 years ago

Hi @shakthi-prashanth-m !

Yes, that is a known issue; you can check https://github.com/rosjava/rosjava_build_tools/issues/32 for more details. In few words, that is correct: android command was deprecated in newer build tools versions.

You have some options:

I think option (2) is the easiest, as it doesn't require so many manual steps. Please let me know if that worked for you.

shakthi-prashanth-m commented 6 years ago

I followed 1st one, and it worked! Thanks @jubeira !