Skip to content

Commit 2e345ab

Browse files
Johnliu/pegasus update (#312)
* updated pegasus version, updated docker compose version. Connects robot and px4, but WIP ogn api updates * Fixed python path in isaac-sim container. Now properly publishes clock and connects to robot for basic flight * uncommented example script code * fixing lidar orientation direction in robot description * updated two_example script as well * added error message for stale docker compose version * fixed example script for 2 robots to properly namespace the two different robots * bump version to 0.16.0 for new Isaac Sim/Pegasus version and on Ubuntu 24 * Update rviz to show lidar * sync with WIP spawn multirotor node to fix sim-airstack timesync issue * fixes to visuals for rviz and robot description based on new default sensor positions * enable proper extension in example script for OnPhysicsStep ogn * properly does not play scripted environment on start if specified in env file * Rename ISAAC_SIM_USE_STANDALONE_SCRIPT to ISAAC_SIM_USE_STANDALONE * Add light to script, add clock display * Update airstack cli to containerize docker compose itself, so that users don't have to manage different versions * Bump to docker-compose 5.0.2, also get docker image tag for tagging airstack-cli image * Fix display forwarding for containerized docker-compose * Fix env variable propagation in containerized docker-compose * Small changes * added environment var to isaac docker compose to properly play sim on start from env file * temporary fix, airstack with USD file has no wobble; scripted mode still wobbles * Add ground plane * update rviz --------- Co-authored-by: John <John Liu> Co-authored-by: Andrew Jong <ajong@andrew.cmu.edu>
1 parent 94f1b8d commit 2e345ab

32 files changed

+762
-100672
lines changed

.airstack/README.md

Lines changed: 263 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# AirStack CLI Tool
22

3-
The `airstack` command-line tool provides a unified interface for common development tasks in the AirStack project, including setup, installation, and container management.
3+
The `airstack` command-line tool provides a unified interface for common development tasks in the AirStack project, including setup, installation, and container management. It uses a containerized docker-compose approach to ensure all developers use the same version (v5.0.0+) regardless of their host machine's Docker installation.
44

55
## Installation
66

@@ -19,6 +19,18 @@ The `airstack` tool is included in the AirStack repository. To set it up:
1919

2020
This will add the `airstack` command to your PATH by modifying your shell profile (`.bashrc` or `.zshrc`).
2121

22+
### Requirements
23+
24+
**Minimal requirements:**
25+
- Docker installed (any recent version with socket at `/var/run/docker.sock`)
26+
- The Docker daemon must be running
27+
28+
**NOT required:**
29+
- Specific docker-compose version on host
30+
- docker-compose CLI on host (container provides it)
31+
32+
**Note:** The `airstack install` command will install Docker Engine and NVIDIA Container Toolkit, but will **not** install docker-compose on the host. Docker Compose runs entirely in the containerized CLI environment.
33+
2234
## Basic Usage
2335

2436
```bash
@@ -35,67 +47,79 @@ To get help for a specific command:
3547
airstack help <command>
3648
```
3749

50+
### First Time Setup
51+
52+
When you run any airstack command that requires docker-compose for the first time, the CLI container will auto-build:
53+
```bash
54+
./airstack.sh up
55+
```
56+
57+
The CLI container includes a pinned version of docker-compose and all necessary tools.
58+
3859
## Core Commands
3960

40-
- `install`: Install dependencies (Docker Engine, Docker Compose, etc.)
61+
- `install`: Install dependencies (Docker Engine, NVIDIA Container Toolkit, etc.)
4162
- `setup`: Configure AirStack settings and add to shell profile
42-
- `up [service]`: Start services using Docker Compose
63+
- `up [service]`: Start services using containerized Docker Compose
4364
- `stop [service]`: Stop services
65+
- `down`: Stop and remove containers
4466
- `connect [container]`: Connect to a running container (supports partial name matching)
4567
- `status`: Show status of all containers
4668
- `logs [container]`: View logs for a container (supports partial name matching)
69+
- `rebuild-cli`: Rebuild the CLI container with latest docker-compose version
4770

4871
### Container Name Matching
4972

5073
The `connect` and `logs` commands support partial name matching for container names. This means you can:
5174

52-
1. Use just a portion of the container name (e.g., `airstack connect web` will match `airstack_web_1`)
75+
1. Use just a portion of the container name (e.g., `airstack connect robot` will match `airstack-robot-1`)
5376
2. If multiple containers match, you'll be shown a list and prompted to select one
5477
3. The matching is case-insensitive and supports fuzzy matching
5578

5679
Example:
5780
```bash
58-
$ airstack connect web
59-
[WARN] Multiple containers match 'web'. Please be more specific or select from the list below:
60-
NUM CONTAINER NAME IMAGE STATUS
61-
1 airstack_web_1 nginx:latest Up 2 hours
62-
2 airstack_webapi_1 node:14 Up 2 hours
81+
$ airstack connect robot
82+
[WARN] Multiple containers match 'robot'. Please be more specific or select from the list below:
83+
NUM CONTAINER NAME STATUS
84+
1 airstack-robot-1 Up 2 hours
85+
2 airstack-robot-2 Up 2 hours
6386

6487
Options:
6588
1. Enter a number to select a container
6689
2. Type 'q' to quit
6790
3. Press Ctrl+C to cancel and try again with a more specific name
6891

6992
Your selection: 1
70-
[INFO] Connecting to container: airstack_web_1
71-
[INFO] Tip: Next time, you can directly use 'airstack connect airstack_web_1' for this container
93+
[INFO] Connecting to container: airstack-robot-1
94+
[INFO] Tip: Next time, you can directly use 'airstack connect airstack-robot-1' for this container
7295
```
7396
74-
## Development Commands
97+
### Environment Variable Overrides
7598
76-
- `test`: Run tests
77-
- `docs`: Build documentation
78-
- `lint`: Lint code
79-
- `format`: Format code
99+
You can override any `.env` variable on the command line:
80100
81-
## Extending the Tool
101+
```bash
102+
# Override single variable
103+
ISAAC_SIM_USE_STANDALONE=true ./airstack.sh up isaac-sim robot
82104

83-
The `airstack` tool is designed to be easily extensible. You can add new commands by creating module files in the `.airstack/modules/` directory.
105+
# Override multiple variables
106+
NUM_ROBOTS=3 AUTOLAUNCH=false ./airstack.sh up
84107

85-
### Creating a New Module
108+
# Works with any .env variable
109+
DOCKER_IMAGE_TAG=dev-latest ./airstack.sh up
110+
```
86111
87-
1. Create a new `.sh` file in the `.airstack/modules/` directory:
88-
```bash
89-
touch .airstack/modules/mymodule.sh
90-
```
112+
The wrapper automatically:
113+
1. Reads all variable names from `.env`
114+
2. Passes them from your current shell environment into the container
115+
3. Command-line overrides naturally take precedence
91116
92-
2. Add your command functions and register them:
93-
```bash
94-
#!/usr/bin/env bash
117+
## Development Commands
95118
96-
# Function to implement your command
97-
function cmd_mymodule_mycommand {
98-
log_info "Running my command..."
119+
- `test`: Run tests
120+
- `docs`: Build documentation
121+
- ```
122+
log_info "Running my command..."
99123
# Your command implementation here
100124
}
101125

@@ -126,6 +150,216 @@ When creating modules, you can use these helper functions:
126150
127151
The `airstack` tool stores its configuration in `~/.airstack.conf`. This file is created when you run `airstack setup`.
128152
153+
## lint`: Lint code
154+
- `format`: Format code
155+
156+
## Extending the Tool
157+
158+
The `airstack` tool is designed to be easily extensible. You can add new commands by creating module files in the `.airstack/modules/` directory.
159+
160+
### Creating a New Module
161+
162+
1. Create a new `.sh` file in the `.airstack/modules/` directory:
163+
```bash
164+
touch .airstack/modules/mymodule.sh
165+
```
166+
167+
2. Add your command functions and register them:
168+
```bash
169+
#!/usr/bin/env bash
170+
171+
# Function to implement your command
172+
function cmd_mymodule_mycommand {
173+
Containerized Docker Compose Implementation
174+
175+
The AirStack CLI uses a containerized approach for docker-compose to ensure consistency across all development environments.
176+
177+
### How It Works
178+
179+
The solution uses **Docker socket mounting** (not Docker-in-Docker):
180+
- The `airstack-cli` container includes a pinned version of docker-compose (v5.0.0+)
181+
- It mounts the host's Docker socket (`/var/run/docker.sock`)
182+
- Commands run in the container but control the host's Docker daemon
183+
- Containers spawned by docker-compose run as siblings on the host, not nested
184+
185+
### Key Files
186+
187+
1. **Dockerfile.airstack-cli**
188+
- Defines the containerized CLI environment
189+
- Pins docker-compose to a specific version
190+
- Includes bash, curl, git for full functionality
191+
192+
2. **airstack.sh**
193+
- `ensure_cli_container()` - builds CLI image if needed
194+
- `run_docker_compose()` - wrapper for containerized compose
195+
- `cmd_rebuild_cli()` - rebuild CLI container with new version
196+
197+
3. **.env**
198+
- Used for docker-compose variable interpolation
199+
- Automatically mounted into the CLI container with project directory
200+
201+
### Customization
202+
203+
#### Changing Docker Compose Version
204+
205+
Edit `Dockerfile.airstack-cli`:
206+
207+
```dockerfile
208+
ARG COMPOSE_VERSION=5.1.0 # Change this version
209+
```
210+
211+
Then rebuild:
212+
```bash
213+
./airstack.sh rebuild-cli
214+
```
215+
216+
#### Adding Tools to the CLI
217+
218+
Add packages to the Dockerfile:
219+
220+
```dockerfile
221+
RUN apk add --no-cache \
222+
bash \
223+
curl \
224+
git \
225+
your-tool-here
226+
```
227+
228+
### Migration from Direct Docker Compose
229+
230+
If you have existing containers:
231+
232+
1. **No action needed** - containers will continue running
233+
2. New `up` commands use containerized compose
234+
3. Existing `docker compose` commands on host still work
235+
4. The `.env` file works identically
236+
237+
### Advanced: How the Wrapper Works
238+
239+
The `run_docker_compose()` function:
240+
241+
1. **Reads `.env` file** to extract all variable names
242+
2. **Passes them from current environment** using `-e VARNAME` flags
243+
3. **Mounts necessary resources** and executes docker-compose
244+
245+
```bash
246+
docker run --rm -i \
247+
-v /var/run/docker.sock:/var/run/docker.sock \ # Host Docker control
248+
-v "$PROJECT_ROOT:$PROJECT_ROOT" \ # Mount project
249+
-v /tmp/.X11-unix:/tmp/.X11-unix \ # X11 socket for GUI
250+
-w "$PROJECT_ROOT" \ # Set working dir
251+
-e USER_ID="$(id -u)" \ # Pass user ID
252+
-e GROUP_ID="$(id -g)" \ # Pass group ID
253+
-e DISPLAY="$DISPLAY" \ # X11 display for GUI
254+
-e PROJECT_NAME \ # All .env variables...
255+
Add packages to the Dockerfile:
256+
257+
```dockerfile
258+
RUN apk add --no-cache \
259+
bash \
260+
curl \
261+
git \
262+
your-tool-here
263+
```
264+
265+
## Developer Requirements
266+
267+
**Minimal requirements:**
268+
- Docker installed (any recent version with socket at `/var/run/docker.sock`)
269+
- The Docker daemon must be running
270+
271+
**NOT required:**
272+
- Specific docker-compose version on host
273+
- docker-compose CLI on host (container provides it)
274+
275+
**Note:** The `airstack install` command will install Docker Engine and NVIDIA Container Toolkit, but will **not** install docker-compose on the host. Docker Compose runs entirely in the containerized CLI environment.
276+
277+
## Migration from Direct Docker Compose
278+
279+
If you have existing containers:
280+
281+
1. **No action needed** - containers will continue running
282+
2. New `up` commands use containerized compose
283+
3. Existing `docker compose` commands on host still work
284+
4. The `.env` file works identically
285+
286+
## Troubleshooting
287+
288+
### CLI container won't build
289+
```bash
290+
# Ensure Dockerfile.airstack-cli exists
291+
ls -la Dockerfile.airstack-cli
292+
293+
# Try building manually
294+
docker build -f Dockerfile.airstack-cli -t airstack-cli:latest .
295+
```
296+
297+
### Docker socket permission denied
298+
```bash
299+
# Check Docker group membership
300+
groups | grep docker
301+
302+
# If not in docker group:
303+
sudo usermod -aG docker $USER
304+
# Then log out and back in
305+
```
306+
307+
### Environment variables not propagating
308+
- The `.env` file must be in the project root
309+
- The entire project directory is mounted into the container
310+
- `USER_ID` and `GROUP_ID` are automatically set from host
311+
312+
### GUI windows not displaying
313+
```bash
314+
# Check DISPLAY is set on host
315+
echo $DISPLAY
316+
# Should show something like ":0" or ":1"
317+
318+
# Ensure xhost allows connections
319+
xhost +
320+
# Should show: "access control disabled, clients can connect from any host"
321+
322+
# Check your docker-compose.yaml has X11 config
323+
# It should include:
324+
environment:
325+
- DISPLAY=${DISPLAY}
326+
volumes:
327+
- /tmp/.X11-unix:/tmp/.X11-unix
328+
329+
# Verify DISPLAY is passed through
330+
./airstack.sh up
331+
# The containerized compose will have DISPLAY set
332+
```
333+
334+
### Environment variable overrides not working
335+
```bash
336+
# Verify the variable is defined in .env
337+
grep ISAAC_SIM_USE_STANDALONE .env
338+
# Should show: ISAAC_SIM_USE_STANDALONE="false"
339+
340+
# Check if the override is being set
341+
ISAAC_SIM_USE_STANDALONE=true env | grep ISAAC_SIM_USE_STANDALONE
342+
# Should show: ISAAC_SIM_USE_STANDALONE=true
343+
344+
# The variable must be defined in .env to be passed through
345+
# If you need a new variable, add it to .env first (even with a default value)
346+
347+
# Debug: Check what's passed to the container
348+
# Add this temporarily to run_docker_compose:
349+
# echo "Passing variables: ${env_args[@]}"
350+
```
351+
352+
## Benefits
353+
354+
The containerized approach provides:
355+
356+
1. **Consistency**: All developers use identical docker-compose version
357+
2. **Isolation**: No host environment interference
358+
3. **Simplicity**: No version checking or installation logic needed
359+
4. **Maintainability**: Single Dockerfile defines tooling
360+
5. **Compatibility**: Works on any Docker-capable host
361+
6. **Flexibility**: Easy to update compose version or add tools
362+
129363
## License
130364
131365
This tool is part of the AirStack project and is subject to the same license terms.

.env

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PROJECT_NAME="airstack"
1111
# If you've run ./airstack.sh setup, then this will auto-generate from the git commit hash every time a change is made
1212
# to a Dockerfile or docker-compose.yaml file. Otherwise this can also be set explicitly to make a release version.
1313
# auto-generated from git commit hash
14-
DOCKER_IMAGE_TAG="0.15.2"
14+
DOCKER_IMAGE_TAG="0.16.0"
1515
# Can replace with your docker hub username
1616
PROJECT_DOCKER_REGISTRY="airlab-docker.andrew.cmu.edu/airstack"
1717
# ============================================
@@ -22,12 +22,17 @@ NUM_ROBOTS="1"
2222
ROBOT_DEFINTIONS="/config/robot_definitions.yaml" # Path to the robot definitions file, which is mounted at /config in containers.
2323

2424
# ============== SIMULATION =====================
25-
ISAAC_SIM_GUI="/root/AirStack/simulation/isaac-sim/assets/scenes/simple_pegasus.scene.usd"
25+
# ISAAC_SIM_GUI="/root/AirStack/simulation/isaac-sim/assets/scenes/simple_pegasus.scene.usd"
26+
# ISAAC_SIM_GUI="/root/AirStack/simulation/isaac-sim/assets/robots/debug_wobble_flat.scene.usd"
27+
# ISAAC_SIM_GUI="/root/AirStack/simulation/isaac-sim/assets/robots/scripted_prim_old_omnigraph.usd"
28+
# ISAAC_SIM_GUI="/root/AirStack/simulation/isaac-sim/assets/robots/old_prim_scripted_omnigraph.usd"
29+
# ISAAC_SIM_GUI="/root/AirStack/simulation/isaac-sim/assets/robots/scripted_iris_prim.usd"
30+
ISAAC_SIM_GUI="/root/AirStack/simulation/isaac-sim/assets/robots/scripted_iris_prim_with_sensors.usd"
2631
# Set to "true" to launch Isaac Sim using a standalone Python script instead of USD file
27-
ISAAC_SIM_USE_STANDALONE_SCRIPT="false" # "true" or "false"
32+
ISAAC_SIM_USE_STANDALONE="false" # "true" or "false"
2833
# Script name (must be in /AirStack/simulation/isaac-sim/launch_scripts/)
2934
ISAAC_SIM_SCRIPT_NAME="example_one_px4_pegasus_launch_script.py"
30-
PLAY_SIM_ON_START="false" # Not supported in standalone script mode
35+
PLAY_SIM_ON_START="false"
3136
# ===============================================
3237

3338
# ================= ROBOT =====================

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,7 @@ frames_*.pdf
6161
nucleus_token.txt
6262

6363
docker/sitl_integration/px
64+
65+
66+
# mkdocs
67+
mkdocs.log

0 commit comments

Comments
 (0)