ROS2 Docker Container Environment
A containerized ROS2 development environment with GUI support and NVIDIA GPU acceleration. This Docker setup provides an isolated workspace for ROS2 development while maintaining seamless integration with your host filesystem.
Features
- ROS2 Distribution: Default
humble(configurable) - GUI Support: X11 forwarding for ROS2 GUI applications
- GPU Support: NVIDIA GPU acceleration (when available)
- Workspace Mounting: Host
ws/directory mounted with full permissions - User Permissions: Runs with matching host user/group IDs
- Sample Movie: video
Prerequisites
- Docker: Install following Docker Engine installation guide
- Post-install Setup: Configure Docker for non-root usage
- NVIDIA Runtime (optional): For GPU support, install nvidia-container-toolkit
Quick Start
Clone and navigate to repository
git clone git@github.com:Standard-Cognition/keypoint-db.git cd keypoint_dbBuild the container
makeRun container
./run_container.shJoin from another terminal (optional)
./join_container.sh
ROS2 Development Workflow
Inside the container (/home/user/ws):
Install dependencies (first time only):
sudo apt-get update
rosdep update
rosdep install -i --from-path src --rosdistro ${ROS_DISTRO} -y
Build workspace:
./compile_and_source.sh
Run rviz with a layout:
ros2 launch db_loader layout_visualization_launch.py json_file:=/home/user/ws/data/research.sc.s2016.json
Outside of the container download the track csv file
download from: https://drive.google.com/file/d/1sf924lEBK2VLuBmHUzGXUakn6blwY9r2/view?usp=sharing
cp chunk_1971-03-29T03_20_00Z_1971-03-29T03_25_00Z.csv YOUR_FOLDER/Tracks/keypoint-db/ws/data/
Join from another terminal
./join_container.sh
Run the keypoint_publisher:
ros2 run db_loader keypoint_publisher data/chunk_1971-03-29T03_20_00Z_1971-03-29T03_25_00Z.csv
From a 3rd terminal window, join the container
./join_container.sh
Run the keypoint_publisher:
ros2 run db_loader keypoint_subscriber
Project Structure
dataset_ros2_container/
βββ Dockerfile # Container image definition
βββ Makefile # Build automation
βββ docker-compose.yml # Docker Compose configuration
βββ .env # Environment variables
βββ utils # Shared shell utilities
βββ run_container.sh # Start container script
βββ join_container.sh # Join running container script
βββ ws/ # ROS2 workspace (mounted)
β βββ src/ # Your ROS2 packages
β βββ build/ # Build artifacts
β βββ install/ # Installation directory
β βββ log/ # Build logs
βββ README.md # This file
Configuration
Environment Variables
ROS2_DISTRO: ROS2 distribution (default: from.envfile)IMAGE_NAME: Docker image name (default:ros2_devel)APT_MIRROR: APT mirror location (default:jp)DOCKER_BUILD_OPTS: Additional Docker build options
Container Features
- X11 Forwarding: Automatic GUI application support
- NVIDIA GPU: Auto-detected and enabled when available
- Network: Host networking for ROS2 communication
- Workspace Persistence:
ws/directory changes persist on host
Troubleshooting
GPU not detected:
- Ensure NVIDIA drivers are installed on host
- Install nvidia-container-toolkit
- Verify with
nvidia-smicommand
Permission issues:
- Container runs with host user/group IDs automatically
- Ensure Docker post-install steps completed
GUI applications not working:
- Verify X11 forwarding:
echo $DISPLAY - Check XAUTH permissions in container
Build failures:
- Use
--no-cachebuild option - Update base images with
--pull=true
Contributing
- Fork the repository
- Create feature branch:
git checkout -b feature-name - Commit changes:
git commit -am 'Add feature' - Push branch:
git push origin feature-name - Submit pull request
License
See LICENSE file for details.