Connecting to sources…

How to build UBTECH Alpha Mini (Wukong): the whole process

160 steps to build UBTECH Alpha Mini (Wukong), from buying parts, printing and assembly to software, calibration and training, with the bill of materials, shop links and…

UBTECH's site shows no price and no official store page selling it was found; the Python SDK and demos are free (PyPI, GitHub)

Buy parts

  • Download the open SDK

    Download the open SDK from the download resources page.

Assemble

  • Connect the robot by USB

    Connect the robot to the PC with a USB cable.

Software

  • Download and install Python

    Download and install Python according to the installation environment section.

  • Install PyCharm

    Install PyCharm.

  • Download and run the demo

    Clone the mini_demo repository, switch to the oversea_develop branch, and run the demo.

  • Import the AlphaMini SDK

    Import mini.mini_sdk in the Python program and access the SDK with the MiniSdk name.

  • Connect to the robot

    Call MiniSdk.connect with a WiFiDevice. The call returns a boolean, which the example ignores.

  • Disconnect and release resources

    Wait 1 second, then call MiniSdk.release to disconnect and release resources.

  • Set the SDK log level

    The default log level is Warning. Set the log level to INFO.

  • Import the MiniSdk APIs

    Import the APIs in mini.apis with from mini.apis import *.

  • Stop the playing sound

    Start text-to-speech with is_serial=False, wait 3 seconds, then send the command to stop all audio and read the result.

  • Test face detection

    Create a face-detection interface with a 10-second timeout, wait for the response, and print the result. The result includes the face count, success status, and return code.

  • Test and switch off mouth light

    Call ControlMouthLamp with is_open set to False, then print the execution result.

  • Test the translation interface

    Use StartTranslate to translate “Jacky Cheung” from Chinese to English, wait for the response, and print the result.

  • Test Registered Face Recognition

    Create an ObserveFaceRecognise observer and set its handler. When recognition succeeds and faceInfos is returned, stop the observer and use PlayTTS to say the recognized name.

  • Test Face Detection

    Create an ObserveFaceDetect observer and set its handler. When detection succeeds and count is nonzero, stop the observer and use PlayTTS to announce the number of people in front.

  • Create posture observer

    Create an ObserveRobotPosture listener, define the event handler, assign the handler, start the observer, and wait with asyncio.sleep(0).

  • Detect falling and stop observer

    The event handler prints the received message. When the status is 8 or 7, the observer stops and creates an __tts() task.

  • Play fall voice prompt

    __tts() plays the voice message “I fell down” and then stops the event loop through the running loop’s executor.

  • Run posture detection test

    The main program gets a device by name, connects to it, starts the run program, and executes the posture observer test. It then keeps the event loop running with run_forever() and calls shutdown().

  • Package and Install a Python Program

    After debugging the program on a PC, package the project as a .whl or .egg file, write setup.py in the project root, and use pip to install it in the robot's built-in Python 3.8 environment and trigger execution. Use AlphaMini SDK V1.0.0 or higher and an AlphaMini robot v1.4.0 or higher.

  • Install Packaging Tools

    Make sure the latest versions of setuptools, wheel, and twine are installed on the PC.

  • Write the Basic setup.py Configuration

    Create setup.py in the project directory and use the demo as a reference to configure the program name, version, author, author email, short and long descriptions, license, and package discovery. The example uses tts_demo as the program name, version 0.0.2, and setuptools.find_packages() to find packages.

  • Configure Dependencies and Command Entry

    Declare the alphamini dependency module in install_requires. Define the tts_demo = play_tts.test_playTTS:main command-line entry under console_scripts in entry_points.

  • Fill in setup.py Metadata Parameters

    Fill in setup.py using the listed parameters: --name, --version (-V), --author, --author_email, --maintainer, --maintainer_email, --url, license authorization information, and --description.

  • Configure setup.py Packaging Options

    In setup.py, set long_description, platforms, classifiers, keywords, packages, py_modules, download_url, cmdclass, data_files, scripts, package_dir, define, and provides. Packages contain __init__.py, py_modules lists Python files, package_dir maps source package directories, and data_files includes data such as images and configuration files.

  • Find Packages and Declare Dependencies

    find_packages() searches by default for packages containing __init__.py beside setup.py; packages can also be placed in one src directory and contain aaa.txt files and data folders. Exclude test packages with the listed patterns and declare the requests dependency with install_requires = ["requests"].

  • Define a Command-Line Entry

    Define the command-line tool in the console_scripts section of entry_points. The example tts_demo = play_tts.test_playTTS:main specifies the tool name before the equals sign and the program entry address after it.

  • Add Multiple Command-Line Tools

    A project's entry_points can contain multiple records to create multiple command-line tools. The example maps both foo and bar to demo:test.

  • Package the Project from the CLI

    After writing setup.py in the project directory, package it with python setup.py sdist bdist_wheel. You can also specify the Python project directory with setup_py_pkg "your py project directory".

  • Package with the AlphaMini Toolkit

    Use the AlphaMini inner toolkit to package the tts_demo project in the current directory into a Python wheel. pkg_path stores the path of the resulting whl file, and print(f'{pkg_path}') outputs that path.

  • Install a Python Package via Command

    Make sure the robot and PC are on the same LAN. Upload the .whl file, make the robot execute pip install xx.whl first, then enter the last four digits of the robot serial number and run the installation command.

  • Install a Package with Python SDK

    Make sure the robot and PC are on the same LAN and upload the .whl file. Set the robot type to EDU, then call the installation tool with the package path and the last four digits of the robot serial number.

  • List Robot Python Modules

    Run list_py_pkg with the last four digits of the robot serial number and use the EDU type to query Python packages installed in the robot.

  • List Python Packages with SDK

    Set the robot type to EDU and call list_py_pkg with the robot ID. Print the returned information about Python packages in the robot.

  • Query Python Module Specification

    Make sure the robot and PC are on the same LAN. Run pip show xx to query a Python module specification, using tts_demo as the example, and specify the last four digits of the robot serial number.

  • Query Module Specification with SDK

    Set the robot type to EDU and call query_py_pkg with the package name and robot ID. Print the query result for the tts_demo package.

  • Set SDK Log Level

    The default log level is Warning; set it to INFO.

  • Import Mini SDK APIs

    Import the APIs from mini.apis for the robot-control examples.

  • Play Text-to-Speech Audio
  • Play an Online Sound Effect

    Use PlayAudio with the NET_PUBLIC storage type to play the specified online MP3 sound effect and wait for the result. Supported formats include mp3, amr, and wav.

  • Play preset local audio read_016

    Use the PlayAudio block with url "read_016" and storage_type AudioStorageType.PRESET_LOCAL to play the robot's built-in sound and wait for the result.

Calibrate and test

  • Test Face Gender Analysis

    Create FaceAnalysis with a 10-second timeout, await execute(), and print the analysis result, result code, and vision error string. The response contains age, gender, height, and width; gender values below 50 are female and above 50 are male, and the largest face by frame proportion is returned when several people are present.

  • Test Flower Recognition

    Manually place a flower or a photo of a flower in front of the robot, create ObjectRecognise with FLOWER and a 10-second timeout, and await the recognition result. The response contains an array of object names, a success indicator, and a result code.

  • Test Fruit Recognition

    Manually place fruit or a photo of fruit in front of the robot, create ObjectRecognise with FRUIT and a 10-second timeout, and await the recognition result. The response contains an array of object names, a success indicator, and a result code.

  • Test Gesture Recognition

    Use ObjectRecogniseType.GESTURE and wait up to 10 seconds for the robot's gesture-recognition result. The response contains an object-name array, success status, and result code.

  • Test Immediate Photo Capture

    Make the robot take a picture immediately and wait for the result. Use the IMMEDIATELY picture type; the response includes success status, return code, and the photo's storage path on the robot.

  • Test Face Recognition

    Run the robot's face-recognition detection with a 10-second timeout and wait for the result. The response contains a face-information array with ID, name, gender, and age, plus success status and result code.

  • Set green mouth lamp

    Call SetMouthLamp to set the mouth lamp to normal mode and green for 3000 milliseconds, with breath_duration set to 1000 milliseconds. Wait for the robot response and print it.

  • Turn off mouth lamp

    Call ControlMouthLamp with is_open set to False to turn off the robot's mouth lamp. Wait for the operation result and print the response.

  • Create the head touch observer

    Create an ObserveHeadRacket object to listen for head touch events.

  • Handle head touch events

    Set an event handler on the observer. Event types are SINGLE_CLICK, LONG_PRESS, and DOUBLE_CLICK; after an event, stop listening, print its type, and start the dance task.

  • Run the touch-triggered dance

    Execute the ControlBehavior dance named dance_0002.

  • Start the touch-listener program

    After obtaining the device, connect it, start the run program, and execute the touch listener; the event loop must keep running when an event observer is defined.

  • Play the Wukong speech
  • Create the speech recognition observer
  • Start the speech recognition program

    After obtaining the device, connect it, start the run program, and begin speech recognition listening; keep the event loop running and finally execute shutdown().

  • Create the infrared distance observer

    Create an ObserveInfraredDistance observer and define its handler; the observation response includes distance.

  • Test infrared distance sensor
  • Test face recognition observer

    Create a face-recognition observer and register its event handler. The handler prints the response; when recognition succeeds and faceInfos is present, it stops the observer and greets the first recognized name by voice.

  • Speak the recognized name
  • Query Robot Python Package Information

    Ensure the robot and PC are on the same LAN and specify the robot serial number or its last five digits. The query sends the pip list command to the robot and returns the result.

  • List All Python Modules

    Use the SDK to set the robot type to DEDU. Query the Python packages installed on robot 0090 and print the result.

  • Query a Specific Python Module

    Ensure the robot and PC are on the same LAN and specify the robot serial number or its last five digits. In the example, xx represents tts_demo; the tool sends pip show xx to the robot and returns the result.

  • Query tts_demo Through the SDK

    Set the robot type to DEDU. Query the tts_demo package information using robot 0090’s serial number and print the result.

  • Set log level and robot type

    Set the log level to INFO and set the robot type to MiniSdk.RobotType.EDU before scanning for robots on the LAN.

  • Search by robot serial number

    Search for the robot using the serial number on the back of the robot. The serial number length is arbitrary, but more than five characters are recommended for an exact match, with a 10-second timeout.

  • Get the robot device list

    Get the device list for the robot with the specified serial number, with a 10-second timeout.

  • Connect to the robot

    Use MiniSdk.connect() to connect to the robot based on the scanning results.

  • Test online audio playback

    Create a PlayAudio block with the NET_PUBLIC storage type and an MP3 URL, then execute it and inspect the response, resultCode, and error message.

  • Test preset local audio

    Create a PlayAudio block with the PRESET_LOCAL storage type and the built-in sound name read_016, then execute it and inspect the response and error message.

  • Test infrared detection distance

    Execute GetInfraredDistance, wait for the result, and print the response containing the infrared distance.

  • Test registered face information

    Execute GetRegisterFaces, wait for the results, and print the response. The response includes face IDs, names, genders, ages, success status, and return codes.

  • Test robot expression

    Create a PlayExpression with the address name "codemao1", execute it, wait for the reply results, and print the response. The response includes success status and return code.

  • Test Moving the Robot Left

    Execute MoveRobot to move the robot left by 10 steps, wait for the response, and print the result.

  • Get the Built-In Action List

    Use RobotActionType.INNER to get the list of non-modifiable action files built into the robot, and wait for the response.

  • Set Up Touch Event Listening

    Create an ObserveHeadRacket listener and set its event handler. When an event occurs, stop listening, print the event type, and start the dance task.

  • Execute the Built-In Dance

    In the touch event handler, call ControlBehavior to execute the dance named dance_0002, then stop the event loop.

  • Enable Test Mode

    Enable test mode and make sure the robot is connected to the network.

  • Rebind and reconnect the robot

    Reconnect the robot with the bound account; after switching, waking it prompts that it is not bound. If it was already bound, select that robot in the app; if only one robot is bound, exit and reopen the app before connecting.

  • Test the voice-triggered skill

    Install the developed app on the robot, then trigger and test the skill with the configured voice command.

  • Enter the H5 test link

    Enter the H5 test link in the developer test interface.

Data and training

  • Recognize a Flower

    Manually place a flower or a photo of a flower in front of the robot, wait up to 10 seconds, and inspect the results. The response contains the recognized object names, whether it succeeded, and the return code.

  • Recognize Fruit

    Manually place fruit or a picture of fruit in front of the robot, wait up to 10 seconds, and inspect the results. The response contains the recognized object names, whether it succeeded, and the return code.

Use it

  • Prepare one AlphaMini

    Prepare one AlphaMini robot.

  • Enter programming mode

    Execute StartRunProgram to put the robot in programming mode so other skills cannot interrupt it while commands execute. Wait 6 seconds for the robot's TTS broadcast to finish.

  • Play synthesized speech

    Create StartPlayTTS with the text "Hello, I'm AlphaMini, la-la-la", execute the block, and receive a ControlTTSResponse. The response contains resultCode and isSuccess; when resultCode is not 0, query the error with errors.get_speech_error_str.

  • Test and execute an action file

    Use PlayAction to execute the local built-in or custom action named “018,” wait for the response, and print the result.

  • Submit the app for review

    After debugging, submit the corresponding APK and H5 offline package to the open platform for official-environment review.

  • Push the version and publish

    After the official-environment review passes, push the corresponding version to the designated devices and complete the app publication.

  • Query wiki content

Parts

  • Bought assembled: 14 servos (3 DoF head, 2 per arm, 1 waist, 3 per leg)
  • 13 MP autofocus camera, 4-mic ring array plus a call mic, distance, acceleration, gyro and touch sensors
  • 2 GB RAM / 16 GB ROM; WLAN, Bluetooth 4.2, GPS, Nano SIM 4G
  • 3.85V 4060 mAh Li-polymer battery, 5V 3A adapter; 245×149×112 mm, about 700 g

Tools

  • Ships assembled, nothing to build
  • A PC on the same LAN as the robot with Python 3.7 or later; the docs suggest PyCharm

Skills

  • Graphical block coding in the app (uCode, based on Scratch 3.0, on the education edition)
  • Python asyncio: the SDK's calls are all asynchronous
  • The SDK's command-line tools: package a Python program onto the robot and run it, or run shell commands

Software

  • alphamini Python SDK 1.2.0: action, dance, expression, voice, face and object detection, IR distance and posture monitoring APIs
  • mini_demo examples (the oversea_develop branch has English comments)
  • Wukong app 2.3.0, Wukong education edition app 1.9.0, international AlphaMini app 1.3.0

Documents