• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
ModalAI Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
    • Register
    • Login

    How to copy your MAVSDK Python Docker container and edit the files?

    Ask your questions right here!
    5
    9
    789
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      Alfonso Ponce
      last edited by 10 May 2021, 22:18

      Hello! I'm new to Dockers, as well as everything about drones basically. I have done everything needed to run the takeoff_and_land2.py file using MAVSDK Python using your documentation. What I want to try now is do the exact same (using a Docker container) but instead of running the takeoff_and_land2.py file use another python code to experiment.

      How am I able to copy your container and just replace the .py files for other .py files and begin experimenting with the drone (I use an m500 and a Linux host PC)? Is this the easiest way to do this (using Docker containers)?

      Thank you!

      1 Reply Last reply Reply Quote 0
      • C
        Chad Sweet ModalAI Team
        last edited by 10 May 2021, 23:00

        Great to hear you got the tutorial up and running.

        One thing you could do is use the '-v' option of docker run to share a directory between the docker and base image, documentation here: https://docs.docker.com/engine/reference/commandline/run/

        You can edit your code on your PC and push to the target in the shared folder to access inside of the Docker

        1 Reply Last reply Reply Quote 0
        • R
          ryan_meagher
          last edited by ryan_meagher 12 May 2021, 07:27 12 May 2021, 07:25

          You can add a directory from your host machine which has whatever python files you wish to add via adding a src directory path and mapping it to a path in the containers file structure.

          docker run -it --rm -v /host_src_dir_path:/container_dir_path --privileged --net=host <img>:<tag>
          

          Upon running the docker container, the directory from /host_src_dir_path will be available at /container_dir_path

          A 1 Reply Last reply 12 May 2021, 23:08 Reply Quote 1
          • A
            Alfonso Ponce @ryan_meagher
            last edited by 12 May 2021, 23:08

            Thank you very much @ryan_meagher
            I just have some basic questions about this you're telling me. Remember I'm new to this 😞

            According to the instructions in this README repository from ModalAI:

            https://gitlab.com/voxl-public/voxl-docker-images/voxl-docker-mavsdk-python

            I’ve been able to do everything for the example program to run in the drone, however I’m not sure which is the container’s directory path that I need to add in the command you’re telling me. The directory in my host machine is just the path where the .py files would be right? Also, I haven't build the image (as it says it's optional) because I'm not sure what benefits does that bring. I don't even know if I have to build the image inside the drone or inside my computer.

            Anyway, here are the commands I use to make an SSH connection to the drone and start the terminal.

            (base) ponchoponce95@ponchoponce95-Lenovo-Y50-70:~$ ssh root@10.96.67.121
            root@10.96.67.121's password: 
            ~ # docker run -it --rm --privileged --net=host gcr.io/modalai-public/voxl-mavsdk-python:v1.1 /bin/bash
            root@apq8096:/home# 
            

            So in order to access my .py files in my computer, instead of typing:

            docker run -it --rm --privileged --net=host gcr.io/modalai-public/voxl-mavsdk-python:v1.1 /bin/bash
            

            I must type:

            docker run -it --rm -v /Home/Rutinas:/home --privileged --net=host gcr.io/modalai-public/voxl-mavsdk-python:v1.1 /bin/bash
            

            ???

            Because that last command is telling me that it can't find the .py files that I have inside my Rutinas folder.

            1 Reply Last reply Reply Quote 0
            • M
              modaltb ModalAI Team
              last edited by 13 May 2021, 16:12

              First off, thanks @ryan_meagher for the assitance!!!

              @Alfonso-Ponce ,

              Although you can build on a host computer, you need to understand how to build for ARM, so if you aren't comfortable with that it's easier to build on target (on the VOXL). Here's a good overview: https://www.stereolabs.com/docs/docker/building-arm-container-on-x86/

              A docker container is typically a self contained "box", and you can build the files into the container at BUILD time of said container.

              Like @ryan_meagher mentioned, you can also use mounting to 'copy' files into the container at startup, for example, here's the source to the voxl-docker script (used on host computer) to mount files into the container from the current working directory: https://gitlab.com/voxl-public/utilities/voxl-docker/-/blob/master/files/voxl-docker.sh#L102

              What you have above needs to be updated to valid paths ON THE VOXL. /Home/Rutinas likely doesn't exist on VOXL.... unless you've made a 'Rutinas' diectory

              Here's a defeault /home

              /home # ls
              adb   audio	 camera    input  root	   system
              apps  bluetooth  graphics  radio  sensors 
              

              You could instead make a new directory put the files you want to mount in /home/root/rutinas

              /home # cd root/
              ~ # ls
              my_ros_env.sh  voxl-suite-ipk
              ~ # mkdir rutinas
              ~ # cd rutinas/
              ~/rutinas # pwd
              /home/root/rutinas
              

              If you mount it like this /home/root/rutinas:/home you will 'overwrite' or hide the default /home in the docker container btw, so the original files will be gone (e.g. all the files copied here...)

              https://gitlab.com/voxl-public/voxl-docker-images/voxl-docker-mavsdk-python/-/blob/master/Dockerfile#L27

              So you want to mount to another place inside the container likely, perhaps:
              /home/root/rutinas:/home/rutinas

              A 2 Replies Last reply 13 May 2021, 20:01 Reply Quote 0
              • A
                Alfonso Ponce @modaltb
                last edited by 13 May 2021, 20:01

                @modaltb
                Thank you very much again. Now I understand much more. The build-image.sh file that was in the repository is just a code that builds the image inside the VOXL even though I run it in my PC. In the beginning I thought that this file had to be run inside the VOXL.

                Ok so I just built the image using that file and everything went well (I understand the image was built inside VOXL). I created a directory just like you mentioned inside the VOXL and I know how to copy my python files to the new directory I created inside the VOXL, until there everything fine. Now, how do I know the containers directory? How do I acces to it? How do I create a new folder in it if I don't know where it is? 😞
                And finally, does it matter where do I mount my files inside the container? If I run the

                python3 my_own_exampe.py udp://:14551
                

                Will it find it? Or where is that original takeoff_and_land2.py file inside the container?
                In other words, how do I browse inside the container?

                Thank you! And sorry for all these basic questions.

                1 Reply Last reply Reply Quote 0
                • A
                  Alfonso Ponce @modaltb
                  last edited by 13 May 2021, 21:52

                  @modaltb Ok so I can see that by looking at the Dockerfile you linked, the directories of the container are listed there, but I still don't know how can I create a new directory inside /home for example.

                  ? 1 Reply Last reply 14 May 2021, 10:46 Reply Quote 0
                  • ?
                    A Former User @Alfonso Ponce
                    last edited by 14 May 2021, 10:46

                    @Alfonso-Ponce
                    You surf in the terminal in docker or home like a standard linux terminal. So,
                    I think you should check first this for Linux commands and then this for Docker commands.

                    A 1 Reply Last reply 17 May 2021, 16:05 Reply Quote 1
                    • A
                      Alfonso Ponce @Guest
                      last edited by 17 May 2021, 16:05

                      @Voxlady Thank you! In the end I was finally able to understand better how the VOXL shell and the Docker image/container were working together. I was able to mount the volume just like they recommended and I could send my .py files and execute them.

                      1 Reply Last reply Reply Quote 0
                      1 out of 9
                      • First post
                        1/9
                        Last post
                      Powered by NodeBB | Contributors