How to copy your MAVSDK Python Docker container and edit the files?
-
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!
-
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
-
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
-
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
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/bashI 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.
-
First off, thanks @ryan_meagher for the assitance!!!
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/Rutinaslikely doesn't exist on VOXL.... unless you've made a 'Rutinas' diectoryHere's a defeault
/home/home # ls adb audio camera input root system apps bluetooth graphics radio sensorsYou 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/rutinasIf you mount it like this
/home/root/rutinas:/homeyou will 'overwrite' or hide the default/homein the docker container btw, so the original files will be gone (e.g. all the files copied here...)So you want to mount to another place inside the container likely, perhaps:
/home/root/rutinas:/home/rutinas -
First off, thanks @ryan_meagher for the assitance!!!
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/Rutinaslikely doesn't exist on VOXL.... unless you've made a 'Rutinas' diectoryHere's a defeault
/home/home # ls adb audio camera input root system apps bluetooth graphics radio sensorsYou 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/rutinasIf you mount it like this
/home/root/rutinas:/homeyou will 'overwrite' or hide the default/homein the docker container btw, so the original files will be gone (e.g. all the files copied here...)So you want to mount to another place inside the container likely, perhaps:
/home/root/rutinas:/home/rutinas@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 thepython3 my_own_exampe.py udp://:14551Will 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.
-
First off, thanks @ryan_meagher for the assitance!!!
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/Rutinaslikely doesn't exist on VOXL.... unless you've made a 'Rutinas' diectoryHere's a defeault
/home/home # ls adb audio camera input root system apps bluetooth graphics radio sensorsYou 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/rutinasIf you mount it like this
/home/root/rutinas:/homeyou will 'overwrite' or hide the default/homein the docker container btw, so the original files will be gone (e.g. all the files copied here...)So you want to mount to another place inside the container likely, perhaps:
/home/root/rutinas:/home/rutinas@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.
-
@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.
@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. -
@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.@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.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login