upkie 6.1.0
Open-source wheeled biped robots
|
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 (by forking upkie/new_agent), you may want to contribute some features back to the upstream repository. Here is a short guide on compiling from source to do that.
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 run a bullet spine from source:
Once the simulation builds and runs successfully, move onto building the pi3hat spine from source, upload it and run it on your robot.
If you make changes to the upkie
Python module, you will want to make Python import your local version rather than the one installed from conda-forge or PyPI. There are two ways to do so. One of them is to re-install the package locally, using pip
from the root of (your local copy of) the repository:
Another one is to simply link the module from the directory you are working in. For instance, in the examples directory:
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.