Skip to content

Commit c8b3c7e

Browse files
committed
Update scaling of robots to use replicas instead, much cleaner. Can now prepend NUM_ROBOTS=N
and Update docs about airstack cli
1 parent 6756bea commit c8b3c7e

File tree

11 files changed

+89
-97
lines changed

11 files changed

+89
-97
lines changed

.env

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
# This is the main .env file for AirStack, which sets docker compose variables for variable interpolation.
2-
# Standard Usage: docker compose --env-file .env up
2+
# Standard Usage: airstack --env-file .env up
33

4-
# See overrides/ for overriding specific variables.
5-
# To override, run docker compose --env-file .env --env-file overrides/<override_file>.env up. Any variables set in
6-
# the following --env-file will override previous ones.
7-
8-
# Warning: all variables get propagated to all sub-level docker-compose files, so be careful about naming conflicts.
4+
# Warning: even though this file is organized into sections, all variables get propagated to all sub-level
5+
# docker-compose files, so be careful about naming conflicts.
96

107
# =============== PROJECT ====================
118
# These variables are used to tag the docker images.
@@ -18,13 +15,15 @@ PROJECT_DOCKER_REGISTRY="airlab-storage.andrew.cmu.edu:5001/shared"
1815
# ============================================
1916

2017
# ================ SIMULATION =================
21-
DEFAULT_ISAAC_SCENE="omniverse://airlab-storage.andrew.cmu.edu:8443/Projects/AirStack/AFCA/fire_academy_faro_with_sky.scene.usd"
18+
ISAAC_SIM_SCENE="omniverse://airlab-storage.andrew.cmu.edu:8443/Projects/AirStack/AFCA/fire_academy_faro_with_sky.scene.usd"
2219
PLAY_SIM_ON_START="true"
2320
# =============================================
2421

2522
# ================= ROBOT =====================
2623
# See robot/docker/docker-compose.yaml for how these variables get propagated in
2724
# the container's entry command.
25+
NUM_ROBOTS="1"
26+
2827
ROBOT_LAUNCH_PACKAGE="robot_bringup"
2928
ROBOT_LAUNCH_FILE="robot.launch.xml"
3029

docs/development/airstack-cli/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# AirStack CLI Architecture
1+
# Advanced: AirStack CLI Architecture
22

33
This document describes the architecture of the AirStack CLI tool, explaining how it's organized and how the different components work together.
44

docs/development/docker_usage.md renamed to docs/development/airstack-cli/docker_usage.md

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Launch Workflow with Docker and Docker Compose
22

3-
To mimic interacting with multiple real world robots, we use Docker Compose to manage Docker containers that isolate the simulation, each robot, and the ground control station.
3+
At its core, the `airstack` CLI is simply a wrapper around Docker Compose. `airstack up` is equivalent to `docker compose up -d`, and `airstack down` is equivalent to `docker compose down`.
4+
5+
Docker Compose is useful to mimic interacting with multiple robots in a simulated environment, such as Isaac Sim, while isolating each robot's environment and the ground control station.
46

57
The details of the docker compose setup is in the project root's `docker-compose.yaml`.
68

@@ -13,7 +15,7 @@ In essence, the compose file launches:
1315
all get created on the same default Docker bridge network.
1416
This lets them communicate with ROS2 on the same network.
1517

16-
Each robot has its own ROS_DOMAIN_ID.
18+
Each robot has its own ROS_DOMAIN_ID, which is extracted from the container name, e.g. `airstack-robot-1` has `ROS_DOMAIN_ID=1`. See the robot `.bashrc` for details.
1719

1820
## Pull Images
1921

@@ -42,33 +44,27 @@ docker compose build
4244
Start
4345

4446
```bash
45-
docker compose up --scale robot=[NUM_ROBOTS] -d
47+
airstack up # or equivalently: docker compose up -d
4648

4749
# see running containers
48-
docker ps -a
49-
```
50-
51-
Stop
52-
53-
```bash
54-
docker compose stop
50+
airstack status # or equivalently: docker ps -a
5551
```
5652

5753
Remove
5854

5955
```bash
60-
docker compose down
56+
airstack down # or equivalently: docker compose down
6157
```
6258

6359
Launch only specific services:
6460

6561
```bash
6662
# only robot
67-
docker compose up robot --scale robot=[NUM_ROBOTS] -d
63+
airstack up robot # or equivalently: docker compose up robot -d
6864
# only isaac
69-
docker compose up isaac-sim -d
65+
airstack up isaac-sim # or equivalently: docker compose up isaac-sim -d
7066
# only ground control station
71-
docker compose up gcs -d
67+
airstack up gcs # or equivalently: docker compose up gcs -d
7268
```
7369

7470

@@ -79,9 +75,7 @@ Start a bash shell in the Isaac Sim container:
7975

8076
```bash
8177
# if the isaac container is already running, execute a bash shell in it
82-
docker exec -it isaac-sim bash
83-
# or if not, start a new container
84-
docker compose run isaac-sim bash
78+
airstack connect isaac-sim # or equivalently: docker exec -it isaac-sim bash
8579
```
8680

8781
Within the isaac-sim Docker container, the alias `runapp` launches Isaac Sim.
@@ -96,10 +90,17 @@ The container also has the isaacsim ROS2 package within that can be launched wit
9690
Start a bash shell in a robot container, e.g. for robot_1:
9791

9892
```bash
99-
docker exec -it airstack-robot-1 bash
93+
airstack connect robot # or equivalently: docker exec -it airstack-robot-1 bash
10094
```
10195

102-
The previous `docker compose up` launches robot_bringup in a tmux session. To attach to the session within the docker container, e.g. to inspect output, run `tmux attach`.
96+
To launch more than one robot, prepend with the `NUM_ROBOTS=[NUM]` environment variable, e.g. to launch 2 robots (along with the ground control station and Isaac Sim):
97+
```bash
98+
NUM_ROBOTS=2 airstack up
99+
airstack connect robot-1 # to connect to robot 1
100+
airstack connect robot-2 # to connect to robot 2
101+
```
102+
103+
The previous `docker compose up` launches robot_bringup in a tmux session. To attach to the session within the docker container, e.g. to inspect output, run `tmux a`.
103104

104105
The following commands are available within the robot container:
105106

@@ -112,7 +113,7 @@ sws # sources workspace
112113
ros2 launch robot_bringup robot.launch.xml # top-level launch
113114
```
114115

115-
These aliases are in `AirStack/robot/.bashrc`.
116+
These aliases are defined in `AirStack/robot/.bashrc`.
116117

117118
Each robot has `ROS_DOMAIN_ID` set to its ID number. `ROBOT_NAME` is set to `robot_$ROS_DOMAIN_ID`.
118119

@@ -123,7 +124,7 @@ Currently the ground control station uses the same image as the robot container.
123124
Start a bash shell in a robot container:
124125

125126
```bash
126-
docker exec -it ground-control-station bash
127+
airstack connect gcs # or equivalently: docker exec -it ground-control-station bash
127128
```
128129

129130
The available aliases within the container are currently the same.
@@ -181,27 +182,31 @@ docker compose up autotest
181182
This command will spin up a `robot` container, build the ROS2 workspace, source the workspace and run all the configured tests for the provided packages using `colcon test`. Excessive output log from the build process is presently piped away to preserve readability.
182183

183184
## Docker Compose Variable Overrides
184-
Sometimes you may want to test different configurations of the autonomy stack. For example, you may want to disable automatically playing the sim on startup,
185-
or to change a child launch file.
186-
187-
The `docker compose` workflow is designed to support these overrides for local development.
188-
`docker compose` uses `.env` files to set docker-compose variables that get propagated and interpolated into `docker-compose.yaml` files.
189-
See the [docker compose documentation](https://docs.docker.com/compose/how-tos/environment-variables/variable-interpolation/) for more details.
185+
As mentioned above, the `airstack` CLI is a wrapper around Docker Compose.
186+
Therefore, it supports [variable interpolation](https://docs.docker.com/compose/how-tos/environment-variables/variable-interpolation/) in the `docker-compose.yaml` file, allowing you to adjust project settings by modifying environment variables.
190187

191-
The default `.env` file is in the project root directory.
192-
When no `--env-file` argument is passed to `docker compose`, it automatically uses this default `.env` file.
193-
194-
To override the default `.env` file, you can pass the `--env-file` argument to `docker compose` with a path to your custom `.env` file.
188+
For example, to disable playing the simulation on startup, you can set the `PLAY_SIM_ON_START` variable to `false`:
189+
```bash
190+
PLAY_SIM_ON_START=false airstack up
191+
```
195192

196-
For example, this command disables playing the simulation on startup by overriding the `PLAY_SIM_ON_START` variable:
193+
To change the Isaac Sim scene:
197194
```bash
198-
docker compose --env-file .env --env-file overrides/no_play_sim_on_start.env up -d
195+
ISAAC_SIM_SCENE=path/to/your_scene.usd airstack up
199196
```
200197

201-
As another example, this command changes the perception launch file to `perception_no_macvo.launch.xml`:
198+
A list of all available environment variables is in the default `.env` file in the project root directory, which allows specifying all the variables in one place.
199+
When no `--env-file` argument is passed to `docker compose`, it automatically uses this default `.env` file.
200+
201+
The top-level env file is reproduced below:
202202
```bash
203-
docker compose --env-file .env --env-file overrides/no_macvo.env up -d
203+
--8<-- ".env"
204204
```
205205

206+
To override the default `.env` file, you can pass the `--env-file` argument with the syntax `airstack --env-file [env_file] up` (or `docker compose --env-file [env_file] up -d`).
207+
208+
Multiple `--env-file` arguments can be passed to compose overriding sets of variables.env` file.
209+
When overriding, the default `.env` file must be loaded first. The overrides are applied on top of it.
210+
211+
206212

207-
When overriding, the default `.env` file must be loaded first. The overrides are applied on top of it.

docs/development/airstack-cli/extending.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Extending the AirStack CLI
1+
# Advanced: Extending the AirStack CLI
22

33
The AirStack CLI tool is designed to be easily extensible through modules. This guide explains how to create new modules and add commands to the AirStack CLI.
44

docs/development/airstack-cli/index.md

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ The AirStack CLI tool is designed to be:
1111
- **Helpful**: Includes detailed help text and error messages
1212
- **Extensible**: New commands can be added without modifying the core script
1313

14+
At its core, `airstack.sh` is simply a light wrapper around [docker compose](https://docs.docker.com/compose/), providing additional functionality and convenience for AirStack development.
15+
1416
## Basic Usage
1517

1618
```bash
@@ -29,6 +31,18 @@ To get help for a specific command:
2931
./airstack.sh help <command>
3032
```
3133

34+
## Adding to Shell Profile
35+
36+
For convenience, you can add the AirStack CLI to your shell profile to make it available from any directory:
37+
38+
```bash
39+
./airstack.sh setup
40+
# now you can use `airstack` instead of `./airstack.sh`
41+
airstack commands
42+
```
43+
44+
This will add the necessary aliases to your shell profile (`~/.bashrc`, `~/.zshrc`, etc.) so you can use the `airstack` command from any directory.
45+
3246
## Core Commands
3347

3448
The AirStack CLI includes several built-in commands:
@@ -49,7 +63,7 @@ The AirStack CLI includes several built-in commands:
4963
The `install` command sets up the necessary dependencies for AirStack development:
5064

5165
```bash
52-
./airstack.sh install [options]
66+
airstack install [options]
5367
```
5468

5569
Options:
@@ -62,7 +76,7 @@ Options:
6276
The `setup` command configures your environment for AirStack development:
6377

6478
```bash
65-
./airstack.sh setup [options]
79+
airstack setup [options]
6680
```
6781

6882
Options:
@@ -75,19 +89,23 @@ The AirStack CLI provides several commands for managing Docker containers:
7589

7690
```bash
7791
# Start services
78-
./airstack.sh up [service...]
92+
airstack up [service...]
93+
airstack up robot # start only the robot service
94+
airstack up isaac-sim # start only the Isaac Sim service
95+
airstack up gcs # start only the Ground Control Station service
96+
airstack up docs # start only the documentation service
7997

8098
# Stop services
81-
./airstack.sh down [service...]
99+
airstack down [service...]
82100

83101
# Show container status
84-
./airstack.sh status
102+
airstack status
85103

86-
# Connect to a container shell
87-
./airstack.sh connect <container_name>
104+
# Connect to a container shell, supports partial name matching
105+
airstack connect <container_name>
88106

89107
# View container logs
90-
./airstack.sh logs <container_name>
108+
airstack logs <container_name>
91109
```
92110

93111
## Module-Specific Commands
@@ -98,37 +116,27 @@ In addition to the core commands, the AirStack CLI includes several module-speci
98116

99117
```bash
100118
# Run all configuration tasks
101-
./airstack.sh config
119+
airstack config
102120

103121
# Configure Isaac Sim
104-
./airstack.sh config:isaac-sim
122+
airstack config:isaac-sim
105123

106124
# Configure Nucleus
107-
./airstack.sh config:nucleus
125+
airstack config:nucleus
108126

109127
# Configure Git hooks
110-
./airstack.sh config:git-hooks
128+
airstack config:git-hooks
111129
```
112130

113131
### WinTAK Commands
114132

115133
```bash
116134
# Install WinTAK
117-
./airstack.sh wintak:install
135+
airstack wintak:install
118136

119137
# Start WinTAK VM
120-
./airstack.sh wintak:start
138+
airstack wintak:start
121139

122140
# Stop WinTAK VM
123-
./airstack.sh wintak:stop
141+
airstack wintak:stop
124142
```
125-
126-
## Adding to Shell Profile
127-
128-
For convenience, you can add the AirStack CLI to your shell profile to make it available from any directory:
129-
130-
```bash
131-
./airstack.sh setup
132-
```
133-
134-
This will add the necessary aliases to your shell profile (`~/.bashrc`, `~/.zshrc`, etc.) so you can use the `airstack` command from any directory.

docs/development/project_configuration.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

docs/development/vscode/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
Start containers
44
```bash
5-
# optionally pass the --scale robot=N argument to start N robots
6-
dc compose up -d # --scale robot=2
5+
# optionally prepend NUM_ROBOTS=N argument to start N robots
6+
airstack up -d
77
```
88

99
Open AirStack folder

docs/robot/index.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,6 @@ At a high level, the launch files are organized as follows:
2828
### Desktop vs Jetson
2929
If you look at the `robot/docker/docker-compose.yaml` file, you'll see it contains two services. `robot` is meant for x86-64 desktop development whereas `robot_l4t` is meant to run on NVIDIA Jetson devices. Both extend a base service in `robot/docker/robot-base-docker-compose.yaml`.
3030

31-
### Environment Variables
32-
Environment variables are used to configure the robot Docker container. The top level `AirStack/.env` file points to a `ROBOT_ENV_FILE_NAME` (default: `robot.env`), that in turn is used to load environment variables for the robot Docker container. The file that `ROBOT_ENV_FILE_NAME` points to gets added into the container under `robot/docker/robot-base-docker-compose.yaml`.
33-
34-
The environment variables can be used to trigger nodes to launch. For example, the `USE_MACVO` environmental variable is checked by `perception.launch.xml` to determine whether to launch the `macvo` node.
35-
36-
The file `robot.env` is reproduced below:
37-
```bash
38-
--8<-- "robot/docker/robot.env"
39-
```
40-
4131
## Common Topics
4232
| Topic | Type | Description |
4333
| -------------------------------| ------------------| ---------------------------------------------------------------------------------------------------------------------------|

mkdocs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ nav:
4949
- docs/development/index.md
5050
- AirStack CLI Tool:
5151
- docs/development/airstack-cli/index.md
52+
- docs/development/airstack-cli/docker_usage.md
5253
- docs/development/airstack-cli/extending.md
5354
- docs/development/airstack-cli/architecture.md
54-
- docs/development/docker_usage.md
5555
- docs/development/vscode/index.md
56-
- docs/development/project_configuration.md
5756
- Testing:
5857
- docs/development/testing/index.md
5958
- docs/development/testing/testing_frameworks.md

robot/docker/docker-compose.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ services:
3232
ports:
3333
# for ssh, starting from 2223-2243 on the host port all map to 22 in the container. Assumes no more than 21 robots
3434
- "2223-2243:22"
35+
# for multiple robots
36+
deploy:
37+
replicas: ${NUM_ROBOTS:-1}
3538

3639
# -------------------------------------------------------------------------------------------------------------------
3740
# dev container for developer debugging

0 commit comments

Comments
 (0)