Search code examples
javascriptpepper

How can I continuously detect if someone is in front of Pepper?


I've been toying with:

PeoplePerception/PeopleDetected()

PeoplePerception/PopulationUpdated()

PeoplePerception/PeopleList()

PeoplePerception/NonVisiblePeopleList()

PeoplePerception/VisiblePeopleList()

Yet I cant seem to figure out how to detect if there is someone in front of Pepper. Those events trigger when the population is updated, but I can't make sense out of the returning values.

What I'm trying to accomplish is to make Pepper remain in a certain state as long as someone is within the detection area number 2 and make it go to a "screensaver" when it doesnt detect someone for 1 minute.

I'm fairly new when it comes to Pepper development, so any help would be apreciated, thank you!


Solution

  • It sounds like you want to combine the ALPeoplePerception API with the ALEngagmentZones API. This is described in some detail here. There's a key in ALMemory (Pepper's memory) that does what you want - stores a list of all people in engagement zone 2 (EngagementZones/PeopleInZone2).

    You've tagged the question as javascript, so I'll give a brief example with how to access this.

    QiSession(function (session){
        session.service("ALMemory").then(function(mem) {
            mem.getData("EngagementZones/PeopleInZone2").then(function(data) {
                // now you can access data and do something with it...
                // it should be a list of IDs of the people in the engagement zone
                // so you could check data.length > 0 to see if there's any people
            }, console.log);
        }, console.log);
    }, console.log);
    

    There are also other events that might be useful, like EngagementZones/PersonEnteredZone2. If you haven't found it yet, there's more details about the javascript API here.