Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

A demo where a pepper tries to keep a person in the center of the frame, without the information being processed by the user’s laptop

...

Code Block

languagepy
pepper = Pepper(device_id="pepper1") facerec = self.connect(FaceRecognitionService, device_id='local') lookat = self.connect(LookAtPersonService, device_id='local') facerec.register_input(pepper.top_camera) lookat.register_input(facerec) pepper.motion.register_input(lookat)There is a list of targets that Nao can track using the Naoqi Tracker API, which works well under good lighting conditions. Here is a walkthrough on how to track a face with its head and a red ball with its arms.

Track a face with Nao’s head

  1. First, import the necessary functions from the SIC framework:

Code Block
from sic_framework.devices import Nao
from sic_framework.devices.common_naoqi.naoqi_stiffness import Stiffness
from sic_framework.devices.common_naoqi.naoqi_tracker import (
    RemoveTargetRequest,
    StartTrackRequest,
    StopAllTrackRequest,
)
  1. Connect to the Nao (computer must be connected to the same network)

Code Block
nao = Nao(ip="NAO_IP_HERE")
  1. Set a tracking target, a list of available targets can be found here: http://doc.aldebaran.com/2-5/naoqi/trackers/index.html#target-names

Code Block
target_name = "Face"
  1. Since we want to use the head to track a face, we need to set the stiffness to 1 to enable the motors to control the head joint

Code Block
nao.stiffness.request(Stiffness(stiffness=1.0, joints=["Head"]))
  1. Start tracking, the size is the diameter of the target and a list of available modes can be found here: http://doc.aldebaran.com/2-5/naoqi/trackers/index.html#tracking-modes

Code Block
nao.tracker.request(
    StartTrackRequest(target_name=target_name, size=0.2, mode="Head", effector="None")
)
  1. Unregister a target

Code Block
nao.tracker.request(RemoveTargetRequest(target_name))

Track a red ball with Nao’s arms

  1. Set a new target

Code Block
target_name = "RedBall"
  1. Set a robot position relative to target. This is only needed in Move mode. The parameters represent [coordX, coordY, coordWz, thresholdX, thresholdY, thresholdWz]. In this case, the robot stays 30 cm away (along the x-axis) with a 10 cm threshold from the red ball. The XYZ frame reference for the robot can be found here position-identification

Code Block
move_rel_position = [-0.3, 0.0, 0.0, 0.1, 0.1, 0.1]
  1. Track a red ball

Code Block
nao.tracker.request(
    StartTrackRequest(
        target_name=target_name,
        size=0.06,
        mode="Move",
        effector="Arms",
        move_rel_position=move_rel_position,
    )
)

4. Stop all tracking. This will put the robot into rest mode, unlocking all joints and setting stiffness to 0

Code Block
nao.tracker.request(StopAllTrackRequest())

A complete script for this tutorial can be found here: demo_nao_tracker.py