1

I want to detect people without relying on face detection. In cases where lighting conditions are poor, or Pepper is facing away, people are not detected. The memory events 'PeoplePerception/JustArrived' and 'EngagementZones/PersonApproached' seem to rely on faces being detectable by the camera. Is there a memory event which is triggered by changes in laser/infrared/sonar distance?

I wonder if there is a better solution than:

while True:
    floatDist = self.memory.getData('Device/SubDeviceList/Platform/Front/Sonar/Sensor/Value')
    if floatDist < 1.0:
        doSomething() 
    sleep(0.5)
4

1 回答 1

1

You can use the front sonar and the event "FaceDetected" for the human detection.

But you can use a PeriodicTask and not a while loop. You while check the event each 0.5secs and you will be allowed to stop it.

I will do it like that :

class HumanDetector:
    def __init__(self, ALMemory):
        self.ALMemory = ALMemory

        # subscribe to FaceDetected
        self.subscriber = self.ALMemory.subscriber("FaceDetected")
        self.subscriber.signal.connect(self.on_human_tracked)

        self.task = qi.PeriodicTask()
        self.task.setCallback(self._task)
        self.task.setUsPeriod(50000)
        self.task.start(True)

    def on_human_tracked(self, value):
        print "do something with the face"

    def _stop(self):
        print "_stop..."
        self.task.stop()
        self.face_detection.unsubscribe("FaceDetected")
        print "_stop done"

    def _task(self):
        print "_task..."
        floatDist = self.memory.getData('Device/SubDeviceList/Platform/Front/Sonar/Sensor/Value')
        if floatDist < 1.0:
            print "do something with the object in front of the robot"

        print "_task done"

So it is an example of a python Class that need the module ALMemory. With the module ALMemory you will check the sonar and if a face is detected.

于 2017-10-12T13:50:39.087 回答