diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..363aad3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +# Built application files +*.apk +*.ap_ + +# Files for the dex VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ + +# Local configuration file (sdk path, etc) +local.properties + +# Windows thumbnail db +Thumbs.db + +# OSX files +.DS_Store + +# Android Studio +*.iml +.idea +.gradle +build/ +.navigation +captures/ +output.json + +# NDK +obj/ +.externalNativeBuild + +# Keys +keystore.properties +keys/ + + +# Android QiSDK project config +robotsdk.xml diff --git a/AUTHORS.md b/AUTHORS.md new file mode 100644 index 0000000..ce516f0 --- /dev/null +++ b/AUTHORS.md @@ -0,0 +1,5 @@ +## Pepper Point At Authors + +The Pepper Point At library was written by the Developer Experience team at Softbank Robotics Europe, Paris, December 2019. + +* **Alexandre Roux** (aroux@softbankrobotics.com) diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..177ec4e --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,19 @@ +Copyright (c) 2011-2019, SoftBank Robotics Europe +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +* Neither the name of the SoftBank Robotics Europe nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL SoftBank Robotics Europe BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..db88c57 --- /dev/null +++ b/README.md @@ -0,0 +1,81 @@ +# Pepper Point At Library + +This Android Library will help you make Pepper point at a nearby position by running a specific animation or by giving a Frame to point at. + + +## Getting Started + +### Prerequisites + +A robotified project for Pepper with QiSDK. Read the [documentation](https://developer.softbankrobotics.com/pepper-qisdk) if needed. + +### Running the Sample Application + +The project comes complete with a sample project. You can clone the repository, open it in Android Studio, and run this directly onto a Robot. + +The sample app provides a screen representing Pepper in the middle of a room with different animal emojis displayed around him. +If you press an emoji or if you say the name of the animal it's representing, Pepper will point at its position. + +Full implementation details are available to see in the project. + +### Installing + +[**Follow these instructions**](https://jitpack.io/#softbankrobotics-labs/pepper-point-at) + +Make sure to replace 'Tag' by the number of the version of the library you want to use. + + +## Usage + +*This README assumes some standard setup can be done by the user, such as initialising variables or implementing code in the correct functions. Refer to the Sample Project for full usage code.* + +Initialise the QiSDK in the onCreate. If you are unsure how to do this, refer to the QiSDK tutorials [here](https://qisdk.softbankrobotics.com/sdk/doc/pepper-sdk/ch1_gettingstarted/starting_project.html) +``` +QiSDK.register(this, this) +``` +In the `onRobotFocusGained`, instantiate a `PointAtAnimator` object by passing it the QiContext. + +``` +override fun onRobotFocusGained(qiContext: QiContext) { + Log.i(TAG, "onRobotFocusGained") + pointAtAnimator = PointAtAnimator(qiContext) +} +``` +You can them launch a specific `PointAtAnimation` with the following code: +``` +pointAtAnimator.playPointAnimation(PointAtAnimation.MEDIUM_LEFT) +``` +Here is the list of the different `PointAtAnimation`: +``` +CLOSE_FRONT_LEFT +CLOSE_FRONT_RIGHT +CLOSE_MEDIUM_LEFT +CLOSE_MEDIUM_RIGHT +CLOSE_HALF_LEFT +CLOSE_HALF_RIGHT +FRONT_LEFT +FRONT_RIGHT +MEDIUM_LEFT +MEDIUM_RIGHT +HALF_LEFT +HALF_RIGHT +``` +You can also ask Pepper to point at a specific `Frame`: +``` +pointAtAnimator.pointAt(targetFrame) +``` +Refer to this [documentation](https://android.aldebaran.com/sdk/doc/pepper-sdk/ch4_api/movement/reference/frame.html) +if you are not familiar with the concept of `Frame` + + +## Additional information + +When asking the library to point at a specific `Frame`, the library will define if it is close to Pepper or not to run the right `PointAtAnimation`. A "close" `Frame` is closer than 3 meters from Pepper. + +For instance, if the library is asked to point at a `Frame` that is one meter directly to the left of Pepper, the `PointAtAnimation` CLOSE_HALF_LEFT will be played. +But if the library is asked to point at a `Frame` that is ten meters away directly to the left of Pepper, the `PointAtAnimation` HALF_LEFT will be played. + + +## License + +This project is licensed under the BSD 3-Clause "New" or "Revised" License- see the [LICENSE](LICENSE.md) file for details. \ No newline at end of file diff --git a/pepper-point-at-root/.gitignore b/pepper-point-at-root/.gitignore new file mode 100644 index 0000000..03b3a16 --- /dev/null +++ b/pepper-point-at-root/.gitignore @@ -0,0 +1,35 @@ +# Built application files +*.apk +*.ap_ + +# Files for the dex VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ + +# Local configuration file (sdk path, etc) +local.properties + +# Windows thumbnail db +Thumbs.db + +# OSX files +.DS_Store + +# Android Studio +*.iml +.idea +.gradle +build/ +.navigation +captures/ +output.json + +# NDK +obj/ +.externalNativeBuild diff --git a/pepper-point-at-root/build.gradle b/pepper-point-at-root/build.gradle new file mode 100644 index 0000000..7299b45 --- /dev/null +++ b/pepper-point-at-root/build.gradle @@ -0,0 +1,29 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '1.3.50' + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.5.3' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + maven { + url 'https://qisdk.softbankrobotics.com/sdk/maven' + } + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/pepper-point-at-root/gradle.properties b/pepper-point-at-root/gradle.properties new file mode 100644 index 0000000..23339e0 --- /dev/null +++ b/pepper-point-at-root/gradle.properties @@ -0,0 +1,21 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official diff --git a/pepper-point-at-root/gradle/wrapper/gradle-wrapper.jar b/pepper-point-at-root/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f Binary files /dev/null and b/pepper-point-at-root/gradle/wrapper/gradle-wrapper.jar differ diff --git a/pepper-point-at-root/gradle/wrapper/gradle-wrapper.properties b/pepper-point-at-root/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..2b28b0b --- /dev/null +++ b/pepper-point-at-root/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Thu Dec 05 16:41:19 CET 2019 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/pepper-point-at-root/gradlew b/pepper-point-at-root/gradlew new file mode 100755 index 0000000..cccdd3d --- /dev/null +++ b/pepper-point-at-root/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/pepper-point-at-root/gradlew.bat b/pepper-point-at-root/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/pepper-point-at-root/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/pepper-point-at-root/pepper-point-at/.gitignore b/pepper-point-at-root/pepper-point-at/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/.gitignore @@ -0,0 +1 @@ +/build diff --git a/pepper-point-at-root/pepper-point-at/build.gradle b/pepper-point-at-root/pepper-point-at/build.gradle new file mode 100644 index 0000000..72a90ea --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/build.gradle @@ -0,0 +1,31 @@ +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' +android { + compileSdkVersion 29 + buildToolsVersion "29.0.2" + defaultConfig { + minSdkVersion 23 + targetSdkVersion 29 + versionCode 1 + versionName "1.0.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + consumerProguardFiles 'consumer-rules.pro' + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.core:core-ktx:1.1.0' + implementation 'com.aldebaran:qisdk:1.6.7' + implementation 'com.aldebaran:qisdk-design:1.6.7' +} diff --git a/pepper-point-at-root/pepper-point-at/consumer-rules.pro b/pepper-point-at-root/pepper-point-at/consumer-rules.pro new file mode 100644 index 0000000..e69de29 diff --git a/pepper-point-at-root/pepper-point-at/proguard-rules.pro b/pepper-point-at-root/pepper-point-at/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/pepper-point-at-root/pepper-point-at/src/main/AndroidManifest.xml b/pepper-point-at-root/pepper-point-at/src/main/AndroidManifest.xml new file mode 100644 index 0000000..6221a7a --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/pepper-point-at-root/pepper-point-at/src/main/assets/PointFrontL.qianim b/pepper-point-at-root/pepper-point-at/src/main/assets/PointFrontL.qianim new file mode 100644 index 0000000..2bf3c7b --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/src/main/assets/PointFrontL.qianim @@ -0,0 +1,411 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pepper-point-at-root/pepper-point-at/src/main/assets/PointFrontR.qianim b/pepper-point-at-root/pepper-point-at/src/main/assets/PointFrontR.qianim new file mode 100644 index 0000000..d979fc3 --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/src/main/assets/PointFrontR.qianim @@ -0,0 +1,411 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pepper-point-at-root/pepper-point-at/src/main/assets/PointHalfL.qianim b/pepper-point-at-root/pepper-point-at/src/main/assets/PointHalfL.qianim new file mode 100644 index 0000000..ac9fd70 --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/src/main/assets/PointHalfL.qianim @@ -0,0 +1,431 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pepper-point-at-root/pepper-point-at/src/main/assets/PointHalfR.qianim b/pepper-point-at-root/pepper-point-at/src/main/assets/PointHalfR.qianim new file mode 100644 index 0000000..940846b --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/src/main/assets/PointHalfR.qianim @@ -0,0 +1,431 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pepper-point-at-root/pepper-point-at/src/main/assets/PointMediumL.qianim b/pepper-point-at-root/pepper-point-at/src/main/assets/PointMediumL.qianim new file mode 100644 index 0000000..29d0c73 --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/src/main/assets/PointMediumL.qianim @@ -0,0 +1,640 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pepper-point-at-root/pepper-point-at/src/main/assets/PointMediumR.qianim b/pepper-point-at-root/pepper-point-at/src/main/assets/PointMediumR.qianim new file mode 100644 index 0000000..a79643f --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/src/main/assets/PointMediumR.qianim @@ -0,0 +1,640 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortFrontL.qianim b/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortFrontL.qianim new file mode 100644 index 0000000..8a1cd5e --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortFrontL.qianim @@ -0,0 +1,351 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortFrontR.qianim b/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortFrontR.qianim new file mode 100644 index 0000000..6f24e3d --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortFrontR.qianim @@ -0,0 +1,371 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortHalfL.qianim b/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortHalfL.qianim new file mode 100644 index 0000000..bc460f5 --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortHalfL.qianim @@ -0,0 +1,423 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortHalfR.qianim b/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortHalfR.qianim new file mode 100644 index 0000000..216c770 --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortHalfR.qianim @@ -0,0 +1,423 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortMediumL.qianim b/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortMediumL.qianim new file mode 100644 index 0000000..f7a2b66 --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortMediumL.qianim @@ -0,0 +1,396 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortMediumR.qianim b/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortMediumR.qianim new file mode 100644 index 0000000..5cb074c --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/src/main/assets/PointShortMediumR.qianim @@ -0,0 +1,396 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pepper-point-at-root/pepper-point-at/src/main/java/com/softbankrobotics/pepperpointat/PointAtAnimator.kt b/pepper-point-at-root/pepper-point-at/src/main/java/com/softbankrobotics/pepperpointat/PointAtAnimator.kt new file mode 100644 index 0000000..3de6749 --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/src/main/java/com/softbankrobotics/pepperpointat/PointAtAnimator.kt @@ -0,0 +1,186 @@ +package com.softbankrobotics.pepperpointat + +import com.aldebaran.qi.Future +import com.aldebaran.qi.sdk.QiContext +import com.aldebaran.qi.sdk.`object`.actuation.Animate +import com.aldebaran.qi.sdk.`object`.actuation.Frame +import com.aldebaran.qi.sdk.builder.AnimateBuilder +import com.aldebaran.qi.sdk.builder.AnimationBuilder +import kotlin.math.* + +enum class PointAtAnimation { + CLOSE_FRONT_LEFT, + CLOSE_FRONT_RIGHT, + CLOSE_MEDIUM_LEFT, + CLOSE_MEDIUM_RIGHT, + CLOSE_HALF_LEFT, + CLOSE_HALF_RIGHT, + FRONT_LEFT, + FRONT_RIGHT, + MEDIUM_LEFT, + MEDIUM_RIGHT, + HALF_LEFT, + HALF_RIGHT +} + +class PointAtAnimator(context: QiContext) { + + private val qiContext = context + + fun playPointAnimation(pointAtAnimation: PointAtAnimation): Future { + return pointAtAnimateBuilder(pointAtAnimation).andThenCompose { + it.async().run() + } + } + + private fun pointAtAnimateBuilder(pointAtAnimation: PointAtAnimation): Future { + val animName = when (pointAtAnimation) { + PointAtAnimation.CLOSE_FRONT_LEFT -> "PointShortFrontL.qianim" + PointAtAnimation.CLOSE_FRONT_RIGHT -> "PointShortFrontR.qianim" + PointAtAnimation.CLOSE_MEDIUM_LEFT -> "PointShortMediumL.qianim" + PointAtAnimation.CLOSE_MEDIUM_RIGHT -> "PointShortMediumR.qianim" + PointAtAnimation.CLOSE_HALF_LEFT -> "PointShortHalfL.qianim" + PointAtAnimation.CLOSE_HALF_RIGHT -> "PointShortHalfR.qianim" + PointAtAnimation.FRONT_LEFT -> "PointFrontL.qianim" + PointAtAnimation.FRONT_RIGHT -> "PointFrontR.qianim" + PointAtAnimation.MEDIUM_LEFT -> "PointMediumL.qianim" + PointAtAnimation.MEDIUM_RIGHT -> "PointMediumR.qianim" + PointAtAnimation.HALF_LEFT -> "PointHalfL.qianim" + PointAtAnimation.HALF_RIGHT -> "PointHalfR.qianim" + } + + return AnimationBuilder.with(qiContext) + .withAssets(animName) + .buildAsync() + .andThenCompose { + AnimateBuilder.with(qiContext) + .withAnimation(it) + .buildAsync() + } + } + + fun pointAt(targetFrame: Frame): Future { + return qiContext.actuation.async().robotFrame().andThenCompose { + val transformTime = targetFrame.computeTransform(it) + val transform = transformTime.transform + val translation = transform.translation + val x = translation.x + val y = translation.y + val distance = sqrt(x * x + y * y) + val angle = atan2(y, x) * 180 / PI + + if (x >= 0) { + handleTargetFrameInFront(distance, angle) + } else { + handleTargetFrameBehind(distance, x, y) + } + } + } + + private fun handleTargetFrameInFront( + distance: Double, + angle: Double + ): Future { + val pointAtAnimateFuture: Future + + if (distance <= 3) { + pointAtAnimateFuture = if (angle <= 0 && angle > -22) { + playPointAnimation(PointAtAnimation.CLOSE_FRONT_RIGHT) + } else if (angle >= 0 && angle < 22) { + playPointAnimation(PointAtAnimation.CLOSE_FRONT_LEFT) + } else if (angle <= -22 && angle >= -68) { + playPointAnimation(PointAtAnimation.CLOSE_MEDIUM_RIGHT) + } else if (angle >= 22 && angle <= 68) { + playPointAnimation(PointAtAnimation.CLOSE_MEDIUM_LEFT) + } else if (angle < -22 && angle >= -90) { + playPointAnimation(PointAtAnimation.CLOSE_HALF_RIGHT) + } else { + playPointAnimation(PointAtAnimation.CLOSE_HALF_LEFT) + } + } else { + pointAtAnimateFuture = if (angle <= 0 && angle > -22) { + playPointAnimation(PointAtAnimation.FRONT_RIGHT) + } else if (angle >= 0 && angle < 22) { + playPointAnimation(PointAtAnimation.FRONT_LEFT) + } else if (angle <= -22 && angle >= -68) { + playPointAnimation(PointAtAnimation.MEDIUM_RIGHT) + } else if (angle >= 22 && angle <= 68) { + playPointAnimation(PointAtAnimation.MEDIUM_LEFT) + } else if (angle < -22 && angle >= -90) { + playPointAnimation(PointAtAnimation.HALF_RIGHT) + } else { + playPointAnimation(PointAtAnimation.HALF_LEFT) + } + } + + return pointAtAnimateFuture + } + + private fun handleTargetFrameBehind( + distance: Double, + x: Double, + y: Double + ): Future { + // Build coordinates of the Frame at 90° of the target Frame + val frameToAlignX: Double + val frameToAlignY: Double + // Behind left + if (y >= 0) { + frameToAlignX = y + frameToAlignY = -x + } + // Behind right + else { + frameToAlignX = -y + frameToAlignY = x + } + + // Create the rotation Animates + val theta = atan(frameToAlignY / frameToAlignX) + val rotationAnimate = buildRotationAnimate(theta) + val backToInitialPositionAnimate = buildRotationAnimate(-theta) + + // Create the point at Animate + val pointAtAnimateFuture = if (y >= 0) { + if (distance > 5) { + playPointAnimation(PointAtAnimation.HALF_LEFT) + } else { + playPointAnimation(PointAtAnimation.CLOSE_HALF_LEFT) + } + } else { + if (distance > 5) { + playPointAnimation(PointAtAnimation.HALF_RIGHT) + } else { + playPointAnimation(PointAtAnimation.CLOSE_HALF_RIGHT) + } + } + + return rotationAnimate.async().run().andThenCompose { + pointAtAnimateFuture.andThenCompose { + backToInitialPositionAnimate.async().run() + } + } + } + + private fun buildRotationAnimate(theta: Double): Animate { + val timeMax = 5.0 + val angleMax = Math.PI + val duration = abs(theta) / angleMax * timeMax + val animationString = + String.format( + "[\"Holonomic\", [\"Line\", [%f, %f]], %f, %f]", + 0.0, + 0.0, + theta, + duration + ) + + val animation = AnimationBuilder.with(qiContext) + .withTexts(animationString) + .build() + + return AnimateBuilder.with(qiContext) + .withAnimation(animation) + .build() + } +} \ No newline at end of file diff --git a/pepper-point-at-root/pepper-point-at/src/main/res/values/strings.xml b/pepper-point-at-root/pepper-point-at/src/main/res/values/strings.xml new file mode 100644 index 0000000..cec5ab0 --- /dev/null +++ b/pepper-point-at-root/pepper-point-at/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Pepper Point at + diff --git a/pepper-point-at-root/sample-app/.gitignore b/pepper-point-at-root/sample-app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/pepper-point-at-root/sample-app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/pepper-point-at-root/sample-app/build.gradle b/pepper-point-at-root/sample-app/build.gradle new file mode 100644 index 0000000..57bd469 --- /dev/null +++ b/pepper-point-at-root/sample-app/build.gradle @@ -0,0 +1,39 @@ +apply plugin: 'com.android.application' + +apply plugin: 'kotlin-android' + +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 29 + buildToolsVersion "29.0.2" + defaultConfig { + applicationId "com.softbankrobotics.pepperpointat" + minSdkVersion 23 + targetSdkVersion 29 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.1.0' + implementation 'androidx.core:core-ktx:1.1.0' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'com.aldebaran:qisdk:1.6.7' + implementation 'com.aldebaran:qisdk-design:1.6.7' + implementation project(":pepper-point-at") +} diff --git a/pepper-point-at-root/sample-app/proguard-rules.pro b/pepper-point-at-root/sample-app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/pepper-point-at-root/sample-app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/pepper-point-at-root/sample-app/src/main/AndroidManifest.xml b/pepper-point-at-root/sample-app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..f86bdfc --- /dev/null +++ b/pepper-point-at-root/sample-app/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pepper-point-at-root/sample-app/src/main/java/com/softbankrobotics/pepperpointatsample/MainActivity.kt b/pepper-point-at-root/sample-app/src/main/java/com/softbankrobotics/pepperpointatsample/MainActivity.kt new file mode 100644 index 0000000..15ae1d0 --- /dev/null +++ b/pepper-point-at-root/sample-app/src/main/java/com/softbankrobotics/pepperpointatsample/MainActivity.kt @@ -0,0 +1,188 @@ +package com.softbankrobotics.pepperpointatsample + +import android.os.Bundle +import android.util.Log +import android.view.View +import com.aldebaran.qi.sdk.QiContext +import com.aldebaran.qi.sdk.QiSDK +import com.aldebaran.qi.sdk.RobotLifecycleCallbacks +import com.aldebaran.qi.sdk.`object`.actuation.Animate +import com.aldebaran.qi.sdk.`object`.actuation.Frame +import com.aldebaran.qi.sdk.`object`.conversation.* +import com.aldebaran.qi.sdk.`object`.locale.Language +import com.aldebaran.qi.sdk.`object`.locale.Locale +import com.aldebaran.qi.sdk.`object`.locale.Region +import com.aldebaran.qi.sdk.builder.* +import com.aldebaran.qi.sdk.design.activity.RobotActivity +import com.aldebaran.qi.sdk.design.activity.conversationstatus.SpeechBarDisplayStrategy +import com.softbankrobotics.pepperpointat.PointAtAnimation +import com.softbankrobotics.pepperpointat.PointAtAnimator +import kotlinx.android.synthetic.main.activity_main.* +import java.util.concurrent.Future + +class MainActivity : RobotActivity(), RobotLifecycleCallbacks, View.OnClickListener { + companion object { + private const val TAG = "MainActivity" + } + + private lateinit var qiContext: QiContext + private lateinit var pointAtAnimator: PointAtAnimator + + private lateinit var catFrame: Frame + private lateinit var cowFrame: Frame + + private lateinit var pointAtAnimateFuture: Future + + private lateinit var mainTopic: Topic + private lateinit var qiChatbot: QiChatbot + private lateinit var chat: Chat + + private lateinit var imHereAnimate: Animate + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setSpeechBarDisplayStrategy(SpeechBarDisplayStrategy.IMMERSIVE) + setContentView(R.layout.activity_main) + QiSDK.register(this, this) + + monkey.setOnClickListener(this) + tiger.setOnClickListener(this) + wolf.setOnClickListener(this) + lion.setOnClickListener(this) + pig.setOnClickListener(this) + cat.setOnClickListener(this) + horse.setOnClickListener(this) + cow.setOnClickListener(this) + } + + override fun onClick(view: View?) { + val animalName = view?.tag as String + goToBookmark(animalName) + runPointAtAnimation(animalName) + } + + private fun runPointAtAnimation(animalName: String) { + if (!::qiContext.isInitialized) { + return + } + + if (::pointAtAnimateFuture.isInitialized && !pointAtAnimateFuture.isDone) { + return + } + + pointAtAnimateFuture = when (animalName) { + "monkey" -> pointAtAnimator.playPointAnimation(PointAtAnimation.MEDIUM_LEFT) + "tiger" -> pointAtAnimator.playPointAnimation(PointAtAnimation.FRONT_RIGHT) + "dog" -> pointAtAnimator.playPointAnimation(PointAtAnimation.CLOSE_HALF_LEFT) + "wolf" -> pointAtAnimator.playPointAnimation(PointAtAnimation.CLOSE_FRONT_LEFT) + "pig" -> pointAtAnimator.playPointAnimation(PointAtAnimation.CLOSE_MEDIUM_RIGHT) + "horse" -> pointAtAnimator.playPointAnimation(PointAtAnimation.HALF_RIGHT) + "cat" -> pointAtAnimator.pointAt(catFrame) + "cow" -> pointAtAnimator.pointAt(cowFrame) + "pepper" -> imHereAnimate.async().run() + else -> return + } + } + + override fun onResume() { + super.onResume() + // Enables sticky immersive mode. + window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + // Set the content to appear under the system bars so that the + // content doesn't resize when the system bars hide and show. + or View.SYSTEM_UI_FLAG_LAYOUT_STABLE + or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + // Hide the nav bar and status bar + or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + or View.SYSTEM_UI_FLAG_FULLSCREEN) + } + + override fun onRobotFocusGained(qiContext: QiContext) { + Log.i(TAG, "onRobotFocusGained") + this.qiContext = qiContext + pointAtAnimator = PointAtAnimator(qiContext) + + // Build target Frames used to point at the giraffe and the panda + buildTargetFrames() + buildAndRunChat() + + // Build Animate to run when asking where's Pepper + val animation = AnimationBuilder.with(qiContext) + .withResources(R.raw.show_tablet_a004) + .build() + + imHereAnimate = AnimateBuilder.with(qiContext) + .withAnimation(animation) + .build() + } + + private fun buildTargetFrames() { + val tigerFreeFrame = qiContext.mapping.makeFreeFrame() + val cowFreeFrame = qiContext.mapping.makeFreeFrame() + val robotFrame = qiContext.actuation.robotFrame() + var transform = TransformBuilder.create().from2DTranslation(-1.0, -1.0) + tigerFreeFrame.update(robotFrame, transform, 0L) + catFrame = tigerFreeFrame.frame() + transform = TransformBuilder.create().from2DTranslation(-10.0, 10.0) + cowFreeFrame.update(robotFrame, transform, 0L) + cowFrame = cowFreeFrame.frame() + } + + private fun buildAndRunChat() { + // Create the topic + mainTopic = TopicBuilder.with(qiContext) + .withResource(R.raw.main) + .build() + + // Create the QiChatbot + qiChatbot = QiChatbotBuilder.with(qiContext) + .withTopic(mainTopic) + .withLocale(Locale(Language.ENGLISH, Region.UNITED_STATES)) + .build() + + // Create the Chat action + chat = ChatBuilder.with(qiContext) + .withChatbot(qiChatbot) + .withLocale(Locale(Language.ENGLISH, Region.UNITED_STATES)) + .build() + + // Go to "start" bookmark when launching Chat + chat.addOnStartedListener { + goToBookmark("start") + } + + // Launch Chat + chat.async().run() + + // Launch PointAtAnimations when reaching Bookmarks + qiChatbot.addOnBookmarkReachedListener { + runPointAtAnimation(it.name) + } + } + + private fun goToBookmark(bookmarkName: String) { + mainTopic.async().bookmarks.andThenConsume { + val bookmark = it[bookmarkName] + qiChatbot.goToBookmark( + bookmark, + AutonomousReactionImportance.HIGH, + AutonomousReactionValidity.IMMEDIATE + ) + } + } + + override fun onRobotFocusLost() { + Log.i(TAG, "onRobotFocusLost") + chat.removeAllOnStartedListeners() + } + + override fun onRobotFocusRefused(reason: String?) { + Log.e(TAG, "onRobotFocusRefused: $reason") + } + + override fun onDestroy() { + super.onDestroy() + QiSDK.unregister(this, this) + } +} diff --git a/pepper-point-at-root/sample-app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/pepper-point-at-root/sample-app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..1f6bb29 --- /dev/null +++ b/pepper-point-at-root/sample-app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/pepper-point-at-root/sample-app/src/main/res/drawable/background.png b/pepper-point-at-root/sample-app/src/main/res/drawable/background.png new file mode 100644 index 0000000..e43b294 Binary files /dev/null and b/pepper-point-at-root/sample-app/src/main/res/drawable/background.png differ diff --git a/pepper-point-at-root/sample-app/src/main/res/drawable/ic_launcher_background.xml b/pepper-point-at-root/sample-app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..0d025f9 --- /dev/null +++ b/pepper-point-at-root/sample-app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pepper-point-at-root/sample-app/src/main/res/layout/activity_main.xml b/pepper-point-at-root/sample-app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..8c5c861 --- /dev/null +++ b/pepper-point-at-root/sample-app/src/main/res/layout/activity_main.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pepper-point-at-root/sample-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/pepper-point-at-root/sample-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/pepper-point-at-root/sample-app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/pepper-point-at-root/sample-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/pepper-point-at-root/sample-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..eca70cf --- /dev/null +++ b/pepper-point-at-root/sample-app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/pepper-point-at-root/sample-app/src/main/res/mipmap-hdpi/ic_launcher.png b/pepper-point-at-root/sample-app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..898f3ed Binary files /dev/null and b/pepper-point-at-root/sample-app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/pepper-point-at-root/sample-app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/pepper-point-at-root/sample-app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..dffca36 Binary files /dev/null and b/pepper-point-at-root/sample-app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/pepper-point-at-root/sample-app/src/main/res/mipmap-mdpi/ic_launcher.png b/pepper-point-at-root/sample-app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..64ba76f Binary files /dev/null and b/pepper-point-at-root/sample-app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/pepper-point-at-root/sample-app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/pepper-point-at-root/sample-app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..dae5e08 Binary files /dev/null and b/pepper-point-at-root/sample-app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/pepper-point-at-root/sample-app/src/main/res/mipmap-xhdpi/ic_launcher.png b/pepper-point-at-root/sample-app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..e5ed465 Binary files /dev/null and b/pepper-point-at-root/sample-app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/pepper-point-at-root/sample-app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/pepper-point-at-root/sample-app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..14ed0af Binary files /dev/null and b/pepper-point-at-root/sample-app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/pepper-point-at-root/sample-app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/pepper-point-at-root/sample-app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..b0907ca Binary files /dev/null and b/pepper-point-at-root/sample-app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/pepper-point-at-root/sample-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/pepper-point-at-root/sample-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..d8ae031 Binary files /dev/null and b/pepper-point-at-root/sample-app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/pepper-point-at-root/sample-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/pepper-point-at-root/sample-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..2c18de9 Binary files /dev/null and b/pepper-point-at-root/sample-app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/pepper-point-at-root/sample-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/pepper-point-at-root/sample-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..beed3cd Binary files /dev/null and b/pepper-point-at-root/sample-app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/pepper-point-at-root/sample-app/src/main/res/raw/main.top b/pepper-point-at-root/sample-app/src/main/res/raw/main.top new file mode 100644 index 0000000..85f8843 --- /dev/null +++ b/pepper-point-at-root/sample-app/src/main/res/raw/main.top @@ -0,0 +1,122 @@ +topic: ~main() + +concept:(where_is_the) [ + "{"do you know"} where is the" + "where's the" + "I'm looking for the" + "{"[can could] you"} show me the" + "{"[can could] you"} point at the" + "{"[can could] you"} locate the" + the +] + +proposal: %start +^rand[ + "Let me help you ^rand[find locate] the animals around me." + "Let's ^rand[find locate] the animals around me." + "We're going to ^rand[find locate] the animals around me." +] +^rand[ + "Which one are you ^rand["looking for" "interested in"]?" + "Tell me which one you're ^rand["looking for" "interested in"]!" + "Please choose one!" +] + +u:([ + "{~where_is_the} dog" + "do you know where the dog is" +]) %dog +^rand[ + "The dog is {really} close to me, on my left." + "The dog is on ^rand[the my] left, really close to me." + "The dog is close to me, right by my left hand." +] + +u:([ + "{~where_is_the} wolf" + "do you know where the wolf is" +]) %wolf +^rand[ + "The wolf is right in front of me, a little bit ^rand[to on] ^rand[the my] left." + "The wolf is right in front of my left ^rand[hand wheel]." + "The wolf is really close to me, right in front of my left ^rand[hand wheel]." +] + +u:([ + "{~where_is_the} pig" + "do you know where the pig is" +]) %pig +^rand[ + "The pig is on the right in front of me, really close." + "The pig is just in front of me, on ^rand[the my] right." + "The pig is close to me, 45 degrees in front and to ^rand[the my] right." +] + +u:([ + "{~where_is_the} cat" + "do you know where the cat is" +]) %cat +^rand[ + "The cat is on the right behind me, really close." + "The cat is just behind me, on ^rand[the my] right." + "The cat is close to me, 45 degrees behind and to ^rand[the my] right." +] + +u:([ + "{~where_is_the} tiger" + "do you know where the tiger is" +]) %tiger +^rand[ + "The tiger is in front of me, {just} a little {bit} further on ^rand[the my] right." + "The tiger is in front of me, {just} a little on ^rand[the my] right." + "The tiger is in front of my right ^rand[hand wheel], but a little {bit} further off." +] + +u:([ + "{~where_is_the} horse" + "do you know where the horse is" +]) %horse +^rand[ + "The horse is far away from me, on ^rand[the my] right." + "The horse is far away on ^rand[the my] right." + "The horse is on ^rand[the my] right, far away from me." +] + +u:([ + "{~where_is_the} cow" + "do you know where the cow is" +]) %cow +^rand[ + "The cow is behind me, far to the left." + "The cow is far away, on the left behind me." + "The cow is far away, behind me ^rand[to on] ^rand[the my] left." + "The cow is far away behind me, ^rand[to on] ^rand[the my] left." + "The cow is far away behind me, 45 degrees to ^rand[the my] left." + "The cow is far away {"from me"}, 45 degrees behind and to ^rand[the my] left." +] + +u:([ + "{~where_is_the} monkey" + "do you know where the monkey is" +]) %monkey +^rand[ + "The monkey is in front of me, {but} far to the left." + "The monkey is far away, on the left in front of me." + "The monkey is far away, in front of me ^rand[to on] ^rand[the my] left." + "The monkey is far away in front of me, ^rand[to on] ^rand[the my] left." + "The monkey is far away in front of me, 45 degrees to ^rand[the my] left." + "The monkey is far away {"from me"}, 45 degrees in front and to ^rand[the my] left." +] + +u:([ + "where are you" + "where is Pepper" + "{~where_is_the} robot" + "do you know where you are" + "do you know where [Pepper "the robot"] is" +]) %pepper +^rand[ + "I'm here!" + "Here I am!" + "Right here!" +] diff --git a/pepper-point-at-root/sample-app/src/main/res/raw/show_tablet_a004.qianim b/pepper-point-at-root/sample-app/src/main/res/raw/show_tablet_a004.qianim new file mode 100644 index 0000000..7eb4423 --- /dev/null +++ b/pepper-point-at-root/sample-app/src/main/res/raw/show_tablet_a004.qianim @@ -0,0 +1,303 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pepper-point-at-root/sample-app/src/main/res/values/colors.xml b/pepper-point-at-root/sample-app/src/main/res/values/colors.xml new file mode 100644 index 0000000..69b2233 --- /dev/null +++ b/pepper-point-at-root/sample-app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #008577 + #00574B + #D81B60 + diff --git a/pepper-point-at-root/sample-app/src/main/res/values/strings.xml b/pepper-point-at-root/sample-app/src/main/res/values/strings.xml new file mode 100644 index 0000000..cec5ab0 --- /dev/null +++ b/pepper-point-at-root/sample-app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + Pepper Point at + diff --git a/pepper-point-at-root/sample-app/src/main/res/values/styles.xml b/pepper-point-at-root/sample-app/src/main/res/values/styles.xml new file mode 100644 index 0000000..5885930 --- /dev/null +++ b/pepper-point-at-root/sample-app/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/pepper-point-at-root/sample-app/src/main/res/xml/backup_descriptor.xml b/pepper-point-at-root/sample-app/src/main/res/xml/backup_descriptor.xml new file mode 100644 index 0000000..6fd6103 --- /dev/null +++ b/pepper-point-at-root/sample-app/src/main/res/xml/backup_descriptor.xml @@ -0,0 +1,4 @@ + + + + diff --git a/pepper-point-at-root/settings.gradle b/pepper-point-at-root/settings.gradle new file mode 100644 index 0000000..96e6682 --- /dev/null +++ b/pepper-point-at-root/settings.gradle @@ -0,0 +1,2 @@ +include ':sample-app', ':pepper-point-at' +rootProject.name='Pepper Point at'