Skip to main content
Version: QTrobot V3

Face and Emotion

robot.face controls QTrobot's face display — playing emotion animations and moving the eyes. These examples assume you already have a connected robot — see Connection if you haven't set one up yet.

Setup

<script src="https://cdn.jsdelivr.net/npm/@luxai-qtrobot/robot-sdk/dist/qtrobot-sdk.umd.js"></script>
npm install @luxai-qtrobot/robot-sdk

List emotions

const emotions = await robot.face.listEmotions()
console.log(`Available emotions (${emotions.length}):`)
for (const e of emotions) {
console.log(` ${e}`)
}

Show emotion

// Play an emotion and wait for it to finish
await robot.face.showEmotion({ emotion: 'QT/kiss' })

// Play an emotion at 2x speed
await robot.face.showEmotion({ emotion: 'QT/surprise', speed: 2.0 })

Cancel an emotion

const controller = new AbortController()
const emotion = robot.face.showEmotion({
emotion: 'QT/breathing_exercise',
signal: controller.signal,
})

setTimeout(() => controller.abort(), 3000)

try {
await emotion
} catch {
console.log('Emotion cancelled.')
}

Look (eye gaze)

// Move both eyes to the right
await robot.face.look({ l_eye: [30, 0], r_eye: [30, 0] })

// Move eyes up-left
await robot.face.look({ l_eye: [-20, -20], r_eye: [-20, -20] })

// Move eyes down, auto-reset to centre after 3 seconds
await robot.face.look({ l_eye: [0, 20], r_eye: [0, 20], duration: 3.0 })

Next steps

Continue with the Gesture tutorial, or see the full robot.face namespace in the TypeScript/Node.js API Reference.