softbankrobotics-labs / pepper-aruco

A library for Pepper QiSDK, to find Aruco markers, and provide their position as a frame, useful for localization and navigation.
BSD 3-Clause "New" or "Revised" License
15 stars 5 forks source link

About id determination of Aruco mark #2

Open d16310 opened 4 years ago

d16310 commented 4 years ago

Hello

I always use it for the development of pepper. I have one question this time

I want the ”EngageAndReturnToMarkerActivity” program to determine the id and change the behavior depending on the id. What should I do? For example, after reading "id10", move to "id10" and search 1 meter ahead again. For example, if you read "id11", say "Hello".

I generally understand "waitToDetectAMarkerInFront" and "goToFrame" Please tell me how to add "marker.id" to the conditional statement (if).

I'm sorry if it's hard to understand the meaning. There may be a mistake because it was translated by google translate.

Thank you as always. Please be careful about "COVID-19" and do your best in research and development.

rhumbert commented 3 years ago

Hello !

You might do something like this:

say(qiContext, "Please place a 4x4 Aruco Marker on the floor in front of me.").andThenCompose {

    Log.d(TAG, "STATE: hold basic awareness")
    holder = holdAutonomousAbilities(qiContext, AutonomousAbilitiesType.BASIC_AWARENESS)
    holder

}.andThenCompose {

    Log.d(TAG, "STATE: detect marker")
    displayLine("Detection started", ConversationItemType.INFO_LOG)
    waitToDetectAMarkerInFront(qiContext)

}.andThenCompose { marker ->

    arucoMarker = marker
    displayLine("Detection stopped", ConversationItemType.INFO_LOG)
    say(qiContext,"I see marker ${marker.id}, this marker will represent my home position.")

    when (marker.id) {
        10 -> { say("Hello") }
        11 -> {
            // ....
        }
        else -> {
        }
    }
}   // Remove all the code that was here

If you have a hard time understanding the .andThenCompose syntax, you can read the documentation which is available here: https://developer.softbankrobotics.com/pepper-qisdk/principles/chaining-operations

Hope it helps