Skip to main content
XROBOTLIBXR

The same Module code runs on different hardware and operating systems

LibXR is a cross-platform C++ compatibility layer with peripheral drivers, data structures, communication middleware, OS abstractions and math utilities, plus the USB protocol stack XRUSB.

The CodeGenerator and XRobot are two command-line tools used with LibXR: the CodeGenerator generates the peripheral objects and the entry function app_main from an STM32CubeMX project, and XRobot fetches Modules, locks each one to a commit, and generates the main function XRobotMain from a configuration.

Animation
LIBXRWEBASSEMBLYTERMINAL

The LibXR terminal runs in the browser

The terminal here is LibXR compiled to WebAssembly and running in the browser. Terminal provides line editing, history and path completion, and runs the commands stored in RamFS by path.

On a microcontroller, the same Terminal provides a command line over a UART or a USB virtual serial port.

TerminalRamFSWebAssembly
LIBXRUARTREADPORT

UART receive: the hardware keeps writing, software reads on demand

On microcontrollers the UART driver keeps the receive DMA running. The interrupt works out the new bytes from the DMA write pointer, writes them with PushBatch into SPSCQueue, the ring queue of the ReadPort, and calls Publish() to complete pending reads.

The receive path has no step that stops and restarts the DMA; software only catches up with the hardware write pointer.

ReadPortSPSCQueueDMA
LIBXRMESSAGETOPIC

Topic: publish and subscribe with an exact type

Topic is an in-process publish/subscribe channel with an exact payload type. A publish is delivered synchronously to the registered subscribers, each of which receives it in one of four ways: synchronous, asynchronous, queued or callback.

On Linux, LinuxSharedTopic keeps the data in shared-memory slots and subscribers read the same memory through descriptors, so no data is copied between processes.

TopicLinuxSharedTopic
XROBOTMODULESCI

Fetching and locking Modules, generating the main function

A BSP lists the Modules it needs in Modules/modules.yaml. xrobot setup fetches them and locks each one to a commit in xrobot.lock, and xrobot gen generates the main function XRobotMain from a configuration under User/.

The CI of an STM32 BSP calls a shared workflow: it checks that the generated files match the commit, builds every configuration, and uploads the firmware on a push to master, a v* tag or a published release.

xrobot.lockXRobotMainCI
LIBXRXRUSBDAP

XRUSB: the device-side USB stack and debug interfaces

XRUSB is the USB device stack in LibXR. It provides device classes such as CDC, HID, UAC, GSUSB, CMSIS-DAP v1/v2 and DFU, and one device can contain several device classes at once.

The debug interfaces implement SWD and JTAG with GPIO timing; the DAPLink device classes use them to access a target chip, for example to read the DP IDCODE.

CDCDAPLinkDFUSWD
XROBOTMODULESROBOTS

Robots built from Modules

The official Source includes Modules for IMUs, magnetometers, barometers, optical flow, laser ranging, grey-scale line following, RC receivers, displays and attitude estimation.

A configuration selects Modules and fills in their parameters, and xrobot gen generates the main function of one robot from it; different configurations make up the firmware of different robots.

ModuleBSP
DOCS

Enter the docs by project type

The four entries match four kinds of projects; the scenario list gives starting points for common tasks.

DOCSBASELINE

Documentation Baseline

The xrobot and libxr releases and the LibXR commit this documentation corresponds to.

xrobot
1.0.1
libxr (CodeGenerator)
6.0.1
LibXR master
5161373

Recent Development

  • XRobot 1.0XRobot 1.0 generates the main function statically from the configurationThe entry source registers hardware with XR_REGISTER, and xrobot gen generates an XRobotMain that constructs the instances in configuration order.
  • PlatformPlatform drivers cover STM32, CH32, ESP32, HPM, MSPM0, Linux, Webots and WebAssemblyEach platform's drivers are in their own subdirectory under driver in LibXR.
  • XRUSBXRUSB provides the CDC, DAP, DFU, GSUSB, HID and UAC device classesThe documentation has one page per device class.
  • DebugThe debug link supports SWD and JTAGThis includes SWD and JTAG implemented with GPIO timing, and the CMSIS-DAP v1/v2 device classes.
COMMUNITY

Getting Started and Contributing

ONBOARDING

Onboarding Tasks (Chinese)

Starting paths by platform that introduce the design ideas and the basic usage of XRobot and LibXR step by step.

AGENT

Agent Quick Start

A one-page start-up context: the coding agent first decides whether the repository is an XRobot BSP, a platform project or a driver project, then opens the matching docs and code.

XRobot is all you need