更多创客作品,请关注笔者网站园丁鸟,搜集全球极具创意,且有价值的创客作品
1.开发环境
RobotCA是采用Eclipse进行开发,在DiegoAPP中将整个项目迁移到了Android Studio 3.4开发,有兴趣的同学可以到https://www.diegorobot.com下载试用。
Android Studio中Gradle 和Gradle Plugin的版本入下图,Gradle和Gradle Plugin的版本非常重要,其他的版本会出现一些编译错误。
Diego APP支持了Android8.0,Android8.1,Android9.0版本,适应现在主流的Android手机,其他版本的也可以下载最新的Android SDK进行编译,但有由于Android升级过程中接口函数会有所变化,故可能会影响正常的运行,如闪退等异常。
2.项目架构
Diego APP的目录组织结构符合Android Studio APP的项目组织规范
com.diegorobot.app是主要的程序目录
Core:主要的控制逻辑代码,包括Robot的控制,Map,导航等。
Dialogs:对话框的逻辑代码,对应res中的对话框资源
Fragments:对应与res中视图的控制代码
Layers:针对需要渲染的层的逻辑代码,现在只有针对激光雷达数据的渲染代码
Views:对应res的视图文件的控制代码
ControlAPP:主要的控制Activity,APP在连接进入控制模式后,运行此Activity
RobotChooser:APP启动时的Activity,用来配置连接信息,显示Robot列表
ToolbarActionItemTarget:Robot列表中的工具条对应的类
2.Build.gradle
App的编译配置文件中定义了App支持的版本,依赖的包等信息,特别是编译时所涉及到包,一定要正确,否则会出现编译异常, build.gradle代码如下
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.diegorobot.app"
minSdkVersion 26
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
dexOptions {
javaMaxHeapSize "4g"
}
}
configurations {
all*.exclude group: 'org.ros.rosjava_bootstrap', module: 'gradle_plugins'
}
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://github.com/rosjava/rosjava_mvn_repo/raw/master"
}
//maven { url "https://jitpack.io" }
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'org.ros.android_core:android_core_components:0.4.0'
implementation 'com.github.rosjava.android_extras:gingerbread:[0.3,0.4)'
implementation 'org.ros.rosjava_messages:tf2_msgs:[0.5,0.6)'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'org.apache.commons:commons-lang3:3.9'
implementation 'com.squareup.okhttp:okhttp:2.7.5'
implementation 'com.github.amlcurran.showcaseview:library:5.4.3'
//testCompile 'junit:junit:4.12'
}
dependencies {
// Required -- JUnit 4 framework
testImplementation 'junit:junit:4.12'
// Optional -- Mockito framework
testImplementation 'org.mockito:mockito-core:2.27.0'
androidTestImplementation 'com.android.support:support-annotations:28.0.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
// Optional -- Hamcrest library
androidTestImplementation 'org.hamcrest:hamcrest-library:2.1'
// Optional -- UI testing with Espresso
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// Optional -- UI testing with UI Automator
// androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v15'
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
resolutionStrategy.force 'junit:junit:4.12'
}