Skip to content

Commit 9eef443

Browse files
committed
doc: add readme for bindings
1 parent a3eeb6a commit 9eef443

File tree

2 files changed

+102
-3
lines changed

2 files changed

+102
-3
lines changed

.bazelrc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,4 @@ build --action_env=LD_LIBRARY_PATH=
5151
# use python3 by default
5252
build --python_path=python3
5353

54-
build --define=WITH_GUROBI=ON
55-
56-
build --local_resources=cpu=8
54+
build --define=WITH_GUROBI=ON

bindings/pyc3/README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# pyc3 Python Bindings
2+
3+
This directory contains the Bazel build configuration and source files for the `pyc3` Python bindings for C3 (Consensus Complementarity Control).
4+
5+
The `pyc3` package provides Python bindings for the C3 algorithm, allowing you to work with Linear Complementarity Systems (LCS), solve Mixed-Integer Quadratic Programs (MIQP), and control systems using the C3 framework.
6+
7+
---
8+
9+
## Prerequisites
10+
11+
Before building and installing pyc3, ensure you have:
12+
13+
1. **Drake**: C3 depends on Drake for multibody dynamics and optimization
14+
2. **Gurobi**: Required for the MIQP solver (version 10.0 recommended)
15+
3. **Bazel**: For building the project
16+
4. **Python 3.8+**: With development headers
17+
18+
For detailed setup instructions, see the main [C3 README](../../README.md).
19+
20+
---
21+
22+
## Building and Installing pyc3 in a Virtual Environment
23+
24+
Follow these steps to build the `pyc3` Python wheel and install it into a virtual environment.
25+
26+
### 1. Create and Activate a Python Virtual Environment
27+
28+
```sh
29+
python3 -m venv venv
30+
source venv/bin/activate
31+
```
32+
33+
### 2. Build the pyc3 Python Wheel
34+
35+
From the root of the C3 repository, build the Python wheel using Bazel:
36+
37+
```sh
38+
bazel build //bindings/pyc3:pyc3_wheel
39+
```
40+
41+
This will create a wheel file in the Bazel output directory.
42+
43+
### 3. Install the pyc3 Wheel
44+
45+
Install the built wheel into your virtual environment:
46+
47+
```sh
48+
pip install bazel-bin/bindings/pyc3/pyc3_wheel.whl
49+
```
50+
51+
### 4. Verify Installation
52+
53+
Test that pyc3 was installed correctly:
54+
55+
```python
56+
python -c 'import pyc3; print("pyc3 installed successfully!")'
57+
```
58+
59+
---
60+
61+
## Examples
62+
63+
Complete examples are available in the `examples/python/` directory:
64+
65+
- **`c3_example.py`**: Basic C3 optimization example
66+
- **`c3_controller_example.py`**: Real-time controller with Drake integration
67+
- **`lcs_factory_example.py`**: LCS creation from multibody systems
68+
69+
To run an example:
70+
71+
```sh
72+
cd examples/python
73+
python c3_example.py
74+
```
75+
76+
---
77+
78+
## Troubleshooting
79+
80+
### Common Issues
81+
82+
1. **Import Error**: If you get import errors, ensure Drake is properly installed and your virtual environment is activated.
83+
84+
2. **Gurobi License**: Make sure your Gurobi license is properly configured:
85+
```sh
86+
export GUROBI_HOME=/opt/gurobi1000/linux64
87+
export GRB_LICENSE_FILE=/path/to/your/gurobi.lic
88+
```
89+
90+
3. **Build Errors**: Ensure all prerequisites are installed and Bazel can find Drake:
91+
```sh
92+
bazel clean
93+
bazel build //bindings/pyc3:pyc3_wheel
94+
```
95+
96+
### Getting Help
97+
98+
- Check the main [C3 repository issues](https://github.com/DAIRLab/c3/issues)
99+
- Review the [C3 paper](https://arxiv.org/abs/2304.11259) for algorithmic details
100+
- See [dairlib](https://github.com/DAIRLab/dairlib) for more comprehensive examples
101+

0 commit comments

Comments
 (0)