Python module to control Upkie wheeled bipeds.
Project description
Upkie wheeled biped
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 upkie.envs
upkie.envs.register()
with gym.make("UpkieWheelsEnv-v2", frequency=200.0) as env:
observation = env.reset()
action = 0.0 * env.action_space.sample()
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
Installation
PyPI
$ 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file upkie-1.0.0.tar.gz
.
File metadata
- Download URL: upkie-1.0.0.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1946aefe53067ee3f63985b2f518699641830d8eb5f245d6a21d08ad5459a72 |
|
MD5 | f13ad905f436f6010c1e1a960cf09f69 |
|
BLAKE2b-256 | 15b561640bb6c5e7712f8b33f9f8487f1538969f617647a5095ea5919ec5ccc3 |
File details
Details for the file upkie-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: upkie-1.0.0-py3-none-any.whl
- Upload date:
- Size: 31.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.28.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff43b2238f8b1268a4785863c86f13c9fc42809aff71c62f87cfef90d4e78267 |
|
MD5 | 5358a085faaae745de88d5673179c2da |
|
BLAKE2b-256 | e4f543f225de0aaa5b04c2bcd5f4f46fcc02cd7a4d8d544f03155f5417171c0b |