1
$\begingroup$

I have used catkin_make in ROS1 to build packages successfully. I am using ROS2 in an image in docker on a raspberry pi zero 2W. To my knowledge I cannot install ROS2 in raspbian OS directly so I am trying the docker route. Once I run the image I can run ros commands (rosrun) so that all works. Is it possible to write the source code files in a package subdirectory within the raspbian OS and then compile and run the package in the docker ROS2 image? If so, is there a simple tutorial or other relevant reference? If not, do I have any other options? Thanks.

$\endgroup$

1 Answer 1

1
$\begingroup$

Docker allows to mount shared volumes that are visible both inside and outside the docker:

docker run -it -v /host/directory:/container/directory  image_name

"-it" calls for interactive session. You will get a command line access inside the docker image and be able to type in the build commands (and many others). Simplest seems to mount all ROS workspace.

You may face the problem that group and user of the docker will not be your group and your user (if you do nothing about this). Due this the docker may be unable to overwrite files in the mounted folder, or you may be unable to modify content that was initially created by the docker. This defends on settings but it is not uncommon on Linux to have files that only the owner (creator) has the right to modify.

You can obtain your group and user ids with the id command under Linux ( id -u and id -g).

Then you can launch the docker image with internal user matching group and user id of the external user:

docker run -u $(id -u):$(id -g) -v host/directory:container/directory image_name

here $(..) is a bash construct to execute the command and capture the value.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.