Skip to main content

Python module to control Upkie wheeled bipeds.

Project description

Upkie wheeled biped

Build Documentation Coverage Vulp Chat

Main repository to build and control Upkie wheeled bipeds. Made for Linux 🐧

Questions about using the code, contributing, or balancing robots in general are welcome in the Discussions forum or on the Chat.

Quick test

Run a simulated Upkie right away from the command line, no installation required:

$ git clone https://github.com/tasts-robots/upkie.git
$ cd upkie
$ ./start_test_balancer.sh

Connect a USB controller to move the robot around 🎮

Example

import gym
import loop_rate_limiters
import upkie.envs

upkie.envs.register()

with gym.make("UpkieWheelsEnv-v2") as env:
    observation = env.reset()
    action = 0.0 * env.action_space.sample()
    rate = loop_rate_limiters.RateLimiter(frequency=200.0)
    for step in range(1_000_000):
        observation, reward, done, _ = env.step(action)
        if done:
            observation = env.reset()
        pitch = observation[0]
        action[0] = 10.0 * pitch
        rate.sleep()

Installation

PyPI

PyPI version PyPI downloads

$ pip install upkie

Code overview

This repository uses Bazel for building and testing. One benefit of this choice is that there is no dependency to install: Bazel builds everything locally in a local cache. Compilation will only take a while the first time.

Locomotion code is organized into spines, which communicate with the simulator or actuators using Vulp, and agents, the main programs that implement behaviors in Python. In the example above we ran the test balancer. We could also start the Bullet spine independently, and let it run waiting for agents to connect:

$ ./tools/bazelisk run -c opt //spines:bullet -- --show

The -c opt argument to Bazel makes sure we compile optimized code, while the --show argument to the spine displays the Bullet visualization.

Agents

Test balancer
A baseline agent designed to check out Upkie's physical capabilities. It balances the robot using PD feedback from the head's pitch and wheel odometry to wheel velocities, plus a feedforward non-minimum phase trick for smoother transitions from standing to rolling.
Pink balancer
A more capable agent that combines wheeled balancing with inverse kinematics computed by Pink. This is the controller that runs in the first two videos of Upkie.
PPO balancer
An agent trained by reinforcement learning to balance with straight legs. Training uses the UpkieWheelsEnv gym environment and the PPO implementation from Stable Baselines3.

Environments

UpkieServosEnv
Upkie with full observation and joint position-velocity-torque actions.
UpkieWheelsEnv
Upkie with full observation but only wheel velocity actions.

Environments are single-threaded rather than vectorized. In return, they run as-is on the real robot.

Observers

Floor contact
Detect contact between the wheels and the floor. The Pink and test balancers use contact as a reset flag for their integrators, to avoid over-spinning the wheels while the robot is in the air.
Wheel contact
Detect contact between a given wheel and the floor.
Wheel odometry
Measure the relative motion of the floating base with respect to the floor. Wheel odometry is part of their secondary task (after keeping the head straight), which is to stay around the same spot on the floor.

Spines

Bullet
Spawn Upkie in a Bullet simulation. Resetting this spine moves the robot back to its initial configuration in this world.
pi3hat
Spine is made to be called from a Raspberry Pi with an onboard mjbots pi3hat. Servos are stopped when the spine is stopped, and switch to position mode (which is a position-velocity-torque controller) when the spine idles. Check out the spine state machine for details.

See also

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

upkie-0.5.0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

upkie-0.5.0-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

Details for the file upkie-0.5.0.tar.gz.

File metadata

  • Download URL: upkie-0.5.0.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for upkie-0.5.0.tar.gz
Algorithm Hash digest
SHA256 feafa5325351e8d79ef2d4761d180ebcf2667709d9f87004c8bd94d9b39001f1
MD5 32935aa47d31b0ee208ee3a730151300
BLAKE2b-256 eedceab10e618cf7aa0dc67a6e1d778274c5bd80e1955af4e2350f005471f6d4

See more details on using hashes here.

File details

Details for the file upkie-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: upkie-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 30.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for upkie-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8af6561c74be961baa72084ae0ac043f5caa59d2f46ff58330c24ca46f8be58b
MD5 cda2f904014197b9a1e0217ec6f95216
BLAKE2b-256 b82e41b26e997205a74a73053d9e3e7e71aaff5b37346a8ad37a55505f5c4421

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page