Script overview
The.devcontainer/ directory contains three main scripts that automate the setup and verification of the TurtleBot3 development environment.
Scripts
post-create.sh
Purpose: One-time initialization when the container is first created When it runs: Automatically executed bypostCreateCommand in devcontainer.json
What it does:
- Detects GPU capabilities (hardware vs software rendering)
- Configures user’s
.bashrcwith ROS2 environment - Sets up environment variables
- Creates useful bash aliases
- Clones TurtleBot3 repositories from GitHub
- Initializes and updates rosdep
- Installs package dependencies
- Creates maps directory
- Generates GPU information file
- Intelligent GPU detection with software rendering fallback
- Idempotent repository cloning (won’t re-clone if content exists)
- Verifies package integrity by counting package.xml files
.devcontainer/post-create.sh
Documentation: See post-create.sh
post-start.sh
Purpose: Build workspace and verify readiness on every container start When it runs: Automatically executed bypostStartCommand in devcontainer.json
What it does:
- Sources ROS2 Jazzy environment
- Verifies packages exist in src/ directory
- Checks if workspace is already built
- Builds workspace with colcon if needed
- Displays quick start instructions
- Skips build if workspace is already built and functional
- Handles Windows mount compatibility issues
- Provides immediate feedback on container readiness
- Shows TurtleBot3 package list after successful build
.devcontainer/post-start.sh
Documentation: See post-start.sh
verify-setup.sh
Purpose: Comprehensive setup verification and diagnostics When it runs: Manually by the user when needed Usage:- System checks: ROS2, Gazebo, Python, colcon
- Package checks: TurtleBot3, Navigation2, Cartographer
- Environment variables: ROS_DISTRO, TURTLEBOT3_MODEL, GZ_VERSION
- Directory structure: Workspace, source, and build directories
- Build status: Build and install directories
- Color-coded test results (green = pass, red = fail, yellow = warning)
- Pass/fail summary
- Quick start instructions if all tests pass
- Troubleshooting guidance if tests fail
.devcontainer/verify-setup.sh
Documentation: See verify-setup.sh
Script execution order
-
Container creation:
post-create.shruns once- Sets up environment
- Clones repositories
- Installs dependencies
-
Container start:
post-start.shruns every time- Builds workspace (if needed)
- Verifies readiness
-
Manual verification:
verify-setup.shruns on-demand- Diagnoses issues
- Confirms setup
Common workflows
First time setup
Container restart
Troubleshooting
Exit codes
| Script | Success | Failure |
|---|---|---|
| post-create.sh | 0 | Non-zero |
| post-start.sh | 0 | 1 (no packages or build failed) |
| verify-setup.sh | 0 | Always 0 (shows results in output) |