【ROS】Android开发环境搭建
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path>
</svg>
<p></p>
目录
ROS Android开发环境搭建
目前ROS和Android的通信方式主要分两种:
一、rosbridge 通过Websocket以JSON格式的API为非ROS环境提供ROS通信支持,这种通信方式轻量级,跨平台
二、rosjava ros官方支持的语言只有C++和Python,目前Android想要和ROS通信的话,需要借助rosjava包
那么我们主要介绍通过rosjava开发的方式
通过rosjava让android端和ros进行通信的话需要依赖两个包rosjava_core和android_core
rosjava_core:它是用纯JAVA实现的ROS 它提供了一个客户端库是JAVA程序可以快速的调用ROS的Topics,Services,Parameters
android_core:集合rosjava组件和范例的ROS开发应用,提供了android库程序来帮助ROS应用开发
我使用的系统和ros版本是ubuntu16.04 + ROS Kinetic
1.安装ROSJAVA
mkdir -p ~/Android/rosjava/src
wstool init -j4 ~/Android/rosjava/src https://raw.githubusercontent.com/rosjava/rosjava/kinetic/rosjava.rosinstall
source /opt/ros/kinetic/setup.bash
cd ~/Android/rosjava
rosdep update
rosdep install --from-paths src -i -y
catkin_make
2.Android Core安装
mkdir -p ~/Android/android_core
wstool init -j4 ~/Android/android_core/src https://raw.github.com/rosjava/rosjava/kinetic/android_core.rosinstall
source /opt/ros/kinetic/setup.bash
source ~/Android/rosjava/devel/setup.bash
cd ~/Android/android_core
rosdep update
rosdep install --from-paths src -i -y
catkin_make
3.Creating Android Packages
4.Android Studio 创建ROS APP
新建项目,修改Project的build.gradle,如下图所示:
buildscript {
apply from: "https://github.com/rosjava/android_core/raw/kinetic/buildscript.gradle"
}
subprojects {
apply plugin: 'ros-android'afterEvaluate { project -> android { // Exclude a few files that are duplicated across our dependencies and // prevent packaging Android applications. packagingOptions { exclude "META-INF/LICENSE.txt" exclude "META-INF/NOTICE.txt" } } }
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
在Module下面的build.gradle中添加依赖:
...
dependencies {
...
// You now now add any rosjava dependencies, like so:
implementation 'org.ros.android_core:android_core_components:0.4.0'
}
...
可能会遇到的坑:解决方案