Docker

In order to get started quickly with Ros2 and ds-crazyflies we dockerised this project. Therefore if you only want to have a quick peek at the project, you can use the provided Docker setup. With the container you will be able to run webots with a single crazyflie.

Note

The Docker setup described here was created for Windows 11 with a nvidia GPU and DockerDesktop. If you do have a different setup, you may need to adjust the docker-compose file etc.

Warning

Using the docker setup with real hardware is neither tested nor recommended. It should only be used with the Webots simulation.

1. Docker-Desktop Settings

Inside DockerDesktop go to Settings -> Docker Engine and add the following configuration:

 "runtimes": {
    "nvidia": {
    "path": "/usr/bin/nvidia-container-runtime",
    "runtimeArgs": []
    }
}

2. MobaXterm

Install and launch MobaXterm:

https://mobaxterm.mobatek.net/download.html

! We also tried VcXsrv with our setup. This did not work !

3. Building the Image

  1. Clone this repo to your local machine:

    git clone https://github.com/DynamicSwarms/ds-crazyflies.git
    
  2. Run the services in docker/docker-compose.windows_dev.yaml

    We used VSCode with the following extensions:

    With this setup open the cloned ds-crazyflies folder with VSCode. Open the docker-compose file and a button appears to run the service.

4. Usage

  1. Run the autolaunch service.

    This will automatically start webots and the necessary backend (See Usage). Webots should be able to open windows with MobaXterm installed. There are a few Webots Windows you have to close at the beginning.

  2. You can now attach a terminal to the running container.

    With the VSCode extension you can do this by clicking on the container in the Docker view and selecting Attach Shell. Or you can Attach Visual Studio Code and then open a terminal in the fresh VSCode window.

  3. You can now use the ROS 2 CLI and get comfortable with the framework:

    1. Start by using the gateway to add the Crazyflie.

      ros2 service call /crazyflie_webots_gateway/add_crazyflie crazyflie_webots_gateway_interfaces/srv/WebotsCrazyflie "id: 0
          initial_position:
          x: 0.0
          y: 0.0
          z: 0.0
          type: ''"
      

      The service should respond with the following:

      requester: making request: crazyflie_webots_gateway_interfaces.srv.WebotsCrazyflie_Request(id=0, initial_position=geometry_msgs.msg.Point(x=0.0, y=0.0, z=0.0), type='')
      
      response:
      crazyflie_webots_gateway_interfaces.srv.WebotsCrazyflie_Response(success=True)
      
    2. You can now publish a takeoff command to the Crazyflie.

      ros2 topic pub /cf0/takeoff crazyflie_interfaces/msg/Takeoff "group_mask: 0
          height: 1.0
          yaw: 0.0
          use_current_yaw: false
          duration:
          sec: 0
          nanosec: 0" --once
      

      You should now see the crazyflie rising to 1 meter in the simulation window.