8.1 Blockly Coding Overview
No text-based code is required: you write programs by dragging and snapping together visual blocks to control the robot. The programming platform is XGO Blockly, which supports visual block programming, AI code generation, agent conversations, and a variety of system tools. The programming entry is the 2nd card 「Coding」 on the home screen.
8.2 Entering the Coding Interface
Navigate to the 2nd card 「Coding」 on the home screen and press D
The screen shows the Blockly Coding page with the robot's IP address (e.g., 192.168.31.81) and the Program List at the bottom
The robot's screen only displays the entry and information; programming is done in the web browser: open the address on any device on the same network
Program List
The Program List at the bottom of the robot's screen manages all programs saved to the Raspberry Pi
After writing and saving a program in the web browser, it will appear in this list
8.3 Interface Overview
After opening the programming page in a browser, you will see the XGO Blockly editor:
Top toolbar: AI Code, New, Open, Save, Screenshot, Run, Reset, Status, Show Code, Tools, Docs, language switch, API Key, Encrypt
Left panel: block categories, grouped by function
Workspace: the editing area where you drag and snap blocks together, starting from the "🚩 Start" block
Bottom-right controls: zoom in / zoom out and the trash bin for deleting blocks
Bottom-left status indicator: shows the current state (e.g., Idle)
The detailed functions of each toolbar button are described in sections 8.5 ~ 8.8.
8.4 Block Categories
Category | Subcategories / Blocks | Description |
|---|---|---|
Robot | Move, Rotate, Set Move Velocity, Posture Pos/Rot, Translation, Arm control, Set Gait, Perform Action, Performance Mode, Get Battery, Reset, Stop, Self-balance, Read Firmware Version | Motion, posture, arm and action controls |
Programming Basics | Logic (if/else, comparison, and/or/not), Loops (repeat N times, while, infinite loop, break), Variables (create/set/get), Functions (define/call/return) | Program execution logic and flow control |
Data Processing | Math (arithmetic, random, trigonometry), Text (concatenation, find & replace), Lists, JSON Data, Type Conversion | Data manipulation and conversion |
System Tools | Python utilities (print, time.sleep, datetime, random, etc.) | Built-in Python helper blocks |
Interaction & AI | Screen, Media, Key, Gamepad, AI Vision, Agent, Doubao AI, Voice Chat | Screen display, interaction and AI capabilities |
Advanced | Execute Code, Code Expression | Run raw Python code blocks |
8.5 Running and File Management
Run & Stop
Click Run to execute the program in the workspace; the button changes to Stop while running, and clicking it again stops the program
You can also run the program by double-clicking a block in the workspace
If the workspace is empty, clicking Run shows the message "Workspace is empty, please add blocks before running"
Reset
Click Reset to reset the robot to its initial standing posture and stop all motion
The execution log shows the reset process
Status
Click Status to open the robot real-time status window, which shows:
Battery level (e.g., 99%)
Posture angles: Roll, Pitch, Yaw
Servo angles: M11~M53, 15 servos in total (5 legs × 3 joints)
Save
Click Save to open the save dialog, then choose:
Save to Raspberry Pi: the program is stored locally on the robot (Raspberry Pi) and can be viewed and run from the Program List on the robot's screen
Save to local: downloads the program as a .xml file to your computer for backup and sharing
Program List (Robot Screen)
After saving a program to the Raspberry Pi in the web browser, it will appear in the Program List on the robot's screen
Program List controls:
A: move selection up
B: move selection down
C: go back to the previous screen
D: run the currently selected program
Press D to run the selected program immediately
Open / New
Open loads a locally saved .xml program file
New creates a new blank project (the workspace is cleared, keeping the "🚩 Start" block)
Screenshot
Screenshot saves the current workspace as a PNG image
Show Code
Show Code / Hide Code expands or collapses the right panel, showing the generated Python code and execution log
Encrypt
Encrypt sets a password to protect the program
8.6 AI Programming Features
API Key Configuration
The Agent, AI Code and Voice Chat features use the Tongyi Qianwen (Qwen) model; Doubao AI is used for multimodal experiences. Both require an API Key to be configured first
Click the API Key button in the toolbar and fill in the corresponding API Key (see the links in the dialog: Alibaba Cloud Bailian console / Volcano Engine docs)
API keys are stored locally only and never uploaded to any server; all AI calls are sent directly from your local device to the AI provider
Note: real-name verification is required to call the large model APIs; for Doubao, you also need to enable the corresponding model (e.g., Doubao-Seed-1.6-flash) in the management console
AI Code
Click the AI Code button, then describe what you want in natural language in the input box at the bottom-right (e.g., "draw a small sun", "dance") and press Enter
AI generates the code automatically and loads it into the editor, perfect for beginners to get started quickly
Defaults to the qwen3-max model; click the model name to switch to other models on Alibaba Cloud Bailian
Agent
Intelligently plans tasks with customizable system prompts
Supports long-term memory and knowledge base content
Built-in tools: code execution, file operations, web search (Bailian web search) and XGO robot control
Doubao AI
Directly calls the multimodal Doubao large model to experience its basic HTTP interface
Configurable parameters: model ID, temperature, max tokens, etc.
Voice Chat
Supports speech recognition and speech synthesis for voice conversations with the robot
8.7 AI Vision
The Interaction & AI → AI Vision category provides the following vision blocks:
Face recognition: detect and recognize faces
Gesture recognition: recognize gestures (e.g., number gestures)
Ball recognition/tracking: detect and track colored balls
Line following: follow a line on the ground
AprilTag pose detection: detect AprilTag markers, returning the tag ID, family and pose information (translations and rotations), useful for following and obstacle avoidance
Color detection: detect targets based on HSV color
Object detection: general object recognition
Get camera image: get the real-time camera frame
8.8 Toolbox
Click Tools to open the toolbox page, which contains 4 tools:
SSH Terminal
File manager: browse the program directory on the robot (/opt/luwu-os/xgoBlocklyProjects), supporting create, upload, download, rename and delete
Terminal: connect and run SSH commands
Color Range Editor
Adjust HSV color space thresholds for color detection
Supports updating the image from the camera, picking colors, inverting and resetting sliders
Copy the tuned thresholds and use them with the AI Vision → Color detection block
Camera Calibration
Print a 9×6 checkerboard and take at least 10 photos from different angles for calibration
Calibration improves the distance and angle accuracy of the AprilTag pose detection block (default parameters are used if not calibrated)
Gamepad Mapping
Configure Bluetooth gamepad button mapping, with support for re-learning buttons and joystick calibration
Save, load and reset to default configurations
8.9 Useful Programming Tips
Module Initialization
Before using Media, Vision, or Screen blocks, first add the INIT XGOEDU block to initialize
Motion-related blocks require an XGO initialization block first
Loops
Use the loop blocks in Programming Basics → Loops to repeat actions
Set the number of iterations (e.g., repeat 5 times) or loop forever
Conditions
Use the logic blocks in Programming Basics → Logic for conditional execution
For example: if a face is detected, then wave
Action Sequences
Blocks snap together from top to bottom and execute in order
After each action finishes, the next one runs automatically
Debugging
If the program behaves unexpectedly, click Reset and edit the blocks again
Use Show Code to review the generated Python code for troubleshooting
Use Screenshot to save a picture of your program
Block Operations
Drag: click a block in the category list and drag it into the workspace
Snap: align the protrusion of one block with the notch of another to snap them together
Delete: drag a block to the trash bin icon in the bottom-right corner, or select it and press Delete
Adjust parameters: click number inputs or dropdown menus on a block to modify its values
Run by double-click: double-click a block in the workspace to run the program
Zoom: use the + and - buttons in the bottom-right corner of the workspace to zoom in or out
Stop during execution: click the Stop button at any time to terminate a running program
8.10 Coding on a PC
Programming is done entirely in the web browser; a computer browser is recommended:
Make sure the robot is connected to WiFi
Open the IP address shown on the Blockly Coding page (e.g., http://192.168.31.81) in a Chrome browser on the same network
The browser shows the XGO Blockly editor
Drag and snap blocks on the computer to write the program
Click Save to store the program locally on the robot (Raspberry Pi); it will appear in the Program List on the robot's screen
Click Run, and the robot executes the program synchronously
💡 Programs are written and saved in the web browser, stored locally on the robot, and can be run directly from the Program List next time.
