Skip to content

Commit

Permalink
Add docker environment
Browse files Browse the repository at this point in the history
  • Loading branch information
shaoanlu committed Nov 22, 2024
1 parent 833b917 commit 9630d26
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 6 deletions.
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Use an official Python image with version 3.6+
FROM python:3.10-slim

# Set the working directory inside the container
WORKDIR /app

# Copy the application code into the container
COPY . /app

# Install required dependencies
RUN apt-get update && apt-get install -y \
fontconfig \
fonts-dejavu-core \
x11-apps \
libx11-6 \
libxext6 \
libsm6 \
libxrender1 \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir numpy==1.26.4 scipy==1.13.1 osqp==0.6.7 pygame==2.6.1

# Expose any required ports (if needed by pygame or other services)
EXPOSE 8000

# Set the default command to run the demo
CMD ["python3", "demo.py"]
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,28 @@ This Python program demonstrates the use of control barrier functions (CBFs) for

## Dependencies
The program was developed and tested in the following environment.
- Python 3.6+
- Python 3.9+
- `torch==1.8.1+cpu` (optional)
- `osqp==0.6.2.post8`
- `pygame==2.3.0`
- `numpy==1.16.6`
- `scipy==1.1.0`
- `osqp==0.6.7`
- `pygame==2.6.1`
- `numpy==1.26.4`
- `scipy==1.13.1`

## Usage
### Execution
### Execution in docker container (recommended)
First, install Docker and Docker Compose using the [official install guide](https://docs.docker.com/engine/install/ubuntu/).

Then, clone this repository and go into the project folder
```bash
git clone https://github.com/shaoanlu/CBF_QP_safety_filter.git
cd CBF_QP_safety_filter
```
To run the application, build the docker image and launch the container
```bash
docker compose up --build
```

### Execution in local environment
Run `demo.py` to start the simulation. A simple version w/ code generation is provided as `demo_codegen_osqp.py`.
```bash
python demo.py # a PyGame window will be spawn
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "3.8"
services:
cbf_qp_playground:
build:
context: .
dockerfile: Dockerfile
container_name: cbf_qp_playground
ports:
- "8000:8000" # Adjust if any other port mapping is necessary
volumes:
- .:/app
- /tmp/.X11-unix:/tmp/.X11-unix # Share the X11 socket for GUI rendering
environment:
- DISPLAY=${DISPLAY} # Pass the host's display to the container
- SDL_VIDEODRIVER=x11 # Use X11 for PyGame
stdin_open: true
tty: true

0 comments on commit 9630d26

Please sign in to comment.