How yuanqizhiti/hongtu works
1. Repository shape
This repo is really three systems side by side:
- G1Nav2D: a ROS1 Catkin workspace for 2D SLAM/navigation on a Unitree robot.
- PythonProject/py-xiaozhi-main: a separate Python voice-assistant application with MCP tool integration.
- unitree_sdk2_python: a vendored Unitree SDK used for robot control and state access.
2. Main robotics stack boundary: ROS1 navigation
G1Nav2D is the core autonomy stack. It assumes:
- a Livox LiDAR publishes point clouds,
- localization/mapping nodes build or match against a map,
- move_base plans navigation goals,
- a separate control program sends motion commands to the robot.
3. Sensor ingestion layer
src/livox_ros_driver2-master is the LiDAR driver layer. Its job is to turn Livox hardware input into ROS topics. Configuration is device-specific (MID360_config.json, HAP_config.json, mixed configs), and launch files select ROS1/ROS2 publish modes. This is the upstream data source for SLAM.
4. SLAM and localization
src/fastlio2 is the mapping/localization subsystem. It contains:
- LiDAR-IMU odometry and map building logic,
- IMU processing (lio_builder/imu_processor),
- ICP-based localization (localizer/icp_localizer),
- k-d tree map indexing (ikd-Tree),
- IKFoM/ESEKF math utilities for state estimation.
Its launch/config split indicates two modes:
- mapping (mapping.launch, mapping.yaml)
- localization (localize.yaml, navigation.launch with loaded map)
5. Navigation and planning
src/movebase is the path planning layer. It packages:
- move_base / Move Base Flex parameters,
- global and local costmaps,
- planner configs such as DWA and TEB,
- SBPL motion primitives and recovery behavior settings.
In the architecture, this sits downstream of localization and upstream of the robot motion interface.
6. Map artifact management
Maps are treated as persistent assets, not just runtime outputs:
- fastlio2/PCD stores point-cloud maps.
- ros_map_edit/maps stores occupancy map bundles (.pgm, .yaml, .json).
- path/key_poses.txt and tool/path/teaching_paths.txt store navigation/path history.
This means the system has both 3D mapping artifacts and 2D occupancy-grid artifacts.
7. Interactive map editing and publishing
src/ros_map_edit is a GUI/utility subsystem for editing occupancy maps. It provides:
- RViz plugins/tools for erasing, regions, and virtual walls,
- map file management,
- launch files for map server + editor.
This is a human-in-the-loop boundary: maps are generated by SLAM, then edited before being consumed by navigation.
8. Point-cloud and frame conversion tools
src/tool and src/pointcloud_to_laserscan are support layers:
- point-cloud frame transforms,
- downsampling,
- LiDAR-to-vehicle/odometry transformations,
- point-cloud-to-2D-scan conversion for navigation compatibility,
- path/waypoint utilities and teaching-path replay.
These nodes bridge raw sensor geometry into formats expected by the planner and map stack.
9. Robot control boundary
The actual robot actuation is not implemented inside G1Nav2D; it is delegated to unitree_sdk2_python.
That SDK exposes DDS/RPC-based APIs for:
- sport/high-level motion control,
- low-level state and command access,
- audio/video and other robot services.
The README’s g1_control.py usage shows the navigation stack depends on an external control process that talks over the robot network interface.
10. Voice interaction and task orchestration
PythonProject/py-xiaozhi-main is a separate AI voice assistant application. Its architecture includes:
- audio processing and wake-word/VAD modules,
- MQTT/WebSocket protocol clients,
- GUI/CLI front ends,
- a large mcp tool registry for actions like search, timer, camera, system control, and custom navigation tasks.
The custom daohang_* modules and scripts are the bridge into robot navigation.
11. Voice-to-navigation data flow
The README shows the main integration path:
- user speaks a destination keyword,
- py-xiaozhi-main recognizes intent,
- MCP service resolves it to a custom navigation tool,
- the tool launches a Python script in PythonProject/daohang or point_nav,
- that script triggers navigation to a preconfigured point in the ROS system.
So voice control does not directly drive the robot; it dispatches a prewired navigation task into the ROS navigation stack.
12. Runtime orchestration
Most behavior is wired through launch files rather than a single monolith:
- ROS launch files start sensing, SLAM, mapping, navigation, map server, and RViz.
- Python entrypoints start the voice assistant and its MCP services.
- Separate shell/scripts are used for build, activation, and startup on Linux.
For an architecture diagram, the critical boundaries are:
- hardware sensors → ROS driver → SLAM/localization → planner → Unitree control SDK,
- voice assistant → MCP tools/scripts → ROS navigation stack,
- map generation/editing as a persisted asset pipeline between SLAM and planning.
Main entry points: fastlio2 FAST-LIO2 · movebase Move Base · py-xiaozhi-main Voice app · maps Map assets
Components 19
G1Nav2D ROS stack
ROS1 catkin workspace for sensing, SLAM, map editing, planning, and motion support.
- Livox driver · Turns Livox LiDAR hardware input into ROS point-cloud topics in ROS1/ROS2 modes.
G1Nav2D/src/livox_ros_driver2-master - FAST-LIO2 · LiDAR-IMU odometry, map building, and ICP-based localization subsystem.
G1Nav2D/src/fastlio2 - IMU fusion · IMU processing and LiDAR-IMU state estimation path.
G1Nav2D/src/fastlio2/include/lio_builder - ICP localizer · Map matching and localization against a prebuilt map.
G1Nav2D/src/fastlio2/include/localizer - ikd tree · Spatial index used for efficient point-cloud map querying and updates.
G1Nav2D/src/fastlio2/include/ikd-Tree - Move Base · Global/local planning, costmaps, recovery behavior, and planner parameterization.
G1Nav2D/src/movebase - Costmaps · Global and local obstacle maps plus converter and planner parameters.
G1Nav2D/src/movebase/param - Map editor · GUI tools for editing occupancy maps, regions, and virtual walls before navigation consumes them.
G1Nav2D/src/ros_map_edit - Map assets · Occupancy-grid bundles and region metadata stored as map artifacts.
G1Nav2D/src/ros_map_edit/maps - Geometry tools · Point-cloud transforms, downsampling, frame conversion, and teaching-path helpers.
G1Nav2D/src/tool - Scan bridge · Converts point clouds into laser-scan-compatible data for navigation components.
G1Nav2D/src/pointcloud_to_laserscan - Vel smoother · Velocity smoothing layer used between planning and robot command output.
G1Nav2D/src/velocity_smoother_ema
Voice assistant
Separate Python assistant with MCP tools and navigation dispatch.
- Voice app · Main voice-assistant application with audio, protocols, GUI/CLI, and task orchestration.
PythonProject/py-xiaozhi-main - Audio pipeline · Wake-word detection, VAD, and audio codec/processing modules.
PythonProject/py-xiaozhi-main/src/audio_processing - MCP server · Registers and routes assistant actions to tool managers and scripts.
PythonProject/py-xiaozhi-main/src/mcp - Nav tools · Custom daohang and point-navigation tools that launch prewired robot destinations.
PythonProject/py-xiaozhi-main/src/mcp/tools/daohang_dianti - Nav scripts · Script entrypoints for destination-specific navigation actions.
PythonProject/daohang
Unitree SDK
Vendored robot control and state-access SDK.
- Robot SDK · Core Unitree SDK layer for sport, state, video, audio, and RPC access.
unitree_sdk2_python/unitree_sdk2py - G1 control · Example high-level control client showing how external code commands the robot.
unitree_sdk2_python/example/g1/high_level/g1_control.py
Connections 20
- Livox driver → FAST-LIO2: point clouds · LiDAR data feeds SLAM and localization.
- FAST-LIO2 → IMU fusion: estimates · LiDAR-IMU odometry uses IMU processing and fusion.
- FAST-LIO2 → ICP localizer: localize · Loads a map and matches against it for localization mode.
- FAST-LIO2 → ikd tree: indexes map · Uses the k-d tree structure for efficient map operations.
- FAST-LIO2 → Map assets: writes maps · Produces persistent point-cloud map artifacts.
- Map editor → Map assets: edits maps · Human-in-the-loop map editing and saving.
- Map assets → Move Base: loaded by · Edited occupancy maps are consumed by navigation.
- Scan bridge → Move Base: scan input · Provides 2D scan-compatible sensing to planner components.
- Geometry tools → Scan bridge: converts · Transforms point clouds and frames into navigation-friendly geometry.
- FAST-LIO2 → Geometry tools: poses · Supplies map/local frame transformations and path history.
- Move Base → Vel smoother: cmd vel · Planner output is smoothed before actuation.
- Vel smoother → G1 control: motion cmd · Smoothed velocity commands reach the external robot control process.
- Voice app → Audio pipeline: listens · Assistant starts from speech capture and recognition.
- Voice app → MCP server: dispatches · Assistant hands intents to MCP tool routing.
- MCP server → Nav tools: navigation tools · Custom MCP tools expose robot-destination actions.
- Nav tools → Nav scripts: launches · Tools invoke Python navigation scripts for specific destinations.
- Nav scripts → Move Base: goal request · Navigation scripts trigger ROS navigation goals.
- G1 control → Robot SDK: SDK calls · External control clients use the Unitree SDK APIs.
- Voice app → Robot SDK: optional services · Assistant ecosystem can access device and service capabilities through the SDK.
- Move Base → G1 control: requires actuation · Planner depends on an external process to actually drive the robot.