Yumi und die ersten Schritte mit Kotlin

  • Veröffentlicht am
  • von

Yumi war zurück. Aber sie konnte erst einmal gar nichts.

Aber SB hatte ja eine auf den ersten Blick recht vernünftige Doku.

Also alles nach Vorgabe abgearbeitet:

- Android Studio installiert

- Pepper SDK installiert

- erstes Projekt aufgebaut

- Zur Robot-Anwendung gemacht

Die erste MainActivity erstellt. Alles wohlgemerkt exakt nach Schritt für Schritt ANleitung.

*ruuuuuuummmmmssssss*

Ging natürlich nicht.. Bibliotheken nicht gefunden, alles Mist.

STUUUUUUUUUUUUUUUNDENLANGES wühlen im Netz später.

1. Die Settings.gradle Datei muss so aussehen:

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
maven {
url 'http://android.aldebaran.com/sdk/maven'
allowInsecureProtocol = true
}
}
}
rootProject.name = "HalloYumi"
include ':app'

Natürlich kann der String "HalloYumi" gegen den eigenen Programmnamen getauschrt werden.

Aber das hat nicht gereicht.

In die MainActivity mussten noch jede Menger importds eingefügt werden.

Eine Basis-MainActivity sieht also so aus:

package com.example.halloyumi

import android.os.Bundle
import android.util.Log
import android.view.View
import com.aldebaran.qi.Future
import com.aldebaran.qi.sdk.QiContext
import com.aldebaran.qi.sdk.QiSDK
import com.aldebaran.qi.sdk.RobotLifecycleCallbacks
import com.aldebaran.qi.sdk.builder.ChatBuilder
import com.aldebaran.qi.sdk.builder.QiChatbotBuilder
import com.aldebaran.qi.sdk.builder.SayBuilder
import com.aldebaran.qi.sdk.builder.TopicBuilder
import com.aldebaran.qi.sdk.design.activity.RobotActivity
import com.aldebaran.qi.sdk.`object`.conversation.Chat
import com.aldebaran.qi.sdk.`object`.conversation.QiChatbot
import com.aldebaran.qi.sdk.`object`.conversation.Say
import com.aldebaran.qi.sdk.`object`.conversation.Topic

class MainActivity : RobotActivity(), RobotLifecycleCallbacks {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Register the RobotLifecycleCallbacks to this Activity.
QiSDK.register(this, this)
}

override fun onDestroy() {
// Unregister the RobotLifecycleCallbacks for this Activity.
QiSDK.unregister(this, this)
super.onDestroy()
}

override fun onRobotFocusGained(qiContext: QiContext) {
// The robot focus is gained.
val say: Say = SayBuilder.with(qiContext) // Create the builder with the context.
.withText("Hallo Papa san und hallo Mama san") // Set the text to say.
.build() // Build the say action.

// Execute the action.
say.run()
}

override fun onRobotFocusLost() {
// The robot focus is lost.
}

override fun onRobotFocusRefused(reason: String) {
// The robot focus is refused.
}
}

Wenn man das Programm nun mittels Sideloading (Entwicklermodus des Tabletts) auf den Roboter überträgt, findet man ein kleines neues Programm auf dem Tablett.

Startet man das ... *Trommelwirbel* spricht Yumi wieder!

Yay!

Ron 1 Tor

Softbank 0 Tore!