Simulation setup using Docker Compose - osrf/mbzirc GitHub Wiki

The final evaluation runs will be done on Open Robotics's cloud simulation platform that will execute the run over multiple machine instances. To reproduce a similar setup that will be used, we provide a script to generate a Docker-Compose config file for launching multiple containers locally on a single machine.

The script is located in the mbzirc/docker/compose. Please see the README.md file for usage instructions.

You will need the following in order to launch a simulation with Docker Compose:

  1. Solution Docker image
  2. Team configuration file

We will demonstrate how the setup works with the example mbzirc_seed solution and its team config file.

  1. First run the gen_docker_compose.py script to generate a Docker Compose yaml file. The mbzirc_seed argument is the name of the docker image which we built using these Docker files.

    python3 gen_docker_compose.py --config `ros2 pkg prefix mbzirc_seed`/share/mbzirc_seed/config/team.yaml --image mbzirc_seed

    This should generate a mbzirc_compose.yaml file containing 1 simulation container, 3 bridge containers, and 3 solution containers.

  2. To launch the whole simulation setup, run:

    docker compose -f mbzirc_compose.yaml up -d

    To see the console logs, you can run docker compose in non-detached mode, i.e. omit the -d argument.

    Once launched, the gazebo window should pop up. After a while, simulation should start running and the 2 quadrotors and 1 USV will be moving.

    mbzirc_seed_coast

  3. To bring down all the containers, run

    docker compose -f mbzirc_compose.yaml down 
    

Troubleshooting

  1. If you have an issue spawning more than 8 or 9 robots in simulation after launching the whole setup using docker compose, please try commenting out the ROS_LOCALHOST_ONLY=1 line.

  2. If the gazebo gui quits immediately when launched using docker compose with a stack trace and the following errors:

    compose-sim-1  | [ign gazebo-1] qt.qpa.xcb: could not connect to display :1
    compose-sim-1  | [ign gazebo-1] qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
    compose-sim-1  | [ign gazebo-1] This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    

    Then try launching everything in headless mode.

    1. Add the --headless argument when generating the mbzirc_compose.yaml file.

      python3 gen_docker_compose.py --config <your_config_file> --image <your_image> --headless 1

      This will tell docker to run the simulation without a GUI. Do not run docker compose yet.

    2. Launch the mbzirc_sim docker container.

      cd <path_to_mbzirc>/docker
      bash run.bash osrf/mbzirc:mbzirc_sim_latest
    3. To get meshes to show up correctly in this docker container when you attach a GUI to the simulation started by docker compose, you need to run the simulation with your config file inside the container at least once.

      1. From the host machine, copy your team yaml configuration file into the container that was just started

        # run docker ps to see the container that was just started. Make note of the container id
        docker ps
        
        # copy your yaml config file to the home directory of the docker container
        docker cp <path_to_config_yaml> <container_id>:/home/developer/config.yaml
      2. From inside the docker container, run the simulation once

        ros2 launch mbzirc_ign competition.launch.py world:=coast config_file:=/home/developer/config.yaml
        
      3. Mesh files should be generated. Terminate the simulation.

    4. From the host machine, run docker compose with the new yaml file:

      docker compose -f mbzirc_compose.yaml up
      
    5. From inside your docker container, attach a GUI to it:

      IGN_PARTITION=sim ign gazebo -v 4 -g
      
⚠️ **GitHub.com Fallback** ⚠️