Ask Your Question
0

catkin_make command not found executing by a dockerfile

asked 2019-01-12 09:36:18 -0500

Daniel_1337 gravatar image

updated 2019-01-12 14:48:20 -0500

Hello,

I am creating a dockerfile for creating automatically an Ubuntu 16.04 operation system on which ROS kinetic is installed.

Until now, my the building process of the dockerfile yields to the installation of Ubuntu 16.04 as well as ROS kinetic. Unfortunately, the RUN catkin_make command inside inside of the dockerfile is not working in the building process, even executing the command RUN /bin/bash -c "bash /ros_entrypoint.sh" beforehand.

However, when I run the resulting docker image ( sudo docker run -it <its hash-number> ) and execute $bash /ros_entrypoint.sh && cd ~/catkin_ws/ && catkin_make in the Ubuntu shell, the catkin_make is working as you can see in the following image:

https://i.imgur.com/WcwHigJ.png

My goal is to achieve the same result with the building process of a dockerfile. I am out of ideas, how I could achieve this. Therefore I am asking for help.

I have already tried the answers of other questions, dealing with the almost same issue:

https://stackoverflow.com/questions/2...

https://answers.ros.org/question/2418...

https://github.com/ros-planning/movei...

The current dockerfile, which needs to be improved, looks currently like this:

FROM ubuntu:16.04
FROM osrf/ros:kinetic-desktop-full

#### HACK, replacing shell with bash for later docker build commands
RUN mv /bin/sh /bin/sh-old && \
ln -s /bin/bash /bin/sh

RUN /bin/bash -c "bash /ros_entrypoint.sh"

RUN mkdir -p ~/catkin_ws/src/

RUN cd ~/catkin_ws/ && \
catkin_make
edit retag flag offensive close merge delete

Comments

1

Please don't use an image to display text. Images are not searchable and people cannot copy and paste the text from the image. Please update your question with a copy and paste of the text.

jayess gravatar imagejayess ( 2019-01-12 13:51:21 -0500 )edit

@jayess: The picuture is not important. It just shows that the commands(bash /ros_entrypoint.sh && cd ~/catkin_ws/ && catkin_make) are working, when I run the dockerfile.

Daniel_1337 gravatar imageDaniel_1337 ( 2019-01-12 14:45:56 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2019-01-14 16:10:03 -0500

Daniel_1337 gravatar image

In order to be able to execute a catkin_make command one can use the following command:

RUN /bin/bash -c '. /opt/ros/kinetic/setup.bash; cd <into the desired folder e.g. catkin_ws>; catkin_make'

Thus, the working dockerfile looks like this:

FROM osrf/ros:kinetic-desktop-full

# ...
# do what you need to do for example git clone something into ~/catkin_ws/src
# ...

RUN /bin/bash -c '. /opt/ros/kinetic/setup.bash; cd <into the desired folder e.g. ~/catkin_ws/src>; catkin_make'
edit flag offensive delete link more

Comments

Ty this works for me. I wonder why

RUN /bin/bash -c /opt/ros/kinetic/setup.bash \
        && catkin_make

doesn't work. It is the same layer of container and using same tty. Do you know why it has to be written like that?

wthwlh gravatar imagewthwlh ( 2019-05-02 16:41:40 -0500 )edit
0

answered 2019-01-14 15:27:08 -0500

ruffsl gravatar image

updated 2019-01-14 15:31:27 -0500

You dockerfile is a bit erratic, so I'll just provide a complete minimal example of building a ROS 1 package from source. Just swap melodic for kinetic if that is the distro you still require; the following includes:
Cloning source code into workspace
Installing package dependencies
Building package using catkin tools
Sourcing workspace into entrypoint
And launching package nodes

FROM ros:melodic

# install build tools
RUN apt-get update && apt-get install -y \
      python-catkin-tools \
    && rm -rf /var/lib/apt/lists/*

# clone ros package repo
ENV ROS_WS /opt/ros_ws
RUN mkdir -p $ROS_WS/src
WORKDIR $ROS_WS
RUN git -C src clone \
      -b $ROS_DISTRO-devel \
      https://github.com/ros/ros_tutorials.git

# install ros package dependencies
RUN apt-get update && \
    rosdep update && \
    rosdep install -y \
      --from-paths \
        src/ros_tutorials/roscpp_tutorials \
      --ignore-src && \
    rm -rf /var/lib/apt/lists/*

# build ros package source
RUN catkin config \
      --extend /opt/ros/$ROS_DISTRO && \
    catkin build \
      roscpp_tutorials

# source ros package from entrypoint
RUN sed --in-place --expression \
      '$isource "$ROS_WS/devel/setup.bash"' \
      /ros_entrypoint.sh

# run ros package launch file
CMD ["roslaunch", "roscpp_tutorials", "talker_listener.launch"]
edit flag offensive delete link more

Comments

thank you for your response. Unfortunately, you do not answer the question how one can execute a catkin_make command.

Daniel_1337 gravatar imageDaniel_1337 ( 2019-01-14 15:55:36 -0500 )edit

As catkin_make doesn't have the same --extend argument to Explicitly Specifying Workspace Chaining, I elected show you how to catkin build without resorting to swapping the shell.

ruffsl gravatar imageruffsl ( 2019-01-14 17:48:15 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-01-12 09:21:23 -0500

Seen: 1,202 times

Last updated: Jan 14