Localization Library

v1.0.2 - Documentation last updated on 29/04/2021

Localization Library is an optional Android library containing high level APIs.

It allows application developers to retrieve maps previously created using the Localization Setup application.

Minimum configuration

  • Pepper 1.9
  • QiSDK API level 7 (dependency on ExplorationMap and StreamableBuffer APIs)
  • A real robot (does not work on a virtual robot)
  • Localization Setup application installed on the robot

Setup

Add the dependency to your module’s build.gradle file:

implementation 'com.aldebaran:qisdk-localization:1.0.2'

Concepts

A Place represents a physical place. Each application can have 1 Place, or no Place.

A Place contains an ExplorationMap and a list of PointOfInterest. Each PointOfInterest has a name and a transform with respect to the mapFrame.

Usage

Get the ExplorationMap

val place: Place? = Localization.requestPlace(qiContext)
// The Place is nullable, don't forget to null-check it.
if (place != null) {
    val explorationMap: ExplorationMap = place.explorationMap
    // Do something with the ExplorationMap.
} else {
    // No Place found.
}

Get the Points of Interest

val place: Place? = Localization.requestPlace(qiContext)
// The Place is nullable, don't forget to null-check it.
if (place != null) {
    val pointsOfInterest: List<PointOfInterest> = place.pointsOfInterest
    pointsOfInterest.forEach { poi: PointOfInterest ->
        Log.i("POI", "${poi.name} is at ${poi.transform}")
    }
}

Build the frames associated to the Points of Interest

val place: Place? = Localization.requestPlace(qiContext)
// The Place is nullable, don't forget to null-check it.
if (place != null) {
    // Build Localize action
    val explorationMap = place.explorationMap
    val localize = LocalizeBuilder.with(qiContext)
        .withMap(explorationMap)
        .build()

    // Build the POI frames once localized
    localize.addOnStatusChangedListener { status ->
        if (status == LocalizationStatus.LOCALIZED) {
            val mapFrame = qiContext.mapping.mapFrame()
            place.pointsOfInterest.forEach {
                val frame = mapFrame.makeAttachedFrame(it.transform).frame()
                // Store or use the frame
            }
        }
    }

    // Run Localize action
    localize.async().run()
}

Note: you can request the Place asynchronously using Localization.async().requestPlace(qiContext).

See also

License

See the COPYING file for the license.