upkie 9.0.0
Open-source wheeled biped robots
|
The attitude reference system (ARS) frame is an inertial frame of reference used by the IMU filter onboard the pi3hat. It has its x-axis pointing forward, y-axis pointing to the right and z-axis pointing down (details). This is not the convention we use in the world frame, and the rotation matrix from the ARS frame to the world frame is:
\( R_{WA} = \begin{bmatrix} 1 & 0 & 0 \\ 0 & -1 & 0 \\ 0 & 0 & -1 \\ \end{bmatrix} \)
While newcomers will likely run start_simulation.sh
and import the upkie
package in Python, as you get acquainted with the robot and develop your own agents (in your fork of the repository or using the new_agent template), you may want to contribute some features back upstream. Here is a short guide on compiling from source to do that.
The C++ development workflow consists of Makefile rules. First, setup a build environment following the instructions for your system:
To upload software to the robot, you will also need to define the UPKIE_NAME
environment variable. Assuming the hostname of your Upkie is "michel-strogoff", for example, you can add the following to your shell configuration file:
An IP address will also work.
To make sure your build environment works, try to rebuild the pi3hat spine from source:
You can then upload it by make upload
and check that it runs on the Raspberry Pi of your Upkie:
Once the spine is running, you can run any agent in a separate shell on the robot, for example the PID balancer from the examples directory:
The Python development workflow is based on Pixi. You can list the available tasks with a dry:
For instance:
pixi run docs-open
pixi run lint
pixi run -e test-py12 test
pixi shell
Upkie implements an action-observation loop to control robot actuators from a standalone "agent" process. The inter-process communication (IPC) protocol between the agent and the "spine" process that talks to actuators looks like this:
The agent can be a simple Python script with few dependencies. This separation between agent and spine provides a robot/simulation switch to train or test agents in a simulation spine before running them on a real robot.
This protocol is suitable for real-time but not high-frequency (> 1000 Hz) performance, which is fine for balancing and locomotion on Upkies. (If you are wondering whether Python is suitable for real-time applications, we were too, until we tried it out.) All design decisions have their pros and cons. Some pros for this design are:
Meanwhile, cons against this design include:
Spines run a state machine depicted in the following diagram:
States have the following purposes:
There are three possible events:
BEGIN
: beginning of a control cycle.END
: end of a control cycle.SIGINT
: the process received an interrupt signal.Guards (in blue), i.e. conditions required to trigger a transition, may involve two variables:
req
: the current Request from the agent.stop_cycles
: the number of stop commands cycled in the current state (only available in "stop" and "shutdown" states).Read/write operations from/to the shared memory are indicated in red.
We want a single spine binary per interface: Bullet, pi3hat, etc. That binary may offer several observer and controller pipelines, configured via the command line.
Upkie-Spine-*
Gymnasium environment namesAll C++ source files should start with the license line:
All Python source files should start with the following four lines:
Optionally, license lines can be followed by copyright lines corresponding to the various contributions to the file (those are optional as in most legal systems copyright is automatically conferred upon the creation of an original work, without the need for a notice), and author lines to identify the individuals who contributed them.