Installing ROS docker with GPU support, for controlling DJI's Tello drone.

Hey, its been a while.

That probably because I'm knees deep in Technion's Autonomous & Perception course,
of the Aerodynamics & Space faculty.

As for the final project, we ought to implement (and improve):
Sampling-based robotic information gathering algorithm,
By Geoffrey A. Hollingerand Gaurav S. Sukhatme.

We aim to demonstrate our work in a real life example, where a drone (my beloved Tello drone) will use GIL algorithms for planning and executing an optimal trajectory between two points, while avoiding obstacles.

In this post I'll focus on the platform well use for developing and testing our project.


Using ros docker tutorial, We can create a ros docker with Hardware Acceleration.

  • We create a Dockerfile, with NVIDIA support, and all dependencies for TelloPy:
FROM osrf/ros:melodic-desktop-full

# nvidia-container-runtime
# Set the working directory
# WORKDIR /usr/src/app

# Install any needed packages specified in requirements.txt
RUN apt-get update  
RUN apt-get install -y pkg-config  
RUN apt install -y python3-dev  
RUN apt-get install -y python3-pip

# AV library dependencies
RUN apt-get install -y libavformat-dev libavdevice-dev  
RUN apt-get install -y libsm6 libxext6 libxrender-dev

# Tello library dependencies
RUN pip3 install av==6.1.2

# OpenCV
RUN pip3 install opencv-python  
  • Then we build
docker build -t ros_tello .  
  • Now we create a script to run the image called run_my_image.bash:
# Exposing Tellos ports.
if [ ! -f $XAUTH ]  
    xauth_list=$(xauth nlist :0 | sed -e 's/^..../ffff/')
    if [ ! -z "$xauth_list" ]
        echo $xauth_list | xauth -f $XAUTH nmerge -
        touch $XAUTH
    chmod a+r $XAUTH

xhost + && docker run -it \  
    --privileged \ # Needed to access display, otherwise
    --network host \
    --env="DISPLAY=$DISPLAY" \
    --env="QT_X11_NO_MITSHM=1" \
    --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
    -env="XAUTHORITY=$XAUTH" \
    --volume="$XAUTH:$XAUTH" \
    --runtime=nvidia \
    --name tello_ros \
    ros_tello \
  • Make the script executable
$ chmod a+x run_my_image.bash
  • Execute the script
$ ./run_my_image.bash
  • Flags explanations:

    • --privleged: Otherwise
    • --network host: Will be using ports to communicate with the Tello. So well expose all host's ports.
    • --env="DISPLAY=$DISPLAY": Point to which display to to show context.
    • --env="QT_X11_NO_MITSHM=1": IDK
    • --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw": Point to the X11 server, unix graphics server.
    • -env="XAUTHORITY=$XAUTH": Point to config that gives authority for controlling graphics.
    • --volume="$XAUTH:$XAUTH": Point to the volume of that config.
    • --runtime=nvidia: Run with external GPU's capabilities.
    • --name tello_ros: Name of the new container.
    • ros_tello: Name of the Image, that will creates our container.
    • bash: Start command.
  • Test if everything work fine (within the container):

roscore > /dev/null & rosrun rviz rviz  

RVIZ should open, with ros in the background.

Installing tello-driver

Assuming we're out of the container

  • Start container
docker container start tello_ros  
  • Attach container
docker container attach tello_ros  
  • Make a catkin_ws:
mkdir -p /home/catkin_ws/src  
cd /home/catkin_ws && catkin_make # Create workspace for the first time.  
  • Download the tello-driver
cd ./src  
git clone --recursive  
  • Making the package
cd .. # Go back to /catkin_ws  
rosdep install --from-paths src --ignore-src -r -y  # Install package dependencies.  

That will build the project.

Now we run tello-driver:

source ./devel/setup.bash

#### Before, we make sure we're connected to Tello's wifi.
roslaunch tello_driver tello_node.launch  

Testing connection

In another terminal:

docker exec -it tello_ros bash  
cd home/catkin_ws/  
source devel/setup.bash  


RVIZ should show stream from camera

We have ROS docker. with Tello driver. And GPU capabilities.

New we can start our project :)

Here's some raw High Level overview of our project:

Installing Pycharm inside Docker

It took me tonne of work just to make the ros-tello-driver to run within ROS container, when that being said, developing with python against a container, is somewhat a painful process. Pycharm isn't using python interpreter within a docker. It is possible to get it to work, but I had enough, thus installed ROS2 on my laptop, and started from scratch. Ditching the docker part.

Till next time.


Read more posts by this author.

Subscribe to What I Made Today

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!