Skip to main content
Version: QTrobot V3

Face and Emotion

The /qtrobot/face/... services control QTrobot's animated face — playing emotions and moving its gaze. These examples assume the gateway from Connection is already running.

List available emotions

ros2 service call /qtrobot/face/emotion/list qtrobot_interfaces/srv/FaceEmotionList "{}"

Show an emotion

#!/usr/bin/env python3
import rclpy
from rclpy.node import Node
from qtrobot_interfaces.srv import FaceEmotionShow, FaceEmotionStop


class FaceClient(Node):
def __init__(self):
super().__init__('face_client')
self.show_client = self.create_client(FaceEmotionShow, '/qtrobot/face/emotion/show')
self.stop_client = self.create_client(FaceEmotionStop, '/qtrobot/face/emotion/stop')
self.show_client.wait_for_service(timeout_sec=5.0)

def show(self, emotion: str, speed: float = 1.0):
future = self.show_client.call_async(FaceEmotionShow.Request(emotion=emotion, speed=speed))
rclpy.spin_until_future_complete(self, future)
return future.result()

def stop(self):
future = self.stop_client.call_async(FaceEmotionStop.Request())
rclpy.spin_until_future_complete(self, future)
return future.result()


def main():
rclpy.init()
node = FaceClient()
node.show('QT/happy')
node.destroy_node()
rclpy.shutdown()


if __name__ == '__main__':
main()

Emotion names follow the <group>/<name> pattern returned by /qtrobot/face/emotion/list, such as QT/happy or QT/sad.

Stop an emotion

ros2 service call /qtrobot/face/emotion/stop qtrobot_interfaces/srv/FaceEmotionStop "{}"

Look at a point

ros2 service call /qtrobot/face/look qtrobot_interfaces/srv/FaceLook \
"{l_eye: '[0.2, 0.1]', r_eye: '[0.2, 0.1]', duration: 1.0}"

l_eye/r_eye are JSON-encoded [x, y] normalized gaze targets, and duration is how long the movement should take, in seconds.

Next steps

Continue with the Gesture tutorial, or see the full face namespace in the ROS2 API Reference.